#640 bug fixes and enhancements
This commit is contained in:
parent
a083f8983b
commit
4c7ad0c539
@ -51,7 +51,7 @@ local function init(panel)
|
|||||||
|
|
||||||
local system = Div{parent=panel,width=14,height=18,x=2,y=3}
|
local system = Div{parent=panel,width=14,height=18,x=2,y=3}
|
||||||
|
|
||||||
local degraded = LED{parent=system,label="STATUS",colors=cpair(colors.green,colors.red)}
|
local degraded = LED{parent=system,label="STATUS",colors=cpair(colors.red,colors.green)}
|
||||||
local heartbeat = LED{parent=system,label="HEARTBEAT",colors=ind_grn}
|
local heartbeat = LED{parent=system,label="HEARTBEAT",colors=ind_grn}
|
||||||
system.line_break()
|
system.line_break()
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
reactor_enabled = false,
|
reactor_enabled = false,
|
||||||
enabled_at = 0,
|
enabled_at = 0,
|
||||||
emer_cool_active = nil, ---@type boolean
|
emer_cool_active = nil, ---@type boolean
|
||||||
formed = is_formed,
|
formed = is_formed, ---@type boolean|nil
|
||||||
force_disabled = false,
|
force_disabled = false,
|
||||||
tripped = false,
|
tripped = false,
|
||||||
trip_cause = "ok" ---@type rps_trip_cause
|
trip_cause = "ok" ---@type rps_trip_cause
|
||||||
@ -364,29 +364,35 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
return public.activate()
|
return public.activate()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check all safety conditions
|
-- check all safety conditions if we have a formed reactor, otherwise handle a subset of conditions
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
|
---@param has_reactor boolean if the PLC state indicates we have a reactor
|
||||||
---@return boolean tripped, rps_trip_cause trip_status, boolean first_trip
|
---@return boolean tripped, rps_trip_cause trip_status, boolean first_trip
|
||||||
function public.check()
|
function public.check(has_reactor)
|
||||||
local status = RPS_TRIP_CAUSE.OK
|
local status = RPS_TRIP_CAUSE.OK
|
||||||
local was_tripped = self.tripped
|
local was_tripped = self.tripped
|
||||||
local first_trip = false
|
local first_trip = false
|
||||||
|
|
||||||
if self.formed then
|
if has_reactor then
|
||||||
-- update state
|
if self.formed then
|
||||||
parallel.waitForAll(
|
-- update state
|
||||||
_is_formed,
|
parallel.waitForAll(
|
||||||
_is_force_disabled,
|
_is_formed,
|
||||||
_high_damage,
|
_is_force_disabled,
|
||||||
_high_temp,
|
_high_damage,
|
||||||
_low_coolant,
|
_high_temp,
|
||||||
_excess_waste,
|
_low_coolant,
|
||||||
_excess_heated_coolant,
|
_excess_waste,
|
||||||
_insufficient_fuel
|
_excess_heated_coolant,
|
||||||
)
|
_insufficient_fuel
|
||||||
|
)
|
||||||
|
else
|
||||||
|
-- check to see if its now formed
|
||||||
|
_is_formed()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- check to see if its now formed
|
self.formed = nil
|
||||||
_is_formed()
|
self.state[CHK.SYS_FAIL] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check system states in order of severity
|
-- check system states in order of severity
|
||||||
@ -474,6 +480,7 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
---@nodiscard
|
---@nodiscard
|
||||||
function public.is_active() return self.reactor_enabled end
|
function public.is_active() return self.reactor_enabled end
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
|
---@return boolean|nil formed true if formed, false if not, nil if unknown
|
||||||
function public.is_formed() return self.formed end
|
function public.is_formed() return self.formed end
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function public.is_force_disabled() return self.force_disabled end
|
function public.is_force_disabled() return self.force_disabled end
|
||||||
@ -495,14 +502,14 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- partial RPS reset that only clears fault and sys_fail
|
-- partial RPS reset that only clears fault and sys_fail
|
||||||
function public.reset_formed()
|
function public.reset_reattach()
|
||||||
self.tripped = false
|
self.tripped = false
|
||||||
self.trip_cause = RPS_TRIP_CAUSE.OK
|
self.trip_cause = RPS_TRIP_CAUSE.OK
|
||||||
|
|
||||||
self.state[CHK.FAULT] = false
|
self.state[CHK.FAULT] = false
|
||||||
self.state[CHK.SYS_FAIL] = false
|
self.state[CHK.SYS_FAIL] = false
|
||||||
|
|
||||||
log.info("RPS: partial reset on formed")
|
log.info("RPS: partial reset on connected or formed")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- reset the automatic and timeout trip flags, then clear trip if that was the trip cause
|
-- reset the automatic and timeout trip flags, then clear trip if that was the trip cause
|
||||||
@ -584,11 +591,7 @@ function plc.comms(version, nic, reactor, rps, conn_watchdog)
|
|||||||
-- dynamic reactor status information, excluding heating rate
|
-- dynamic reactor status information, excluding heating rate
|
||||||
---@return table data_table, boolean faulted
|
---@return table data_table, boolean faulted
|
||||||
local function _get_reactor_status()
|
local function _get_reactor_status()
|
||||||
local fuel = nil
|
local fuel, waste, coolant, hcoolant = nil, nil, nil, nil
|
||||||
local waste = nil
|
|
||||||
local coolant = nil
|
|
||||||
local hcoolant = nil
|
|
||||||
|
|
||||||
local data_table = {}
|
local data_table = {}
|
||||||
|
|
||||||
reactor.__p_disable_afc()
|
reactor.__p_disable_afc()
|
||||||
|
|||||||
@ -94,12 +94,9 @@ function threads.thread__main(smem)
|
|||||||
-- reactor now formed
|
-- reactor now formed
|
||||||
plc_state.reactor_formed = true
|
plc_state.reactor_formed = true
|
||||||
|
|
||||||
println_ts("reactor is now formed.")
|
println_ts("reactor is now formed")
|
||||||
log.info("reactor is now formed")
|
log.info("reactor is now formed")
|
||||||
|
|
||||||
-- SCRAM newly formed reactor
|
|
||||||
smem.q.mq_rps.push_command(MQ__RPS_CMD.SCRAM)
|
|
||||||
|
|
||||||
-- determine if we are still in a degraded state
|
-- determine if we are still in a degraded state
|
||||||
if (not networked) or nic.is_connected() then
|
if (not networked) or nic.is_connected() then
|
||||||
plc_state.degraded = false
|
plc_state.degraded = false
|
||||||
@ -107,10 +104,10 @@ function threads.thread__main(smem)
|
|||||||
|
|
||||||
-- partial reset of RPS, specific to becoming formed
|
-- partial reset of RPS, specific to becoming formed
|
||||||
-- without this, auto control can't resume on chunk load
|
-- without this, auto control can't resume on chunk load
|
||||||
rps.reset_formed()
|
rps.reset_reattach()
|
||||||
elseif plc_state.reactor_formed and not rps.is_formed() then
|
elseif plc_state.reactor_formed and (rps.is_formed() == false) then
|
||||||
-- reactor no longer formed
|
-- reactor no longer formed
|
||||||
println_ts("reactor is no longer formed.")
|
println_ts("reactor is no longer formed")
|
||||||
log.info("reactor is no longer formed")
|
log.info("reactor is no longer formed")
|
||||||
|
|
||||||
plc_state.reactor_formed = false
|
plc_state.reactor_formed = false
|
||||||
@ -182,7 +179,7 @@ function threads.thread__main(smem)
|
|||||||
plc_dev.reactor = device
|
plc_dev.reactor = device
|
||||||
plc_state.no_reactor = false
|
plc_state.no_reactor = false
|
||||||
|
|
||||||
println_ts("reactor reconnected.")
|
println_ts("reactor reconnected")
|
||||||
log.info("reactor reconnected")
|
log.info("reactor reconnected")
|
||||||
|
|
||||||
-- we need to assume formed here as we cannot check in this main loop
|
-- we need to assume formed here as we cannot check in this main loop
|
||||||
@ -203,7 +200,7 @@ function threads.thread__main(smem)
|
|||||||
|
|
||||||
-- partial reset of RPS, specific to becoming formed/reconnected
|
-- partial reset of RPS, specific to becoming formed/reconnected
|
||||||
-- without this, auto control can't resume on chunk load
|
-- without this, auto control can't resume on chunk load
|
||||||
rps.reset_formed()
|
rps.reset_reattach()
|
||||||
elseif networked and type == "modem" then
|
elseif networked and type == "modem" then
|
||||||
---@cast device Modem
|
---@cast device Modem
|
||||||
-- note, check init_ok first since nic will be nil if it is false
|
-- note, check init_ok first since nic will be nil if it is false
|
||||||
@ -218,7 +215,7 @@ function threads.thread__main(smem)
|
|||||||
log.info("comms modem reconnected")
|
log.info("comms modem reconnected")
|
||||||
|
|
||||||
-- determine if we are still in a degraded state
|
-- determine if we are still in a degraded state
|
||||||
if not plc_state.no_reactor then
|
if plc_state.reactor_formed and not plc_state.no_reactor then
|
||||||
plc_state.degraded = false
|
plc_state.degraded = false
|
||||||
end
|
end
|
||||||
elseif device.isWireless() then
|
elseif device.isWireless() then
|
||||||
@ -327,15 +324,10 @@ function threads.thread__rps(smem)
|
|||||||
if not (networked or smem.plc_state.fp_ok) then rps.reset(true) end
|
if not (networked or smem.plc_state.fp_ok) then rps.reset(true) end
|
||||||
|
|
||||||
-- check safety (SCRAM occurs if tripped)
|
-- check safety (SCRAM occurs if tripped)
|
||||||
if not plc_state.no_reactor then
|
local rps_tripped, rps_status_string, rps_first = rps.check(not plc_state.no_reactor)
|
||||||
local rps_tripped, rps_status_string, rps_first = rps.check()
|
if rps_tripped and rps_first then
|
||||||
|
println_ts("[RPS] SCRAM! safety trip: " .. rps_status_string)
|
||||||
if rps_tripped and rps_first then
|
if networked then plc_comms.send_rps_alarm(rps_status_string) end
|
||||||
println_ts("[RPS] SCRAM! safety trip: " .. rps_status_string)
|
|
||||||
if networked and not plc_state.no_modem then
|
|
||||||
plc_comms.send_rps_alarm(rps_status_string)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for messages in the message queue
|
-- check for messages in the message queue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user