code wiki / _hdl_build / nx_paste_gcode_gate.nx
nx_paste_gcode_gate.nx source
↩ module page · 98 lines · 5437 B
1// nx_paste_gcode_gate.nx -- GATE: 3D-printing workstream R2. The concrete/paste G-code emitter for the R-ECO
2// cistern. Proves: T1 valid construction G-code structure (cold paste -- NO hotend), T2 correct layer count
3// from the material profile, T3 CARDINAL-26 NEVER-BRICK (no firmware/EEPROM commands), T4 material-profile-
4// driven layer height, T5 extrusion accumulates, T6 sovereign provenance. Writes the printable .gcode.
5// license_tier: ORIGINAL
6import "nx_paste_gcode.nx"
7import "nx_print_material.nx"
8import "nx_food_science.nx"
9import "nx_seg_store.nx"
10import "nx_syscalls.nx"
11import "nx_gate_verdict.nx"
12
13const PG_PRINT: *u8 = "knowledge/store/print-"
14const PG_OUT: *u8 = "knowledge/staging/print/cistern.gcode"
15
16func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
17func g_i(v: i64) -> i64 {
18 let bb: *u8 = sys_mmap(28); var m: i64 = v
19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
20 let t: *u8 = sys_mmap(28); var k: i64 = 0
21 if m == 0 { t[0] = 48 as u8; k = 1 }
22 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
23 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0
24}
25
26func main() -> i64 {
27 g_p("=== nx_paste_gcode_gate (3D-printing R2: concrete G-code for the R-ECO cistern) ===\n" as *u8)
28 pm_seed(PG_PRINT)
29
30 let g: *u8 = sys_mmap(262144)
31 let n: i64 = pg_emit(PG_PRINT, 4000, 4000, 2000, g) // 4m x 4m footprint, 2m tall wall
32 g_p("emitted " as *u8); g_i(n); g_p(" bytes of construction G-code; wall concrete = " as *u8); g_i(pg_concrete_cm3(PG_PRINT, 4000, 4000, 2000)); g_p(" cm3\n" as *u8)
33
34 var pass: i64 = 0
35 var tot: i64 = 0
36
37 // T1 valid cold-paste construction G-code
38 tot = tot + 1
39 var ok1: i64 = 1
40 if as_contains(g, n, "G21" as *u8) != 1 { ok1 = 0 }
41 if as_contains(g, n, "G90" as *u8) != 1 { ok1 = 0 }
42 if as_contains(g, n, "G28" as *u8) != 1 { ok1 = 0 }
43 if as_contains(g, n, "G1 Z" as *u8) != 1 { ok1 = 0 }
44 if as_contains(g, n, "G1 X" as *u8) != 1 { ok1 = 0 }
45 if as_contains(g, n, "M84" as *u8) != 1 { ok1 = 0 }
46 if as_contains(g, n, "M104" as *u8) != 0 { ok1 = 0 } // COLD paste: no hotend
47 if as_contains(g, n, "M109" as *u8) != 0 { ok1 = 0 }
48 if ok1 == 1 { pass = pass + 1; g_p("PASS T1 valid construction G-code (cold paste -- no hotend M104/M109)\n" as *u8) } else { g_p("FAIL T1\n" as *u8) }
49
50 // T2 layer count from the profile (2000mm / 10mm = 200 layers, indices 0..199)
51 tot = tot + 1
52 var ok2: i64 = 1
53 if as_contains(g, n, ";LAYER:0" as *u8) != 1 { ok2 = 0 }
54 if as_contains(g, n, ";LAYER:199" as *u8) != 1 { ok2 = 0 }
55 if as_contains(g, n, ";LAYER:200" as *u8) != 0 { ok2 = 0 }
56 if ok2 == 1 { pass = pass + 1; g_p("PASS T2 200 layers (height / profile layer-height), indexed 0..199\n" as *u8) } else { g_p("FAIL T2\n" as *u8) }
57
58 // T3 CARDINAL 26 never-brick: no firmware/EEPROM commands
59 tot = tot + 1
60 var ok3: i64 = 1
61 if as_contains(g, n, "M997" as *u8) != 0 { ok3 = 0 } // firmware update -- THE brick command
62 if as_contains(g, n, "M500" as *u8) != 0 { ok3 = 0 } // save settings to EEPROM
63 if as_contains(g, n, "M502" as *u8) != 0 { ok3 = 0 } // reset EEPROM
64 if ok3 == 1 { pass = pass + 1; g_p("PASS T3 never-brick: no M997 (firmware flash), no M500/M502 (EEPROM) -- emit-only\n" as *u8) } else { g_p("FAIL T3\n" as *u8) }
65
66 // T4 material-profile-driven layer height (concrete profile = 10mm layers)
67 tot = tot + 1
68 var ok4: i64 = 1
69 if as_contains(g, n, "G1 Z10 " as *u8) != 1 { ok4 = 0 } // first layer at 10mm
70 if as_contains(g, n, "G1 Z2000 " as *u8) != 1 { ok4 = 0 } // last layer at 2000mm
71 if ok4 == 1 { pass = pass + 1; g_p("PASS T4 layer height driven by the concrete material profile (10mm)\n" as *u8) } else { g_p("FAIL T4\n" as *u8) }
72
73 // T5 extrusion accumulates (final E = 200 layers x 16000mm perimeter)
74 tot = tot + 1
75 if as_contains(g, n, "E3200000" as *u8) == 1 { pass = pass + 1; g_p("PASS T5 extrusion accumulates to E3200000 (pump volume over the whole print)\n" as *u8) } else { g_p("FAIL T5\n" as *u8) }
76
77 // T6 sovereign provenance
78 tot = tot + 1
79 var ok6: i64 = 1
80 if as_contains(g, n, "Nishi" as *u8) != 1 { ok6 = 0 }
81 if as_contains(g, n, "NEVER-BRICK" as *u8) != 1 { ok6 = 0 }
82 if ok6 == 1 { pass = pass + 1; g_p("PASS T6 sovereign provenance header (Nishi + never-brick note, firmware-ignored comment)\n" as *u8) } else { g_p("FAIL T6\n" as *u8) }
83
84 sys_mkdir("knowledge/staging" as *u8, 0x1ed)
85 sys_mkdir("knowledge/staging/print" as *u8, 0x1ed)
86 let fd: i64 = sys_openat_wr(PG_OUT, 420); if fd >= 0 { sys_write(fd, g, n); sys_close(fd); g_p("wrote " as *u8); g_p(PG_OUT); g_p("\n" as *u8) }
87
88 g_p("nx_paste_gcode_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot)
89 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
90 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
91 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
92 let ctr__dry: *i64 = gv_ctr()
93 ctr__dry[0] = pass
94 ctr__dry[1] = tot
95 let rc__dry: i64 = gv_verdict("PASTE-GCODE-GATE" as *u8, ctr__dry, "the ladder grew into CONCRETE: printable cistern G-code, never-brick)" as *u8)
96 sys_exit(rc__dry)
97 return rc__dry
98}