code wiki / _hdl_build / nx_eff_board.nx
nx_eff_board.nx source
↩ module page · 39 lines · 1547 B
1// nx_eff_board.nx -- THE efficiency / ROI board CLI (eff lane F732). Thin main over nx_eff_board_lib
2// (split lib+CLI+gate like nx_pm_cockpit). Reads knowledge/store/eff- + roi-, emits JSON (MCP/agent
3// interchange, default) or the /efficiency HTML page. Runs on the NAS (CWD=nishihost, MCP fork-exec).
4// argv[1] = "json" (default) | "html" [argv[2]=out path, default sites/nishifamily/efficiency.html]
5// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
6import "nx_eff_board_lib.nx"
7
8func main(argc: i64, argv: *i64) -> i64 {
9 var html: i64 = 0
10 var outp: *u8 = "sites/nishifamily/efficiency.html" as *u8
11 if argc >= 2 { let mo: *u8 = argv[1] as *u8; if mo[0] == (EB_HTMLH as u8) { html = 1 } }
12 if argc >= 3 { outp = argv[2] as *u8 }
13
14 let m: *i64 = sys_mmap(64*8) as *i64
15 var z: i64 = 0
16 while z < 64 { m[z] = 0; z = z + 1 }
17
18 let eff: *u8 = sys_mmap(EB_PLANE_CAP)
19 let en: i64 = sts_load("knowledge/store/eff-" as *u8, eff, EB_PLANE_CAP)
20 eb_eff_scan(eff, en, m)
21
22 let roi: *u8 = sys_mmap(EB_PLANE_CAP)
23 let rn: i64 = sts_load("knowledge/store/roi-" as *u8, roi, EB_PLANE_CAP)
24 eb_roi_value(roi, rn, m)
25
26 let out: *u8 = sys_mmap(EB_OUT_CAP)
27 if html == 1 {
28 let n: i64 = eb_emit_html(out, m)
29 ss_writefile(outp, out, n)
30 sys_write(1, "wrote " as *u8, 6)
31 sys_write(1, outp, eb_len(outp))
32 sys_write(1, "\n" as *u8, 1)
33 } else {
34 let n: i64 = eb_emit_json(out, m)
35 sys_write(1, out, n)
36 }
37 sys_exit(0)
38 return 0
39}