From 556331f75b6bbbef7ffc3d9bc8bf14ef90fa2255 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 9 Feb 2025 13:07:01 -0500 Subject: [PATCH] better unit ready check --- supervisor/session/plc.lua | 15 +++++++++++++-- supervisor/unitlogic.lua | 9 ++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index 68a8791..4eea46d 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -72,6 +72,7 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue, connected = true, received_struct = false, received_status_cache = false, + received_rps_status = false, conn_watchdog = util.new_watchdog(timeout), last_rtt = 0, -- 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 local status = pcall(_copy_rps_status, pkt.data) 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 initial_reset[reactor_id] = false 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 local status = pcall(_copy_rps_status, { true, table.unpack(pkt.data) }) 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 initial_reset[reactor_id] = false 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 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 ---@nodiscard function public.is_ramp_complete() diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index f0e4c33..8364d20 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -67,11 +67,10 @@ function logic.update_annunciator(self) local plc_db = self.plc_i.get_db() -- update ready state - -- - can't be tripped - -- - must have received status at least once - -- - must have received struct at least once - plc_ready = plc_db.formed and (not plc_db.no_reactor) and (not plc_db.rps_tripped) and - (next(self.plc_i.get_status()) ~= nil) and (next(self.plc_i.get_struct()) ~= nil) + -- - must be connected to a formed reactor + -- - can't have a tripped RPS + -- - 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 self.plc_i.check_received_all_data() -- 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