From 6a04354964b6d6b347e9f4a676c40127faaf4adc Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Thu, 3 Oct 2024 22:56:38 -0400 Subject: [PATCH] fixes for control app data updating --- coordinator/iocontrol.lua | 2 +- coordinator/session/pocket.lua | 3 +- pocket/iocontrol.lua | 2 +- scada-common/types.lua | 77 ++++++++++++++++++++++++++++++++++ scada-common/util.lua | 2 +- supervisor/session/plc.lua | 71 +------------------------------ supervisor/startup.lua | 2 +- 7 files changed, 84 insertions(+), 75 deletions(-) diff --git a/coordinator/iocontrol.lua b/coordinator/iocontrol.lua index 41bb058..5670219 100644 --- a/coordinator/iocontrol.lua +++ b/coordinator/iocontrol.lua @@ -219,7 +219,7 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale) annunciator = {}, ---@type annunciator unit_ps = psil.create(), - reactor_data = {}, ---@type reactor_db + reactor_data = types.new_reactor_db(), boiler_ps_tbl = {}, ---@type psil[] boiler_data_tbl = {}, ---@type boilerv_session_db[] diff --git a/coordinator/session/pocket.lua b/coordinator/session/pocket.lua index fa702c9..25dd2da 100644 --- a/coordinator/session/pocket.lua +++ b/coordinator/session/pocket.lua @@ -256,8 +256,9 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout) u.a_group } - _send(CRDN_TYPE.API_GET_CTRL, data) end + + _send(CRDN_TYPE.API_GET_CTRL, data) else log.debug(log_tag .. "handler received unsupported CRDN packet type " .. pkt.type) end diff --git a/pocket/iocontrol.lua b/pocket/iocontrol.lua index 3850795..8ad6b90 100644 --- a/pocket/iocontrol.lua +++ b/pocket/iocontrol.lua @@ -231,7 +231,7 @@ function iocontrol.init_fac(conf) annunciator = {}, ---@type annunciator unit_ps = psil.create(), - reactor_data = {}, ---@type reactor_db + reactor_data = types.new_reactor_db(), boiler_ps_tbl = {}, ---@type psil[] boiler_data_tbl = {}, ---@type boilerv_session_db[] diff --git a/scada-common/types.lua b/scada-common/types.lua index 29c52c5..ca1b885 100644 --- a/scada-common/types.lua +++ b/scada-common/types.lua @@ -127,6 +127,83 @@ function types.new_zero_coordinate() return { x = 0, y = 0, z = 0 } end ---@field reactor integer ---@field rsio IO_PORT[]|nil +-- create a new reactor database +---@nodiscard +function types.new_reactor_db() + ---@class reactor_db + local db = { + auto_ack_token = 0, + last_status_update = 0, + control_state = false, + no_reactor = false, + formed = false, + rps_tripped = false, + rps_trip_cause = "ok", ---@type rps_trip_cause + max_op_temp_H2O = 1200, + max_op_temp_Na = 1200, + ---@class rps_status + rps_status = { + high_dmg = false, + high_temp = false, + low_cool = false, + ex_waste = false, + ex_hcool = false, + no_fuel = false, + fault = false, + timeout = false, + manual = false, + automatic = false, + sys_fail = false, + force_dis = false + }, + ---@class mek_status + mek_status = { + heating_rate = 0.0, + + status = false, + burn_rate = 0.0, + act_burn_rate = 0.0, + temp = 0.0, + damage = 0.0, + boil_eff = 0.0, + env_loss = 0.0, + + fuel = 0, + fuel_need = 0, + fuel_fill = 0.0, + waste = 0, + waste_need = 0, + waste_fill = 0.0, + ccool_type = types.FLUID.EMPTY_GAS, ---@type fluid + ccool_amnt = 0, + ccool_need = 0, + ccool_fill = 0.0, + hcool_type = types.FLUID.EMPTY_GAS, ---@type fluid + hcool_amnt = 0, + hcool_need = 0, + hcool_fill = 0.0 + }, + ---@class mek_struct + mek_struct = { + length = 0, + width = 0, + height = 0, + min_pos = types.new_zero_coordinate(), + max_pos = types.new_zero_coordinate(), + heat_cap = 0, + fuel_asm = 0, + fuel_sa = 0, + fuel_cap = 0, + waste_cap = 0, + ccool_cap = 0, + hcool_cap = 0, + max_burn = 0.0 + } + } + + return db +end + --#endregion -- ALIASES -- diff --git a/scada-common/util.lua b/scada-common/util.lua index 2ae76a7..86645f8 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -24,7 +24,7 @@ local t_pack = table.pack local util = {} -- scada-common version -util.version = "1.4.5" +util.version = "1.4.6" util.TICK_TIME_S = 0.05 util.TICK_TIME_MS = 50 diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index 8850a16..bedbd8b 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -98,76 +98,7 @@ function plc.new_session(id, s_addr, i_seq_num, reactor_id, in_queue, out_queue, rps_reset = true }, -- session database - ---@class reactor_db - sDB = { - auto_ack_token = 0, - last_status_update = 0, - control_state = false, - no_reactor = false, - formed = false, - rps_tripped = false, - rps_trip_cause = "ok", ---@type rps_trip_cause - max_op_temp_H2O = 1200, - max_op_temp_Na = 1200, - ---@class rps_status - rps_status = { - high_dmg = false, - high_temp = false, - low_cool = false, - ex_waste = false, - ex_hcool = false, - no_fuel = false, - fault = false, - timeout = false, - manual = false, - automatic = false, - sys_fail = false, - force_dis = false - }, - ---@class mek_status - mek_status = { - heating_rate = 0.0, - - status = false, - burn_rate = 0.0, - act_burn_rate = 0.0, - temp = 0.0, - damage = 0.0, - boil_eff = 0.0, - env_loss = 0.0, - - fuel = 0, - fuel_need = 0, - fuel_fill = 0.0, - waste = 0, - waste_need = 0, - waste_fill = 0.0, - ccool_type = types.FLUID.EMPTY_GAS, ---@type fluid - ccool_amnt = 0, - ccool_need = 0, - ccool_fill = 0.0, - hcool_type = types.FLUID.EMPTY_GAS, ---@type fluid - hcool_amnt = 0, - hcool_need = 0, - hcool_fill = 0.0 - }, - ---@class mek_struct - mek_struct = { - length = 0, - width = 0, - height = 0, - min_pos = types.new_zero_coordinate(), - max_pos = types.new_zero_coordinate(), - heat_cap = 0, - fuel_asm = 0, - fuel_sa = 0, - fuel_cap = 0, - waste_cap = 0, - ccool_cap = 0, - hcool_cap = 0, - max_burn = 0.0 - } - } + sDB = types.new_reactor_db() } ---@class plc_session diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 5e47cef..db6c2c6 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -22,7 +22,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.5.5" +local SUPERVISOR_VERSION = "v1.5.6" local println = util.println local println_ts = util.println_ts