diff --git a/coordinator/coordinator.lua b/coordinator/coordinator.lua index 7df62d0..26410e6 100644 --- a/coordinator/coordinator.lua +++ b/coordinator/coordinator.lua @@ -444,6 +444,8 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range else log.debug("SCADA_CRDN process start (with configuration) ack echo packet length mismatch") end + elseif cmd == FAC_COMMANDS.ACK_ALL_ALARMS then + iocontrol.get_db().facility.ack_alarms_ack(ack) else log.debug(util.c("received facility command ack with unknown command ", cmd)) end diff --git a/coordinator/iocontrol.lua b/coordinator/iocontrol.lua index 51399a6..1fe04f4 100644 --- a/coordinator/iocontrol.lua +++ b/coordinator/iocontrol.lua @@ -31,12 +31,13 @@ function iocontrol.init(conf, comms) auto_saturated = false, auto_scram = false, - num_units = conf.num_units, ---@type integer + num_units = conf.num_units, ---@type integer - save_cfg_ack = function (success) end, ---@param success boolean - start_ack = function (success) end, ---@param success boolean - stop_ack = function (success) end, ---@param success boolean - scram_ack = function (success) end, ---@param success boolean + save_cfg_ack = function (success) end, ---@param success boolean + start_ack = function (success) end, ---@param success boolean + stop_ack = function (success) end, ---@param success boolean + scram_ack = function (success) end, ---@param success boolean + ack_alarms_ack = function (success) end, ---@param success boolean ps = psil.create(), diff --git a/coordinator/process.lua b/coordinator/process.lua index 11871e7..b3a6bb3 100644 --- a/coordinator/process.lua +++ b/coordinator/process.lua @@ -17,11 +17,11 @@ local self = { comms = nil, ---@type coord_comms ---@class coord_auto_config config = { - mode = 0, ---@type PROCESS + mode = PROCESS.INACTIVE, burn_target = 0.0, charge_target = 0.0, gen_target = 0.0, - limits = {} ---@type table + limits = {} } } @@ -88,6 +88,18 @@ function process.init(iocontrol, comms) end end +-- facility SCRAM command +function process.fac_scram() + self.comms.send_fac_command(FAC_COMMANDS.SCRAM_ALL) + log.debug("FAC: SCRAM ALL") +end + +-- facility alarm acknowledge command +function process.fac_ack_alarms() + self.comms.send_fac_command(FAC_COMMANDS.ACK_ALL_ALARMS) + log.debug("FAC: ACK ALL ALARMS") +end + -- start reactor ---@param id integer unit ID function process.start(id) @@ -193,12 +205,6 @@ end -- AUTO PROCESS CONTROL -- -------------------------- --- facility SCRAM command -function process.fac_scram() - self.comms.send_fac_command(FAC_COMMANDS.SCRAM_ALL) - log.debug("FAC: SCRAM ALL") -end - -- stop automatic process control function process.stop_auto() self.comms.send_fac_command(FAC_COMMANDS.STOP) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index e789f38..4d71b67 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 = "beta-v0.9.2" +local COORDINATOR_VERSION = "beta-v0.9.3" local print = util.print local println = util.println diff --git a/coordinator/ui/components/processctl.lua b/coordinator/ui/components/processctl.lua index 9b9b2a3..5d7484e 100644 --- a/coordinator/ui/components/processctl.lua +++ b/coordinator/ui/components/processctl.lua @@ -47,8 +47,10 @@ local function new_view(root, x, y) local main = Div{parent=root,width=104,height=24,x=x,y=y} local scram = HazardButton{parent=main,x=1,y=1,text="FAC SCRAM",accent=colors.yellow,dis_colors=dis_colors,callback=process.fac_scram,fg_bg=hzd_fg_bg} + local ack_a = HazardButton{parent=main,x=16,y=1,text="ACK \x13",accent=colors.orange,dis_colors=dis_colors,callback=process.fac_ack_alarms,fg_bg=hzd_fg_bg} facility.scram_ack = scram.on_response + facility.ack_alarms_ack = ack_a.on_response local all_ok = IndicatorLight{parent=main,y=5,label="Unit Systems Online",colors=cpair(colors.green,colors.red)} local ind_mat = IndicatorLight{parent=main,label="Induction Matrix",colors=cpair(colors.green,colors.gray)} @@ -208,7 +210,7 @@ local function new_view(root, x, y) local save = HazardButton{parent=auto_controls,x=2,y=2,text="SAVE",accent=colors.purple,dis_colors=dis_colors,callback=_save_cfg,fg_bg=hzd_fg_bg} local start = HazardButton{parent=auto_controls,x=13,y=2,text="START",accent=colors.lightBlue,dis_colors=dis_colors,callback=_start_auto,fg_bg=hzd_fg_bg} - local stop = HazardButton{parent=auto_controls,x=23,y=2,text="STOP",accent=colors.orange,dis_colors=dis_colors,callback=process.stop_auto,fg_bg=hzd_fg_bg} + local stop = HazardButton{parent=auto_controls,x=23,y=2,text="STOP",accent=colors.red,dis_colors=dis_colors,callback=process.stop_auto,fg_bg=hzd_fg_bg} facility.start_ack = start.on_response facility.stop_ack = stop.on_response diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index b4ffb89..c8f8b23 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 = "beta-v0.10.6" +local R_PLC_VERSION = "beta-v0.10.7" local print = util.print local println = util.println diff --git a/rtu/startup.lua b/rtu/startup.lua index 392c039..557bf28 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 = "beta-v0.10.0" +local RTU_VERSION = "beta-v0.10.1" local rtu_t = types.rtu_t diff --git a/scada-common/comms.lua b/scada-common/comms.lua index 672d4e2..94bfd15 100644 --- a/scada-common/comms.lua +++ b/scada-common/comms.lua @@ -14,7 +14,7 @@ local insert = table.insert local max_distance = nil -comms.version = "1.3.0" +comms.version = "1.3.1" ---@alias PROTOCOLS integer local PROTOCOLS = { @@ -103,7 +103,8 @@ local PLC_AUTO_ACK = { local FAC_COMMANDS = { SCRAM_ALL = 0, -- SCRAM all reactors STOP = 1, -- stop automatic control - START = 2 -- start automatic control + START = 2, -- start automatic control + ACK_ALL_ALARMS = 3 -- acknowledge all alarms on all units } ---@alias UNIT_COMMANDS integer @@ -198,21 +199,21 @@ function comms.scada_packet() -- outside of maximum allowable transmission distance -- log.debug("comms.scada_packet.receive(): discarding packet with distance " .. distance .. " outside of trusted range") else - if type(self.raw) == "table" then - if #self.raw >= 3 then - self.seq_num = self.raw[1] - self.protocol = self.raw[2] + if type(self.raw) == "table" then + if #self.raw >= 3 then + self.seq_num = self.raw[1] + self.protocol = self.raw[2] - -- element 3 must be a table - if type(self.raw[3]) == "table" then - self.length = #self.raw[3] - self.payload = self.raw[3] + -- element 3 must be a table + if type(self.raw[3]) == "table" then + self.length = #self.raw[3] + self.payload = self.raw[3] + end end - end - self.valid = type(self.seq_num) == "number" and - type(self.protocol) == "number" and - type(self.payload) == "table" + self.valid = type(self.seq_num) == "number" and + type(self.protocol) == "number" and + type(self.payload) == "table" end end diff --git a/supervisor/session/coordinator.lua b/supervisor/session/coordinator.lua index 03b0eb7..9075d2a 100644 --- a/supervisor/session/coordinator.lua +++ b/supervisor/session/coordinator.lua @@ -233,6 +233,9 @@ function coordinator.new_session(id, in_queue, out_queue, facility) else log.debug(log_header .. "CRDN auto start (with configuration) packet length mismatch") end + elseif cmd == FAC_COMMANDS.ACK_ALL_ALARMS then + facility.ack_all() + _send(SCADA_CRDN_TYPES.FAC_CMD, { cmd, true }) else log.debug(log_header .. "CRDN facility command unknown") end diff --git a/supervisor/session/facility.lua b/supervisor/session/facility.lua index 9d82477..fddb467 100644 --- a/supervisor/session/facility.lua +++ b/supervisor/session/facility.lua @@ -556,6 +556,14 @@ function facility.new(num_reactors, cooling_conf) end end + -- ack all alarms on all reactor units + function public.ack_all() + for i = 1, #self.units do + local u = self.units[i] ---@type reactor_unit + u.ack_all() + end + end + -- stop auto control function public.auto_stop() self.mode = PROCESS.INACTIVE diff --git a/supervisor/startup.lua b/supervisor/startup.lua index ee39614..831727b 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 = "beta-v0.10.1" +local SUPERVISOR_VERSION = "beta-v0.10.2" local print = util.print local println = util.println