From d9e48f5cac4d01d2a79d2f0fbcf195a95e831883 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 25 Aug 2023 20:02:59 -0400 Subject: [PATCH 1/9] #325 fixed coordinator unit overview height calcs --- coordinator/startup.lua | 2 +- coordinator/ui/components/unit_overview.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 826c256..16bd8e5 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.2" +local COORDINATOR_VERSION = "v1.0.3" local println = util.println local println_ts = util.println_ts diff --git a/coordinator/ui/components/unit_overview.lua b/coordinator/ui/components/unit_overview.lua index 3af8c83..b4a3750 100644 --- a/coordinator/ui/components/unit_overview.lua +++ b/coordinator/ui/components/unit_overview.lua @@ -34,7 +34,7 @@ local function make(parent, x, y, unit) if num_boilers == 0 and num_turbines == 1 then height = 9 - elseif num_boilers == 1 and num_turbines <= 2 then + elseif num_boilers <= 1 and num_turbines <= 2 then height = 17 end From 89d1087b1c0f0d7bcb262a219e0dc368620e79e4 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 25 Aug 2023 20:49:38 -0400 Subject: [PATCH 2/9] updated flow monitor to say boiler when 1, boilers when 2 --- coordinator/startup.lua | 2 +- coordinator/ui/components/unit_flow.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 16bd8e5..317ee5e 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.3" +local COORDINATOR_VERSION = "v1.0.4" local println = util.println local println_ts = util.println_ts diff --git a/coordinator/ui/components/unit_flow.lua b/coordinator/ui/components/unit_flow.lua index dbac025..2f371f5 100644 --- a/coordinator/ui/components/unit_flow.lua +++ b/coordinator/ui/components/unit_flow.lua @@ -112,7 +112,7 @@ local function make(parent, x, y, wide, unit) local boiler = Rectangle{parent=root,x=_wide(47,40),y=1,border=border(1, colors.gray, true),width=19,height=5,fg_bg=wh_gray} TextBox{parent=boiler,y=1,text="THERMO-ELECTRIC",alignment=TEXT_ALIGN.CENTER,height=1} - TextBox{parent=boiler,y=3,text="BOILERS",alignment=TEXT_ALIGN.CENTER,height=1} + TextBox{parent=boiler,y=3,text=util.trinary(unit.num_boilers>1,"BOILERS","BOILER"),alignment=TEXT_ALIGN.CENTER,height=1} TextBox{parent=root,x=_wide(47,40),y=2,text="\x1b \x80 \x1a",width=1,height=3,fg_bg=lg_gray} TextBox{parent=root,x=_wide(65,58),y=2,text="\x1b \x80 \x1a",width=1,height=3,fg_bg=lg_gray} From d18a93f7d211714dd8efeacabb70019d26ddd2c2 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 25 Aug 2023 20:53:28 -0400 Subject: [PATCH 3/9] #326 added commas to dynamic tank fill --- coordinator/startup.lua | 2 +- coordinator/ui/layout/flow_view.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 317ee5e..3f0c769 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.4" +local COORDINATOR_VERSION = "v1.0.5" local println = util.println local println_ts = util.println_ts diff --git a/coordinator/ui/layout/flow_view.lua b/coordinator/ui/layout/flow_view.lua index 54b14b5..99611a1 100644 --- a/coordinator/ui/layout/flow_view.lua +++ b/coordinator/ui/layout/flow_view.lua @@ -297,7 +297,7 @@ local function init(main) TextBox{parent=tank_box,x=2,y=3,text="Fill",height=1,width=10,fg_bg=style.label} local tank_pcnt = DataIndicator{parent=tank_box,x=10,y=3,label="",format="%5.2f",value=100,unit="%",lu_colors=lu_col,width=8,fg_bg=text_col} - local tank_amnt = DataIndicator{parent=tank_box,x=2,label="",format="%13d",value=0,unit="mB",lu_colors=lu_col,width=16,fg_bg=bw_fg_bg} + local tank_amnt = DataIndicator{parent=tank_box,x=2,label="",format="%13d",value=0,commas=true,unit="mB",lu_colors=lu_col,width=16,fg_bg=bw_fg_bg} TextBox{parent=tank_box,x=2,y=6,text="Water Level",height=1,width=11,fg_bg=style.label} local level = HorizontalBar{parent=tank_box,x=2,y=7,bar_fg_bg=cpair(colors.blue,colors.gray),height=1,width=16} From 8b0a5d529e98e0cd3e106cc390fff6f657cf11fe Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 25 Aug 2023 21:02:24 -0400 Subject: [PATCH 4/9] #330 close coordinator comms on error exit --- coordinator/startup.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 3f0c769..5bbff2b 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.5" +local COORDINATOR_VERSION = "v1.0.6" local println = util.println local println_ts = util.println_ts @@ -394,6 +394,9 @@ local function main() if link_failed then println_ts("failed to connect to supervisor") end if not ui_ok then println_ts("main UI creation failed") end + -- close on error exit (such as UI error) + if coord_comms.is_linked() then coord_comms.close() end + println_ts("exited") log.info("exited") end From b7d4468cea9f3618252dd43f26f081c46ae92b90 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 25 Aug 2023 21:42:35 -0400 Subject: [PATCH 5/9] #327 close connections on timeout --- reactor-plc/startup.lua | 2 +- reactor-plc/threads.lua | 4 ++-- rtu/startup.lua | 2 +- rtu/threads.lua | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 66435d9..2c58637 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -19,7 +19,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.5.6" +local R_PLC_VERSION = "v1.5.7" local println = util.println local println_ts = util.println_ts diff --git a/reactor-plc/threads.lua b/reactor-plc/threads.lua index 12ae75a..3b06904 100644 --- a/reactor-plc/threads.lua +++ b/reactor-plc/threads.lua @@ -154,8 +154,8 @@ function threads.thread__main(smem, init) smem.q.mq_comms_rx.push_packet(packet) end elseif event == "timer" and networked and plc_state.init_ok and conn_watchdog.is_timer(param1) then - -- haven't heard from server recently? shutdown reactor - plc_comms.unlink() + -- haven't heard from server recently? close connection and shutdown reactor + plc_comms.close() smem.q.mq_rps.push_command(MQ__RPS_CMD.TRIP_TIMEOUT) elseif event == "timer" then -- notify timer callback dispatcher if no other timer case claimed this event diff --git a/rtu/startup.lua b/rtu/startup.lua index acec142..1663bce 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.6.0" +local RTU_VERSION = "v1.6.1" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/rtu/threads.lua b/rtu/threads.lua index ee8e270..6ac05bd 100644 --- a/rtu/threads.lua +++ b/rtu/threads.lua @@ -93,8 +93,8 @@ function threads.thread__main(smem) smem.q.mq_comms.push_packet(packet) end elseif event == "timer" and conn_watchdog.is_timer(param1) then - -- haven't heard from server recently? unlink - rtu_comms.unlink(rtu_state) + -- haven't heard from server recently? close connection + rtu_comms.close(rtu_state) elseif event == "timer" then -- notify timer callback dispatcher if no other timer case claimed this event tcd.handle(param1) From 386a33ffd8dfad25fa970fabe3f8bdbed8137804 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 26 Aug 2023 11:54:58 -0400 Subject: [PATCH 6/9] #298 consistent log tags --- coordinator/session/apisessions.lua | 12 ++++++------ coordinator/startup.lua | 2 +- supervisor/session/svsessions.lua | 20 ++++++++++---------- supervisor/startup.lua | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/coordinator/session/apisessions.lua b/coordinator/session/apisessions.lua index c1f1d4e..6e8c771 100644 --- a/coordinator/session/apisessions.lua +++ b/coordinator/session/apisessions.lua @@ -42,8 +42,8 @@ local function _api_handle_outq(session) -- max 100ms spent processing queue if util.time() - handle_start > 100 then - log.warning("[API] out queue handler exceeded 100ms queue process limit") - log.warning(util.c("[API] offending session: ", session)) + log.warning("API: out queue handler exceeded 100ms queue process limit") + log.warning(util.c("API: offending session: ", session)) break end end @@ -63,7 +63,7 @@ local function _shutdown(session) end end - log.debug(util.c("[API] closed session ", session)) + log.debug(util.c("API: closed session ", session)) end -- PUBLIC FUNCTIONS -- @@ -114,7 +114,7 @@ function apisessions.establish_session(source_addr, version) setmetatable(pkt_s, mt) iocontrol.fp_pkt_connected(id, version, source_addr) - log.debug(util.c("[API] established new session: ", pkt_s)) + log.debug(util.c("API: established new session: ", pkt_s)) self.next_id = id + 1 @@ -130,7 +130,7 @@ function apisessions.check_all_watchdogs(timer_event) if session.open then local triggered = session.instance.check_wd(timer_event) if triggered then - log.debug(util.c("[API] watchdog closing session ", session, "...")) + log.debug(util.c("API: watchdog closing session ", session, "...")) _shutdown(session) end end @@ -156,7 +156,7 @@ function apisessions.free_all_closed() ---@param session pkt_session_struct local on_delete = function (session) - log.debug(util.c("[API] free'ing closed session ", session)) + log.debug(util.c("API: free'ing closed session ", session)) end util.filter_table(self.sessions, f, on_delete) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 5bbff2b..52405b9 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.6" +local COORDINATOR_VERSION = "v1.0.7" local println = util.println local println_ts = util.println_ts diff --git a/supervisor/session/svsessions.lua b/supervisor/session/svsessions.lua index 05b543b..166a067 100644 --- a/supervisor/session/svsessions.lua +++ b/supervisor/session/svsessions.lua @@ -81,7 +81,7 @@ local function _sv_handle_outq(session) elseif cmd.key == SV_Q_DATA.SET_BURN and type(cmd.val) == "table" and #cmd.val == 2 then plc_s.in_queue.push_data(PLC_S_DATA.BURN_RATE, cmd.val[2]) else - log.debug(util.c("[SVS] unknown PLC SV queue command ", cmd.key)) + log.debug(util.c("SVS: unknown PLC SV queue command ", cmd.key)) end end else @@ -104,8 +104,8 @@ local function _sv_handle_outq(session) -- max 100ms spent processing queue if util.time() - handle_start > 100 then - log.debug("[SVS] supervisor out queue handler exceeded 100ms queue process limit") - log.debug(util.c("[SVS] offending session: ", session)) + log.debug("SVS: supervisor out queue handler exceeded 100ms queue process limit") + log.debug(util.c("SVS: offending session: ", session)) break end end @@ -139,7 +139,7 @@ local function _shutdown(session) end end - log.debug(util.c("[SVS] closed session ", session)) + log.debug(util.c("SVS: closed session ", session)) end -- close connections @@ -160,7 +160,7 @@ local function _check_watchdogs(sessions, timer_event) if session.open then local triggered = session.instance.check_wd(timer_event) if triggered then - log.debug(util.c("[SVS] watchdog closing session ", session, "...")) + log.debug(util.c("SVS: watchdog closing session ", session, "...")) _shutdown(session) end end @@ -174,7 +174,7 @@ local function _free_closed(sessions) ---@param session sv_session_structs local on_delete = function (session) - log.debug(util.c("[SVS] free'ing closed session ", session)) + log.debug(util.c("SVS: free'ing closed session ", session)) end util.filter_table(sessions, f, on_delete) @@ -312,7 +312,7 @@ function svsessions.establish_plc_session(source_addr, for_reactor, version) setmetatable(plc_s, mt) databus.tx_plc_connected(for_reactor, version, source_addr) - log.debug(util.c("[SVS] established new session: ", plc_s)) + log.debug(util.c("SVS: established new session: ", plc_s)) self.next_ids.plc = id + 1 @@ -357,7 +357,7 @@ function svsessions.establish_rtu_session(source_addr, advertisement, version) setmetatable(rtu_s, mt) databus.tx_rtu_connected(id, version, source_addr) - log.debug(util.c("[SVS] established new session: ", rtu_s)) + log.debug(util.c("SVS: established new session: ", rtu_s)) self.next_ids.rtu = id + 1 @@ -398,7 +398,7 @@ function svsessions.establish_crd_session(source_addr, version) setmetatable(crd_s, mt) databus.tx_crd_connected(version, source_addr) - log.debug(util.c("[SVS] established new session: ", crd_s)) + log.debug(util.c("SVS: established new session: ", crd_s)) self.next_ids.crd = id + 1 @@ -442,7 +442,7 @@ function svsessions.establish_pdg_session(source_addr, version) setmetatable(pdg_s, mt) databus.tx_pdg_connected(id, version, source_addr) - log.debug(util.c("[SVS] established new session: ", pdg_s)) + log.debug(util.c("SVS: established new session: ", pdg_s)) self.next_ids.pdg = id + 1 diff --git a/supervisor/startup.lua b/supervisor/startup.lua index c1a7036..45f4d4f 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.0" +local SUPERVISOR_VERSION = "v1.0.1" local println = util.println local println_ts = util.println_ts From 17698b7fb4313e23175405b580fa58839707cff0 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 26 Aug 2023 12:22:47 -0400 Subject: [PATCH 7/9] #332 fixed turbine production rate on coordinator UI --- coordinator/startup.lua | 2 +- coordinator/ui/components/turbine.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 52405b9..910d3db 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.7" +local COORDINATOR_VERSION = "v1.0.8" local println = util.println local println_ts = util.println_ts diff --git a/coordinator/ui/components/turbine.lua b/coordinator/ui/components/turbine.lua index 9fb6f50..7bd4405 100644 --- a/coordinator/ui/components/turbine.lua +++ b/coordinator/ui/components/turbine.lua @@ -31,8 +31,8 @@ local function new_view(root, x, y, ps) local flow_rate = DataIndicator{parent=turbine,x=5,y=4,lu_colors=lu_col,label="",unit="mB/t",format="%10.0f",value=0,commas=true,width=16,fg_bg=text_fg_bg} status.register(ps, "computed_status", status.update) - prod_rate.register(ps, "steam_input_rate", function (val) prod_rate.update(util.joules_to_fe(val)) end) - flow_rate.register(ps, "flow_rate", flow_rate.update) + prod_rate.register(ps, "prod_rate", function (val) prod_rate.update(util.joules_to_fe(val)) end) + flow_rate.register(ps, "steam_input_rate", flow_rate.update) local steam = VerticalBar{parent=turbine,x=2,y=1,fg_bg=cpair(colors.white,colors.gray),height=4,width=1} local energy = VerticalBar{parent=turbine,x=3,y=1,fg_bg=cpair(colors.green,colors.gray),height=4,width=1} From 2ed28cf74dc4dbd86b39bfba75ecf1ec19478f9b Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 26 Aug 2023 19:01:22 -0400 Subject: [PATCH 8/9] #324 fixed alarm sounder lag --- coordinator/sounder.lua | 2 +- coordinator/startup.lua | 2 +- rtu/startup.lua | 2 +- rtu/threads.lua | 2 +- scada-common/audio.lua | 3 +++ scada-common/util.lua | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/coordinator/sounder.lua b/coordinator/sounder.lua index e3b2051..e7a02ac 100644 --- a/coordinator/sounder.lua +++ b/coordinator/sounder.lua @@ -51,7 +51,7 @@ function sounder.set(states) -- re-compute output if needed, then play audio if available if alarm_ctl.stream.is_recompute_needed() then alarm_ctl.stream.compute_buffer() end - if alarm_ctl.stream.has_next_block() then play() else sounder.stop() end + if alarm_ctl.stream.any_active() then play() else sounder.stop() end end -- stop all audio and clear output buffer diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 910d3db..b4f08ce 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.0.8" +local COORDINATOR_VERSION = "v1.0.9" local println = util.println local println_ts = util.println_ts diff --git a/rtu/startup.lua b/rtu/startup.lua index 1663bce..02679c2 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.6.1" +local RTU_VERSION = "v1.6.2" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/rtu/threads.lua b/rtu/threads.lua index 6ac05bd..bed6294 100644 --- a/rtu/threads.lua +++ b/rtu/threads.lua @@ -73,7 +73,7 @@ function threads.thread__main(smem) -- re-compute output if needed, then play audio if available if sounder.stream.is_recompute_needed() then sounder.stream.compute_buffer() - if sounder.stream.has_next_block() then sounder.play() else sounder.stop() end + if sounder.stream.any_active() then sounder.play() else sounder.stop() end end end diff --git a/scada-common/audio.lua b/scada-common/audio.lua index 32dfb57..019b510 100644 --- a/scada-common/audio.lua +++ b/scada-common/audio.lua @@ -296,6 +296,9 @@ function audio.new_stream() end end + -- check if any alarms are active + function public.any_active() return self.any_active end + -- check if the next audio block has data function public.has_next_block() return #self.quad_buffer[self.next_block] > 0 end diff --git a/scada-common/util.lua b/scada-common/util.lua index bf44884..ea53575 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -8,7 +8,7 @@ local cc_strings = require("cc.strings") local util = {} -- scada-common version -util.version = "1.0.1" +util.version = "1.0.2" -- ENVIRONMENT CONSTANTS -- From 37f8b85924236048c858316f7cab800f36cb04f2 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 27 Aug 2023 13:42:25 -0400 Subject: [PATCH 9/9] #333 always set emergency coolant state --- supervisor/startup.lua | 2 +- supervisor/unitlogic.lua | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 45f4d4f..dbde074 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.1" +local SUPERVISOR_VERSION = "v1.0.2" local println = util.println local println_ts = util.println_ts diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index 080f529..f2ee7aa 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -793,12 +793,10 @@ function logic.handle_redstone(self) local enable_emer_cool = self.plc_cache.rps_status.low_cool or (self.auto_engaged and self.db.annunciator.CoolantLevelLow and is_active(self.alarms.ReactorOverTemp)) + -- don't turn off emergency coolant on sufficient coolant level since it might drop again + -- turn off once system is OK again + -- if auto control is engaged, alarm check will SCRAM on reactor over temp so that's covered if not self.plc_cache.rps_trip then - -- can't turn off on sufficient coolant level since it might drop again - -- turn off once system is OK again - -- if auto control is engaged, alarm check will SCRAM on reactor over temp so that's covered - self.valves.emer_cool.close() - -- set turbines to not dump steam for i = 1, #self.turbines do local session = self.turbines[i] ---@type unit_session @@ -816,8 +814,6 @@ function logic.handle_redstone(self) self.emcool_opened = false elseif enable_emer_cool or self.emcool_opened then - self.valves.emer_cool.open() - -- set turbines to dump excess steam for i = 1, #self.turbines do local session = self.turbines[i] ---@type unit_session @@ -845,6 +841,9 @@ function logic.handle_redstone(self) self.emcool_opened = true end + + -- set valve state always + if self.emcool_opened then self.valves.emer_cool.open() else self.valves.emer_cool.close() end end return logic