better unit ready check

This commit is contained in:
Mikayla Fischler 2025-02-09 13:07:01 -05:00
parent 40cb9f599a
commit 556331f75b
2 changed files with 17 additions and 7 deletions

View File

@ -72,6 +72,7 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue,
connected = true, connected = true,
received_struct = false, received_struct = false,
received_status_cache = false, received_status_cache = false,
received_rps_status = false,
conn_watchdog = util.new_watchdog(timeout), conn_watchdog = util.new_watchdog(timeout),
last_rtt = 0, last_rtt = 0,
-- periodic messages -- periodic messages
@ -380,7 +381,10 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue,
if pkt.length == 14 then if pkt.length == 14 then
local status = pcall(_copy_rps_status, pkt.data) local status = pcall(_copy_rps_status, pkt.data)
if status then if status then
-- copied in RPS status data OK, try initial reset if applicable -- copied in RPS status data OK
self.received_rps_status = true
-- try initial reset if needed
if initial_reset[reactor_id] then if initial_reset[reactor_id] then
initial_reset[reactor_id] = false initial_reset[reactor_id] = false
if self.sDB.rps_trip_cause == "timeout" then if self.sDB.rps_trip_cause == "timeout" then
@ -400,7 +404,10 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue,
if pkt.length == 13 then if pkt.length == 13 then
local status = pcall(_copy_rps_status, { true, table.unpack(pkt.data) }) local status = pcall(_copy_rps_status, { true, table.unpack(pkt.data) })
if status then if status then
-- copied in RPS status data OK, try initial reset if applicable -- copied in RPS status data OK
self.received_rps_status = true
-- try initial reset if needed
if initial_reset[reactor_id] then if initial_reset[reactor_id] then
initial_reset[reactor_id] = false initial_reset[reactor_id] = false
if self.sDB.rps_trip_cause == "timeout" then if self.sDB.rps_trip_cause == "timeout" then
@ -501,6 +508,10 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue,
---@nodiscard ---@nodiscard
function public.get_db() return self.sDB end function public.get_db() return self.sDB end
-- check if the reactor structure, status, and RPS status have been received
---@nodiscard
function public.check_received_all_data() return self.received_struct and self.received_status_cache and self.received_rps_status end
-- check if ramping is completed by first verifying auto command token ack -- check if ramping is completed by first verifying auto command token ack
---@nodiscard ---@nodiscard
function public.is_ramp_complete() function public.is_ramp_complete()

View File

@ -67,11 +67,10 @@ function logic.update_annunciator(self)
local plc_db = self.plc_i.get_db() local plc_db = self.plc_i.get_db()
-- update ready state -- update ready state
-- - can't be tripped -- - must be connected to a formed reactor
-- - must have received status at least once -- - can't have a tripped RPS
-- - must have received struct at least once -- - must have received status, struct, and RPS status at least once
plc_ready = plc_db.formed and (not plc_db.no_reactor) and (not plc_db.rps_tripped) and plc_ready = plc_db.formed and (not plc_db.no_reactor) and (not plc_db.rps_tripped) and self.plc_i.check_received_all_data()
(next(self.plc_i.get_status()) ~= nil) and (next(self.plc_i.get_struct()) ~= nil)
-- update auto control limit -- update auto control limit
if (plc_db.mek_struct.max_burn > 0) and ((self.db.control.lim_br100 / 100) > plc_db.mek_struct.max_burn) then if (plc_db.mek_struct.max_burn > 0) and ((self.db.control.lim_br100 / 100) > plc_db.mek_struct.max_burn) then