#498 supervisor block disallowed commands based on state, removed unused acks
This commit is contained in:
parent
bf10b3241e
commit
8ffbbb5ac9
@ -632,16 +632,10 @@ function coordinator.comms(version, nic, sv_watchdog)
|
||||
process.unit_ack(unit_id, cmd, ack)
|
||||
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
||||
process.unit_ack(unit_id, cmd, ack)
|
||||
elseif cmd == UNIT_COMMAND.SET_BURN then
|
||||
-- this also doesn't exist
|
||||
elseif cmd == UNIT_COMMAND.SET_WASTE then
|
||||
-- updated by unit updates
|
||||
elseif cmd == UNIT_COMMAND.ACK_ALL_ALARMS then
|
||||
process.unit_ack(unit_id, cmd, ack)
|
||||
elseif cmd == UNIT_COMMAND.SET_GROUP then
|
||||
-- updated by unit updates
|
||||
else
|
||||
log.debug(util.c("received unit command ack with unknown command ", cmd))
|
||||
log.debug(util.c("received unsupported unit command ack for command ", cmd))
|
||||
end
|
||||
else
|
||||
log.debug(util.c("received unit command ack with unknown unit ", unit_id))
|
||||
|
||||
@ -73,8 +73,8 @@ function facility.new(config)
|
||||
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
||||
charge_setpoint = 0, -- FE charge target setpoint
|
||||
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
|
||||
group_map = {}, -- units -> group IDs
|
||||
prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units)
|
||||
group_map = {}, ---@type integer[] units -> group IDs
|
||||
prio_defs = { {}, {}, {}, {} }, ---@type reactor_unit[][] priority definitions (each level is a table of units)
|
||||
at_max_burn = false,
|
||||
ascram = false,
|
||||
ascram_reason = AUTO_SCRAM.NONE,
|
||||
@ -375,6 +375,9 @@ function facility.new(config)
|
||||
end
|
||||
end
|
||||
|
||||
-- check automatic control mode
|
||||
function public.auto_is_active() return self.mode ~= PROCESS.INACTIVE end
|
||||
|
||||
-- stop auto control
|
||||
function public.auto_stop() self.mode = PROCESS.INACTIVE end
|
||||
|
||||
@ -469,6 +472,11 @@ function facility.new(config)
|
||||
end
|
||||
end
|
||||
|
||||
-- get the automatic control group of a unit
|
||||
---@param unit_id integer unit ID
|
||||
---@nodiscard
|
||||
function public.get_group(unit_id) return self.group_map[unit_id] end
|
||||
|
||||
-- set waste production
|
||||
---@param product WASTE_PRODUCT target product
|
||||
---@return WASTE_PRODUCT product newly set value, if valid
|
||||
|
||||
@ -241,8 +241,13 @@ function coordinator.new_session(id, s_addr, i_seq_num, in_queue, out_queue, tim
|
||||
facility.scram_all()
|
||||
_send(CRDN_TYPE.FAC_CMD, { cmd, true })
|
||||
elseif cmd == FAC_COMMAND.STOP then
|
||||
local was_active = facility.auto_is_active()
|
||||
|
||||
if was_active then
|
||||
facility.auto_stop()
|
||||
_send(CRDN_TYPE.FAC_CMD, { cmd, true })
|
||||
end
|
||||
|
||||
_send(CRDN_TYPE.FAC_CMD, { cmd, was_active })
|
||||
elseif cmd == FAC_COMMAND.START then
|
||||
if pkt.length == 6 then
|
||||
---@type sys_auto_config
|
||||
@ -300,16 +305,24 @@ function coordinator.new_session(id, s_addr, i_seq_num, in_queue, out_queue, tim
|
||||
-- continue if valid unit id
|
||||
if util.is_int(uid) and uid > 0 and uid <= #self.units then
|
||||
local unit = self.units[uid] ---@type reactor_unit
|
||||
local manual = facility.get_group(uid) == 0
|
||||
|
||||
if cmd == UNIT_COMMAND.START then
|
||||
if manual then
|
||||
out_queue.push_data(SV_Q_DATA.START, data)
|
||||
else
|
||||
-- denied
|
||||
_send(CRDN_TYPE.UNIT_CMD, { cmd, uid, false })
|
||||
end
|
||||
elseif cmd == UNIT_COMMAND.SCRAM then
|
||||
out_queue.push_data(SV_Q_DATA.SCRAM, data)
|
||||
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
||||
out_queue.push_data(SV_Q_DATA.RESET_RPS, data)
|
||||
elseif cmd == UNIT_COMMAND.SET_BURN then
|
||||
if pkt.length == 3 then
|
||||
if manual then
|
||||
out_queue.push_data(SV_Q_DATA.SET_BURN, data)
|
||||
end
|
||||
else
|
||||
log.debug(log_tag .. "CRDN unit command burn rate missing option")
|
||||
end
|
||||
@ -337,7 +350,6 @@ function coordinator.new_session(id, s_addr, i_seq_num, in_queue, out_queue, tim
|
||||
elseif cmd == UNIT_COMMAND.SET_GROUP then
|
||||
if (pkt.length == 3) and (type(pkt.data[3]) == "number") and (pkt.data[3] >= 0) and (pkt.data[3] <= 4) then
|
||||
facility.set_group(unit.get_id(), pkt.data[3])
|
||||
_send(CRDN_TYPE.UNIT_CMD, { cmd, uid, pkt.data[3] })
|
||||
else
|
||||
log.debug(log_tag .. "CRDN unit command set group missing group id")
|
||||
end
|
||||
|
||||
@ -395,13 +395,6 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue,
|
||||
elseif ack == false then
|
||||
log.debug(log_tag .. "burn rate update failed!")
|
||||
end
|
||||
|
||||
-- send acknowledgement to coordinator
|
||||
out_queue.push_data(svqtypes.SV_Q_DATA.CRDN_ACK, {
|
||||
unit = reactor_id,
|
||||
cmd = UNIT_COMMAND.SET_BURN,
|
||||
ack = ack
|
||||
})
|
||||
elseif pkt.type == RPLC_TYPE.RPS_ENABLE then
|
||||
-- enable acknowledgement
|
||||
local ack = _get_ack(pkt)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user