#589 moved boot recovery to facility update file
This commit is contained in:
parent
3b2fb00285
commit
ecdaf78ed0
@ -5,7 +5,6 @@ local util = require("scada-common.util")
|
|||||||
local unit = require("supervisor.unit")
|
local unit = require("supervisor.unit")
|
||||||
local fac_update = require("supervisor.facility_update")
|
local fac_update = require("supervisor.facility_update")
|
||||||
|
|
||||||
local plc = require("supervisor.session.plc")
|
|
||||||
local rsctl = require("supervisor.session.rsctl")
|
local rsctl = require("supervisor.session.rsctl")
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ function facility.new(config)
|
|||||||
---@class _facility_self
|
---@class _facility_self
|
||||||
local self = {
|
local self = {
|
||||||
units = {}, ---@type reactor_unit[]
|
units = {}, ---@type reactor_unit[]
|
||||||
types = { AUTO_SCRAM = AUTO_SCRAM, START_STATUS = START_STATUS },
|
types = { AUTO_SCRAM = AUTO_SCRAM, START_STATUS = START_STATUS, RCV_STATE = RCV_STATE },
|
||||||
status_text = { "START UP", "initializing..." },
|
status_text = { "START UP", "initializing..." },
|
||||||
all_sys_ok = false,
|
all_sys_ok = false,
|
||||||
allow_testing = false,
|
allow_testing = false,
|
||||||
@ -177,6 +176,7 @@ function facility.new(config)
|
|||||||
|
|
||||||
-- PRIVATE FUNCTIONS --
|
-- PRIVATE FUNCTIONS --
|
||||||
|
|
||||||
|
-- check an auto process control configuration and save it if its valid (does not start the process)
|
||||||
---@param auto_cfg start_auto_config configuration
|
---@param auto_cfg start_auto_config configuration
|
||||||
---@return boolean ready, number[] unit_limits
|
---@return boolean ready, number[] unit_limits
|
||||||
local function _auto_check_and_save(auto_cfg)
|
local function _auto_check_and_save(auto_cfg)
|
||||||
@ -319,46 +319,8 @@ function facility.new(config)
|
|||||||
|
|
||||||
-- update (iterate) the facility management
|
-- update (iterate) the facility management
|
||||||
function public.update()
|
function public.update()
|
||||||
-- attempt reboot recovery if in progress
|
-- run reboot recovery routine if needed
|
||||||
if self.recovery == RCV_STATE.RUNNING then
|
f_update.boot_recovery()
|
||||||
-- try to start auto control
|
|
||||||
if self.recovery_boot_state.mode ~= nil and self.units_ready then
|
|
||||||
if self.recovery_boot_state.mode ~= PROCESS.INACTIVE and self.recovery_boot_state.mode ~= PROCESS.SYSTEM_ALARM_IDLE then
|
|
||||||
self.mode = self.mode_set
|
|
||||||
log.info("FAC: process startup resume initiated")
|
|
||||||
end
|
|
||||||
|
|
||||||
self.recovery_boot_state.mode = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local recovered = self.recovery_boot_state.mode == nil or self.recovery_boot_state.mode == PROCESS.INACTIVE
|
|
||||||
|
|
||||||
-- restore manual control reactors
|
|
||||||
for i = 1, #self.units do
|
|
||||||
local u = self.units[i]
|
|
||||||
|
|
||||||
if self.recovery_boot_state.unit_states[i] and self.group_map[i] == AUTO_GROUP.MANUAL then
|
|
||||||
recovered = false
|
|
||||||
|
|
||||||
if u.get_control_inf().ready then
|
|
||||||
local plc_s = svsessions.get_reactor_session(i)
|
|
||||||
if plc_s ~= nil then
|
|
||||||
plc_s.in_queue.push_command(plc.PLC_S_CMDS.ENABLE)
|
|
||||||
log.info("FAC: startup resume enabling manually controlled reactor unit #" .. i)
|
|
||||||
|
|
||||||
-- only execute once
|
|
||||||
self.recovery_boot_state.unit_states[i] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if recovered then
|
|
||||||
self.recovery = RCV_STATE.STOPPED
|
|
||||||
self.recovery_boot_state = nil
|
|
||||||
log.info("FAC: startup resume sequence completed")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- run process control and evaluate automatic SCRAM
|
-- run process control and evaluate automatic SCRAM
|
||||||
f_update.pre_auto()
|
f_update.pre_auto()
|
||||||
|
|||||||
@ -1,17 +1,21 @@
|
|||||||
local audio = require("scada-common.audio")
|
local audio = require("scada-common.audio")
|
||||||
local const = require("scada-common.constants")
|
local const = require("scada-common.constants")
|
||||||
local log = require("scada-common.log")
|
local log = require("scada-common.log")
|
||||||
local rsio = require("scada-common.rsio")
|
local rsio = require("scada-common.rsio")
|
||||||
local types = require("scada-common.types")
|
local types = require("scada-common.types")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local qtypes = require("supervisor.session.rtu.qtypes")
|
local plc = require("supervisor.session.plc")
|
||||||
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
|
local qtypes = require("supervisor.session.rtu.qtypes")
|
||||||
|
|
||||||
local TONE = audio.TONE
|
local TONE = audio.TONE
|
||||||
|
|
||||||
local ALARM = types.ALARM
|
local ALARM = types.ALARM
|
||||||
local PRIO = types.ALARM_PRIORITY
|
local PRIO = types.ALARM_PRIORITY
|
||||||
local ALARM_STATE = types.ALARM_STATE
|
local ALARM_STATE = types.ALARM_STATE
|
||||||
|
local AUTO_GROUP = types.AUTO_GROUP
|
||||||
local CONTAINER_MODE = types.CONTAINER_MODE
|
local CONTAINER_MODE = types.CONTAINER_MODE
|
||||||
local PROCESS = types.PROCESS
|
local PROCESS = types.PROCESS
|
||||||
local PROCESS_NAMES = types.PROCESS_NAMES
|
local PROCESS_NAMES = types.PROCESS_NAMES
|
||||||
@ -131,6 +135,54 @@ end
|
|||||||
|
|
||||||
--#region PUBLIC FUNCTIONS
|
--#region PUBLIC FUNCTIONS
|
||||||
|
|
||||||
|
-- run reboot recovery routine if needed
|
||||||
|
function update.boot_recovery()
|
||||||
|
local RCV_STATE = self.types.RCV_STATE
|
||||||
|
|
||||||
|
-- attempt reboot recovery if in progress
|
||||||
|
if self.recovery == RCV_STATE.RUNNING then
|
||||||
|
local was_inactive = self.recovery_boot_state.mode == PROCESS.INACTIVE or self.recovery_boot_state.mode == PROCESS.SYSTEM_ALARM_IDLE
|
||||||
|
|
||||||
|
-- try to start auto control
|
||||||
|
if self.recovery_boot_state.mode ~= nil and self.units_ready then
|
||||||
|
if was_inactive then
|
||||||
|
self.mode = self.mode_set
|
||||||
|
log.info("FAC: process startup resume initiated")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.recovery_boot_state.mode = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local recovered = self.recovery_boot_state.mode == nil or was_inactive
|
||||||
|
|
||||||
|
-- restore manual control reactors
|
||||||
|
for i = 1, #self.units do
|
||||||
|
local u = self.units[i]
|
||||||
|
|
||||||
|
if self.recovery_boot_state.unit_states[i] and self.group_map[i] == AUTO_GROUP.MANUAL then
|
||||||
|
recovered = false
|
||||||
|
|
||||||
|
if u.get_control_inf().ready then
|
||||||
|
local plc_s = svsessions.get_reactor_session(i)
|
||||||
|
if plc_s ~= nil then
|
||||||
|
plc_s.in_queue.push_command(plc.PLC_S_CMDS.ENABLE)
|
||||||
|
log.info("FAC: startup resume enabling manually controlled reactor unit #" .. i)
|
||||||
|
|
||||||
|
-- only execute once
|
||||||
|
self.recovery_boot_state.unit_states[i] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if recovered then
|
||||||
|
self.recovery = RCV_STATE.STOPPED
|
||||||
|
self.recovery_boot_state = nil
|
||||||
|
log.info("FAC: startup resume sequence completed")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- automatic control pre-update logic
|
-- automatic control pre-update logic
|
||||||
function update.pre_auto()
|
function update.pre_auto()
|
||||||
-- unlink RTU sessions if they are closed
|
-- unlink RTU sessions if they are closed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user