code wiki / _hdl_build / nx_batt_facility.nx
nx_batt_facility.nx source
↩ module page · 50 lines · 3244 B
1// nx_batt_facility.nx -- R3 FIRE-SAFE FACILITY + self-service station INTERLOCK = the "laundromat where fires cant
2// happen" as gated logic. A charging session is ADMITTED only if (never-ignite first) thermal auto-isolation is
3// ARMED, the pack passed triage (UNSAFE/RETIRE packs are NEVER admitted to a charging bay), and it stays within the
4// per-bay + facility energy/fire-load caps, the station current cap, and the regulatory Li-ion STORAGE cap (VSQG
5// ~220 lb/mo, VERIFIED in the cost-basis). Plus auto-isolation: a bay over its thermal ceiling is cut from power.
6// Data-driven FacilitySpec (#11). Composes R0 (never-ignite envelope) + R1 (nx_batt_intake verdict). license_tier: ORIGINAL
7import "nx_batt_intake.nx" // NX_BI_* verdicts gate bay admission
8const NX_MAGIC_231703: i64 = 231703
9
10struct FacilitySpec {
11 n_bays: i64, // charging / express self-service bays
12 bay_max_energy_wh: i64, // per-bay energy cap (fire load)
13 facility_max_energy_wh: i64, // total simultaneous-charge energy cap
14 cabinet_capacity_wh: i64, // fire-rated cabinet total (Justrite NX_MAGIC_231703 = 4000Wh, VERIFIED)
15 station_max_charge_ma: i64, // self-service station current cap (<= never-ignite envelope)
16 storage_cap_lb: i64, // monthly Li-ion accumulation cap (VSQG 220 lb, VERIFIED)
17 thermal_isolation_armed: i64, // 1 = thermal monitor + auto-isolation active
18}
19
20const NX_FAC_ADMIT: i64 = 0
21const NX_FAC_REFUSE_PACK_UNSAFE: i64 = 1
22const NX_FAC_REFUSE_BAY_FULL: i64 = 2
23const NX_FAC_REFUSE_ENERGY_CAP: i64 = 3
24const NX_FAC_REFUSE_STATION_RATE: i64 = 4
25const NX_FAC_REFUSE_NO_THERMAL: i64 = 5
26const NX_FAC_REFUSE_STORAGE_CAP: i64 = 6
27
28// Decide whether to admit a charging session at a bay. SAFETY IS CHECKED FIRST (never-ignite priority).
29func nx_fac_admit(spec: *FacilitySpec, pack_verdict: i64, active_bays: i64, active_energy_wh: i64,
30 req_energy_wh: i64, req_charge_ma: i64, current_storage_lb: i64) -> i64 {
31 // never-ignite: no charging at all without armed thermal monitoring + auto-isolation
32 if spec.thermal_isolation_armed != 1 { return NX_FAC_REFUSE_NO_THERMAL }
33 // safety: an unsafe or retire-bound pack is NEVER admitted to a charging bay
34 if pack_verdict == NX_BI_UNSAFE_REJECT { return NX_FAC_REFUSE_PACK_UNSAFE }
35 if pack_verdict == NX_BI_RETIRE_RECYCLE { return NX_FAC_REFUSE_PACK_UNSAFE }
36 // capacity / fire-load
37 if active_bays >= spec.n_bays { return NX_FAC_REFUSE_BAY_FULL }
38 if req_charge_ma > spec.station_max_charge_ma { return NX_FAC_REFUSE_STATION_RATE }
39 if req_energy_wh > spec.bay_max_energy_wh { return NX_FAC_REFUSE_ENERGY_CAP }
40 if active_energy_wh + req_energy_wh > spec.facility_max_energy_wh { return NX_FAC_REFUSE_ENERGY_CAP }
41 // regulatory: stay under the VSQG / fire-code Li-ion accumulation limit
42 if current_storage_lb > spec.storage_cap_lb { return NX_FAC_REFUSE_STORAGE_CAP }
43 return NX_FAC_ADMIT
44}
45
46// Auto-isolation: a bay above its thermal ceiling is cut from power (1 = isolate). The facility-level never-ignite.
47func nx_fac_isolate(bay_temp_mc: i64, max_temp_mc: i64) -> i64 {
48 if bay_temp_mc > max_temp_mc { return 1 }
49 return 0
50}