This commit is contained in:
parent
1100051585
commit
1d3a1672c8
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
_notes/
|
_notes/
|
||||||
|
program.sh
|
||||||
@ -28,9 +28,8 @@ function iocontrol.init(conf, comms)
|
|||||||
auto_ready = false,
|
auto_ready = false,
|
||||||
auto_active = false,
|
auto_active = false,
|
||||||
auto_ramping = false,
|
auto_ramping = false,
|
||||||
|
auto_saturated = false,
|
||||||
auto_scram = false,
|
auto_scram = false,
|
||||||
---@todo not currently used or set
|
|
||||||
auto_scram_cause = "ok", ---@type auto_scram_cause
|
|
||||||
|
|
||||||
num_units = conf.num_units, ---@type integer
|
num_units = conf.num_units, ---@type integer
|
||||||
|
|
||||||
@ -274,24 +273,26 @@ function iocontrol.update_facility_status(status)
|
|||||||
|
|
||||||
local ctl_status = status[1]
|
local ctl_status = status[1]
|
||||||
|
|
||||||
if type(ctl_status) == "table" then
|
if type(ctl_status) == "table" and (#ctl_status == 9) then
|
||||||
fac.all_sys_ok = ctl_status[1]
|
fac.all_sys_ok = ctl_status[1]
|
||||||
fac.auto_ready = ctl_status[2]
|
fac.auto_ready = ctl_status[2]
|
||||||
fac.auto_active = ctl_status[3] > 0
|
fac.auto_active = ctl_status[3] > 0
|
||||||
fac.auto_ramping = ctl_status[4]
|
fac.auto_ramping = ctl_status[4]
|
||||||
fac.auto_scram = ctl_status[5]
|
fac.auto_saturated = ctl_status[5]
|
||||||
fac.status_line_1 = ctl_status[6]
|
fac.auto_scram = ctl_status[6]
|
||||||
fac.status_line_2 = ctl_status[7]
|
fac.status_line_1 = ctl_status[7]
|
||||||
|
fac.status_line_2 = ctl_status[8]
|
||||||
|
|
||||||
fac.ps.publish("all_sys_ok", fac.all_sys_ok)
|
fac.ps.publish("all_sys_ok", fac.all_sys_ok)
|
||||||
fac.ps.publish("auto_ready", fac.auto_ready)
|
fac.ps.publish("auto_ready", fac.auto_ready)
|
||||||
fac.ps.publish("auto_active", fac.auto_active)
|
fac.ps.publish("auto_active", fac.auto_active)
|
||||||
fac.ps.publish("auto_ramping", fac.auto_ramping)
|
fac.ps.publish("auto_ramping", fac.auto_ramping)
|
||||||
|
fac.ps.publish("auto_saturated", fac.auto_saturated)
|
||||||
fac.ps.publish("auto_scram", fac.auto_scram)
|
fac.ps.publish("auto_scram", fac.auto_scram)
|
||||||
fac.ps.publish("status_line_1", fac.status_line_1)
|
fac.ps.publish("status_line_1", fac.status_line_1)
|
||||||
fac.ps.publish("status_line_2", fac.status_line_2)
|
fac.ps.publish("status_line_2", fac.status_line_2)
|
||||||
|
|
||||||
local group_map = ctl_status[8]
|
local group_map = ctl_status[9]
|
||||||
|
|
||||||
if (type(group_map) == "table") and (#group_map == fac.num_units) then
|
if (type(group_map) == "table") and (#group_map == fac.num_units) then
|
||||||
local names = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
local names = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
||||||
@ -302,7 +303,7 @@ function iocontrol.update_facility_status(status)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "control status not a table")
|
log.debug(log_header .. "control status not a table or length mismatch")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- RTU statuses
|
-- RTU statuses
|
||||||
|
|||||||
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
|||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "beta-v0.9.0"
|
local COORDINATOR_VERSION = "beta-v0.9.1"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@ -62,11 +62,13 @@ local function new_view(root, x, y)
|
|||||||
local auto_ready = IndicatorLight{parent=main,label="Configured Units Ready",colors=cpair(colors.green,colors.red)}
|
local auto_ready = IndicatorLight{parent=main,label="Configured Units Ready",colors=cpair(colors.green,colors.red)}
|
||||||
local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)}
|
local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)}
|
||||||
local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS}
|
local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS}
|
||||||
|
local auto_sat = IndicatorLight{parent=main,label="Max Burn Rate",colors=cpair(colors.yellow,colors.gray)}
|
||||||
local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
|
local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
|
||||||
|
|
||||||
facility.ps.subscribe("auto_ready", auto_ready.update)
|
facility.ps.subscribe("auto_ready", auto_ready.update)
|
||||||
facility.ps.subscribe("auto_active", auto_act.update)
|
facility.ps.subscribe("auto_active", auto_act.update)
|
||||||
facility.ps.subscribe("auto_ramping", auto_ramp.update)
|
facility.ps.subscribe("auto_ramping", auto_ramp.update)
|
||||||
|
facility.ps.subscribe("auto_saturated", auto_sat.update)
|
||||||
facility.ps.subscribe("auto_scram", auto_scram.update)
|
facility.ps.subscribe("auto_scram", auto_scram.update)
|
||||||
|
|
||||||
main.line_break()
|
main.line_break()
|
||||||
@ -176,7 +178,7 @@ local function new_view(root, x, y)
|
|||||||
-- controls and status --
|
-- controls and status --
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
local ctl_opts = { "Regulated", "Burn Rate", "Charge Level", "Generation Rate" }
|
local ctl_opts = { "Monitored Max Burn", "Combined Burn Rate", "Charge Level", "Generation Rate" }
|
||||||
local mode = RadioButton{parent=proc,x=34,y=1,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.purple,colors.black),radio_bg=colors.gray}
|
local mode = RadioButton{parent=proc,x=34,y=1,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.purple,colors.black),radio_bg=colors.gray}
|
||||||
|
|
||||||
facility.ps.subscribe("process_mode", mode.set_value)
|
facility.ps.subscribe("process_mode", mode.set_value)
|
||||||
|
|||||||
@ -387,6 +387,19 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
if not quiet then log.info("RPS: reset") end
|
if not quiet then log.info("RPS: reset") end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- reset the automatic and timeout trip flags, then clear trip if that was the trip cause
|
||||||
|
function public.auto_reset()
|
||||||
|
self.state[state_keys.automatic] = false
|
||||||
|
self.state[state_keys.timeout] = false
|
||||||
|
|
||||||
|
if self.trip_cause == rps_status_t.automatic or self.trip_cause == rps_status_t.timeout then
|
||||||
|
self.trip_cause = rps_status_t.ok
|
||||||
|
self.tripped = false
|
||||||
|
end
|
||||||
|
|
||||||
|
log.info("RPS: auto reset")
|
||||||
|
end
|
||||||
|
|
||||||
return public
|
return public
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -808,6 +821,10 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
|
|||||||
-- reset the RPS status
|
-- reset the RPS status
|
||||||
rps.reset()
|
rps.reset()
|
||||||
_send_ack(packet.type, true)
|
_send_ack(packet.type, true)
|
||||||
|
elseif packet.type == RPLC_TYPES.RPS_AUTO_RESET then
|
||||||
|
-- reset automatic SCRAM and timeout trips
|
||||||
|
rps.auto_reset()
|
||||||
|
_send_ack(packet.type, true)
|
||||||
elseif packet.type == RPLC_TYPES.AUTO_BURN_RATE then
|
elseif packet.type == RPLC_TYPES.AUTO_BURN_RATE then
|
||||||
-- automatic control requested a new burn rate
|
-- automatic control requested a new burn rate
|
||||||
if (packet.length == 3) and (type(packet.data[1]) == "number") and (type(packet.data[3]) == "number") then
|
if (packet.length == 3) and (type(packet.data[1]) == "number") and (type(packet.data[3]) == "number") then
|
||||||
|
|||||||
@ -14,7 +14,7 @@ local config = require("reactor-plc.config")
|
|||||||
local plc = require("reactor-plc.plc")
|
local plc = require("reactor-plc.plc")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "beta-v0.10.4"
|
local R_PLC_VERSION = "beta-v0.10.5"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@ -266,6 +266,7 @@ function threads.thread__main(smem, init)
|
|||||||
-- this thread cannot be slept because it will miss events (namely "terminate" otherwise)
|
-- this thread cannot be slept because it will miss events (namely "terminate" otherwise)
|
||||||
if not plc_state.shutdown then
|
if not plc_state.shutdown then
|
||||||
log.info("main thread restarting now...")
|
log.info("main thread restarting now...")
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
util.push_event("clock_start")
|
util.push_event("clock_start")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "beta-v0.9.12"
|
local RTU_VERSION = "beta-v0.9.13"
|
||||||
|
|
||||||
local rtu_t = types.rtu_t
|
local rtu_t = types.rtu_t
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ local rtu_t = types.rtu_t
|
|||||||
|
|
||||||
local insert = table.insert
|
local insert = table.insert
|
||||||
|
|
||||||
comms.version = "1.2.0"
|
comms.version = "1.3.0"
|
||||||
|
|
||||||
---@alias PROTOCOLS integer
|
---@alias PROTOCOLS integer
|
||||||
local PROTOCOLS = {
|
local PROTOCOLS = {
|
||||||
@ -34,7 +34,8 @@ local RPLC_TYPES = {
|
|||||||
RPS_STATUS = 6, -- RPS status
|
RPS_STATUS = 6, -- RPS status
|
||||||
RPS_ALARM = 7, -- RPS alarm broadcast
|
RPS_ALARM = 7, -- RPS alarm broadcast
|
||||||
RPS_RESET = 8, -- clear RPS trip (if in bad state, will trip immediately)
|
RPS_RESET = 8, -- clear RPS trip (if in bad state, will trip immediately)
|
||||||
AUTO_BURN_RATE = 9 -- set an automatic burn rate, PLC will respond with status, enable toggle speed limited
|
RPS_AUTO_RESET = 9, -- clear RPS trip if it is just a timeout or auto scram
|
||||||
|
AUTO_BURN_RATE = 10 -- set an automatic burn rate, PLC will respond with status, enable toggle speed limited
|
||||||
}
|
}
|
||||||
|
|
||||||
---@alias SCADA_MGMT_TYPES integer
|
---@alias SCADA_MGMT_TYPES integer
|
||||||
@ -223,12 +224,12 @@ end
|
|||||||
function comms.modbus_packet()
|
function comms.modbus_packet()
|
||||||
local self = {
|
local self = {
|
||||||
frame = nil,
|
frame = nil,
|
||||||
raw = nil,
|
raw = {},
|
||||||
txn_id = nil,
|
txn_id = -1,
|
||||||
length = nil,
|
length = 0,
|
||||||
unit_id = nil,
|
unit_id = -1,
|
||||||
func_code = nil,
|
func_code = 0,
|
||||||
data = nil
|
data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class modbus_packet
|
---@class modbus_packet
|
||||||
@ -312,11 +313,11 @@ end
|
|||||||
function comms.rplc_packet()
|
function comms.rplc_packet()
|
||||||
local self = {
|
local self = {
|
||||||
frame = nil,
|
frame = nil,
|
||||||
raw = nil,
|
raw = {},
|
||||||
id = nil,
|
id = 0,
|
||||||
type = nil,
|
type = -1,
|
||||||
length = nil,
|
length = 0,
|
||||||
body = nil
|
data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class rplc_packet
|
---@class rplc_packet
|
||||||
@ -333,6 +334,7 @@ function comms.rplc_packet()
|
|||||||
self.type == RPLC_TYPES.RPS_STATUS or
|
self.type == RPLC_TYPES.RPS_STATUS or
|
||||||
self.type == RPLC_TYPES.RPS_ALARM or
|
self.type == RPLC_TYPES.RPS_ALARM or
|
||||||
self.type == RPLC_TYPES.RPS_RESET or
|
self.type == RPLC_TYPES.RPS_RESET or
|
||||||
|
self.type == RPLC_TYPES.RPS_AUTO_RESET or
|
||||||
self.type == RPLC_TYPES.AUTO_BURN_RATE
|
self.type == RPLC_TYPES.AUTO_BURN_RATE
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -411,10 +413,10 @@ end
|
|||||||
function comms.mgmt_packet()
|
function comms.mgmt_packet()
|
||||||
local self = {
|
local self = {
|
||||||
frame = nil,
|
frame = nil,
|
||||||
raw = nil,
|
raw = {},
|
||||||
type = nil,
|
type = -1,
|
||||||
length = nil,
|
length = 0,
|
||||||
data = nil
|
data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class mgmt_packet
|
---@class mgmt_packet
|
||||||
@ -500,10 +502,10 @@ end
|
|||||||
function comms.crdn_packet()
|
function comms.crdn_packet()
|
||||||
local self = {
|
local self = {
|
||||||
frame = nil,
|
frame = nil,
|
||||||
raw = nil,
|
raw = {},
|
||||||
type = nil,
|
type = -1,
|
||||||
length = nil,
|
length = 0,
|
||||||
data = nil
|
data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class crdn_packet
|
---@class crdn_packet
|
||||||
@ -590,10 +592,10 @@ end
|
|||||||
function comms.capi_packet()
|
function comms.capi_packet()
|
||||||
local self = {
|
local self = {
|
||||||
frame = nil,
|
frame = nil,
|
||||||
raw = nil,
|
raw = {},
|
||||||
type = nil,
|
type = -1,
|
||||||
length = nil,
|
length = 0,
|
||||||
data = nil
|
data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class capi_packet
|
---@class capi_packet
|
||||||
|
|||||||
@ -37,6 +37,8 @@ types.TRI_FAIL = {
|
|||||||
|
|
||||||
---@alias PROCESS integer
|
---@alias PROCESS integer
|
||||||
types.PROCESS = {
|
types.PROCESS = {
|
||||||
|
UNIT_ALARM_IDLE = -2,
|
||||||
|
MATRIX_FAULT_IDLE = -1,
|
||||||
INACTIVE = 0,
|
INACTIVE = 0,
|
||||||
SIMPLE = 1,
|
SIMPLE = 1,
|
||||||
BURN_RATE = 2,
|
BURN_RATE = 2,
|
||||||
@ -173,9 +175,6 @@ types.ALARM_STATE = {
|
|||||||
---| "sys_fail"
|
---| "sys_fail"
|
||||||
---| "force_disabled"
|
---| "force_disabled"
|
||||||
|
|
||||||
---@alias auto_scram_cause
|
|
||||||
---| "ok"
|
|
||||||
|
|
||||||
---@alias rtu_t string
|
---@alias rtu_t string
|
||||||
types.rtu_t = {
|
types.rtu_t = {
|
||||||
redstone = "redstone",
|
redstone = "redstone",
|
||||||
|
|||||||
@ -12,13 +12,14 @@ local PROCESS = types.PROCESS
|
|||||||
-- 2856 FE per blade per 1 mB, 285.6 FE per blade per 0.1 mB (minimum)
|
-- 2856 FE per blade per 1 mB, 285.6 FE per blade per 0.1 mB (minimum)
|
||||||
local POWER_PER_BLADE = util.joules_to_fe(7140)
|
local POWER_PER_BLADE = util.joules_to_fe(7140)
|
||||||
|
|
||||||
local MAX_CHARGE = 0.99
|
local HIGH_CHARGE = 1.0
|
||||||
local RE_ENABLE_CHARGE = 0.95
|
local RE_ENABLE_CHARGE = 0.95
|
||||||
|
|
||||||
local AUTO_SCRAM = {
|
local AUTO_SCRAM = {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
MATRIX_DC = 1,
|
MATRIX_DC = 1,
|
||||||
MATRIX_FILL = 2
|
MATRIX_FILL = 2,
|
||||||
|
CRIT_ALARM = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
local charge_Kp = 1.0
|
local charge_Kp = 1.0
|
||||||
@ -46,6 +47,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
units_ready = false,
|
units_ready = false,
|
||||||
mode = PROCESS.INACTIVE,
|
mode = PROCESS.INACTIVE,
|
||||||
last_mode = PROCESS.INACTIVE,
|
last_mode = PROCESS.INACTIVE,
|
||||||
|
return_mode = PROCESS.INACTIVE,
|
||||||
mode_set = PROCESS.SIMPLE,
|
mode_set = PROCESS.SIMPLE,
|
||||||
max_burn_combined = 0.0, -- maximum burn rate to clamp at
|
max_burn_combined = 0.0, -- maximum burn rate to clamp at
|
||||||
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
||||||
@ -53,6 +55,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
gen_rate_target = 0, -- FE/t charge rate target
|
gen_rate_target = 0, -- FE/t charge rate target
|
||||||
group_map = { 0, 0, 0, 0 }, -- units -> group IDs
|
group_map = { 0, 0, 0, 0 }, -- units -> group IDs
|
||||||
prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units)
|
prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units)
|
||||||
|
at_max_burn = false,
|
||||||
ascram = false,
|
ascram = false,
|
||||||
ascram_reason = AUTO_SCRAM.NONE,
|
ascram_reason = AUTO_SCRAM.NONE,
|
||||||
-- closed loop control
|
-- closed loop control
|
||||||
@ -102,6 +105,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
-- split a burn rate among the reactors
|
-- split a burn rate among the reactors
|
||||||
---@param burn_rate number burn rate assignment
|
---@param burn_rate number burn rate assignment
|
||||||
---@param ramp boolean true to ramp, false to set right away
|
---@param ramp boolean true to ramp, false to set right away
|
||||||
|
---@return integer unallocated
|
||||||
local function _allocate_burn_rate(burn_rate, ramp)
|
local function _allocate_burn_rate(burn_rate, ramp)
|
||||||
local unallocated = math.floor(burn_rate * 10)
|
local unallocated = math.floor(burn_rate * 10)
|
||||||
|
|
||||||
@ -117,32 +121,38 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
splits[#units] = splits[#units] + (unallocated % #units)
|
splits[#units] = splits[#units] + (unallocated % #units)
|
||||||
|
|
||||||
-- go through all reactor units in this group
|
-- go through all reactor units in this group
|
||||||
for u = 1, #units do
|
for id = 1, #units do
|
||||||
local ctl = units[u].get_control_inf() ---@type unit_control
|
local u = units[id] ---@type reactor_unit
|
||||||
|
|
||||||
|
local ctl = u.get_control_inf()
|
||||||
|
local lim_br10 = u.a_get_effective_limit()
|
||||||
|
|
||||||
local last = ctl.br10
|
local last = ctl.br10
|
||||||
|
|
||||||
if splits[u] <= ctl.lim_br10 then
|
if splits[id] <= lim_br10 then
|
||||||
ctl.br10 = splits[u]
|
ctl.br10 = splits[id]
|
||||||
else
|
else
|
||||||
ctl.br10 = ctl.lim_br10
|
ctl.br10 = lim_br10
|
||||||
|
|
||||||
if u < #units then
|
if id < #units then
|
||||||
local remaining = #units - u
|
local remaining = #units - id
|
||||||
split = math.floor(unallocated / remaining)
|
split = math.floor(unallocated / remaining)
|
||||||
for x = (u + 1), #units do splits[x] = split end
|
for x = (id + 1), #units do splits[x] = split end
|
||||||
splits[#units] = splits[#units] + (unallocated % remaining)
|
splits[#units] = splits[#units] + (unallocated % remaining)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unallocated = unallocated - ctl.br10
|
unallocated = math.max(0, unallocated - ctl.br10)
|
||||||
|
|
||||||
if last ~= ctl.br10 then units[u].a_commit_br10(ramp) end
|
if last ~= ctl.br10 then
|
||||||
|
log.debug("unit " .. id .. ": set to " .. ctl.br10 .. " (was " .. last .. ")")
|
||||||
|
u.a_commit_br10(ramp)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stop if fully allocated
|
|
||||||
if unallocated <= 0 then break end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return unallocated
|
||||||
end
|
end
|
||||||
|
|
||||||
-- PUBLIC FUNCTIONS --
|
-- PUBLIC FUNCTIONS --
|
||||||
@ -215,10 +225,18 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
local now = util.time_s()
|
local now = util.time_s()
|
||||||
|
|
||||||
local state_changed = self.mode ~= self.last_mode
|
local state_changed = self.mode ~= self.last_mode
|
||||||
|
local next_mode = self.mode
|
||||||
|
|
||||||
-- once auto control is started, sort the priority sublists by limits
|
-- once auto control is started, sort the priority sublists by limits
|
||||||
if state_changed then
|
if state_changed then
|
||||||
|
self.saturated = false
|
||||||
|
|
||||||
|
log.debug("FAC: state changed from " .. self.last_mode .. " to " .. self.mode)
|
||||||
|
|
||||||
if self.last_mode == PROCESS.INACTIVE then
|
if self.last_mode == PROCESS.INACTIVE then
|
||||||
|
---@todo change this to be a reset button
|
||||||
|
if self.mode ~= PROCESS.MATRIX_FAULT_IDLE then self.ascram = false end
|
||||||
|
|
||||||
local blade_count = 0
|
local blade_count = 0
|
||||||
self.max_burn_combined = 0.0
|
self.max_burn_combined = 0.0
|
||||||
|
|
||||||
@ -259,27 +277,31 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
self.initial_ramp = false
|
self.initial_ramp = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.mode == PROCESS.INACTIVE then
|
-- update unit ready state
|
||||||
-- check if we are ready to start when that time comes
|
self.units_ready = true
|
||||||
self.units_ready = true
|
for i = 1, #self.prio_defs do
|
||||||
for i = 1, #self.prio_defs do
|
for _, u in pairs(self.prio_defs[i]) do
|
||||||
for _, u in pairs(self.prio_defs[i]) do
|
self.units_ready = self.units_ready and u.get_control_inf().ready
|
||||||
self.units_ready = self.units_ready and u.get_control_inf().ready
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- perform mode-specific operations
|
||||||
|
if self.mode == PROCESS.INACTIVE then
|
||||||
if self.units_ready then
|
if self.units_ready then
|
||||||
self.status_text = { "IDLE", "control disengaged" }
|
self.status_text = { "IDLE", "control disengaged" }
|
||||||
else
|
else
|
||||||
self.status_text = { "NOT READY", "assigned units not ready" }
|
self.status_text = { "NOT READY", "assigned units not ready" }
|
||||||
end
|
end
|
||||||
elseif self.mode == PROCESS.SIMPLE then
|
elseif self.mode == PROCESS.SIMPLE then
|
||||||
-- run units at their last configured set point
|
-- run units at their limits
|
||||||
if state_changed then
|
if state_changed then
|
||||||
self.time_start = now
|
self.time_start = now
|
||||||
---@todo will still need to ramp?
|
self.saturated = true
|
||||||
|
self.status_text = { "MONITORED MODE", "running reactors at limit" }
|
||||||
log.debug(util.c("FAC: SIMPLE mode first call completed"))
|
log.debug(util.c("FAC: SIMPLE mode first call completed"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
_allocate_burn_rate(self.max_burn_combined, true)
|
||||||
elseif self.mode == PROCESS.BURN_RATE then
|
elseif self.mode == PROCESS.BURN_RATE then
|
||||||
-- a total aggregate burn rate
|
-- a total aggregate burn rate
|
||||||
if state_changed then
|
if state_changed then
|
||||||
@ -294,7 +316,8 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not self.waiting_on_ramp then
|
if not self.waiting_on_ramp then
|
||||||
_allocate_burn_rate(self.burn_target, self.initial_ramp)
|
local unallocated = _allocate_burn_rate(self.burn_target, true)
|
||||||
|
self.saturated = self.burn_target == self.max_burn_combined or unallocated > 0
|
||||||
|
|
||||||
if self.initial_ramp then
|
if self.initial_ramp then
|
||||||
self.status_text = { "BURN RATE MODE", "ramping reactors" }
|
self.status_text = { "BURN RATE MODE", "ramping reactors" }
|
||||||
@ -397,16 +420,27 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
|
|
||||||
_allocate_burn_rate(sp_c, false)
|
_allocate_burn_rate(sp_c, false)
|
||||||
end
|
end
|
||||||
|
elseif self.mode == PROCESS.MATRIX_FAULT_IDLE then
|
||||||
|
-- exceeded charge, wait until condition clears
|
||||||
|
if self.ascram_reason == AUTO_SCRAM.NONE then
|
||||||
|
next_mode = self.return_mode
|
||||||
|
log.info("FAC: exiting matrix fault idle state due to fault resolution")
|
||||||
|
elseif self.ascram_reason == AUTO_SCRAM.CRIT_ALARM then
|
||||||
|
next_mode = PROCESS.INACTIVE
|
||||||
|
log.info("FAC: exiting matrix fault idle state due to critical unit alarm")
|
||||||
|
end
|
||||||
|
elseif self.mode == PROCESS.UNIT_ALARM_IDLE then
|
||||||
|
-- do nothing, wait for user to confirm (stop and reset)
|
||||||
elseif self.mode ~= PROCESS.INACTIVE then
|
elseif self.mode ~= PROCESS.INACTIVE then
|
||||||
log.error(util.c("FAC: unsupported process mode ", self.mode, ", switching to inactive"))
|
log.error(util.c("FAC: unsupported process mode ", self.mode, ", switching to inactive"))
|
||||||
self.mode = PROCESS.INACTIVE
|
next_mode = PROCESS.INACTIVE
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
-- Evaluate Automatic SCRAM --
|
-- Evaluate Automatic SCRAM --
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
if self.mode ~= PROCESS.INACTIVE then
|
if (self.mode ~= PROCESS.INACTIVE) and (self.mode ~= PROCESS.UNIT_ALARM_IDLE) then
|
||||||
local scram = false
|
local scram = false
|
||||||
|
|
||||||
if self.induction[1] ~= nil then
|
if self.induction[1] ~= nil then
|
||||||
@ -415,37 +449,93 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
|
|
||||||
if self.ascram_reason == AUTO_SCRAM.MATRIX_DC then
|
if self.ascram_reason == AUTO_SCRAM.MATRIX_DC then
|
||||||
self.ascram_reason = AUTO_SCRAM.NONE
|
self.ascram_reason = AUTO_SCRAM.NONE
|
||||||
|
log.info("FAC: cleared automatic SCRAM trip due to prior induction matrix disconnect")
|
||||||
end
|
end
|
||||||
|
|
||||||
if (db.tanks.energy_fill > MAX_CHARGE) or
|
if (db.tanks.energy_fill >= HIGH_CHARGE) or
|
||||||
(self.ascram_reason == AUTO_SCRAM.MATRIX_FILL and db.tanks.energy_fill > RE_ENABLE_CHARGE) then
|
(self.ascram_reason == AUTO_SCRAM.MATRIX_FILL and db.tanks.energy_fill > RE_ENABLE_CHARGE) then
|
||||||
scram = true
|
scram = true
|
||||||
|
|
||||||
|
if self.mode ~= PROCESS.MATRIX_FAULT_IDLE then
|
||||||
|
self.return_mode = self.mode
|
||||||
|
next_mode = PROCESS.MATRIX_FAULT_IDLE
|
||||||
|
end
|
||||||
|
|
||||||
if self.ascram_reason == AUTO_SCRAM.NONE then
|
if self.ascram_reason == AUTO_SCRAM.NONE then
|
||||||
self.ascram_reason = AUTO_SCRAM.MATRIX_FILL
|
self.ascram_reason = AUTO_SCRAM.MATRIX_FILL
|
||||||
end
|
end
|
||||||
|
elseif self.ascram_reason == AUTO_SCRAM.MATRIX_FILL then
|
||||||
|
log.info("FAC: charge state of induction matrix entered acceptable range <= " .. (RE_ENABLE_CHARGE * 100) .. "%")
|
||||||
|
self.ascram_reason = AUTO_SCRAM.NONE
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #self.units do
|
||||||
|
local u = self.units[i] ---@type reactor_unit
|
||||||
|
|
||||||
|
if u.has_critical_alarm() then
|
||||||
|
scram = true
|
||||||
|
|
||||||
|
if self.ascram_reason == AUTO_SCRAM.NONE then
|
||||||
|
self.ascram_reason = AUTO_SCRAM.CRIT_ALARM
|
||||||
|
end
|
||||||
|
|
||||||
|
next_mode = PROCESS.UNIT_ALARM_IDLE
|
||||||
|
|
||||||
|
log.info("FAC: emergency exit of process control due to critical unit alarm")
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
scram = true
|
scram = true
|
||||||
|
|
||||||
|
if self.mode ~= PROCESS.MATRIX_FAULT_IDLE then
|
||||||
|
self.return_mode = self.mode
|
||||||
|
next_mode = PROCESS.MATRIX_FAULT_IDLE
|
||||||
|
end
|
||||||
|
|
||||||
if self.ascram_reason == AUTO_SCRAM.NONE then
|
if self.ascram_reason == AUTO_SCRAM.NONE then
|
||||||
self.ascram_reason = AUTO_SCRAM.MATRIX_DC
|
self.ascram_reason = AUTO_SCRAM.MATRIX_DC
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- SCRAM all units
|
-- SCRAM all units
|
||||||
if not self.ascram and scram then
|
if (not self.ascram) and scram then
|
||||||
for i = 1, #self.prio_defs do
|
for i = 1, #self.prio_defs do
|
||||||
for _, u in pairs(self.prio_defs[i]) do
|
for _, u in pairs(self.prio_defs[i]) do
|
||||||
u.a_scram()
|
u.a_scram()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.ascram = true
|
if self.ascram_reason == AUTO_SCRAM.MATRIX_DC then
|
||||||
|
log.info("FAC: automatic SCRAM due to induction matrix disconnection")
|
||||||
|
self.status_text = { "AUTOMATIC SCRAM", "induction matrix disconnected" }
|
||||||
|
elseif self.ascram_reason == AUTO_SCRAM.MATRIX_FILL then
|
||||||
|
log.info("FAC: automatic SCRAM due to induction matrix high charge")
|
||||||
|
self.status_text = { "AUTOMATIC SCRAM", "induction matrix fill high" }
|
||||||
|
elseif self.ascram_reason == AUTO_SCRAM.CRIT_ALARM then
|
||||||
|
log.info("FAC: automatic SCRAM due to critical unit alarm")
|
||||||
|
self.status_text = { "AUTOMATIC SCRAM", "critical unit alarm tripped" }
|
||||||
|
else
|
||||||
|
log.error(util.c("FAC: automatic SCRAM reason (", self.ascram_reason, ") not set to a known value"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.ascram = scram
|
||||||
|
|
||||||
|
-- clear PLC SCRAM if we should
|
||||||
|
if not self.ascram then
|
||||||
|
self.ascram_reason = AUTO_SCRAM.NONE
|
||||||
|
|
||||||
|
for i = 1, #self.units do
|
||||||
|
local u = self.units[i] ---@type reactor_unit
|
||||||
|
u.a_cond_rps_reset()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update last mode
|
-- update last mode and set next mode
|
||||||
self.last_mode = self.mode
|
self.last_mode = self.mode
|
||||||
|
self.mode = next_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call the update function of all units in the facility
|
-- call the update function of all units in the facility
|
||||||
@ -580,6 +670,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
self.units_ready,
|
self.units_ready,
|
||||||
self.mode,
|
self.mode,
|
||||||
self.waiting_on_ramp,
|
self.waiting_on_ramp,
|
||||||
|
self.at_max_burn or self.saturated,
|
||||||
self.ascram,
|
self.ascram,
|
||||||
self.status_text[1],
|
self.status_text[1],
|
||||||
self.status_text[2],
|
self.status_text[2],
|
||||||
|
|||||||
@ -28,7 +28,8 @@ local PLC_S_CMDS = {
|
|||||||
SCRAM = 1,
|
SCRAM = 1,
|
||||||
ASCRAM = 2,
|
ASCRAM = 2,
|
||||||
ENABLE = 3,
|
ENABLE = 3,
|
||||||
RPS_RESET = 4
|
RPS_RESET = 4,
|
||||||
|
RPS_AUTO_RESET = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
local PLC_S_DATA = {
|
local PLC_S_DATA = {
|
||||||
@ -445,18 +446,29 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
|
|||||||
cmd = UNIT_COMMANDS.RESET_RPS,
|
cmd = UNIT_COMMANDS.RESET_RPS,
|
||||||
ack = ack
|
ack = ack
|
||||||
})
|
})
|
||||||
|
elseif pkt.type == RPLC_TYPES.RPS_AUTO_RESET then
|
||||||
|
-- RPS auto control reset acknowledgement
|
||||||
|
local ack = _get_ack(pkt)
|
||||||
|
if ack then
|
||||||
|
self.auto_scram = false
|
||||||
|
else
|
||||||
|
log.debug(log_header .. "RPS auto reset failed")
|
||||||
|
end
|
||||||
elseif pkt.type == RPLC_TYPES.AUTO_BURN_RATE then
|
elseif pkt.type == RPLC_TYPES.AUTO_BURN_RATE then
|
||||||
if pkt.length == 1 then
|
if pkt.length == 1 then
|
||||||
local ack = pkt.data[1]
|
local ack = pkt.data[1]
|
||||||
|
|
||||||
self.acks.burn_rate = ack ~= PLC_AUTO_ACK.FAIL
|
|
||||||
|
|
||||||
---@todo implement error handling here
|
|
||||||
if ack == PLC_AUTO_ACK.FAIL then
|
if ack == PLC_AUTO_ACK.FAIL then
|
||||||
elseif ack == PLC_AUTO_ACK.DIRECT_SET_OK then
|
self.acks.burn_rate = false
|
||||||
elseif ack == PLC_AUTO_ACK.RAMP_SET_OK then
|
log.debug(log_header .. "RPLC automatic burn rate set fail")
|
||||||
elseif ack == PLC_AUTO_ACK.ZERO_DIS_OK then
|
elseif ack == PLC_AUTO_ACK.DIRECT_SET_OK or ack == PLC_AUTO_ACK.RAMP_SET_OK or ack == PLC_AUTO_ACK.ZERO_DIS_OK then
|
||||||
|
self.acks.burn_rate = true
|
||||||
elseif ack == PLC_AUTO_ACK.ZERO_DIS_WAIT then
|
elseif ack == PLC_AUTO_ACK.ZERO_DIS_WAIT then
|
||||||
|
self.acks.burn_rate = false
|
||||||
|
log.debug(log_header .. "RPLC automatic burn rate too soon to disable at 0 mB/t")
|
||||||
|
else
|
||||||
|
self.acks.burn_rate = false
|
||||||
|
log.debug(log_header .. "RPLC automatic burn rate ack unknown")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "RPLC automatic burn rate ack packet length mismatch")
|
log.debug(log_header .. "RPLC automatic burn rate ack packet length mismatch")
|
||||||
@ -614,6 +626,10 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
|
|||||||
self.acks.rps_reset = false
|
self.acks.rps_reset = false
|
||||||
self.retry_times.rps_reset_req = util.time() + INITIAL_WAIT
|
self.retry_times.rps_reset_req = util.time() + INITIAL_WAIT
|
||||||
_send(RPLC_TYPES.RPS_RESET, {})
|
_send(RPLC_TYPES.RPS_RESET, {})
|
||||||
|
elseif cmd == PLC_S_CMDS.RPS_AUTO_RESET then
|
||||||
|
if self.auto_scram or self.sDB.rps_status.timeout then
|
||||||
|
_send(RPLC_TYPES.RPS_AUTO_RESET, {})
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log.warning(log_header .. "unsupported command received in in_queue (this is a bug)")
|
log.warning(log_header .. "unsupported command received in in_queue (this is a bug)")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -375,55 +375,6 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
|
|
||||||
--#endregion
|
--#endregion
|
||||||
|
|
||||||
-- AUTO CONTROL --
|
|
||||||
--#region
|
|
||||||
|
|
||||||
-- engage automatic control
|
|
||||||
function public.a_engage()
|
|
||||||
self.db.annunciator.AutoControl = true
|
|
||||||
if self.plc_i ~= nil then
|
|
||||||
self.plc_i.auto_lock(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- disengage automatic control
|
|
||||||
function public.a_disengage()
|
|
||||||
self.db.annunciator.AutoControl = false
|
|
||||||
if self.plc_i ~= nil then
|
|
||||||
self.plc_i.auto_lock(false)
|
|
||||||
self.db.control.br10 = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set the automatic burn rate based on the last set br10
|
|
||||||
---@param ramp boolean true to ramp to rate, false to set right away
|
|
||||||
function public.a_commit_br10(ramp)
|
|
||||||
if self.db.annunciator.AutoControl then
|
|
||||||
if self.plc_i ~= nil then
|
|
||||||
self.plc_i.auto_set_burn(self.db.control.br10 / 10, ramp)
|
|
||||||
|
|
||||||
if ramp then self.ramp_target_br10 = self.db.control.br10 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if ramping is complete (burn rate is same as target)
|
|
||||||
---@return boolean complete
|
|
||||||
function public.a_ramp_complete()
|
|
||||||
if self.plc_i ~= nil then
|
|
||||||
return self.plc_i.is_ramp_complete() or (self.plc_i.get_status().act_burn_rate == 0 and self.db.control.br10 == 0)
|
|
||||||
else return true end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- perform an automatic SCRAM
|
|
||||||
function public.a_scram()
|
|
||||||
if self.plc_s ~= nil then
|
|
||||||
self.plc_s.in_queue.push_command(PLC_S_CMDS.ASCRAM)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--#endregion
|
|
||||||
|
|
||||||
-- UPDATE SESSION --
|
-- UPDATE SESSION --
|
||||||
|
|
||||||
-- update (iterate) this unit
|
-- update (iterate) this unit
|
||||||
@ -444,6 +395,32 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
-- update degraded state for auto control
|
-- update degraded state for auto control
|
||||||
self.db.control.degraded = (#self.boilers ~= num_boilers) or (#self.turbines ~= num_turbines) or (self.plc_i == nil)
|
self.db.control.degraded = (#self.boilers ~= num_boilers) or (#self.turbines ~= num_turbines) or (self.plc_i == nil)
|
||||||
|
|
||||||
|
-- check boilers formed/faulted
|
||||||
|
for i = 1, #self.boilers do
|
||||||
|
local sess = self.boilers[i] ---@type unit_session
|
||||||
|
local boiler = sess.get_db() ---@type boilerv_session_db
|
||||||
|
if sess.is_faulted() or not boiler.formed then
|
||||||
|
self.db.control.degraded = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check turbines formed/faulted
|
||||||
|
for i = 1, #self.turbines do
|
||||||
|
local sess = self.turbines[i] ---@type unit_session
|
||||||
|
local turbine = sess.get_db() ---@type turbinev_session_db
|
||||||
|
if sess.is_faulted() or not turbine.formed then
|
||||||
|
self.db.control.degraded = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check plc formed/faulted
|
||||||
|
if self.plc_i ~= nil then
|
||||||
|
local rps = self.plc_i.get_rps()
|
||||||
|
if rps.fault or rps.sys_fail then
|
||||||
|
self.db.control.degraded = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- update deltas
|
-- update deltas
|
||||||
_dt__compute_all()
|
_dt__compute_all()
|
||||||
|
|
||||||
@ -457,7 +434,82 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
logic.update_status_text(self)
|
logic.update_status_text(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- AUTO CONTROL OPERATIONS --
|
||||||
|
--#region
|
||||||
|
|
||||||
|
-- engage automatic control
|
||||||
|
function public.a_engage()
|
||||||
|
self.db.annunciator.AutoControl = true
|
||||||
|
if self.plc_i ~= nil then
|
||||||
|
self.plc_i.auto_lock(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- disengage automatic control
|
||||||
|
function public.a_disengage()
|
||||||
|
self.db.annunciator.AutoControl = false
|
||||||
|
if self.plc_i ~= nil then
|
||||||
|
self.plc_i.auto_lock(false)
|
||||||
|
self.db.control.br10 = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- get the actual limit of this unit
|
||||||
|
--
|
||||||
|
-- if it is degraded or not ready, the limit will be 0
|
||||||
|
---@return integer lim_br10
|
||||||
|
function public.a_get_effective_limit()
|
||||||
|
if not self.db.control.ready or self.db.control.degraded or self.plc_cache.rps_trip then
|
||||||
|
self.db.control.br10 = 0
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return self.db.control.lim_br10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set the automatic burn rate based on the last set br10
|
||||||
|
---@param ramp boolean true to ramp to rate, false to set right away
|
||||||
|
function public.a_commit_br10(ramp)
|
||||||
|
if self.db.annunciator.AutoControl then
|
||||||
|
if self.plc_i ~= nil then
|
||||||
|
self.plc_i.auto_set_burn(self.db.control.br10 / 10, ramp)
|
||||||
|
|
||||||
|
if ramp then self.ramp_target_br10 = self.db.control.br10 end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check if ramping is complete (burn rate is same as target)
|
||||||
|
---@return boolean complete
|
||||||
|
function public.a_ramp_complete()
|
||||||
|
if self.plc_i ~= nil then
|
||||||
|
return self.plc_i.is_ramp_complete() or
|
||||||
|
(self.plc_i.get_status().act_burn_rate == 0 and self.db.control.br10 == 0) or
|
||||||
|
public.a_get_effective_limit() == 0
|
||||||
|
else return true end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- perform an automatic SCRAM
|
||||||
|
function public.a_scram()
|
||||||
|
if self.plc_s ~= nil then
|
||||||
|
self.plc_s.in_queue.push_command(PLC_S_CMDS.ASCRAM)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- queue a command to clear timeout/auto-scram if set
|
||||||
|
function public.a_cond_rps_reset()
|
||||||
|
if self.plc_s ~= nil and self.plc_i ~= nil then
|
||||||
|
local rps = self.plc_i.get_rps()
|
||||||
|
if rps.timeout or rps.automatic then
|
||||||
|
self.plc_s.in_queue.push_command(PLC_S_CMDS.RPS_AUTO_RESET)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--#endregion
|
||||||
|
|
||||||
-- OPERATIONS --
|
-- OPERATIONS --
|
||||||
|
--#region
|
||||||
|
|
||||||
-- queue a command to SCRAM the reactor
|
-- queue a command to SCRAM the reactor
|
||||||
function public.scram()
|
function public.scram()
|
||||||
@ -537,7 +589,21 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--#endregion
|
||||||
|
|
||||||
-- READ STATES/PROPERTIES --
|
-- READ STATES/PROPERTIES --
|
||||||
|
--#region
|
||||||
|
|
||||||
|
-- check if a critical alarm is tripped
|
||||||
|
function public.has_critical_alarm()
|
||||||
|
for _, data in pairs(self.alarms) do
|
||||||
|
if data.tier == PRIO.CRITICAL and (data.state == AISTATE.TRIPPED or data.state == AISTATE.ACKED) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- get build properties of all machines
|
-- get build properties of all machines
|
||||||
function public.get_build()
|
function public.get_build()
|
||||||
@ -622,6 +688,8 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
-- get the reactor ID
|
-- get the reactor ID
|
||||||
function public.get_id() return self.r_id end
|
function public.get_id() return self.r_id end
|
||||||
|
|
||||||
|
--#endregion
|
||||||
|
|
||||||
return public
|
return public
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -516,11 +516,7 @@ function logic.update_status_text(self)
|
|||||||
elseif self.db.annunciator.WasteLineOcclusion then
|
elseif self.db.annunciator.WasteLineOcclusion then
|
||||||
self.status_text[2] = "insufficient waste output rate"
|
self.status_text[2] = "insufficient waste output rate"
|
||||||
elseif (util.time_ms() - self.last_rate_change_ms) <= self.defs.FLOW_STABILITY_DELAY_MS then
|
elseif (util.time_ms() - self.last_rate_change_ms) <= self.defs.FLOW_STABILITY_DELAY_MS then
|
||||||
if self.num_turbines > 1 then
|
self.status_text[2] = "awaiting flow stability"
|
||||||
self.status_text[2] = "turbines spinning up"
|
|
||||||
else
|
|
||||||
self.status_text[2] = "turbine spinning up"
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
self.status_text[2] = "system nominal"
|
self.status_text[2] = "system nominal"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -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.9.13"
|
local SUPERVISOR_VERSION = "beta-v0.9.14"
|
||||||
|
|
||||||
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