From c4df8eabf95c1c88c23b91871f161d7ff5a0a0dc Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Thu, 5 May 2022 11:55:04 -0400 Subject: [PATCH] #43 rename ISS to RPS --- reactor-plc/plc.lua | 92 +++++++++++++++++++------------------- reactor-plc/startup.lua | 24 +++++----- reactor-plc/threads.lua | 72 ++++++++++++++--------------- scada-common/comms.lua | 12 ++--- scada-common/types.lua | 2 +- supervisor/session/plc.lua | 92 +++++++++++++++++++------------------- supervisor/startup.lua | 2 +- 7 files changed, 148 insertions(+), 148 deletions(-) diff --git a/reactor-plc/plc.lua b/reactor-plc/plc.lua index 54f47d2..d53ad95 100644 --- a/reactor-plc/plc.lua +++ b/reactor-plc/plc.lua @@ -6,7 +6,7 @@ local util = require("scada-common.util") local plc = {} -local iss_status_t = types.iss_status_t +local rps_status_t = types.rps_status_t local PROTOCOLS = comms.PROTOCOLS local RPLC_TYPES = comms.RPLC_TYPES @@ -18,10 +18,10 @@ local println = util.println local print_ts = util.print_ts local println_ts = util.println_ts --- Internal Safety System +-- Reactor Protection System -- identifies dangerous states and SCRAMs reactor if warranted -- autonomous from main SCADA supervisor/coordinator control -plc.iss_init = function (reactor) +plc.rps_init = function (reactor) local self = { reactor = reactor, cache = { false, false, false, false, false, false, false }, @@ -37,7 +37,7 @@ plc.iss_init = function (reactor) local damage_percent = self.reactor.getDamagePercent() if damage_percent == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor damage") + log.error("RPS: failed to check reactor damage") return false else return damage_percent >= 100 @@ -49,7 +49,7 @@ plc.iss_init = function (reactor) local hc_needed = self.reactor.getHeatedCoolantNeeded() if hc_needed == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor heated coolant level") + log.error("RPS: failed to check reactor heated coolant level") return false else return hc_needed == 0 @@ -61,7 +61,7 @@ plc.iss_init = function (reactor) local w_needed = self.reactor.getWasteNeeded() if w_needed == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor waste level") + log.error("RPS: failed to check reactor waste level") return false else return w_needed == 0 @@ -74,7 +74,7 @@ plc.iss_init = function (reactor) local temp = self.reactor.getTemperature() if temp == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor temperature") + log.error("RPS: failed to check reactor temperature") return false else return temp >= 1200 @@ -86,7 +86,7 @@ plc.iss_init = function (reactor) local fuel = self.reactor.getFuel() if fuel == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor fuel level") + log.error("RPS: failed to check reactor fuel level") return false else return fuel == 0 @@ -98,7 +98,7 @@ plc.iss_init = function (reactor) local coolant_filled = self.reactor.getCoolantFilledPercentage() if coolant_filled == ppm.ACCESS_FAULT then -- lost the peripheral or terminated, handled later - log.error("ISS: failed to check reactor coolant level") + log.error("RPS: failed to check reactor coolant level") return false else return coolant_filled < 0.02 @@ -119,7 +119,7 @@ plc.iss_init = function (reactor) -- check all safety conditions local check = function () - local status = iss_status_t.ok + local status = rps_status_t.ok local was_tripped = self.tripped -- update cache @@ -137,34 +137,34 @@ plc.iss_init = function (reactor) if self.tripped then status = self.trip_cause elseif self.cache[1] then - log.warning("ISS: damage critical!") - status = iss_status_t.dmg_crit + log.warning("RPS: damage critical!") + status = rps_status_t.dmg_crit elseif self.cache[4] then - log.warning("ISS: high temperature!") - status = iss_status_t.high_temp + log.warning("RPS: high temperature!") + status = rps_status_t.high_temp elseif self.cache[2] then - log.warning("ISS: heated coolant backup!") - status = iss_status_t.ex_hcoolant + log.warning("RPS: heated coolant backup!") + status = rps_status_t.ex_hcoolant elseif self.cache[6] then - log.warning("ISS: no coolant!") - status = iss_status_t.no_coolant + log.warning("RPS: no coolant!") + status = rps_status_t.no_coolant elseif self.cache[3] then - log.warning("ISS: full waste!") - status = iss_status_t.ex_waste + log.warning("RPS: full waste!") + status = rps_status_t.ex_waste elseif self.cache[5] then - log.warning("ISS: no fuel!") - status = iss_status_t.no_fuel + log.warning("RPS: no fuel!") + status = rps_status_t.no_fuel elseif self.cache[7] then - log.warning("ISS: supervisor connection timeout!") - status = iss_status_t.timeout + log.warning("RPS: supervisor connection timeout!") + status = rps_status_t.timeout else self.tripped = false end -- if a new trip occured... local first_trip = false - if not was_tripped and status ~= iss_status_t.ok then - log.warning("ISS: reactor SCRAM") + if not was_tripped and status ~= rps_status_t.ok then + log.warning("RPS: reactor SCRAM") first_trip = true self.tripped = true @@ -172,22 +172,22 @@ plc.iss_init = function (reactor) self.reactor.scram() if self.reactor.__p_is_faulted() then - log.error("ISS: failed reactor SCRAM") + log.error("RPS: failed reactor SCRAM") end end return self.tripped, status, first_trip end - -- get the ISS status + -- get the RPS status local status = function () return self.cache end local is_tripped = function () return self.tripped end - -- reset the ISS + -- reset the RPS local reset = function () self.timed_out = false self.tripped = false - self.trip_cause = iss_status_t.ok + self.trip_cause = rps_status_t.ok end return { @@ -201,7 +201,7 @@ plc.iss_init = function (reactor) end -- reactor PLC communications -plc.comms = function (id, modem, local_port, server_port, reactor, iss) +plc.comms = function (id, modem, local_port, server_port, reactor, rps) local self = { id = id, seq_num = 0, @@ -210,7 +210,7 @@ plc.comms = function (id, modem, local_port, server_port, reactor, iss) s_port = server_port, l_port = local_port, reactor = reactor, - iss = iss, + rps = rps, scrammed = false, linked = false, status_cache = nil, @@ -411,7 +411,7 @@ plc.comms = function (id, modem, local_port, server_port, reactor, iss) local sys_status = { util.time(), -- timestamp (not self.scrammed), -- enabled - iss.is_tripped(), -- overridden + rps.is_tripped(), -- overridden degraded, -- degraded self.reactor.getHeatingRate(), -- heating rate mek_data -- mekanism status data @@ -425,22 +425,22 @@ plc.comms = function (id, modem, local_port, server_port, reactor, iss) end end - -- send safety system status - local send_iss_status = function () + -- send reactor protection system status + local send_rps_status = function () if self.linked then - _send(RPLC_TYPES.ISS_STATUS, iss.status()) + _send(RPLC_TYPES.RPS_STATUS, rps.status()) end end - -- send safety system alarm - local send_iss_alarm = function (cause) + -- send reactor protection system alarm + local send_rps_alarm = function (cause) if self.linked then - local iss_alarm = { + local rps_alarm = { cause, - table.unpack(iss.status()) + table.unpack(rps.status()) } - _send(RPLC_TYPES.ISS_ALARM, iss_alarm) + _send(RPLC_TYPES.RPS_ALARM, rps_alarm) end end @@ -581,9 +581,9 @@ plc.comms = function (id, modem, local_port, server_port, reactor, iss) else log.debug("RPLC set burn rate packet length mismatch") end - elseif packet.type == RPLC_TYPES.ISS_CLEAR then - -- clear the ISS status - iss.reset() + elseif packet.type == RPLC_TYPES.RPS_RESET then + -- reset the RPS status + rps.reset() _send_ack(packet.type, true) else log.warning("received unknown RPLC packet type " .. packet.type) @@ -647,8 +647,8 @@ plc.comms = function (id, modem, local_port, server_port, reactor, iss) close = close, send_link_req = send_link_req, send_status = send_status, - send_iss_status = send_iss_status, - send_iss_alarm = send_iss_alarm, + send_rps_status = send_rps_status, + send_rps_alarm = send_rps_alarm, parse_packet = parse_packet, handle_packet = handle_packet, is_scrammed = is_scrammed, diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index dde16e7..e8654dc 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -11,7 +11,7 @@ local config = require("config") local plc = require("plc") local threads = require("threads") -local R_PLC_VERSION = "alpha-v0.6.0" +local R_PLC_VERSION = "alpha-v0.6.1" local print = util.print local println = util.println @@ -55,14 +55,14 @@ local __shared_memory = { -- system objects plc_sys = { - iss = nil, + rps = nil, plc_comms = nil, conn_watchdog = nil }, -- message queues q = { - mq_iss = mqueue.new(), + mq_rps = mqueue.new(), mq_comms_tx = mqueue.new(), mq_comms_rx = mqueue.new() } @@ -100,13 +100,13 @@ function init() -- just booting up, no fission allowed (neutrons stay put thanks) smem_dev.reactor.scram() - -- init internal safety system - smem_sys.iss = plc.iss_init(smem_dev.reactor) - log.debug("iss init") + -- init reactor protection system + smem_sys.rps = plc.rps_init(smem_dev.reactor) + log.debug("rps init") if __shared_memory.networked then -- start comms - smem_sys.plc_comms = plc.comms(config.REACTOR_ID, smem_dev.modem, config.LISTEN_PORT, config.SERVER_PORT, smem_dev.reactor, smem_sys.iss) + smem_sys.plc_comms = plc.comms(config.REACTOR_ID, smem_dev.modem, config.LISTEN_PORT, config.SERVER_PORT, smem_dev.reactor, smem_sys.rps) log.debug("comms init") -- comms watchdog, 3 second timeout @@ -131,7 +131,7 @@ init() -- init threads local main_thread = threads.thread__main(__shared_memory, init) -local iss_thread = threads.thread__iss(__shared_memory) +local rps_thread = threads.thread__rps(__shared_memory) if __shared_memory.networked then -- init comms threads @@ -142,19 +142,19 @@ if __shared_memory.networked then local sp_ctrl_thread = threads.thread__setpoint_control(__shared_memory) -- run threads - parallel.waitForAll(main_thread.exec, iss_thread.exec, comms_thread_tx.exec, comms_thread_rx.exec, sp_ctrl_thread.exec) + parallel.waitForAll(main_thread.exec, rps_thread.exec, comms_thread_tx.exec, comms_thread_rx.exec, sp_ctrl_thread.exec) if plc_state.init_ok then - -- send status one last time after ISS shutdown + -- send status one last time after RPS shutdown smem_sys.plc_comms.send_status(plc_state.degraded) - smem_sys.plc_comms.send_iss_status() + smem_sys.plc_comms.send_rps_status() -- close connection smem_sys.plc_comms.close(smem_sys.conn_watchdog) end else -- run threads, excluding comms - parallel.waitForAll(main_thread.exec, iss_thread.exec) + parallel.waitForAll(main_thread.exec, rps_thread.exec) end println_ts("exited") diff --git a/reactor-plc/threads.lua b/reactor-plc/threads.lua index f689955..5deaf10 100644 --- a/reactor-plc/threads.lua +++ b/reactor-plc/threads.lua @@ -13,13 +13,13 @@ local println_ts = util.println_ts local psleep = util.psleep local MAIN_CLOCK = 1 -- (1Hz, 20 ticks) -local ISS_SLEEP = 500 -- (500ms, 10 ticks) +local RPS_SLEEP = 500 -- (500ms, 10 ticks) local COMMS_SLEEP = 150 -- (150ms, 3 ticks) local SP_CTRL_SLEEP = 250 -- (250ms, 5 ticks) local BURN_RATE_RAMP_mB_s = 5.0 -local MQ__ISS_CMD = { +local MQ__RPS_CMD = { SCRAM = 1, DEGRADED_SCRAM = 2, TRIP_TIMEOUT = 3 @@ -45,7 +45,7 @@ threads.thread__main = function (smem, init) local networked = smem.networked local plc_state = smem.plc_state local plc_dev = smem.plc_dev - local iss = smem.plc_sys.iss + local rps = smem.plc_sys.rps local plc_comms = smem.plc_sys.plc_comms local conn_watchdog = smem.plc_sys.conn_watchdog @@ -84,7 +84,7 @@ threads.thread__main = function (smem, init) elseif event == "timer" and networked and param1 == conn_watchdog.get_timer() then -- haven't heard from server recently? shutdown reactor plc_comms.unlink() - smem.q.mq_iss.push_command(MQ__ISS_CMD.TRIP_TIMEOUT) + smem.q.mq_rps.push_command(MQ__RPS_CMD.TRIP_TIMEOUT) elseif event == "peripheral_detach" then -- peripheral disconnect local device = ppm.handle_unmount(param1) @@ -103,7 +103,7 @@ threads.thread__main = function (smem, init) if plc_state.init_ok then -- try to scram reactor if it is still connected - smem.q.mq_iss.push_command(MQ__ISS_CMD.DEGRADED_SCRAM) + smem.q.mq_rps.push_command(MQ__RPS_CMD.DEGRADED_SCRAM) end plc_state.degraded = true @@ -119,14 +119,14 @@ threads.thread__main = function (smem, init) -- reconnected reactor plc_dev.reactor = device - smem.q.mq_iss.push_command(MQ__ISS_CMD.SCRAM) + smem.q.mq_rps.push_command(MQ__RPS_CMD.SCRAM) println_ts("reactor reconnected.") log.info("reactor reconnected.") plc_state.no_reactor = false if plc_state.init_ok then - iss.reconnect_reactor(plc_dev.reactor) + rps.reconnect_reactor(plc_dev.reactor) if networked then plc_comms.reconnect_reactor(plc_dev.reactor) end @@ -171,7 +171,7 @@ threads.thread__main = function (smem, init) -- check for termination request if event == "terminate" or ppm.should_terminate() then log.info("terminate requested, main thread exiting") - -- iss handles reactor shutdown + -- rps handles reactor shutdown plc_state.shutdown = true break end @@ -181,20 +181,20 @@ threads.thread__main = function (smem, init) return { exec = exec } end --- ISS monitor thread -threads.thread__iss = function (smem) +-- RPS operation thread +threads.thread__rps = function (smem) -- execute thread local exec = function () - log.debug("iss thread start") + log.debug("rps thread start") -- load in from shared memory local networked = smem.networked local plc_state = smem.plc_state local plc_dev = smem.plc_dev - local iss = smem.plc_sys.iss + local rps = smem.plc_sys.rps local plc_comms = smem.plc_sys.plc_comms - local iss_queue = smem.q.mq_iss + local rps_queue = smem.q.mq_rps local was_linked = false local last_update = util.time() @@ -203,14 +203,14 @@ threads.thread__iss = function (smem) while true do local reactor = plc_dev.reactor - -- ISS checks + -- RPS checks if plc_state.init_ok then -- SCRAM if no open connection if networked and not plc_comms.is_linked() then plc_state.scram = true if was_linked then was_linked = false - iss.trip_timeout() + rps.trip_timeout() end else -- would do elseif not networked but there is no reason to do that extra operation @@ -223,38 +223,38 @@ threads.thread__iss = function (smem) reactor.scram() end - -- if we are in standalone mode, continuously reset ISS - -- ISS will trip again if there are faults, but if it isn't cleared, the user can't re-enable + -- if we are in standalone mode, continuously reset RPS + -- RPS will trip again if there are faults, but if it isn't cleared, the user can't re-enable if not networked then plc_state.scram = false - iss.reset() + rps.reset() end -- check safety (SCRAM occurs if tripped) if not plc_state.no_reactor then - local iss_tripped, iss_status_string, iss_first = iss.check() - plc_state.scram = plc_state.scram or iss_tripped + local rps_tripped, rps_status_string, rps_first = rps.check() + plc_state.scram = plc_state.scram or rps_tripped - if iss_first then - println_ts("[ISS] SCRAM! safety trip: " .. iss_status_string) + if rps_first then + println_ts("[RPS] SCRAM! safety trip: " .. rps_status_string) if networked and not plc_state.no_modem then - plc_comms.send_iss_alarm(iss_status_string) + plc_comms.send_rps_alarm(rps_status_string) end end end end -- check for messages in the message queue - while iss_queue.ready() and not plc_state.shutdown do - local msg = iss_queue.pop() + while rps_queue.ready() and not plc_state.shutdown do + local msg = rps_queue.pop() if msg.qtype == mqueue.TYPE.COMMAND then -- received a command - if msg.message == MQ__ISS_CMD.SCRAM then + if msg.message == MQ__RPS_CMD.SCRAM then -- basic SCRAM plc_state.scram = true reactor.scram() - elseif msg.message == MQ__ISS_CMD.DEGRADED_SCRAM then + elseif msg.message == MQ__RPS_CMD.DEGRADED_SCRAM then -- SCRAM with print plc_state.scram = true if reactor.scram() then @@ -264,10 +264,10 @@ threads.thread__iss = function (smem) println_ts("failed reactor SCRAM") log.error("failed reactor SCRAM") end - elseif msg.message == MQ__ISS_CMD.TRIP_TIMEOUT then + elseif msg.message == MQ__RPS_CMD.TRIP_TIMEOUT then -- watchdog tripped plc_state.scram = true - iss.trip_timeout() + rps.trip_timeout() println_ts("server timeout") log.warning("server timeout") end @@ -284,24 +284,24 @@ threads.thread__iss = function (smem) -- check for termination request if plc_state.shutdown then -- safe exit - log.info("iss thread shutdown initiated") + log.info("rps thread shutdown initiated") if plc_state.init_ok then plc_state.scram = true reactor.scram() if reactor.__p_is_ok() then println_ts("reactor disabled") - log.info("iss thread reactor SCRAM OK") + log.info("rps thread reactor SCRAM OK") else println_ts("exiting, reactor failed to disable") - log.error("iss thread failed to SCRAM reactor on exit") + log.error("rps thread failed to SCRAM reactor on exit") end end - log.info("iss thread exiting") + log.info("rps thread exiting") break end -- delay before next check - last_update = util.adaptive_delay(ISS_SLEEP, last_update) + last_update = util.adaptive_delay(RPS_SLEEP, last_update) end end @@ -331,9 +331,9 @@ threads.thread__comms_tx = function (smem) if msg.qtype == mqueue.TYPE.COMMAND then -- received a command if msg.message == MQ__COMM_CMD.SEND_STATUS then - -- send PLC/ISS status + -- send PLC/RPS status plc_comms.send_status(plc_state.degraded) - plc_comms.send_iss_status() + plc_comms.send_rps_status() end elseif msg.qtype == mqueue.TYPE.DATA then -- received data diff --git a/scada-common/comms.lua b/scada-common/comms.lua index 17050a8..da6f5d3 100644 --- a/scada-common/comms.lua +++ b/scada-common/comms.lua @@ -20,9 +20,9 @@ local RPLC_TYPES = { MEK_SCRAM = 4, -- SCRAM reactor MEK_ENABLE = 5, -- enable reactor MEK_BURN_RATE = 6, -- set burn rate - ISS_STATUS = 7, -- ISS status - ISS_ALARM = 8, -- ISS alarm broadcast - ISS_CLEAR = 9 -- clear ISS trip (if in bad state, will trip immediately) + RPS_STATUS = 7, -- RPS status + RPS_ALARM = 8, -- RPS alarm broadcast + RPS_RESET = 9 -- clear RPS trip (if in bad state, will trip immediately) } local RPLC_LINKING = { @@ -232,9 +232,9 @@ comms.rplc_packet = function () self.type == RPLC_TYPES.MEK_SCRAM or self.type == RPLC_TYPES.MEK_ENABLE or self.type == RPLC_TYPES.MEK_BURN_RATE or - self.type == RPLC_TYPES.ISS_ALARM or - self.type == RPLC_TYPES.ISS_STATUS or - self.type == RPLC_TYPES.ISS_CLEAR + self.type == RPLC_TYPES.RPS_ALARM or + self.type == RPLC_TYPES.RPS_STATUS or + self.type == RPLC_TYPES.RPS_RESET end -- make an RPLC packet diff --git a/scada-common/types.lua b/scada-common/types.lua index 5346bca..855334e 100644 --- a/scada-common/types.lua +++ b/scada-common/types.lua @@ -14,7 +14,7 @@ types.rtu_t = { induction_matrix = "induction_matrix" } -types.iss_status_t = { +types.rps_status_t = { ok = "ok", dmg_crit = "dmg_crit", ex_hcoolant = "heated_coolant_backup", diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index ee11819..bb79ac1 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -22,7 +22,7 @@ local PLC_S_CMDS = { SCRAM = 0, ENABLE = 1, BURN_RATE = 2, - ISS_CLEAR = 3 + RPS_RESET = 3 } plc.PLC_S_CMDS = PLC_S_CMDS @@ -62,14 +62,14 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) scram_req = 0, enable_req = 0, burn_rate_req = 0, - iss_clear_req = 0 + rps_reset_req = 0 }, -- command acknowledgements acks = { scram = true, enable = true, burn_rate = true, - iss_clear = true + rps_reset = true }, -- session database sDB = { @@ -77,9 +77,9 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) control_state = false, overridden = false, degraded = false, - iss_tripped = false, - iss_trip_cause = "ok", - iss_status = { + rps_tripped = false, + rps_trip_cause = "ok", + rps_status = { dmg_crit = false, ex_hcool = false, ex_waste = false, @@ -127,14 +127,14 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) } } - local _copy_iss_status = function (iss_status) - self.sDB.iss_status.dmg_crit = iss_status[1] - self.sDB.iss_status.ex_hcool = iss_status[2] - self.sDB.iss_status.ex_waste = iss_status[3] - self.sDB.iss_status.high_temp = iss_status[4] - self.sDB.iss_status.no_fuel = iss_status[5] - self.sDB.iss_status.no_cool = iss_status[6] - self.sDB.iss_status.timed_out = iss_status[7] + local _copy_rps_status = function (rps_status) + self.sDB.rps_status.dmg_crit = rps_status[1] + self.sDB.rps_status.ex_hcool = rps_status[2] + self.sDB.rps_status.ex_waste = rps_status[3] + self.sDB.rps_status.high_temp = rps_status[4] + self.sDB.rps_status.no_fuel = rps_status[5] + self.sDB.rps_status.no_cool = rps_status[6] + self.sDB.rps_status.timed_out = rps_status[7] end local _copy_status = function (mek_data) @@ -317,44 +317,44 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) elseif ack == false then log.debug(log_header .. "burn rate update failed!") end - elseif pkt.type == RPLC_TYPES.ISS_STATUS then - -- ISS status packet received, copy data + elseif pkt.type == RPLC_TYPES.RPS_STATUS then + -- RPS status packet received, copy data if pkt.length == 7 then - local status = pcall(_copy_iss_status, pkt.data) + local status = pcall(_copy_rps_status, pkt.data) if status then - -- copied in ISS status data OK + -- copied in RPS status data OK else - -- error copying ISS status data - log.error(log_header .. "failed to parse ISS status packet data") + -- error copying RPS status data + log.error(log_header .. "failed to parse RPS status packet data") end else - log.debug(log_header .. "RPLC ISS status packet length mismatch") + log.debug(log_header .. "RPLC RPS status packet length mismatch") end - elseif pkt.type == RPLC_TYPES.ISS_ALARM then - -- ISS alarm + elseif pkt.type == RPLC_TYPES.RPS_ALARM then + -- RPS alarm self.sDB.overridden = true if pkt.length == 8 then - self.sDB.iss_tripped = true - self.sDB.iss_trip_cause = pkt.data[1] - local status = pcall(_copy_iss_status, { table.unpack(pkt.data, 2, #pkt.length) }) + self.sDB.rps_tripped = true + self.sDB.rps_trip_cause = pkt.data[1] + local status = pcall(_copy_rps_status, { table.unpack(pkt.data, 2, #pkt.length) }) if status then - -- copied in ISS status data OK + -- copied in RPS status data OK else - -- error copying ISS status data - log.error(log_header .. "failed to parse ISS alarm status data") + -- error copying RPS status data + log.error(log_header .. "failed to parse RPS alarm status data") end else - log.debug(log_header .. "RPLC ISS alarm packet length mismatch") + log.debug(log_header .. "RPLC RPS alarm packet length mismatch") end - elseif pkt.type == RPLC_TYPES.ISS_CLEAR then - -- ISS clear acknowledgement + elseif pkt.type == RPLC_TYPES.RPS_RESET then + -- RPS reset acknowledgement local ack = _get_ack(pkt) if ack then - self.acks.iss_tripped = true - self.sDB.iss_tripped = false - self.sDB.iss_trip_cause = "ok" + self.acks.rps_tripped = true + self.sDB.rps_tripped = false + self.sDB.rps_trip_cause = "ok" elseif ack == false then - log.debug(log_header .. "ISS clear failed") + log.debug(log_header .. "RPS reset failed") end else log.debug(log_header .. "handler received unsupported RPLC packet type " .. pkt.type) @@ -438,11 +438,11 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) self.acks.enable = false self.retry_times.enable_req = util.time() + INITIAL_WAIT _send(RPLC_TYPES.MEK_ENABLE, {}) - elseif cmd == PLC_S_CMDS.ISS_CLEAR then - -- clear ISS - self.acks.iss_clear = false - self.retry_times.iss_clear_req = util.time() + INITIAL_WAIT - _send(RPLC_TYPES.ISS_CLEAR, {}) + elseif cmd == PLC_S_CMDS.RPS_RESET then + -- reset RPS + self.acks.rps_reset = false + self.retry_times.rps_reset_req = util.time() + INITIAL_WAIT + _send(RPLC_TYPES.RPS_RESET, {}) end elseif message.qtype == mqueue.TYPE.DATA then -- instruction with body @@ -540,12 +540,12 @@ plc.new_session = function (id, for_reactor, in_queue, out_queue) end end - -- ISS clear request retry + -- RPS reset request retry - if not self.acks.iss_clear then - if rtimes.iss_clear_req - util.time() <= 0 then - _send(RPLC_TYPES.ISS_CLEAR, {}) - rtimes.iss_clear_req = util.time() + RETRY_PERIOD + if not self.acks.rps_reset then + if rtimes.rps_reset_req - util.time() <= 0 then + _send(RPLC_TYPES.RPS_RESET, {}) + rtimes.rps_reset_req = util.time() + RETRY_PERIOD end end end diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 3059bab..a93dab9 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -14,7 +14,7 @@ local svsessions = require("session.svsessions") local config = require("config") local supervisor = require("supervisor") -local SUPERVISOR_VERSION = "alpha-v0.3.0" +local SUPERVISOR_VERSION = "alpha-v0.3.1" local print = util.print local println = util.println