mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#152 supervisor cleanups and improvements to alarms
This commit is contained in:
parent
6c09772a74
commit
678dafa62f
@ -380,7 +380,7 @@ function coordinator.new_session(id, in_queue, out_queue, facility)
|
|||||||
|
|
||||||
-- exit if connection was closed
|
-- exit if connection was closed
|
||||||
if not self.connected then
|
if not self.connected then
|
||||||
println("connection to coordinator " .. id .. " closed by remote host")
|
println("connection to coordinator closed by remote host")
|
||||||
log.info(log_header .. "session closed by remote host")
|
log.info(log_header .. "session closed by remote host")
|
||||||
return self.connected
|
return self.connected
|
||||||
end
|
end
|
||||||
|
@ -332,7 +332,7 @@ function rtu.new_session(id, in_queue, out_queue, advertisement, facility)
|
|||||||
|
|
||||||
-- exit if connection was closed
|
-- exit if connection was closed
|
||||||
if not self.connected then
|
if not self.connected then
|
||||||
println(log_header .. "connection to RTU closed by remote host")
|
println("RTU connection " .. id .. " closed by remote host")
|
||||||
log.info(log_header .. "session closed by remote host")
|
log.info(log_header .. "session closed by remote host")
|
||||||
return self.connected
|
return self.connected
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ local function _shutdown(session)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
log.debug("closed session " .. session.instance.get_id() .. " on remote port " .. session.r_port)
|
log.debug(util.c("closed ", session.s_type, " session ", session.instance.get_id(), " on remote port ", session.r_port))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close connections
|
-- close connections
|
||||||
@ -158,7 +158,8 @@ local function _check_watchdogs(sessions, timer_event)
|
|||||||
if session.open then
|
if session.open then
|
||||||
local triggered = session.instance.check_wd(timer_event)
|
local triggered = session.instance.check_wd(timer_event)
|
||||||
if triggered then
|
if triggered then
|
||||||
log.debug("watchdog closing session " .. session.instance.get_id() .. " on remote port " .. session.r_port .. "...")
|
log.debug(util.c("watchdog closing ", session.s_type, " session ", session.instance.get_id(),
|
||||||
|
" on remote port ", session.r_port, "..."))
|
||||||
_shutdown(session)
|
_shutdown(session)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -171,7 +172,8 @@ local function _free_closed(sessions)
|
|||||||
local f = function (session) return session.open end
|
local f = function (session) return session.open end
|
||||||
|
|
||||||
local on_delete = function (session)
|
local on_delete = function (session)
|
||||||
log.debug("free'ing closed session " .. session.instance.get_id() .. " on remote port " .. session.r_port)
|
log.debug(util.c("free'ing closed ", session.s_type, " session ", session.instance.get_id(),
|
||||||
|
" on remote port ", session.r_port))
|
||||||
end
|
end
|
||||||
|
|
||||||
util.filter_table(sessions, f, on_delete)
|
util.filter_table(sessions, f, on_delete)
|
||||||
@ -296,7 +298,7 @@ function svsessions.establish_plc_session(local_port, remote_port, for_reactor,
|
|||||||
local units = self.facility.get_units()
|
local units = self.facility.get_units()
|
||||||
units[for_reactor].link_plc_session(plc_s)
|
units[for_reactor].link_plc_session(plc_s)
|
||||||
|
|
||||||
log.debug("established new PLC session to " .. remote_port .. " with ID " .. self.next_plc_id)
|
log.debug(util.c("established new PLC session to ", remote_port, " with ID ", self.next_plc_id, " for reactor ", for_reactor))
|
||||||
|
|
||||||
self.next_plc_id = self.next_plc_id + 1
|
self.next_plc_id = self.next_plc_id + 1
|
||||||
|
|
||||||
|
@ -88,11 +88,39 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
-- logic for alarms
|
-- logic for alarms
|
||||||
had_reactor = false,
|
had_reactor = false,
|
||||||
last_rate_change_ms = 0,
|
last_rate_change_ms = 0,
|
||||||
|
---@type rps_status
|
||||||
|
last_rps_trips = {
|
||||||
|
dmg_crit = false,
|
||||||
|
high_temp = false,
|
||||||
|
no_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
|
||||||
|
},
|
||||||
plc_cache = {
|
plc_cache = {
|
||||||
active = false,
|
active = false,
|
||||||
ok = false,
|
ok = false,
|
||||||
rps_trip = false,
|
---@type rps_status
|
||||||
rps_status = {}, ---@type rps_status
|
rps_status = {
|
||||||
|
dmg_crit = false,
|
||||||
|
high_temp = false,
|
||||||
|
no_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
|
||||||
|
},
|
||||||
damage = 0,
|
damage = 0,
|
||||||
temp = 0,
|
temp = 0,
|
||||||
waste = 0
|
waste = 0
|
||||||
@ -118,11 +146,11 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
-- waste >85%
|
-- waste >85%
|
||||||
ReactorHighWaste = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 2, id = ALARM.ReactorHighWaste, tier = PRIO.TIMELY },
|
ReactorHighWaste = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 2, id = ALARM.ReactorHighWaste, tier = PRIO.TIMELY },
|
||||||
-- RPS trip occured
|
-- RPS trip occured
|
||||||
RPSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 0, id = ALARM.RPSTransient, tier = PRIO.URGENT },
|
RPSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 1, id = ALARM.RPSTransient, tier = PRIO.URGENT },
|
||||||
-- BoilRateMismatch, CoolantFeedMismatch, SteamFeedMismatch, MaxWaterReturnFeed
|
-- BoilRateMismatch, CoolantFeedMismatch, SteamFeedMismatch, MaxWaterReturnFeed
|
||||||
RCSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 5, id = ALARM.RCSTransient, tier = PRIO.TIMELY },
|
RCSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 5, id = ALARM.RCSTransient, tier = PRIO.TIMELY },
|
||||||
-- "It's just a routine turbin' trip!" -Bill Gibson, "The China Syndrome"
|
-- "It's just a routine turbin' trip!" -Bill Gibson, "The China Syndrome"
|
||||||
TurbineTrip = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 0, id = ALARM.TurbineTrip, tier = PRIO.URGENT }
|
TurbineTrip = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 1, id = ALARM.TurbineTrip, tier = PRIO.URGENT }
|
||||||
},
|
},
|
||||||
---@class unit_db
|
---@class unit_db
|
||||||
db = {
|
db = {
|
||||||
|
@ -397,10 +397,12 @@ function logic.update_alarms(self)
|
|||||||
_update_alarm_state(self, plc_cache.damage >= 100, self.alarms.CriticalDamage)
|
_update_alarm_state(self, plc_cache.damage >= 100, self.alarms.CriticalDamage)
|
||||||
|
|
||||||
-- Reactor Damage
|
-- Reactor Damage
|
||||||
_update_alarm_state(self, plc_cache.damage > 0, self.alarms.ReactorDamage)
|
local rps_dmg_90 = plc_cache.rps_status.dmg_crit and not self.last_rps_trips.dmg_crit
|
||||||
|
_update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage)
|
||||||
|
|
||||||
-- Over-Temperature
|
-- Over-Temperature
|
||||||
_update_alarm_state(self, plc_cache.temp >= 1200, self.alarms.ReactorOverTemp)
|
local rps_high_temp = plc_cache.rps_status.high_temp and not self.last_rps_trips.high_temp
|
||||||
|
_update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp)
|
||||||
|
|
||||||
-- High Temperature
|
-- High Temperature
|
||||||
_update_alarm_state(self, plc_cache.temp > 1150, self.alarms.ReactorHighTemp)
|
_update_alarm_state(self, plc_cache.temp > 1150, self.alarms.ReactorHighTemp)
|
||||||
@ -409,7 +411,8 @@ function logic.update_alarms(self)
|
|||||||
_update_alarm_state(self, plc_cache.waste >= 0.99, self.alarms.ReactorWasteLeak)
|
_update_alarm_state(self, plc_cache.waste >= 0.99, self.alarms.ReactorWasteLeak)
|
||||||
|
|
||||||
-- High Waste
|
-- High Waste
|
||||||
_update_alarm_state(self, plc_cache.waste > 0.50, self.alarms.ReactorHighWaste)
|
local rps_high_waste = plc_cache.rps_status.ex_waste and not self.last_rps_trips.ex_waste
|
||||||
|
_update_alarm_state(self, (plc_cache.waste > 0.50) or rps_high_waste, self.alarms.ReactorHighWaste)
|
||||||
|
|
||||||
-- RPS Transient (excludes timeouts and manual trips)
|
-- RPS Transient (excludes timeouts and manual trips)
|
||||||
local rps_alarm = false
|
local rps_alarm = false
|
||||||
@ -444,6 +447,11 @@ function logic.update_alarms(self)
|
|||||||
local any_trip = false
|
local any_trip = false
|
||||||
for i = 1, #annunc.TurbineTrip do any_trip = any_trip or annunc.TurbineTrip[i] end
|
for i = 1, #annunc.TurbineTrip do any_trip = any_trip or annunc.TurbineTrip[i] end
|
||||||
_update_alarm_state(self, any_trip, self.alarms.TurbineTrip)
|
_update_alarm_state(self, any_trip, self.alarms.TurbineTrip)
|
||||||
|
|
||||||
|
-- update last trips table
|
||||||
|
for key, val in pairs(plc_cache.rps_status) do
|
||||||
|
self.last_rps_trips[key] = val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update the two unit status text messages
|
-- update the two unit status text messages
|
||||||
|
@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
|||||||
local config = require("supervisor.config")
|
local config = require("supervisor.config")
|
||||||
local supervisor = require("supervisor.supervisor")
|
local supervisor = require("supervisor.supervisor")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "beta-v0.10.0"
|
local SUPERVISOR_VERSION = "beta-v0.10.1"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
Loading…
x
Reference in New Issue
Block a user