#10 #133 alarm system logic and display, change to comms to support alarm actions, get_x get_y to graphics elements, bugfixes to coord establish and rtu establish, flashing trilight and alarm light indicators

This commit is contained in:
Mikayla Fischler
2022-11-26 16:18:31 -05:00
parent f68c38ccee
commit d4ae18eee7
16 changed files with 824 additions and 160 deletions

View File

@@ -1,73 +0,0 @@
local util = require("scada-common.util")
---@class alarm
local alarm = {}
---@alias SEVERITY integer
SEVERITY = {
INFO = 0, -- basic info message
WARNING = 1, -- warning about some abnormal state
ALERT = 2, -- important device state changes
FACILITY = 3, -- facility-wide alert
SAFETY = 4, -- safety alerts
EMERGENCY = 5 -- critical safety alarm
}
alarm.SEVERITY = SEVERITY
-- severity integer to string
---@param severity SEVERITY
function alarm.severity_to_string(severity)
if severity == SEVERITY.INFO then
return "INFO"
elseif severity == SEVERITY.WARNING then
return "WARNING"
elseif severity == SEVERITY.ALERT then
return "ALERT"
elseif severity == SEVERITY.FACILITY then
return "FACILITY"
elseif severity == SEVERITY.SAFETY then
return "SAFETY"
elseif severity == SEVERITY.EMERGENCY then
return "EMERGENCY"
else
return "UNKNOWN"
end
end
-- create a new scada alarm entry
---@param severity SEVERITY
---@param device string
---@param message string
function alarm.scada_alarm(severity, device, message)
local self = {
time = util.time(),
ts_string = os.date("[%H:%M:%S]"),
severity = severity,
device = device,
message = message
}
---@class scada_alarm
local public = {}
-- format the alarm as a string
---@return string message
function public.format()
return self.ts_string .. " [" .. alarm.severity_to_string(self.severity) .. "] (" .. self.device .. ") >> " .. self.message
end
-- get alarm properties
function public.properties()
return {
time = self.time,
severity = self.severity,
device = self.device,
message = self.message
}
end
return public
end
return alarm

View File

@@ -12,7 +12,7 @@ local rtu_t = types.rtu_t
local insert = table.insert
comms.version = "1.0.0"
comms.version = "1.0.1"
---@alias PROTOCOLS integer
local PROTOCOLS = {
@@ -74,7 +74,10 @@ local CRDN_COMMANDS = {
START = 1, -- start the reactor
RESET_RPS = 2, -- reset the RPS
SET_BURN = 3, -- set the burn rate
SET_WASTE = 4 -- set the waste processing mode
SET_WASTE = 4, -- set the waste processing mode
ACK_ALL_ALARMS = 5, -- ack all active alarms
ACK_ALARM = 6, -- ack a particular alarm
RESET_ALARM = 7 -- reset a particular alarm
}
---@alias CAPI_TYPES integer

View File

@@ -35,6 +35,76 @@ types.TRI_FAIL = {
FULL = 2
}
---@alias ALARM integer
types.ALARM = {
ContainmentBreach = 1,
ContainmentRadiation = 2,
ReactorLost = 3,
CriticalDamage = 4,
ReactorDamage = 5,
ReactorOverTemp = 6,
ReactorHighTemp = 7,
ReactorWasteLeak = 8,
ReactorHighWaste = 9,
RPSTransient = 10,
RCSTransient = 11,
TurbineTrip = 12
}
types.alarm_string = {
"ContainmentBreach",
"ContainmentRadiation",
"ReactorLost",
"CriticalDamage",
"ReactorDamage",
"ReactorOverTemp",
"ReactorHighTemp",
"ReactorWasteLeak",
"ReactorHighWaste",
"RPSTransient",
"RCSTransient",
"TurbineTrip"
}
---@alias ALARM_PRIORITY integer
types.ALARM_PRIORITY = {
CRITICAL = 0,
EMERGENCY = 1,
URGENT = 2,
TIMELY = 3
}
types.alarm_prio_string = {
"CRITICAL",
"EMERGENCY",
"URGENT",
"TIMELY"
}
-- map alarms to alarm priority
types.ALARM_PRIO_MAP = {
types.ALARM_PRIORITY.CRITICAL,
types.ALARM_PRIORITY.CRITICAL,
types.ALARM_PRIORITY.URGENT,
types.ALARM_PRIORITY.CRITICAL,
types.ALARM_PRIORITY.EMERGENCY,
types.ALARM_PRIORITY.URGENT,
types.ALARM_PRIORITY.TIMELY,
types.ALARM_PRIORITY.EMERGENCY,
types.ALARM_PRIORITY.TIMELY,
types.ALARM_PRIORITY.URGENT,
types.ALARM_PRIORITY.TIMELY,
types.ALARM_PRIORITY.URGENT
}
---@alias ALARM_STATE integer
types.ALARM_STATE = {
INACTIVE = 0,
TRIPPED = 1,
ACKED = 2,
RING_BACK = 3
}
-- STRING TYPES --
---@alias os_event