code wiki / (root) / nx_vessel_twin_test.nx

nx_vessel_twin_test.nx source

↩ module page · 39 lines · 1667 B

1// nx_vessel_twin_test.nx -- smoke for nx_vessel_twin (HIL capstone). 2// 3// Proves end-to-end (device + recipe) certification in software: 4// - a good device + the yogurt recipe is CERTIFIED for build (1) 5// - an undersized device is rejected at the hardware stage (2) 6// - a mis-placed cutoff is rejected at the hardware stage (3) 7// - the twin consults R3: yogurt acidifies within the safety window (4-5) 8// Exit code = failed assertion number; 0 = all pass. 9 10import "nx_syscalls.nx" 11import "nx_ferment_safety.nx" 12import "nx_ferment_kinetics.nx" 13import "nx_ferment_recipes.nx" 14import "nx_vessel_thermal.nx" 15import "nx_vessel_io.nx" 16import "nx_vessel_faults.nx" 17import "nx_vessel_design.nx" 18import "nx_vessel_twin.nx" 19 20func main() -> i64 { 21 let env: *NxFermentSafetyEnvelope = nx_ferment_safety_envelope_default(1) 22 23 // --- good device + yogurt recipe -> CERTIFIED --- 24 let good: *NxVesselThermal = nx_vessel_thermal_new(16744, 50000, 1000, 20000) 25 if nx_vessel_twin_certify(env, good, 60000, NX_RCP_YOGURT) != NX_TWIN_CERTIFIED { return 1 } 26 27 // --- undersized device -> rejected at hardware --- 28 let weak: *NxVesselThermal = nx_vessel_thermal_new(16744, 5000, 1000, 20000) 29 if nx_vessel_twin_certify(env, weak, 60000, NX_RCP_YOGURT) != NX_TWIN_FAIL_DESIGN { return 2 } 30 31 // --- mis-placed cutoff -> rejected at hardware --- 32 if nx_vessel_twin_certify(env, good, 40000, NX_RCP_YOGURT) != NX_TWIN_FAIL_DESIGN { return 3 } 33 34 // --- the twin consults R3 kinetics: yogurt sets within the window --- 35 if nx_ferment_kinetics_set_time(43) > 48 { return 4 } 36 if nx_ferment_kinetics_set_time(43) <= 0 { return 5 } 37 38 return 0 39}