#545 coordinator type annotation updates
This commit is contained in:
parent
63a9e23b3a
commit
85fc8d2920
@ -71,7 +71,7 @@ local tool_ctl = {
|
|||||||
net_listen = false,
|
net_listen = false,
|
||||||
sv_addr = comms.BROADCAST,
|
sv_addr = comms.BROADCAST,
|
||||||
sv_seq_num = util.time_ms() * 10,
|
sv_seq_num = util.time_ms() * 10,
|
||||||
sv_cool_conf = nil, ---@type table list of boiler & turbine counts
|
sv_cool_conf = nil, ---@type [ integer, integer ][] list of boiler & turbine counts
|
||||||
show_sv_cfg = nil, ---@type function
|
show_sv_cfg = nil, ---@type function
|
||||||
|
|
||||||
start_fail = 0,
|
start_fail = 0,
|
||||||
@ -110,7 +110,7 @@ local tool_ctl = {
|
|||||||
edit_monitor = nil, ---@type function
|
edit_monitor = nil, ---@type function
|
||||||
|
|
||||||
mon_iface = "",
|
mon_iface = "",
|
||||||
mon_expect = {}
|
mon_expect = {} ---@type integer[]
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class crd_config
|
---@class crd_config
|
||||||
|
|||||||
@ -111,12 +111,12 @@ function coordinator.load_config()
|
|||||||
|
|
||||||
---@class monitors_struct
|
---@class monitors_struct
|
||||||
local monitors = {
|
local monitors = {
|
||||||
main = nil, ---@type table|nil
|
main = nil, ---@type table|nil
|
||||||
main_name = "",
|
main_name = "",
|
||||||
flow = nil, ---@type table|nil
|
flow = nil, ---@type table|nil
|
||||||
flow_name = "",
|
flow_name = "",
|
||||||
unit_displays = {},
|
unit_displays = {}, ---@type table[]
|
||||||
unit_name_map = {}
|
unit_name_map = {} ---@type string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
local mon_cfv = util.new_validator()
|
local mon_cfv = util.new_validator()
|
||||||
@ -623,7 +623,7 @@ function coordinator.comms(version, nic, sv_watchdog)
|
|||||||
local unit_id = packet.data[2]
|
local unit_id = packet.data[2]
|
||||||
local ack = packet.data[3] == true
|
local ack = packet.data[3] == true
|
||||||
|
|
||||||
local unit = iocontrol.get_db().units[unit_id] ---@type ioctl_unit
|
local unit = iocontrol.get_db().units[unit_id]
|
||||||
|
|
||||||
if unit ~= nil then
|
if unit ~= nil then
|
||||||
if cmd == UNIT_COMMAND.SCRAM then
|
if cmd == UNIT_COMMAND.SCRAM then
|
||||||
|
|||||||
@ -29,15 +29,6 @@ local iocontrol = {}
|
|||||||
---@class ioctl
|
---@class ioctl
|
||||||
local io = {}
|
local io = {}
|
||||||
|
|
||||||
-- luacheck: no unused args
|
|
||||||
|
|
||||||
-- placeholder acknowledge function for type hinting
|
|
||||||
---@param success boolean
|
|
||||||
---@diagnostic disable-next-line: unused-local
|
|
||||||
local function __generic_ack(success) end
|
|
||||||
|
|
||||||
-- luacheck: unused args
|
|
||||||
|
|
||||||
-- initialize front panel PSIL
|
-- initialize front panel PSIL
|
||||||
---@param firmware_v string coordinator version
|
---@param firmware_v string coordinator version
|
||||||
---@param comms_v string comms version
|
---@param comms_v string comms version
|
||||||
@ -115,25 +106,23 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
|
|
||||||
radiation = types.new_zero_radiation_reading(),
|
radiation = types.new_zero_radiation_reading(),
|
||||||
|
|
||||||
save_cfg_ack = __generic_ack,
|
save_cfg_ack = nil, ---@type fun(success: boolean)
|
||||||
start_ack = __generic_ack,
|
start_ack = nil, ---@type fun(success: boolean)
|
||||||
stop_ack = __generic_ack,
|
stop_ack = nil, ---@type fun(success: boolean)
|
||||||
|
|
||||||
|
---@type { [TONE]: boolean }
|
||||||
alarm_tones = { false, false, false, false, false, false, false, false },
|
alarm_tones = { false, false, false, false, false, false, false, false },
|
||||||
|
|
||||||
ps = psil.create(),
|
ps = psil.create(),
|
||||||
|
|
||||||
induction_ps_tbl = {},
|
induction_ps_tbl = {}, ---@type psil[]
|
||||||
induction_data_tbl = {},
|
induction_data_tbl = {}, ---@type imatrix_session_db[]
|
||||||
|
|
||||||
sps_ps_tbl = {},
|
sps_ps_tbl = {}, ---@type psil[]
|
||||||
sps_data_tbl = {},
|
sps_data_tbl = {}, ---@type sps_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {},
|
tank_ps_tbl = {}, ---@type psil[]
|
||||||
tank_data_tbl = {},
|
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||||
|
|
||||||
env_d_ps = psil.create(),
|
|
||||||
env_d_data = {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- create induction and SPS tables (currently only 1 of each is supported)
|
-- create induction and SPS tables (currently only 1 of each is supported)
|
||||||
@ -151,7 +140,7 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- create unit data structures
|
-- create unit data structures
|
||||||
io.units = {}
|
io.units = {} ---@type ioctl_unit[]
|
||||||
for i = 1, conf.num_units do
|
for i = 1, conf.num_units do
|
||||||
local function ack(alarm) process.ack_alarm(i, alarm) end
|
local function ack(alarm) process.ack_alarm(i, alarm) end
|
||||||
local function reset(alarm) process.reset_alarm(i, alarm) end
|
local function reset(alarm) process.reset_alarm(i, alarm) end
|
||||||
@ -160,7 +149,10 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
local entry = {
|
local entry = {
|
||||||
unit_id = i,
|
unit_id = i,
|
||||||
connected = false,
|
connected = false,
|
||||||
rtu_hw = { boilers = {}, turbines = {} },
|
rtu_hw = {
|
||||||
|
boilers = {}, ---@type { connected: boolean, faulted: boolean }[]
|
||||||
|
turbines = {} ---@type { connected: boolean, faulted: boolean }[]
|
||||||
|
},
|
||||||
|
|
||||||
num_boilers = 0,
|
num_boilers = 0,
|
||||||
num_turbines = 0,
|
num_turbines = 0,
|
||||||
@ -208,7 +200,7 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
t_trip = { ack = function () ack(12) end, reset = function () reset(12) end }
|
t_trip = { ack = function () ack(12) end, reset = function () reset(12) end }
|
||||||
},
|
},
|
||||||
|
|
||||||
---@type alarms
|
---@type { [ALARM]: ALARM_STATE }
|
||||||
alarms = {
|
alarms = {
|
||||||
ALARM_STATE.INACTIVE, -- containment breach
|
ALARM_STATE.INACTIVE, -- containment breach
|
||||||
ALARM_STATE.INACTIVE, -- containment radiation
|
ALARM_STATE.INACTIVE, -- containment radiation
|
||||||
@ -224,19 +216,19 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
ALARM_STATE.INACTIVE -- turbine trip
|
ALARM_STATE.INACTIVE -- turbine trip
|
||||||
},
|
},
|
||||||
|
|
||||||
annunciator = {}, ---@type annunciator
|
annunciator = {}, ---@type annunciator
|
||||||
|
|
||||||
unit_ps = psil.create(),
|
unit_ps = psil.create(),
|
||||||
reactor_data = {}, ---@type reactor_db
|
reactor_data = {}, ---@type reactor_db
|
||||||
|
|
||||||
boiler_ps_tbl = {},
|
boiler_ps_tbl = {}, ---@type psil[]
|
||||||
boiler_data_tbl = {},
|
boiler_data_tbl = {}, ---@type boilerv_session_db[]
|
||||||
|
|
||||||
turbine_ps_tbl = {},
|
turbine_ps_tbl = {}, ---@type psil[]
|
||||||
turbine_data_tbl = {},
|
turbine_data_tbl = {}, ---@type turbinev_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {},
|
tank_ps_tbl = {}, ---@type psil[]
|
||||||
tank_data_tbl = {}
|
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||||
}
|
}
|
||||||
|
|
||||||
-- on other facility modes, overwrite unit TANK option with facility tank defs
|
-- on other facility modes, overwrite unit TANK option with facility tank defs
|
||||||
@ -357,8 +349,8 @@ end
|
|||||||
-- record and publish multiblock RTU build data
|
-- record and publish multiblock RTU build data
|
||||||
---@param id integer
|
---@param id integer
|
||||||
---@param entry table
|
---@param entry table
|
||||||
---@param data_tbl table
|
---@param data_tbl (imatrix_session_db|sps_session_db|dynamicv_session_db|turbinev_session_db|boilerv_session_db)[]
|
||||||
---@param ps_tbl table
|
---@param ps_tbl psil[]
|
||||||
---@param create boolean? true to create an entry if non exists, false to fail on missing
|
---@param create boolean? true to create an entry if non exists, false to fail on missing
|
||||||
---@return boolean ok true if data saved, false if invalid ID
|
---@return boolean ok true if data saved, false if invalid ID
|
||||||
local function _record_multiblock_build(id, entry, data_tbl, ps_tbl, create)
|
local function _record_multiblock_build(id, entry, data_tbl, ps_tbl, create)
|
||||||
@ -369,8 +361,8 @@ local function _record_multiblock_build(id, entry, data_tbl, ps_tbl, create)
|
|||||||
data_tbl[id] = {}
|
data_tbl[id] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
data_tbl[id].formed = entry[1] ---@type boolean
|
data_tbl[id].formed = entry[1]
|
||||||
data_tbl[id].build = entry[2] ---@type table
|
data_tbl[id].build = entry[2]
|
||||||
|
|
||||||
ps_tbl[id].publish("formed", entry[1])
|
ps_tbl[id].publish("formed", entry[1])
|
||||||
|
|
||||||
@ -444,7 +436,7 @@ function iocontrol.record_unit_builds(builds)
|
|||||||
else
|
else
|
||||||
-- reactor build
|
-- reactor build
|
||||||
if type(build.reactor) == "table" then
|
if type(build.reactor) == "table" then
|
||||||
unit.reactor_data.mek_struct = build.reactor ---@type mek_struct
|
unit.reactor_data.mek_struct = build.reactor
|
||||||
for key, val in pairs(unit.reactor_data.mek_struct) do
|
for key, val in pairs(unit.reactor_data.mek_struct) do
|
||||||
unit.unit_ps.publish(key, val)
|
unit.unit_ps.publish(key, val)
|
||||||
end
|
end
|
||||||
@ -497,10 +489,10 @@ end
|
|||||||
---@param ps psil
|
---@param ps psil
|
||||||
---@return boolean is_faulted
|
---@return boolean is_faulted
|
||||||
local function _record_multiblock_status(entry, data, ps)
|
local function _record_multiblock_status(entry, data, ps)
|
||||||
local is_faulted = entry[1] ---@type boolean
|
local is_faulted = entry[1]
|
||||||
data.formed = entry[2] ---@type boolean
|
data.formed = entry[2]
|
||||||
data.state = entry[3] ---@type table
|
data.state = entry[3]
|
||||||
data.tanks = entry[4] ---@type table
|
data.tanks = entry[4]
|
||||||
|
|
||||||
ps.publish("formed", data.formed)
|
ps.publish("formed", data.formed)
|
||||||
ps.publish("faulted", is_faulted)
|
ps.publish("faulted", is_faulted)
|
||||||
@ -600,8 +592,8 @@ function iocontrol.update_facility_status(status)
|
|||||||
|
|
||||||
-- power statistics
|
-- power statistics
|
||||||
if type(rtu_statuses.power) == "table" and #rtu_statuses.power == 4 then
|
if type(rtu_statuses.power) == "table" and #rtu_statuses.power == 4 then
|
||||||
local data = fac.induction_data_tbl[1] ---@type imatrix_session_db
|
local data = fac.induction_data_tbl[1]
|
||||||
local ps = fac.induction_ps_tbl[1] ---@type psil
|
local ps = fac.induction_ps_tbl[1]
|
||||||
|
|
||||||
local chg = tonumber(rtu_statuses.power[1])
|
local chg = tonumber(rtu_statuses.power[1])
|
||||||
local in_f = tonumber(rtu_statuses.power[2])
|
local in_f = tonumber(rtu_statuses.power[2])
|
||||||
@ -636,23 +628,23 @@ function iocontrol.update_facility_status(status)
|
|||||||
|
|
||||||
for id, matrix in pairs(rtu_statuses.induction) do
|
for id, matrix in pairs(rtu_statuses.induction) do
|
||||||
if type(fac.induction_data_tbl[id]) == "table" then
|
if type(fac.induction_data_tbl[id]) == "table" then
|
||||||
local data = fac.induction_data_tbl[id] ---@type imatrix_session_db
|
local data = fac.induction_data_tbl[id]
|
||||||
local ps = fac.induction_ps_tbl[id] ---@type psil
|
local ps = fac.induction_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(matrix, data, ps)
|
local rtu_faulted = _record_multiblock_status(matrix, data, ps)
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
if data.tanks.energy_fill >= 0.99 then
|
if data.tanks.energy_fill >= 0.99 then
|
||||||
ps.publish("computed_status", 6) -- full
|
ps.publish("computed_status", 6) -- full
|
||||||
elseif data.tanks.energy_fill <= 0.01 then
|
elseif data.tanks.energy_fill <= 0.01 then
|
||||||
ps.publish("computed_status", 5) -- empty
|
ps.publish("computed_status", 5) -- empty
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 4) -- on-line
|
ps.publish("computed_status", 4) -- on-line
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c(log_header, "invalid induction matrix id ", id))
|
log.debug(util.c(log_header, "invalid induction matrix id ", id))
|
||||||
@ -674,21 +666,21 @@ function iocontrol.update_facility_status(status)
|
|||||||
|
|
||||||
for id, sps in pairs(rtu_statuses.sps) do
|
for id, sps in pairs(rtu_statuses.sps) do
|
||||||
if type(fac.sps_data_tbl[id]) == "table" then
|
if type(fac.sps_data_tbl[id]) == "table" then
|
||||||
local data = fac.sps_data_tbl[id] ---@type sps_session_db
|
local data = fac.sps_data_tbl[id]
|
||||||
local ps = fac.sps_ps_tbl[id] ---@type psil
|
local ps = fac.sps_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(sps, data, ps)
|
local rtu_faulted = _record_multiblock_status(sps, data, ps)
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
if data.state.process_rate > 0 then
|
if data.state.process_rate > 0 then
|
||||||
ps.publish("computed_status", 5) -- active
|
ps.publish("computed_status", 5) -- active
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 4) -- idle
|
ps.publish("computed_status", 4) -- idle
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
|
|
||||||
io.facility.ps.publish("am_rate", data.state.process_rate * 1000)
|
io.facility.ps.publish("am_rate", data.state.process_rate * 1000)
|
||||||
@ -712,23 +704,23 @@ function iocontrol.update_facility_status(status)
|
|||||||
|
|
||||||
for id, tank in pairs(rtu_statuses.tanks) do
|
for id, tank in pairs(rtu_statuses.tanks) do
|
||||||
if type(fac.tank_data_tbl[id]) == "table" then
|
if type(fac.tank_data_tbl[id]) == "table" then
|
||||||
local data = fac.tank_data_tbl[id] ---@type dynamicv_session_db
|
local data = fac.tank_data_tbl[id]
|
||||||
local ps = fac.tank_ps_tbl[id] ---@type psil
|
local ps = fac.tank_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(tank, data, ps)
|
local rtu_faulted = _record_multiblock_status(tank, data, ps)
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
if data.tanks.fill >= 0.99 then
|
if data.tanks.fill >= 0.99 then
|
||||||
ps.publish("computed_status", 6) -- full
|
ps.publish("computed_status", 6) -- full
|
||||||
elseif data.tanks.fill < 0.20 then
|
elseif data.tanks.fill < 0.20 then
|
||||||
ps.publish("computed_status", 5) -- low
|
ps.publish("computed_status", 5) -- low
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 4) -- on-line
|
ps.publish("computed_status", 4) -- on-line
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c(log_header, "invalid dynamic tank id ", id))
|
log.debug(util.c(log_header, "invalid dynamic tank id ", id))
|
||||||
@ -812,7 +804,7 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
for i = 1, #statuses do
|
for i = 1, #statuses do
|
||||||
local log_header = util.c("iocontrol.update_unit_statuses[unit ", i, "]: ")
|
local log_header = util.c("iocontrol.update_unit_statuses[unit ", i, "]: ")
|
||||||
|
|
||||||
local unit = io.units[i] ---@type ioctl_unit
|
local unit = io.units[i]
|
||||||
local status = statuses[i]
|
local status = statuses[i]
|
||||||
|
|
||||||
local burn_rate = 0.0
|
local burn_rate = 0.0
|
||||||
@ -848,8 +840,8 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
log.debug(log_header .. "reactor general status length mismatch")
|
log.debug(log_header .. "reactor general status length mismatch")
|
||||||
end
|
end
|
||||||
|
|
||||||
unit.reactor_data.rps_status = rps_status ---@type rps_status
|
unit.reactor_data.rps_status = rps_status
|
||||||
unit.reactor_data.mek_status = mek_status ---@type mek_status
|
unit.reactor_data.mek_status = mek_status
|
||||||
|
|
||||||
-- if status hasn't been received, mek_status = {}
|
-- if status hasn't been received, mek_status = {}
|
||||||
if type(unit.reactor_data.mek_status.act_burn_rate) == "number" then
|
if type(unit.reactor_data.mek_status.act_burn_rate) == "number" then
|
||||||
@ -858,18 +850,18 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if unit.reactor_data.mek_status.status then
|
if unit.reactor_data.mek_status.status then
|
||||||
unit.unit_ps.publish("computed_status", 5) -- running
|
unit.unit_ps.publish("computed_status", 5) -- running
|
||||||
else
|
else
|
||||||
if unit.reactor_data.no_reactor then
|
if unit.reactor_data.no_reactor then
|
||||||
unit.unit_ps.publish("computed_status", 3) -- faulted
|
unit.unit_ps.publish("computed_status", 3) -- faulted
|
||||||
elseif not unit.reactor_data.formed then
|
elseif not unit.reactor_data.formed then
|
||||||
unit.unit_ps.publish("computed_status", 2) -- multiblock not formed
|
unit.unit_ps.publish("computed_status", 2) -- multiblock not formed
|
||||||
elseif unit.reactor_data.rps_status.force_dis then
|
elseif unit.reactor_data.rps_status.force_dis then
|
||||||
unit.unit_ps.publish("computed_status", 7) -- reactor force disabled
|
unit.unit_ps.publish("computed_status", 7) -- reactor force disabled
|
||||||
elseif unit.reactor_data.rps_tripped and unit.reactor_data.rps_trip_cause ~= "manual" then
|
elseif unit.reactor_data.rps_tripped and unit.reactor_data.rps_trip_cause ~= "manual" then
|
||||||
unit.unit_ps.publish("computed_status", 6) -- SCRAM
|
unit.unit_ps.publish("computed_status", 6) -- SCRAM
|
||||||
else
|
else
|
||||||
unit.unit_ps.publish("computed_status", 4) -- disabled
|
unit.unit_ps.publish("computed_status", 4) -- disabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -917,24 +909,24 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
|
|
||||||
for id, boiler in pairs(rtu_statuses.boilers) do
|
for id, boiler in pairs(rtu_statuses.boilers) do
|
||||||
if type(unit.boiler_data_tbl[id]) == "table" then
|
if type(unit.boiler_data_tbl[id]) == "table" then
|
||||||
local data = unit.boiler_data_tbl[id] ---@type boilerv_session_db
|
local data = unit.boiler_data_tbl[id]
|
||||||
local ps = unit.boiler_ps_tbl[id] ---@type psil
|
local ps = unit.boiler_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(boiler, data, ps)
|
local rtu_faulted = _record_multiblock_status(boiler, data, ps)
|
||||||
unit.rtu_hw.boilers[id].faulted = rtu_faulted
|
unit.rtu_hw.boilers[id].faulted = rtu_faulted
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
boil_sum = boil_sum + data.state.boil_rate
|
boil_sum = boil_sum + data.state.boil_rate
|
||||||
|
|
||||||
if data.state.boil_rate > 0 then
|
if data.state.boil_rate > 0 then
|
||||||
ps.publish("computed_status", 5) -- active
|
ps.publish("computed_status", 5) -- active
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 4) -- idle
|
ps.publish("computed_status", 4) -- idle
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c(log_header, "invalid boiler id ", id))
|
log.debug(util.c(log_header, "invalid boiler id ", id))
|
||||||
@ -964,26 +956,26 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
|
|
||||||
for id, turbine in pairs(rtu_statuses.turbines) do
|
for id, turbine in pairs(rtu_statuses.turbines) do
|
||||||
if type(unit.turbine_data_tbl[id]) == "table" then
|
if type(unit.turbine_data_tbl[id]) == "table" then
|
||||||
local data = unit.turbine_data_tbl[id] ---@type turbinev_session_db
|
local data = unit.turbine_data_tbl[id]
|
||||||
local ps = unit.turbine_ps_tbl[id] ---@type psil
|
local ps = unit.turbine_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(turbine, data, ps)
|
local rtu_faulted = _record_multiblock_status(turbine, data, ps)
|
||||||
unit.rtu_hw.turbines[id].faulted = rtu_faulted
|
unit.rtu_hw.turbines[id].faulted = rtu_faulted
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
flow_sum = flow_sum + data.state.flow_rate
|
flow_sum = flow_sum + data.state.flow_rate
|
||||||
|
|
||||||
if data.tanks.energy_fill >= 0.99 then
|
if data.tanks.energy_fill >= 0.99 then
|
||||||
ps.publish("computed_status", 6) -- trip
|
ps.publish("computed_status", 6) -- trip
|
||||||
elseif data.state.flow_rate < 100 then
|
elseif data.state.flow_rate < 100 then
|
||||||
ps.publish("computed_status", 4) -- idle
|
ps.publish("computed_status", 4) -- idle
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 5) -- active
|
ps.publish("computed_status", 5) -- active
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c(log_header, "invalid turbine id ", id))
|
log.debug(util.c(log_header, "invalid turbine id ", id))
|
||||||
@ -1008,23 +1000,23 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
|
|
||||||
for id, tank in pairs(rtu_statuses.tanks) do
|
for id, tank in pairs(rtu_statuses.tanks) do
|
||||||
if type(unit.tank_data_tbl[id]) == "table" then
|
if type(unit.tank_data_tbl[id]) == "table" then
|
||||||
local data = unit.tank_data_tbl[id] ---@type dynamicv_session_db
|
local data = unit.tank_data_tbl[id]
|
||||||
local ps = unit.tank_ps_tbl[id] ---@type psil
|
local ps = unit.tank_ps_tbl[id]
|
||||||
|
|
||||||
local rtu_faulted = _record_multiblock_status(tank, data, ps)
|
local rtu_faulted = _record_multiblock_status(tank, data, ps)
|
||||||
|
|
||||||
if rtu_faulted then
|
if rtu_faulted then
|
||||||
ps.publish("computed_status", 3) -- faulted
|
ps.publish("computed_status", 3) -- faulted
|
||||||
elseif data.formed then
|
elseif data.formed then
|
||||||
if data.tanks.fill >= 0.99 then
|
if data.tanks.fill >= 0.99 then
|
||||||
ps.publish("computed_status", 6) -- full
|
ps.publish("computed_status", 6) -- full
|
||||||
elseif data.tanks.fill < 0.20 then
|
elseif data.tanks.fill < 0.20 then
|
||||||
ps.publish("computed_status", 5) -- low
|
ps.publish("computed_status", 5) -- low
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 4) -- on-line
|
ps.publish("computed_status", 4) -- on-line
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ps.publish("computed_status", 2) -- not formed
|
ps.publish("computed_status", 2) -- not formed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(util.c(log_header, "invalid dynamic tank id ", id))
|
log.debug(util.c(log_header, "invalid dynamic tank id ", id))
|
||||||
|
|||||||
@ -29,13 +29,13 @@ local pctl = {
|
|||||||
burn_target = 0.0,
|
burn_target = 0.0,
|
||||||
charge_target = 0.0,
|
charge_target = 0.0,
|
||||||
gen_target = 0.0,
|
gen_target = 0.0,
|
||||||
limits = {},
|
limits = {}, ---@type number[]
|
||||||
waste_product = PRODUCT.PLUTONIUM,
|
waste_product = PRODUCT.PLUTONIUM,
|
||||||
pu_fallback = false,
|
pu_fallback = false,
|
||||||
sps_low_power = false
|
sps_low_power = false
|
||||||
},
|
},
|
||||||
waste_modes = {},
|
waste_modes = {}, ---@type WASTE_MODE[]
|
||||||
priority_groups = {}
|
priority_groups = {} ---@type AUTO_GROUP[]
|
||||||
},
|
},
|
||||||
commands = {
|
commands = {
|
||||||
unit = {}, ---@type process_command_state[][]
|
unit = {}, ---@type process_command_state[][]
|
||||||
@ -46,7 +46,7 @@ local pctl = {
|
|||||||
---@class process_command_state
|
---@class process_command_state
|
||||||
---@field active boolean if this command is live
|
---@field active boolean if this command is live
|
||||||
---@field timeout integer expiration time of this command request
|
---@field timeout integer expiration time of this command request
|
||||||
---@field requestors table list of callbacks from the requestors
|
---@field requestors function[] list of callbacks from the requestors
|
||||||
|
|
||||||
-- write auto process control to config file
|
-- write auto process control to config file
|
||||||
local function _write_auto_config()
|
local function _write_auto_config()
|
||||||
@ -80,8 +80,8 @@ function process.init(iocontrol, coord_comms)
|
|||||||
ctl_proc.limits[i] = 0.1
|
ctl_proc.limits[i] = 0.1
|
||||||
end
|
end
|
||||||
|
|
||||||
local ctrl_states = settings.get("ControlStates", {})
|
local ctrl_states = settings.get("ControlStates", {}) ---@type sys_control_states
|
||||||
local config = ctrl_states.process ---@type sys_auto_config
|
local config = ctrl_states.process
|
||||||
|
|
||||||
-- facility auto control configuration
|
-- facility auto control configuration
|
||||||
if type(config) == "table" then
|
if type(config) == "table" then
|
||||||
@ -103,7 +103,7 @@ function process.init(iocontrol, coord_comms)
|
|||||||
pctl.io.facility.ps.publish("process_sps_low_power", ctl_proc.sps_low_power)
|
pctl.io.facility.ps.publish("process_sps_low_power", ctl_proc.sps_low_power)
|
||||||
|
|
||||||
for id = 1, math.min(#ctl_proc.limits, pctl.io.facility.num_units) do
|
for id = 1, math.min(#ctl_proc.limits, pctl.io.facility.num_units) do
|
||||||
local unit = pctl.io.units[id] ---@type ioctl_unit
|
local unit = pctl.io.units[id]
|
||||||
unit.unit_ps.publish("burn_limit", ctl_proc.limits[id])
|
unit.unit_ps.publish("burn_limit", ctl_proc.limits[id])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ function process.init(iocontrol, coord_comms)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- unit waste states
|
-- unit waste states
|
||||||
local waste_modes = ctrl_states.waste_modes ---@type table|nil
|
local waste_modes = ctrl_states.waste_modes
|
||||||
if type(waste_modes) == "table" then
|
if type(waste_modes) == "table" then
|
||||||
for id, mode in pairs(waste_modes) do
|
for id, mode in pairs(waste_modes) do
|
||||||
pctl.control_states.waste_modes[id] = mode
|
pctl.control_states.waste_modes[id] = mode
|
||||||
@ -127,7 +127,7 @@ function process.init(iocontrol, coord_comms)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- unit priority groups
|
-- unit priority groups
|
||||||
local prio_groups = ctrl_states.priority_groups ---@type table|nil
|
local prio_groups = ctrl_states.priority_groups
|
||||||
if type(prio_groups) == "table" then
|
if type(prio_groups) == "table" then
|
||||||
for id, group in pairs(prio_groups) do
|
for id, group in pairs(prio_groups) do
|
||||||
pctl.control_states.priority_groups[id] = group
|
pctl.control_states.priority_groups[id] = group
|
||||||
@ -443,7 +443,7 @@ end
|
|||||||
---@param burn_target number burn rate target
|
---@param burn_target number burn rate target
|
||||||
---@param charge_target number charge target
|
---@param charge_target number charge target
|
||||||
---@param gen_target number generation rate target
|
---@param gen_target number generation rate target
|
||||||
---@param limits table unit burn rate limits
|
---@param limits number[] unit burn rate limits
|
||||||
function process.save(mode, burn_target, charge_target, gen_target, limits)
|
function process.save(mode, burn_target, charge_target, gen_target, limits)
|
||||||
log.debug("PROCESS: SAVE")
|
log.debug("PROCESS: SAVE")
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ function process.start_ack_handle(response)
|
|||||||
for i = 1, math.min(#response[6], pctl.io.facility.num_units) do
|
for i = 1, math.min(#response[6], pctl.io.facility.num_units) do
|
||||||
ctl_proc.limits[i] = response[6][i]
|
ctl_proc.limits[i] = response[6][i]
|
||||||
|
|
||||||
local unit = pctl.io.units[i] ---@type ioctl_unit
|
local unit = pctl.io.units[i]
|
||||||
unit.unit_ps.publish("burn_limit", ctl_proc.limits[i])
|
unit.unit_ps.publish("burn_limit", ctl_proc.limits[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ local engine = {
|
|||||||
front_panel = nil, ---@type graphics_element|nil
|
front_panel = nil, ---@type graphics_element|nil
|
||||||
main_display = nil, ---@type graphics_element|nil
|
main_display = nil, ---@type graphics_element|nil
|
||||||
flow_display = nil, ---@type graphics_element|nil
|
flow_display = nil, ---@type graphics_element|nil
|
||||||
unit_displays = {}
|
unit_displays = {} ---@type (graphics_element|nil)[]
|
||||||
},
|
},
|
||||||
disable_flow_view = false
|
disable_flow_view = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ local self = {
|
|||||||
nic = nil, ---@type nic
|
nic = nil, ---@type nic
|
||||||
config = nil, ---@type crd_config
|
config = nil, ---@type crd_config
|
||||||
next_id = 0,
|
next_id = 0,
|
||||||
sessions = {}
|
sessions = {} ---@type pkt_session_struct[]
|
||||||
}
|
}
|
||||||
|
|
||||||
-- PRIVATE FUNCTIONS --
|
-- PRIVATE FUNCTIONS --
|
||||||
@ -129,7 +129,7 @@ end
|
|||||||
---@param timer_event number
|
---@param timer_event number
|
||||||
function apisessions.check_all_watchdogs(timer_event)
|
function apisessions.check_all_watchdogs(timer_event)
|
||||||
for i = 1, #self.sessions do
|
for i = 1, #self.sessions do
|
||||||
local session = self.sessions[i] ---@type pkt_session_struct
|
local session = self.sessions[i]
|
||||||
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
|
||||||
@ -143,7 +143,7 @@ end
|
|||||||
-- iterate all the API sessions
|
-- iterate all the API sessions
|
||||||
function apisessions.iterate_all()
|
function apisessions.iterate_all()
|
||||||
for i = 1, #self.sessions do
|
for i = 1, #self.sessions do
|
||||||
local session = self.sessions[i] ---@type pkt_session_struct
|
local session = self.sessions[i]
|
||||||
|
|
||||||
if session.open and session.instance.iterate() then
|
if session.open and session.instance.iterate() then
|
||||||
_api_handle_outq(session)
|
_api_handle_outq(session)
|
||||||
@ -168,7 +168,7 @@ end
|
|||||||
-- close all open connections
|
-- close all open connections
|
||||||
function apisessions.close_all()
|
function apisessions.close_all()
|
||||||
for i = 1, #self.sessions do
|
for i = 1, #self.sessions do
|
||||||
local session = self.sessions[i] ---@type pkt_session_struct
|
local session = self.sessions[i]
|
||||||
if session.open then _shutdown(session) end
|
if session.open then _shutdown(session) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -217,7 +217,7 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout)
|
|||||||
_send(CRDN_TYPE.API_GET_FAC, data)
|
_send(CRDN_TYPE.API_GET_FAC, data)
|
||||||
elseif pkt.type == CRDN_TYPE.API_GET_UNIT then
|
elseif pkt.type == CRDN_TYPE.API_GET_UNIT then
|
||||||
if pkt.length == 1 and type(pkt.data[1]) == "number" then
|
if pkt.length == 1 and type(pkt.data[1]) == "number" then
|
||||||
local u = db.units[pkt.data[1]] ---@type ioctl_unit
|
local u = db.units[pkt.data[1]]
|
||||||
|
|
||||||
if u then
|
if u then
|
||||||
local data = {
|
local data = {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ function sounder.reconnect(speaker)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- set alarm tones
|
-- set alarm tones
|
||||||
---@param states table alarm tone commands from supervisor
|
---@param states { [TONE]: boolean } alarm tone commands from supervisor
|
||||||
function sounder.set(states)
|
function sounder.set(states)
|
||||||
-- set tone states
|
-- set tone states
|
||||||
for id = 1, #states do alarm_ctl.stream.set_active(id, states[id]) end
|
for id = 1, #states do alarm_ctl.stream.set_active(id, states[id]) end
|
||||||
|
|||||||
@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer")
|
|||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
local threads = require("coordinator.threads")
|
local threads = require("coordinator.threads")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.5.8"
|
local COORDINATOR_VERSION = "v1.5.9"
|
||||||
|
|
||||||
local CHUNK_LOAD_DELAY_S = 30.0
|
local CHUNK_LOAD_DELAY_S = 30.0
|
||||||
|
|
||||||
|
|||||||
@ -177,7 +177,7 @@ local function new_view(root, x, y)
|
|||||||
local cur_lu = style.theme.disabled
|
local cur_lu = style.theme.disabled
|
||||||
|
|
||||||
if i <= facility.num_units then
|
if i <= facility.num_units then
|
||||||
unit = units[i] ---@type ioctl_unit
|
unit = units[i]
|
||||||
tag_fg_bg = cpair(colors.black, colors.lightBlue)
|
tag_fg_bg = cpair(colors.black, colors.lightBlue)
|
||||||
lim_fg_bg = s_hi_box
|
lim_fg_bg = s_hi_box
|
||||||
label_fg = style.theme.label_fg
|
label_fg = style.theme.label_fg
|
||||||
@ -234,7 +234,7 @@ local function new_view(root, x, y)
|
|||||||
local degraded = IndicatorLight{parent=lights,x=2,y=3,label="Degraded",colors=cpair(ind_red.fgd,ind_off),flash=true,period=period.BLINK_250_MS}
|
local degraded = IndicatorLight{parent=lights,x=2,y=3,label="Degraded",colors=cpair(ind_red.fgd,ind_off),flash=true,period=period.BLINK_250_MS}
|
||||||
|
|
||||||
if i <= facility.num_units then
|
if i <= facility.num_units then
|
||||||
local unit = units[i] ---@type ioctl_unit
|
local unit = units[i]
|
||||||
|
|
||||||
ready.register(unit.unit_ps, "U_AutoReady", ready.update)
|
ready.register(unit.unit_ps, "U_AutoReady", ready.update)
|
||||||
degraded.register(unit.unit_ps, "U_AutoDegraded", degraded.update)
|
degraded.register(unit.unit_ps, "U_AutoDegraded", degraded.update)
|
||||||
@ -323,7 +323,7 @@ local function new_view(root, x, y)
|
|||||||
local waste_status = Div{parent=proc,width=24,height=4,x=57,y=1,}
|
local waste_status = Div{parent=proc,width=24,height=4,x=57,y=1,}
|
||||||
|
|
||||||
for i = 1, facility.num_units do
|
for i = 1, facility.num_units do
|
||||||
local unit = units[i] ---@type ioctl_unit
|
local unit = units[i]
|
||||||
|
|
||||||
TextBox{parent=waste_status,y=i,text="U"..i.." Waste",width=8}
|
TextBox{parent=waste_status,y=i,text="U"..i.." Waste",width=8}
|
||||||
local a_waste = IndicatorLight{parent=waste_status,x=10,y=i,label="Auto",colors=ind_wht}
|
local a_waste = IndicatorLight{parent=waste_status,x=10,y=i,label="Auto",colors=ind_wht}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ local function init(parent, id)
|
|||||||
local ind_wht = style.ind_wht
|
local ind_wht = style.ind_wht
|
||||||
|
|
||||||
local db = iocontrol.get_db()
|
local db = iocontrol.get_db()
|
||||||
local unit = db.units[id] ---@type ioctl_unit
|
local unit = db.units[id]
|
||||||
local f_ps = db.facility.ps
|
local f_ps = db.facility.ps
|
||||||
|
|
||||||
local main = Div{parent=parent,x=1,y=1}
|
local main = Div{parent=parent,x=1,y=1}
|
||||||
|
|||||||
@ -84,8 +84,7 @@ local function init(main)
|
|||||||
table.insert(water_pipes, pipe(2, y, 2, y + 3, colors.blue, true))
|
table.insert(water_pipes, pipe(2, y, 2, y + 3, colors.blue, true))
|
||||||
table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true))
|
table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true))
|
||||||
|
|
||||||
local u = units[i] ---@type ioctl_unit
|
local x = util.trinary(units[i].num_boilers == 0, 45, 84)
|
||||||
local x = util.trinary(u.num_boilers == 0, 45, 84)
|
|
||||||
table.insert(water_pipes, pipe(21, y, x, y + 2, colors.blue, true, true))
|
table.insert(water_pipes, pipe(21, y, x, y + 2, colors.blue, true, true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -102,8 +101,7 @@ local function init(main)
|
|||||||
table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true))
|
table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true))
|
||||||
end
|
end
|
||||||
|
|
||||||
local u = units[i] ---@type ioctl_unit
|
local x = util.trinary(units[i].num_boilers == 0, 45, 84)
|
||||||
local x = util.trinary(u.num_boilers == 0, 45, 84)
|
|
||||||
table.insert(water_pipes, pipe(21, y, x, y + 2, colors.blue, true, true))
|
table.insert(water_pipes, pipe(21, y, x, y + 2, colors.blue, true, true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,7 +37,8 @@ local function init(main)
|
|||||||
ping.register(facility.ps, "sv_ping", ping.update)
|
ping.register(facility.ps, "sv_ping", ping.update)
|
||||||
datetime.register(facility.ps, "date_time", datetime.set_value)
|
datetime.register(facility.ps, "date_time", datetime.set_value)
|
||||||
|
|
||||||
local uo_1, uo_2, uo_3, uo_4 ---@type graphics_element
|
---@type graphics_element, graphics_element, graphics_element, graphics_element
|
||||||
|
local uo_1, uo_2, uo_3, uo_4
|
||||||
|
|
||||||
local cnc_y_start = 3
|
local cnc_y_start = 3
|
||||||
local row_1_height = 0
|
local row_1_height = 0
|
||||||
|
|||||||
@ -8,10 +8,12 @@ local util = require("scada-common.util")
|
|||||||
local pgi = {}
|
local pgi = {}
|
||||||
|
|
||||||
local data = {
|
local data = {
|
||||||
pkt_list = nil, ---@type nil|graphics_element
|
pkt_list = nil, ---@type nil|graphics_element
|
||||||
pkt_entry = nil, ---@type function
|
pkt_entry = nil, ---@type function
|
||||||
-- session entries
|
-- session entries
|
||||||
s_entries = { pkt = {} }
|
s_entries = {
|
||||||
|
pkt = {} ---@type graphics_element[]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- link list boxes
|
-- link list boxes
|
||||||
|
|||||||
@ -223,7 +223,7 @@ function iocontrol.init_fac(conf)
|
|||||||
reset_rps_ack = nil, ---@type fun(success: boolean)
|
reset_rps_ack = nil, ---@type fun(success: boolean)
|
||||||
ack_alarms_ack = nil, ---@type fun(success: boolean)
|
ack_alarms_ack = nil, ---@type fun(success: boolean)
|
||||||
|
|
||||||
---@type alarms
|
---@type { [ALARM]: ALARM_STATE }
|
||||||
alarms = { ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE },
|
alarms = { ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE, ALARM_STATE.INACTIVE },
|
||||||
|
|
||||||
annunciator = {}, ---@type annunciator
|
annunciator = {}, ---@type annunciator
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user