mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
commit
f7766d8cba
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.9"
|
||||
|
||||
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
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.2"
|
||||
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||
|
@ -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
|
||||
|
||||
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.2"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user