From 479194b589c7ddf89c7b478b7ff75d233fdc26e3 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 1 May 2022 13:26:02 -0400 Subject: [PATCH] ISS alarm status packet adjustments --- reactor-plc/plc.lua | 6 ++++-- reactor-plc/startup.lua | 4 ++-- supervisor/session/plc.lua | 13 ++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/reactor-plc/plc.lua b/reactor-plc/plc.lua index a8c7c5e..52bd16c 100644 --- a/reactor-plc/plc.lua +++ b/reactor-plc/plc.lua @@ -147,7 +147,7 @@ function iss_init(reactor) elseif self.cache[5] then log._warning("ISS: no fuel!") status = "no_fuel" - elseif self.timed_out then + elseif self.cache[7] then log._warning("ISS: supervisor connection timeout!") status = "timeout" else @@ -368,14 +368,16 @@ function comms_init(id, modem, local_port, server_port, reactor, iss) _send(RPLC_TYPES.STATUS, sys_status) end + -- send safety system status local send_iss_status = function () _send(RPLC_TYPES.ISS_STATUS, iss.status()) end + -- send safety system alarm local send_iss_alarm = function (cause) local iss_alarm = { cause, - iss.status() + table.unpack(iss.status()) } _send(RPLC_TYPES.ISS_ALARM, iss_alarm) diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 3905f0e..17e4a2e 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -131,8 +131,8 @@ end init() -- init threads -local main_thread = threads.thread__main(__shared_memory, init) -local iss_thread = threads.thread__iss(__shared_memory) +local main_thread = threads.thread__main(__shared_memory, init) +local iss_thread = threads.thread__iss(__shared_memory) if __shared_memory.networked then -- init comms threads diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index 8c08b86..bf95dbb 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -49,6 +49,8 @@ function new_session(id, for_reactor, in_queue, out_queue) control_state = false, overridden = false, degraded = false, + iss_tripped = false, + iss_trip_cause = "ok", iss_status = { dmg_crit = false, ex_hcool = false, @@ -262,13 +264,15 @@ function new_session(id, for_reactor, in_queue, out_queue) elseif rplc_pkt.type == RPLC_TYPES.ISS_ALARM then -- ISS alarm self.sDB.overridden = true - if rplc_pkt.length == 7 then - local status = pcall(_copy_iss_status, rplc_pkt.data) + if rplc_pkt.length == 8 then + self.sDB.iss_tripped = true + self.sDB.iss_trip_cause = rplc_pkt.data[1] + local status = pcall(_copy_iss_status, { table.unpack(rplc_pkt.data, 2, #rplc_pkt.length) }) if status then -- copied in ISS status data OK else -- error copying ISS status data - log._error(log_header .. "failed to parse ISS status packet data") + log._error(log_header .. "failed to parse ISS alarm status data") end else log._debug(log_header .. "RPLC ISS alarm packet length mismatch") @@ -277,6 +281,9 @@ function new_session(id, for_reactor, in_queue, out_queue) -- ISS clear acknowledgement if _get_ack(rplc_pkt) == false then log._warning(log_header .. "ISS clear failed") + else + self.sDB.iss_tripped = false + self.sDB.iss_trip_cause = "ok" end else log._debug(log_header .. "handler received unsupported RPLC packet type " .. rplc_pkt.type)