#100 interactive reactor controls (start, scram, reset)

This commit is contained in:
Mikayla Fischler
2022-11-06 18:41:52 -05:00
parent aaab34f1a8
commit 806b217d58
12 changed files with 211 additions and 39 deletions

View File

@@ -29,6 +29,7 @@ local CRD_S_CMDS = {
}
local CRD_S_DATA = {
CMD_ACK = 1
}
coordinator.CRD_S_CMDS = CRD_S_CMDS
@@ -271,6 +272,12 @@ function coordinator.new_session(id, in_queue, out_queue, facility_units)
end
elseif message.qtype == mqueue.TYPE.DATA then
-- instruction with body
local cmd = message.message ---@type queue_data
if cmd.key == CRD_S_DATA.CMD_ACK then
local ack = cmd.val ---@type coord_ack
_send(SCADA_CRDN_TYPES.COMMAND_UNIT, { ack.cmd, ack.unit, ack.ack })
end
end
end

View File

@@ -74,14 +74,12 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
struct_req = (util.time() + 500),
status_req = (util.time() + 500),
scram_req = 0,
enable_req = 0,
burn_rate_req = 0,
rps_reset_req = 0
},
-- command acknowledgements
acks = {
scram = true,
enable = true,
burn_rate = true,
rps_reset = true
},
@@ -355,7 +353,6 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
-- enable acknowledgement
local ack = _get_ack(pkt)
if ack then
self.acks.enable = true
self.sDB.control_state = true
elseif ack == false then
log.debug(log_header .. "enable failed!")
@@ -537,8 +534,6 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
local cmd = message.message
if cmd == PLC_S_CMDS.ENABLE then
-- enable reactor
self.acks.enable = false
self.retry_times.enable_req = util.time() + INITIAL_WAIT
_send(RPLC_TYPES.RPS_ENABLE, {})
elseif cmd == PLC_S_CMDS.SCRAM then
-- SCRAM reactor
@@ -635,15 +630,6 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
end
end
-- enable request retry
if not self.acks.enable then
if rtimes.enable_req - util.time() <= 0 then
_send(RPLC_TYPES.RPS_ENABLE, {})
rtimes.enable_req = util.time() + RETRY_PERIOD
end
end
-- burn rate request retry
if not self.acks.burn_rate then

View File

@@ -14,6 +14,11 @@ local SV_Q_DATA = {
CRDN_ACK = 7
}
---@class coord_ack
---@field unit integer
---@field cmd integer
---@field ack boolean
svqtypes.SV_Q_CMDS = SV_Q_CMDS
svqtypes.SV_Q_DATA = SV_Q_DATA

View File

@@ -17,6 +17,7 @@ local SV_Q_DATA = svqtypes.SV_Q_DATA
local PLC_S_CMDS = plc.PLC_S_CMDS
local PLC_S_DATA = plc.PLC_S_DATA
local CRD_S_CMDS = coordinator.CRD_S_CMDS
local CRD_S_DATA = coordinator.CRD_S_DATA
local svsessions = {}
@@ -70,7 +71,6 @@ local function _sv_handle_outq(session)
if cmd.key < SV_Q_DATA.__END_PLC_CMDS__ then
-- PLC commands from coordinator
local crdn_sid = session.instance.get_id()
local plc_s = svsessions.get_reactor_session(cmd.val[1])
if plc_s ~= nil then
@@ -90,7 +90,11 @@ local function _sv_handle_outq(session)
end
else
if cmd.key == SV_Q_DATA.CRDN_ACK then
---@todo ack to be sent to coordinator
-- ack to be sent to coordinator
local crd_s = svsessions.get_coord_session()
if crd_s ~= nil then
crd_s.in_queue.push_data(CRD_S_DATA.CMD_ACK, cmd.val)
end
end
end
end

View File

@@ -13,7 +13,7 @@ local svsessions = require("supervisor.session.svsessions")
local config = require("supervisor.config")
local supervisor = require("supervisor.supervisor")
local SUPERVISOR_VERSION = "beta-v0.6.7"
local SUPERVISOR_VERSION = "beta-v0.6.8"
local print = util.print
local println = util.println