#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)
|
process.unit_ack(unit_id, cmd, ack)
|
||||||
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
||||||
process.unit_ack(unit_id, cmd, ack)
|
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
|
elseif cmd == UNIT_COMMAND.ACK_ALL_ALARMS then
|
||||||
process.unit_ack(unit_id, cmd, ack)
|
process.unit_ack(unit_id, cmd, ack)
|
||||||
elseif cmd == UNIT_COMMAND.SET_GROUP then
|
|
||||||
-- updated by unit updates
|
|
||||||
else
|
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
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c("received unit command ack with unknown unit ", unit_id))
|
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
|
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
||||||
charge_setpoint = 0, -- FE charge target setpoint
|
charge_setpoint = 0, -- FE charge target setpoint
|
||||||
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
|
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
|
||||||
group_map = {}, -- units -> group IDs
|
group_map = {}, ---@type integer[] units -> group IDs
|
||||||
prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units)
|
prio_defs = { {}, {}, {}, {} }, ---@type reactor_unit[][] priority definitions (each level is a table of units)
|
||||||
at_max_burn = false,
|
at_max_burn = false,
|
||||||
ascram = false,
|
ascram = false,
|
||||||
ascram_reason = AUTO_SCRAM.NONE,
|
ascram_reason = AUTO_SCRAM.NONE,
|
||||||
@ -375,6 +375,9 @@ function facility.new(config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check automatic control mode
|
||||||
|
function public.auto_is_active() return self.mode ~= PROCESS.INACTIVE end
|
||||||
|
|
||||||
-- stop auto control
|
-- stop auto control
|
||||||
function public.auto_stop() self.mode = PROCESS.INACTIVE end
|
function public.auto_stop() self.mode = PROCESS.INACTIVE end
|
||||||
|
|
||||||
@ -469,6 +472,11 @@ function facility.new(config)
|
|||||||
end
|
end
|
||||||
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
|
-- set waste production
|
||||||
---@param product WASTE_PRODUCT target product
|
---@param product WASTE_PRODUCT target product
|
||||||
---@return WASTE_PRODUCT product newly set value, if valid
|
---@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()
|
facility.scram_all()
|
||||||
_send(CRDN_TYPE.FAC_CMD, { cmd, true })
|
_send(CRDN_TYPE.FAC_CMD, { cmd, true })
|
||||||
elseif cmd == FAC_COMMAND.STOP then
|
elseif cmd == FAC_COMMAND.STOP then
|
||||||
facility.auto_stop()
|
local was_active = facility.auto_is_active()
|
||||||
_send(CRDN_TYPE.FAC_CMD, { cmd, true })
|
|
||||||
|
if was_active then
|
||||||
|
facility.auto_stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
_send(CRDN_TYPE.FAC_CMD, { cmd, was_active })
|
||||||
elseif cmd == FAC_COMMAND.START then
|
elseif cmd == FAC_COMMAND.START then
|
||||||
if pkt.length == 6 then
|
if pkt.length == 6 then
|
||||||
---@type sys_auto_config
|
---@type sys_auto_config
|
||||||
@ -299,17 +304,25 @@ function coordinator.new_session(id, s_addr, i_seq_num, in_queue, out_queue, tim
|
|||||||
|
|
||||||
-- continue if valid unit id
|
-- continue if valid unit id
|
||||||
if util.is_int(uid) and uid > 0 and uid <= #self.units then
|
if util.is_int(uid) and uid > 0 and uid <= #self.units then
|
||||||
local unit = self.units[uid] ---@type reactor_unit
|
local unit = self.units[uid] ---@type reactor_unit
|
||||||
|
local manual = facility.get_group(uid) == 0
|
||||||
|
|
||||||
if cmd == UNIT_COMMAND.START then
|
if cmd == UNIT_COMMAND.START then
|
||||||
out_queue.push_data(SV_Q_DATA.START, data)
|
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
|
elseif cmd == UNIT_COMMAND.SCRAM then
|
||||||
out_queue.push_data(SV_Q_DATA.SCRAM, data)
|
out_queue.push_data(SV_Q_DATA.SCRAM, data)
|
||||||
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
||||||
out_queue.push_data(SV_Q_DATA.RESET_RPS, data)
|
out_queue.push_data(SV_Q_DATA.RESET_RPS, data)
|
||||||
elseif cmd == UNIT_COMMAND.SET_BURN then
|
elseif cmd == UNIT_COMMAND.SET_BURN then
|
||||||
if pkt.length == 3 then
|
if pkt.length == 3 then
|
||||||
out_queue.push_data(SV_Q_DATA.SET_BURN, data)
|
if manual then
|
||||||
|
out_queue.push_data(SV_Q_DATA.SET_BURN, data)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log.debug(log_tag .. "CRDN unit command burn rate missing option")
|
log.debug(log_tag .. "CRDN unit command burn rate missing option")
|
||||||
end
|
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
|
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
|
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])
|
facility.set_group(unit.get_id(), pkt.data[3])
|
||||||
_send(CRDN_TYPE.UNIT_CMD, { cmd, uid, pkt.data[3] })
|
|
||||||
else
|
else
|
||||||
log.debug(log_tag .. "CRDN unit command set group missing group id")
|
log.debug(log_tag .. "CRDN unit command set group missing group id")
|
||||||
end
|
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
|
elseif ack == false then
|
||||||
log.debug(log_tag .. "burn rate update failed!")
|
log.debug(log_tag .. "burn rate update failed!")
|
||||||
end
|
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
|
elseif pkt.type == RPLC_TYPE.RPS_ENABLE then
|
||||||
-- enable acknowledgement
|
-- enable acknowledgement
|
||||||
local ack = _get_ack(pkt)
|
local ack = _get_ack(pkt)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user