From 0e5113918c99b1c9d77d2c18533a144d255383f9 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 4 Mar 2023 01:37:15 -0500 Subject: [PATCH] #186 improved sv config validation, changed waste high thresholds, fixed monitored max burn not showing as active, fixed redstone R_ENABLE and U_ALARM, changed RPS high waste trip to 95% --- coordinator/iocontrol.lua | 3 ++- coordinator/startup.lua | 2 +- install_manifest.json | 2 +- reactor-plc/startup.lua | 2 +- rtu/startup.lua | 2 +- scada-common/comms.lua | 4 ++-- scada-common/constants.lua | 6 +++--- scada-common/rsio.lua | 4 ++-- supervisor/startup.lua | 11 +++++++---- supervisor/unitlogic.lua | 4 ++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/coordinator/iocontrol.lua b/coordinator/iocontrol.lua index ea243cd..fc54fb3 100644 --- a/coordinator/iocontrol.lua +++ b/coordinator/iocontrol.lua @@ -11,6 +11,7 @@ local process = require("coordinator.process") local sounder = require("coordinator.sounder") local ALARM_STATE = types.ALARM_STATE +local PROCESS = types.PROCESS local iocontrol = {} @@ -301,7 +302,7 @@ function iocontrol.update_facility_status(status) fac.auto_ready = ctl_status[2] if type(ctl_status[3]) == "number" then - fac.auto_active = ctl_status[3] > 1 + fac.auto_active = ctl_status[3] > PROCESS.INACTIVE else fac.auto_active = false valid = false diff --git a/coordinator/startup.lua b/coordinator/startup.lua index b6a8f10..7d6e39c 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol") local renderer = require("coordinator.renderer") local sounder = require("coordinator.sounder") -local COORDINATOR_VERSION = "v0.11.9" +local COORDINATOR_VERSION = "v0.11.10" local print = util.print local println = util.println diff --git a/install_manifest.json b/install_manifest.json index dcdc18c..0a218b8 100644 --- a/install_manifest.json +++ b/install_manifest.json @@ -1 +1 @@ -{"versions": {"bootloader": "0.2", "comms": "1.4.0", "reactor-plc": "v0.12.2", "rtu": "v0.12.3", "supervisor": "v0.13.4", "coordinator": "v0.11.9", "pocket": "alpha-v0.0.0"}, "files": {"system": ["initenv.lua", "startup.lua"], "common": ["scada-common/crypto.lua", "scada-common/ppm.lua", "scada-common/comms.lua", "scada-common/psil.lua", "scada-common/tcallbackdsp.lua", "scada-common/rsio.lua", "scada-common/constants.lua", "scada-common/mqueue.lua", "scada-common/crash.lua", "scada-common/log.lua", "scada-common/types.lua", "scada-common/util.lua"], "graphics": ["graphics/element.lua", "graphics/flasher.lua", "graphics/core.lua", "graphics/elements/textbox.lua", "graphics/elements/displaybox.lua", "graphics/elements/pipenet.lua", "graphics/elements/rectangle.lua", "graphics/elements/div.lua", "graphics/elements/tiling.lua", "graphics/elements/colormap.lua", "graphics/elements/indicators/alight.lua", "graphics/elements/indicators/icon.lua", "graphics/elements/indicators/power.lua", "graphics/elements/indicators/rad.lua", "graphics/elements/indicators/state.lua", "graphics/elements/indicators/light.lua", "graphics/elements/indicators/vbar.lua", "graphics/elements/indicators/coremap.lua", "graphics/elements/indicators/data.lua", "graphics/elements/indicators/hbar.lua", "graphics/elements/indicators/trilight.lua", "graphics/elements/controls/switch_button.lua", "graphics/elements/controls/spinbox_numeric.lua", "graphics/elements/controls/hazard_button.lua", "graphics/elements/controls/push_button.lua", "graphics/elements/controls/radio_button.lua", "graphics/elements/controls/multi_button.lua", "graphics/elements/animations/waiting.lua"], "lockbox": ["lockbox/init.lua", "lockbox/LICENSE", "lockbox/kdf/pbkdf2.lua", "lockbox/util/bit.lua", "lockbox/util/array.lua", "lockbox/util/stream.lua", "lockbox/util/queue.lua", "lockbox/digest/sha2_224.lua", "lockbox/digest/sha1.lua", "lockbox/digest/sha2_256.lua", "lockbox/cipher/aes128.lua", "lockbox/cipher/aes256.lua", "lockbox/cipher/aes192.lua", "lockbox/cipher/mode/ofb.lua", "lockbox/cipher/mode/cbc.lua", "lockbox/cipher/mode/ctr.lua", "lockbox/cipher/mode/cfb.lua", "lockbox/mac/hmac.lua", "lockbox/padding/ansix923.lua", "lockbox/padding/pkcs7.lua", "lockbox/padding/zero.lua", "lockbox/padding/isoiec7816.lua"], "reactor-plc": ["reactor-plc/threads.lua", "reactor-plc/plc.lua", "reactor-plc/config.lua", "reactor-plc/startup.lua"], "rtu": ["rtu/threads.lua", "rtu/rtu.lua", "rtu/modbus.lua", "rtu/config.lua", "rtu/startup.lua", "rtu/dev/sps_rtu.lua", "rtu/dev/envd_rtu.lua", "rtu/dev/boilerv_rtu.lua", "rtu/dev/redstone_rtu.lua", "rtu/dev/sna_rtu.lua", "rtu/dev/imatrix_rtu.lua", "rtu/dev/turbinev_rtu.lua"], "supervisor": ["supervisor/supervisor.lua", "supervisor/unit.lua", "supervisor/config.lua", "supervisor/startup.lua", "supervisor/unitlogic.lua", "supervisor/facility.lua", "supervisor/session/coordinator.lua", "supervisor/session/svqtypes.lua", "supervisor/session/svsessions.lua", "supervisor/session/rtu.lua", "supervisor/session/plc.lua", "supervisor/session/rsctl.lua", "supervisor/session/rtu/boilerv.lua", "supervisor/session/rtu/txnctrl.lua", "supervisor/session/rtu/unit_session.lua", "supervisor/session/rtu/turbinev.lua", "supervisor/session/rtu/envd.lua", "supervisor/session/rtu/imatrix.lua", "supervisor/session/rtu/sps.lua", "supervisor/session/rtu/qtypes.lua", "supervisor/session/rtu/sna.lua", "supervisor/session/rtu/redstone.lua"], "coordinator": ["coordinator/coordinator.lua", "coordinator/renderer.lua", "coordinator/iocontrol.lua", "coordinator/sounder.lua", "coordinator/config.lua", "coordinator/startup.lua", "coordinator/apisessions.lua", "coordinator/process.lua", "coordinator/ui/dialog.lua", "coordinator/ui/style.lua", "coordinator/ui/layout/main_view.lua", "coordinator/ui/layout/unit_view.lua", "coordinator/ui/components/reactor.lua", "coordinator/ui/components/processctl.lua", "coordinator/ui/components/unit_overview.lua", "coordinator/ui/components/boiler.lua", "coordinator/ui/components/unit_detail.lua", "coordinator/ui/components/imatrix.lua", "coordinator/ui/components/unit_waiting.lua", "coordinator/ui/components/turbine.lua"], "pocket": ["pocket/config.lua", "pocket/startup.lua"]}, "depends": {"reactor-plc": ["system", "common"], "rtu": ["system", "common"], "supervisor": ["system", "common"], "coordinator": ["system", "common", "graphics"], "pocket": ["system", "common", "graphics"]}, "sizes": {"manifest": 4626, "system": 1982, "common": 90549, "graphics": 99858, "lockbox": 100797, "reactor-plc": 75545, "rtu": 82913, "supervisor": 271184, "coordinator": 179375, "pocket": 335}} \ No newline at end of file +{"versions": {"bootloader": "0.2", "comms": "1.4.0", "reactor-plc": "v0.12.3", "rtu": "v0.12.4", "supervisor": "v0.13.5", "coordinator": "v0.11.10", "pocket": "alpha-v0.0.0"}, "files": {"system": ["initenv.lua", "startup.lua"], "common": ["scada-common/crypto.lua", "scada-common/ppm.lua", "scada-common/comms.lua", "scada-common/psil.lua", "scada-common/tcallbackdsp.lua", "scada-common/rsio.lua", "scada-common/constants.lua", "scada-common/mqueue.lua", "scada-common/crash.lua", "scada-common/log.lua", "scada-common/types.lua", "scada-common/util.lua"], "graphics": ["graphics/element.lua", "graphics/flasher.lua", "graphics/core.lua", "graphics/elements/textbox.lua", "graphics/elements/displaybox.lua", "graphics/elements/pipenet.lua", "graphics/elements/rectangle.lua", "graphics/elements/div.lua", "graphics/elements/tiling.lua", "graphics/elements/colormap.lua", "graphics/elements/indicators/alight.lua", "graphics/elements/indicators/icon.lua", "graphics/elements/indicators/power.lua", "graphics/elements/indicators/rad.lua", "graphics/elements/indicators/state.lua", "graphics/elements/indicators/light.lua", "graphics/elements/indicators/vbar.lua", "graphics/elements/indicators/coremap.lua", "graphics/elements/indicators/data.lua", "graphics/elements/indicators/hbar.lua", "graphics/elements/indicators/trilight.lua", "graphics/elements/controls/switch_button.lua", "graphics/elements/controls/spinbox_numeric.lua", "graphics/elements/controls/hazard_button.lua", "graphics/elements/controls/push_button.lua", "graphics/elements/controls/radio_button.lua", "graphics/elements/controls/multi_button.lua", "graphics/elements/animations/waiting.lua"], "lockbox": ["lockbox/init.lua", "lockbox/LICENSE", "lockbox/kdf/pbkdf2.lua", "lockbox/util/bit.lua", "lockbox/util/array.lua", "lockbox/util/stream.lua", "lockbox/util/queue.lua", "lockbox/digest/sha2_224.lua", "lockbox/digest/sha1.lua", "lockbox/digest/sha2_256.lua", "lockbox/cipher/aes128.lua", "lockbox/cipher/aes256.lua", "lockbox/cipher/aes192.lua", "lockbox/cipher/mode/ofb.lua", "lockbox/cipher/mode/cbc.lua", "lockbox/cipher/mode/ctr.lua", "lockbox/cipher/mode/cfb.lua", "lockbox/mac/hmac.lua", "lockbox/padding/ansix923.lua", "lockbox/padding/pkcs7.lua", "lockbox/padding/zero.lua", "lockbox/padding/isoiec7816.lua"], "reactor-plc": ["reactor-plc/threads.lua", "reactor-plc/plc.lua", "reactor-plc/config.lua", "reactor-plc/startup.lua"], "rtu": ["rtu/threads.lua", "rtu/rtu.lua", "rtu/modbus.lua", "rtu/config.lua", "rtu/startup.lua", "rtu/dev/sps_rtu.lua", "rtu/dev/envd_rtu.lua", "rtu/dev/boilerv_rtu.lua", "rtu/dev/redstone_rtu.lua", "rtu/dev/sna_rtu.lua", "rtu/dev/imatrix_rtu.lua", "rtu/dev/turbinev_rtu.lua"], "supervisor": ["supervisor/supervisor.lua", "supervisor/unit.lua", "supervisor/config.lua", "supervisor/startup.lua", "supervisor/unitlogic.lua", "supervisor/facility.lua", "supervisor/session/coordinator.lua", "supervisor/session/svqtypes.lua", "supervisor/session/svsessions.lua", "supervisor/session/rtu.lua", "supervisor/session/plc.lua", "supervisor/session/rsctl.lua", "supervisor/session/rtu/boilerv.lua", "supervisor/session/rtu/txnctrl.lua", "supervisor/session/rtu/unit_session.lua", "supervisor/session/rtu/turbinev.lua", "supervisor/session/rtu/envd.lua", "supervisor/session/rtu/imatrix.lua", "supervisor/session/rtu/sps.lua", "supervisor/session/rtu/qtypes.lua", "supervisor/session/rtu/sna.lua", "supervisor/session/rtu/redstone.lua"], "coordinator": ["coordinator/coordinator.lua", "coordinator/renderer.lua", "coordinator/iocontrol.lua", "coordinator/sounder.lua", "coordinator/config.lua", "coordinator/startup.lua", "coordinator/apisessions.lua", "coordinator/process.lua", "coordinator/ui/dialog.lua", "coordinator/ui/style.lua", "coordinator/ui/layout/main_view.lua", "coordinator/ui/layout/unit_view.lua", "coordinator/ui/components/reactor.lua", "coordinator/ui/components/processctl.lua", "coordinator/ui/components/unit_overview.lua", "coordinator/ui/components/boiler.lua", "coordinator/ui/components/unit_detail.lua", "coordinator/ui/components/imatrix.lua", "coordinator/ui/components/unit_waiting.lua", "coordinator/ui/components/turbine.lua"], "pocket": ["pocket/config.lua", "pocket/startup.lua"]}, "depends": {"reactor-plc": ["system", "common"], "rtu": ["system", "common"], "supervisor": ["system", "common"], "coordinator": ["system", "common", "graphics"], "pocket": ["system", "common", "graphics"]}, "sizes": {"manifest": 4627, "system": 1982, "common": 90588, "graphics": 99858, "lockbox": 100797, "reactor-plc": 75545, "rtu": 82913, "supervisor": 271405, "coordinator": 179421, "pocket": 335}} \ No newline at end of file diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index f8229e5..a41a86e 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -14,7 +14,7 @@ local config = require("reactor-plc.config") local plc = require("reactor-plc.plc") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v0.12.2" +local R_PLC_VERSION = "v0.12.3" local print = util.print local println = util.println diff --git a/rtu/startup.lua b/rtu/startup.lua index 34f0c65..52e08a1 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v0.12.3" +local RTU_VERSION = "v0.12.4" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE diff --git a/scada-common/comms.lua b/scada-common/comms.lua index ad7c0aa..497c3b3 100644 --- a/scada-common/comms.lua +++ b/scada-common/comms.lua @@ -141,9 +141,9 @@ function comms.scada_packet() local self = { modem_msg_in = nil, valid = false, - raw = { -1, -1, {} }, + raw = { -1, PROTOCOL.SCADA_MGMT, {} }, seq_num = -1, - protocol = -1, + protocol = PROTOCOL.SCADA_MGMT, length = 0, payload = {} } diff --git a/scada-common/constants.lua b/scada-common/constants.lua index 902e187..18272f5 100644 --- a/scada-common/constants.lua +++ b/scada-common/constants.lua @@ -16,7 +16,7 @@ local rps = {} rps.MAX_DAMAGE_PERCENT = 90 -- damage >= 90% rps.MAX_DAMAGE_TEMPERATURE = 1200 -- temp >= 1200K rps.MIN_COOLANT_FILL = 0.10 -- fill < 10% -rps.MAX_WASTE_FILL = 0.8 -- fill > 80% +rps.MAX_WASTE_FILL = 0.95 -- fill > 95% rps.MAX_HEATED_COLLANT_FILL = 0.95 -- fill > 95% rps.NO_FUEL_FILL = 0.0 -- fill <= 0% @@ -33,7 +33,7 @@ annunc.CoolantLevelLow = 0.4 -- fill < 40% annunc.ReactorTempHigh = 1000 -- temp > 1000K annunc.ReactorHighDeltaT = 50 -- rate > 50K/s annunc.FuelLevelLow = 0.05 -- fill <= 5% -annunc.WasteLevelHigh = 0.85 -- fill >= 85% +annunc.WasteLevelHigh = 0.80 -- fill >= 80% annunc.WaterLevelLow = 0.4 -- fill < 40% annunc.SteamFeedMismatch = 10 -- ±10mB difference between total coolant flow and total steam input rate annunc.RadiationWarning = 0.00001 -- 10 uSv/h @@ -49,7 +49,7 @@ local alarms = {} -- unit alarms alarms.HIGH_TEMP = 1150 -- temp >= 1150K -alarms.HIGH_WASTE = 0.5 -- fill > 50% +alarms.HIGH_WASTE = 0.85 -- fill > 85% alarms.HIGH_RADIATION = 0.00005 -- 50 uSv/h, not yet damaging but this isn't good -- facility alarms diff --git a/scada-common/rsio.lua b/scada-common/rsio.lua index 6b33a24..42e27aa 100644 --- a/scada-common/rsio.lua +++ b/scada-common/rsio.lua @@ -52,7 +52,7 @@ local IO_PORT = { -- digital outputs -- -- facility - F_ALARM = 7, -- active high, facility alarm (any high priority unit alarm) + F_ALARM = 7, -- active high, facility-wide alarm (any high priority unit alarm) -- waste WASTE_PU = 8, -- active low, waste -> plutonium -> pellets route @@ -75,7 +75,7 @@ local IO_PORT = { R_PLC_TIMEOUT = 23, -- active high, if the reactor PLC has not been heard from -- unit outputs - U_ALARM = 24, -- active high, unit alarm + U_ALARM = 24, -- active high, unit alarm U_EMER_COOL = 25 -- active low, emergency coolant control } diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 1117ff7..743efa6 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions") local config = require("supervisor.config") local supervisor = require("supervisor.supervisor") -local SUPERVISOR_VERSION = "v0.13.4" +local SUPERVISOR_VERSION = "v0.13.5" local print = util.print local println = util.println @@ -43,15 +43,18 @@ cfv.assert_type_int(config.LOG_MODE) assert(cfv.valid(), "bad config file: missing/invalid fields") +cfv.assert_eq(#config.REACTOR_COOLING, config.NUM_REACTORS) +assert(cfv.valid(), "config: number of cooling configs different than number of units") + for i = 1, config.NUM_REACTORS do cfv.assert_type_table(config.REACTOR_COOLING[i]) - assert(cfv.valid(), "missing cooling entry for reactor " .. i) + assert(cfv.valid(), "config: missing cooling entry for reactor " .. i) cfv.assert_type_int(config.REACTOR_COOLING[i].BOILERS) cfv.assert_type_int(config.REACTOR_COOLING[i].TURBINES) - assert(cfv.valid(), "missing boilers/turbines for reactor " .. i) + assert(cfv.valid(), "config: missing boilers/turbines for reactor " .. i) cfv.assert_min(config.REACTOR_COOLING[i].BOILERS, 0) cfv.assert_min(config.REACTOR_COOLING[i].TURBINES, 1) - assert(cfv.valid(), "bad number of boilers/turbines for reactor " .. i) + assert(cfv.valid(), "config: bad number of boilers/turbines for reactor " .. i) end ---------------------------------------- diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index 823c581..56e6460 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -706,7 +706,7 @@ function logic.handle_redstone(self) end if (not self.auto_engaged) and (not self.plc_cache.active) and - (not self.plc_cache.rps_trip) and self.io_ctl.digital_read(IO.R_ACTIVE) then + (not self.plc_cache.rps_trip) and self.io_ctl.digital_read(IO.R_ENABLE) then -- reactor enable requested and allowable, but not yet done; perform it self.plc_s.in_queue.push_command(PLC_S_CMDS.ENABLE) end @@ -739,7 +739,7 @@ function logic.handle_redstone(self) local has_alarm = false for i = 1, #self.db.alarm_states do - if self.db.alarm_states[i] == ALARM_STATE.TRIPPED then + if self.db.alarm_states[i] == ALARM_STATE.TRIPPED or self.db.alarm_states[i] == ALARM_STATE.ACKED then has_alarm = true break end