From 2b73196130ca20dbb6d0f837301fb20d4ac69ca0 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 25 Feb 2025 16:43:03 -0500 Subject: [PATCH] #480 updated aux coolant logic --- scada-common/constants.lua | 2 ++ supervisor/unit.lua | 1 + supervisor/unitlogic.lua | 23 +++++++++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/scada-common/constants.lua b/scada-common/constants.lua index 0472a6c..11a8929 100644 --- a/scada-common/constants.lua +++ b/scada-common/constants.lua @@ -72,6 +72,8 @@ local rs = {} rs.IMATRIX_CHARGE_LOW = 0.05 -- activation threshold (less than) for F_MATRIX_LOW rs.IMATRIX_CHARGE_HIGH = 0.95 -- activation threshold (greater than) for F_MATRIX_HIGH +rs.AUX_COOL_ENABLE = 0.60 -- actiation threshold (less than or equal) for U_AUX_COOL +rs.AUX_COOL_DISABLE = 1.00 -- deactivation threshold (greater than or equal) for U_AUX_COOL constants.RS_THRESHOLDS = rs diff --git a/supervisor/unit.lua b/supervisor/unit.lua index 67992aa..b448a95 100644 --- a/supervisor/unit.lua +++ b/supervisor/unit.lua @@ -114,6 +114,7 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle, aux_coolant) damage_est_last = 0, waste_product = WASTE.PLUTONIUM, ---@type WASTE_PRODUCT status_text = { "UNKNOWN", "awaiting connection..." }, + enable_aux_cool = false, -- logic for alarms had_reactor = false, turbine_flow_stable = false, diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index 25e4f24..6bd7470 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -35,6 +35,7 @@ local FLOW_STABILITY_DELAY_MS = const.FLOW_STABILITY_DELAY_MS local ANNUNC_LIMS = const.ANNUNCIATOR_LIMITS local ALARM_LIMS = const.ALARM_LIMITS +local RS_THRESH = const.RS_THRESHOLDS ---@class unit_logic_extension local logic = {} @@ -54,6 +55,10 @@ function logic.update_annunciator(self) -- variables for boiler, or reactor if no boilers used local total_boil_rate = 0.0 + -- auxiliary coolant control + local need_aux_cool = false + local dis_aux_cool = true + --#region Reactor annunc.AutoControl = self.auto_engaged @@ -148,6 +153,9 @@ function logic.update_annunciator(self) -- if no boilers, use reactor heating rate to check for boil rate mismatch if num_boilers == 0 then total_boil_rate = plc_db.mek_status.heating_rate + + need_aux_cool = plc_db.mek_status.ccool_fill <= RS_THRESH.AUX_COOL_ENABLE + dis_aux_cool = plc_db.mek_status.ccool_fill >= RS_THRESH.AUX_COOL_DISABLE end else self.plc_cache.ok = false @@ -215,6 +223,9 @@ function logic.update_annunciator(self) annunc.BoilerOnline[idx] = true annunc.WaterLevelLow[idx] = boiler.tanks.water_fill < ANNUNC_LIMS.WaterLevelLow + + need_aux_cool = need_aux_cool or (boiler.tanks.water_fill <= RS_THRESH.AUX_COOL_ENABLE) + dis_aux_cool = dis_aux_cool and (boiler.tanks.water_fill >= RS_THRESH.AUX_COOL_DISABLE) end -- check heating rate low @@ -406,6 +417,12 @@ function logic.update_annunciator(self) -- update auto control ready state for this unit self.db.control.ready = plc_ready and boilers_ready and turbines_ready + + -- update auxiliary coolant command + if plc_ready then + self.enable_aux_cool = self.plc_i.get_db().mek_status.status and + (self.enable_aux_cool or need_aux_cool) and not (dis_aux_cool and self.turbine_flow_stable) + else self.enable_aux_cool = false end end -- update an alarm state given conditions @@ -953,12 +970,10 @@ function logic.handle_redstone(self) ----------------------- if self.aux_coolant then - local enable_aux_cool = boiler_water_low or (annunc.CoolantLevelLow and self.num_boilers == 0) - - if enable_aux_cool and not self.aux_cool_opened then + if self.enable_aux_cool and (not self.aux_cool_opened) then log.info(util.c("UNIT ", self.r_id, " auxiliary coolant valve opened")) self.aux_cool_opened = true - elseif self.aux_cool_opened and self.turbine_flow_stable and not enable_aux_cool then + elseif (not self.enable_aux_cool) and self.aux_cool_opened then log.info(util.c("UNIT ", self.r_id, " auxiliary coolant valve closed")) self.aux_cool_opened = false end