#593 radiation monitor data comms
This commit is contained in:
parent
79d63fce78
commit
9e59883a84
@ -132,7 +132,9 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
||||
sps_data_tbl = {}, ---@type sps_session_db[]
|
||||
|
||||
tank_ps_tbl = {}, ---@type psil[]
|
||||
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||
tank_data_tbl = {}, ---@type dynamicv_session_db[]
|
||||
|
||||
rad_monitors = {} ---@type { radiation: radiation_reading, raw: number }[]
|
||||
}
|
||||
|
||||
-- create induction and SPS tables (currently only 1 of each is supported)
|
||||
@ -242,7 +244,9 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
||||
turbine_data_tbl = {}, ---@type turbinev_session_db[]
|
||||
|
||||
tank_ps_tbl = {}, ---@type psil[]
|
||||
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||
tank_data_tbl = {}, ---@type dynamicv_session_db[]
|
||||
|
||||
rad_monitors = {} ---@type { radiation: radiation_reading, raw: number }[]
|
||||
}
|
||||
|
||||
-- on other facility modes, overwrite unit TANK option with facility tank defs
|
||||
@ -797,7 +801,9 @@ function iocontrol.update_facility_status(status)
|
||||
if type(rtu_statuses.envds) == "table" then
|
||||
local max_rad, max_reading, any_conn, any_faulted = 0, types.new_zero_radiation_reading(), false, false
|
||||
|
||||
for _, envd in pairs(rtu_statuses.envds) do
|
||||
fac.rad_monitors = {}
|
||||
|
||||
for id, envd in pairs(rtu_statuses.envds) do
|
||||
local rtu_faulted = envd[1] ---@type boolean
|
||||
local radiation = envd[2] ---@type radiation_reading
|
||||
local rad_raw = envd[3] ---@type number
|
||||
@ -809,6 +815,8 @@ function iocontrol.update_facility_status(status)
|
||||
max_rad = rad_raw
|
||||
max_reading = radiation
|
||||
end
|
||||
|
||||
fac.rad_monitors[id] = { radiation = radiation, raw = rad_raw }
|
||||
end
|
||||
|
||||
if any_conn then
|
||||
@ -1099,7 +1107,9 @@ function iocontrol.update_unit_statuses(statuses)
|
||||
if type(rtu_statuses.envds) == "table" then
|
||||
local max_rad, max_reading, any_conn = 0, types.new_zero_radiation_reading(), false
|
||||
|
||||
for _, envd in pairs(rtu_statuses.envds) do
|
||||
unit.rad_monitors = {}
|
||||
|
||||
for id, envd in pairs(rtu_statuses.envds) do
|
||||
local radiation = envd[2] ---@type radiation_reading
|
||||
local rad_raw = envd[3] ---@type number
|
||||
|
||||
@ -1109,6 +1119,8 @@ function iocontrol.update_unit_statuses(statuses)
|
||||
max_rad = rad_raw
|
||||
max_reading = radiation
|
||||
end
|
||||
|
||||
unit.rad_monitors[id] = { radiation = radiation, raw = rad_raw }
|
||||
end
|
||||
|
||||
if any_conn then
|
||||
|
||||
@ -427,6 +427,13 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout)
|
||||
}
|
||||
|
||||
_send(CRDN_TYPE.API_GET_WASTE, data)
|
||||
elseif pkt.type == CRDN_TYPE.API_GET_RAD then
|
||||
local data = {}
|
||||
|
||||
for i = 1, #db.units do data[i] = db.units[i].rad_monitors end
|
||||
data[#db.units + 1] = db.facility.rad_monitors
|
||||
|
||||
_send(CRDN_TYPE.API_GET_RAD, data)
|
||||
else
|
||||
log.debug(log_tag .. "handler received unsupported CRDN packet type " .. pkt.type)
|
||||
end
|
||||
|
||||
@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer")
|
||||
local sounder = require("coordinator.sounder")
|
||||
local threads = require("coordinator.threads")
|
||||
|
||||
local COORDINATOR_VERSION = "v1.6.15"
|
||||
local COORDINATOR_VERSION = "v1.6.16"
|
||||
|
||||
local CHUNK_LOAD_DELAY_S = 30.0
|
||||
|
||||
|
||||
@ -98,7 +98,8 @@ function iocontrol.init_core(pkt_comms, nav, cfg)
|
||||
get_unit = function (unit) comms.api__get_unit(unit) end,
|
||||
get_ctrl = function () comms.api__get_control() end,
|
||||
get_proc = function () comms.api__get_process() end,
|
||||
get_waste = function () comms.api__get_waste() end
|
||||
get_waste = function () comms.api__get_waste() end,
|
||||
get_rad = function () comms.api__get_rad() end
|
||||
}
|
||||
end
|
||||
|
||||
@ -184,7 +185,9 @@ function iocontrol.init_fac(conf)
|
||||
sps_data_tbl = {}, ---@type sps_session_db[]
|
||||
|
||||
tank_ps_tbl = {}, ---@type psil[]
|
||||
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||
tank_data_tbl = {}, ---@type dynamicv_session_db[]
|
||||
|
||||
rad_monitors = {} ---@type { radiation: radiation_reading, raw: number }[]
|
||||
}
|
||||
|
||||
-- create induction and SPS tables (currently only 1 of each is supported)
|
||||
@ -264,7 +267,9 @@ function iocontrol.init_fac(conf)
|
||||
turbine_data_tbl = {}, ---@type turbinev_session_db[]
|
||||
|
||||
tank_ps_tbl = {}, ---@type psil[]
|
||||
tank_data_tbl = {} ---@type dynamicv_session_db[]
|
||||
tank_data_tbl = {}, ---@type dynamicv_session_db[]
|
||||
|
||||
rad_monitors = {} ---@type { radiation: radiation_reading, raw: number }[]
|
||||
}
|
||||
|
||||
-- on other facility modes, overwrite unit TANK option with facility tank defs
|
||||
|
||||
@ -658,7 +658,6 @@ function iorx.record_waste_data(data)
|
||||
fac.ps.publish("sps_process_rate", f_data[9])
|
||||
end
|
||||
|
||||
|
||||
-- update facility app with facility and unit data from API_GET_FAC_DTL
|
||||
---@param data table
|
||||
function iorx.record_fac_detail_data(data)
|
||||
@ -819,6 +818,42 @@ function iorx.record_fac_detail_data(data)
|
||||
s_ps.publish("SPSStateStatus", s_stat)
|
||||
end
|
||||
|
||||
-- update the radiation monitor app with radiation monitor data from API_GET_RAD
|
||||
---@param data table
|
||||
function iorx.record_radiation_data(data)
|
||||
-- unit radiation monitors
|
||||
|
||||
for u_id = 1, #io.units do
|
||||
local unit = io.units[u_id]
|
||||
|
||||
unit.radiation = types.new_zero_radiation_reading()
|
||||
unit.rad_monitors = data[u_id]
|
||||
|
||||
local max_rad = 0
|
||||
for _, mon in pairs(unit.rad_monitors) do
|
||||
if mon.raw > max_rad then
|
||||
max_rad = mon.raw
|
||||
unit.radiation = mon.radiation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- facility radiation monitors
|
||||
|
||||
local fac = io.facility
|
||||
|
||||
fac.radiation = types.new_zero_radiation_reading()
|
||||
fac.rad_monitors = data[#io.units + 1]
|
||||
|
||||
local max_rad = 0
|
||||
for _, mon in pairs(fac.rad_monitors) do
|
||||
if mon.raw > max_rad then
|
||||
max_rad = mon.raw
|
||||
fac.radiation = mon.radiation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return function (io_obj)
|
||||
io = io_obj
|
||||
return iorx
|
||||
|
||||
@ -583,6 +583,11 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
||||
if self.api.linked then _send_api(CRDN_TYPE.API_GET_WASTE, {}) end
|
||||
end
|
||||
|
||||
-- coordinator get radiation app data
|
||||
function public.api__get_rad()
|
||||
if self.api.linked then _send_api(CRDN_TYPE.API_GET_RAD, {}) end
|
||||
end
|
||||
|
||||
-- send a facility command
|
||||
---@param cmd FAC_COMMAND command
|
||||
---@param option any? optional option options for the optional options (like waste mode)
|
||||
@ -759,6 +764,10 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
||||
if _check_length(packet, #iocontrol.get_db().units + 1) then
|
||||
iocontrol.rx.record_waste_data(packet.data)
|
||||
end
|
||||
elseif packet.type == CRDN_TYPE.API_GET_RAD then
|
||||
if _check_length(packet, #iocontrol.get_db().units + 1) then
|
||||
iocontrol.rx.record_radiation_data(packet.data)
|
||||
end
|
||||
else _fail_type(packet) end
|
||||
else
|
||||
log.debug("discarding coordinator SCADA_CRDN packet before linked")
|
||||
|
||||
@ -86,7 +86,7 @@ local function new_view(root)
|
||||
-- refresh data callback, every 500ms it will re-send the query
|
||||
local function update()
|
||||
if util.time_ms() - last_update >= 500 then
|
||||
-- db.api.get_rad()
|
||||
db.api.get_rad()
|
||||
last_update = util.time_ms()
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,7 +72,8 @@ local CRDN_TYPE = {
|
||||
API_GET_UNIT = 10, -- API: get reactor unit data
|
||||
API_GET_CTRL = 11, -- API: get data for the control app
|
||||
API_GET_PROC = 12, -- API: get data for the process app
|
||||
API_GET_WASTE = 13 -- API: get data for the waste app
|
||||
API_GET_WASTE = 13, -- API: get data for the waste app
|
||||
API_GET_RAD = 14 -- API: get data for the radiation monitor app
|
||||
}
|
||||
|
||||
---@enum ESTABLISH_ACK
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user