#186 F_ALARM use emergency+ level
This commit is contained in:
@@ -10,6 +10,7 @@ local rsctl = require("supervisor.session.rsctl")
|
||||
|
||||
local PROCESS = types.PROCESS
|
||||
local PROCESS_NAMES = types.PROCESS_NAMES
|
||||
local PRIO = types.ALARM_PRIORITY
|
||||
|
||||
local IO = rsio.IO
|
||||
|
||||
@@ -569,7 +570,7 @@ function facility.new(num_reactors, cooling_conf)
|
||||
for i = 1, #self.units do
|
||||
local u = self.units[i] ---@type reactor_unit
|
||||
|
||||
if u.has_critical_alarm() then
|
||||
if u.has_alarm_min_prio(PRIO.CRITICAL) then
|
||||
astatus.crit_alarm = true
|
||||
break
|
||||
end
|
||||
@@ -677,12 +678,12 @@ function facility.new(num_reactors, cooling_conf)
|
||||
-- handle facility ack
|
||||
if self.io_ctl.digital_read(IO.F_ACK) then public.ack_all() end
|
||||
|
||||
-- update facility alarm output
|
||||
-- update facility alarm output (check if emergency+ alarms are active)
|
||||
local has_alarm = false
|
||||
for i = 1, #self.units do
|
||||
local u = self.units[i] ---@type reactor_unit
|
||||
|
||||
if u.has_critical_alarm() then
|
||||
if u.has_alarm_min_prio(PRIO.EMERGENCY) then
|
||||
has_alarm = true
|
||||
return
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
||||
local config = require("supervisor.config")
|
||||
local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local SUPERVISOR_VERSION = "v0.13.7"
|
||||
local SUPERVISOR_VERSION = "v0.13.8"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
||||
@@ -669,12 +669,13 @@ function unit.new(reactor_id, num_boilers, num_turbines)
|
||||
-- READ STATES/PROPERTIES --
|
||||
--#region
|
||||
|
||||
-- check if a critical alarm is tripped
|
||||
-- check if an alarm of at least a certain priority level is tripped
|
||||
---@nodiscard
|
||||
---@param min_prio ALARM_PRIORITY alarms with this priority or higher will be checked
|
||||
---@return boolean tripped
|
||||
function public.has_critical_alarm()
|
||||
function public.has_alarm_min_prio(min_prio)
|
||||
for _, alarm in pairs(self.alarms) do
|
||||
if alarm.tier == PRIO.CRITICAL and (alarm.state == AISTATE.TRIPPED or alarm.state == AISTATE.ACKED) then
|
||||
if alarm.tier <= min_prio and (alarm.state == AISTATE.TRIPPED or alarm.state == AISTATE.ACKED) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user