code wiki / _hdl_build / _gjob_author.nx

_gjob_author.nx source

↩ module page · 33 lines · 1413 B

1// _gjob_author.nx -- the BUILDER authoring the print-job lifecycle machine (NXMOTION M1 seed) 2// from a table via emit13. The table IS the safety policy: start is only defined from READY, 3// so an unhomed start REFUSES. license_tier: ORIGINAL 4import "nx_pattern_emit13.nx" 5import "nx_syscalls.nx" 6 7func ga_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 8 9func main() -> i64 { 10 let spec: *i64 = sys_mmap(8 * 48) as *i64 11 spec[0] = 6 12 spec[1] = 6 13 spec[2] = 0 14 var i: i64 = 0 15 while i < 36 { spec[3 + i] = 0 - 1; i = i + 1 } 16 spec[3 + 0 * 6 + 0] = 1 // IDLE +home_cmd -> HOMING 17 spec[3 + 1 * 6 + 1] = 2 // HOMING +home_done -> READY 18 spec[3 + 2 * 6 + 2] = 3 // READY +start -> PRINTING 19 spec[3 + 3 * 6 + 3] = 4 // PRINTING +pause -> PAUSED 20 spec[3 + 3 * 6 + 5] = 5 // PRINTING +finish -> COMPLETE 21 spec[3 + 4 * 6 + 4] = 3 // PAUSED +resume -> PRINTING 22 let a: i64 = pe13_author_state_machine("_pe_gjob" as *u8, 23 "runtime/_hdl_build/_pe_gjob.nx" as *u8, 24 "runtime/_hdl_build/_pe_gjob_test.nx" as *u8, 25 spec) 26 if a == 1 { 27 ga_w("TEAM AUTHORED MACHINE: _pe_gjob (STATE_MACHINE shape 18 = print-job lifecycle, home-before-print law in the table)\n" as *u8) 28 sys_exit(0) 29 } 30 ga_w("author FAILED\n" as *u8) 31 sys_exit(1) 32 return 1 33}