From 24c787f47d8c423adf7ae8d48295a15eecd0efea Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 14 Oct 2023 17:57:50 -0400 Subject: [PATCH] #353 fixed auto lock not restoring on reconnect --- supervisor/session/plc.lua | 3 +++ supervisor/startup.lua | 2 +- supervisor/unit.lua | 11 ++++++----- supervisor/unitlogic.lua | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index 85a6534..9c79434 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -590,6 +590,9 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f end end + -- check if the auto lock is active + function public.is_auto_locked() return self.auto_lock end + -- set the burn rate on behalf of automatic control ---@param rate number burn rate ---@param ramp boolean true to ramp, false to not diff --git a/supervisor/startup.lua b/supervisor/startup.lua index a1327f1..ec27930 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.0.8" +local SUPERVISOR_VERSION = "v1.0.9" local println = util.println local println_ts = util.println_ts diff --git a/supervisor/unit.lua b/supervisor/unit.lua index e0fe65e..ad6c3b0 100644 --- a/supervisor/unit.lua +++ b/supervisor/unit.lua @@ -498,7 +498,6 @@ function unit.new(reactor_id, num_boilers, num_turbines) self.plc_s = nil self.plc_i = nil self.db.control.br100 = 0 - self.db.control.lim_br100 = 0 end -- unlink RTU unit sessions if they are closed @@ -525,12 +524,14 @@ function unit.new(reactor_id, num_boilers, num_turbines) end end - -- check plc formed/faulted + -- plc instance checks if self.plc_i ~= nil then + -- check if degraded local rps = self.plc_i.get_rps() - if rps.fault or rps.sys_fail then - self.db.control.degraded = true - end + if rps.fault or rps.sys_fail then self.db.control.degraded = true end + + -- re-engage auto lock if it reconnected without it + if self.auto_engaged and not self.plc_i.is_auto_locked() then self.plc_i.auto_lock(true) end end -- update deltas diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index eb7fa27..f16f197 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -75,7 +75,7 @@ function logic.update_annunciator(self) (next(self.plc_i.get_status()) ~= nil) and (next(self.plc_i.get_struct()) ~= nil) -- update auto control limit - if (self.db.control.lim_br100 == 0) or ((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 self.db.control.lim_br100 = math.floor(plc_db.mek_struct.max_burn * 100) end