#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[]
|
sps_data_tbl = {}, ---@type sps_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {}, ---@type psil[]
|
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)
|
-- 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[]
|
turbine_data_tbl = {}, ---@type turbinev_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {}, ---@type psil[]
|
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
|
-- 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
|
if type(rtu_statuses.envds) == "table" then
|
||||||
local max_rad, max_reading, any_conn, any_faulted = 0, types.new_zero_radiation_reading(), false, false
|
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 rtu_faulted = envd[1] ---@type boolean
|
||||||
local radiation = envd[2] ---@type radiation_reading
|
local radiation = envd[2] ---@type radiation_reading
|
||||||
local rad_raw = envd[3] ---@type number
|
local rad_raw = envd[3] ---@type number
|
||||||
@ -809,6 +815,8 @@ function iocontrol.update_facility_status(status)
|
|||||||
max_rad = rad_raw
|
max_rad = rad_raw
|
||||||
max_reading = radiation
|
max_reading = radiation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fac.rad_monitors[id] = { radiation = radiation, raw = rad_raw }
|
||||||
end
|
end
|
||||||
|
|
||||||
if any_conn then
|
if any_conn then
|
||||||
@ -1099,7 +1107,9 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
if type(rtu_statuses.envds) == "table" then
|
if type(rtu_statuses.envds) == "table" then
|
||||||
local max_rad, max_reading, any_conn = 0, types.new_zero_radiation_reading(), false
|
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 radiation = envd[2] ---@type radiation_reading
|
||||||
local rad_raw = envd[3] ---@type number
|
local rad_raw = envd[3] ---@type number
|
||||||
|
|
||||||
@ -1109,6 +1119,8 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
max_rad = rad_raw
|
max_rad = rad_raw
|
||||||
max_reading = radiation
|
max_reading = radiation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unit.rad_monitors[id] = { radiation = radiation, raw = rad_raw }
|
||||||
end
|
end
|
||||||
|
|
||||||
if any_conn then
|
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)
|
_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
|
else
|
||||||
log.debug(log_tag .. "handler received unsupported CRDN packet type " .. pkt.type)
|
log.debug(log_tag .. "handler received unsupported CRDN packet type " .. pkt.type)
|
||||||
end
|
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.6.15"
|
local COORDINATOR_VERSION = "v1.6.16"
|
||||||
|
|
||||||
local CHUNK_LOAD_DELAY_S = 30.0
|
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_unit = function (unit) comms.api__get_unit(unit) end,
|
||||||
get_ctrl = function () comms.api__get_control() end,
|
get_ctrl = function () comms.api__get_control() end,
|
||||||
get_proc = function () comms.api__get_process() 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
|
end
|
||||||
|
|
||||||
@ -184,7 +185,9 @@ function iocontrol.init_fac(conf)
|
|||||||
sps_data_tbl = {}, ---@type sps_session_db[]
|
sps_data_tbl = {}, ---@type sps_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {}, ---@type psil[]
|
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)
|
-- 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[]
|
turbine_data_tbl = {}, ---@type turbinev_session_db[]
|
||||||
|
|
||||||
tank_ps_tbl = {}, ---@type psil[]
|
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
|
-- 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])
|
fac.ps.publish("sps_process_rate", f_data[9])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- update facility app with facility and unit data from API_GET_FAC_DTL
|
-- update facility app with facility and unit data from API_GET_FAC_DTL
|
||||||
---@param data table
|
---@param data table
|
||||||
function iorx.record_fac_detail_data(data)
|
function iorx.record_fac_detail_data(data)
|
||||||
@ -819,6 +818,42 @@ function iorx.record_fac_detail_data(data)
|
|||||||
s_ps.publish("SPSStateStatus", s_stat)
|
s_ps.publish("SPSStateStatus", s_stat)
|
||||||
end
|
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)
|
return function (io_obj)
|
||||||
io = io_obj
|
io = io_obj
|
||||||
return iorx
|
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
|
if self.api.linked then _send_api(CRDN_TYPE.API_GET_WASTE, {}) end
|
||||||
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
|
-- send a facility command
|
||||||
---@param cmd FAC_COMMAND command
|
---@param cmd FAC_COMMAND command
|
||||||
---@param option any? optional option options for the optional options (like waste mode)
|
---@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
|
if _check_length(packet, #iocontrol.get_db().units + 1) then
|
||||||
iocontrol.rx.record_waste_data(packet.data)
|
iocontrol.rx.record_waste_data(packet.data)
|
||||||
end
|
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 _fail_type(packet) end
|
||||||
else
|
else
|
||||||
log.debug("discarding coordinator SCADA_CRDN packet before linked")
|
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
|
-- refresh data callback, every 500ms it will re-send the query
|
||||||
local function update()
|
local function update()
|
||||||
if util.time_ms() - last_update >= 500 then
|
if util.time_ms() - last_update >= 500 then
|
||||||
-- db.api.get_rad()
|
db.api.get_rad()
|
||||||
last_update = util.time_ms()
|
last_update = util.time_ms()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -72,7 +72,8 @@ local CRDN_TYPE = {
|
|||||||
API_GET_UNIT = 10, -- API: get reactor unit data
|
API_GET_UNIT = 10, -- API: get reactor unit data
|
||||||
API_GET_CTRL = 11, -- API: get data for the control app
|
API_GET_CTRL = 11, -- API: get data for the control app
|
||||||
API_GET_PROC = 12, -- API: get data for the process 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
|
---@enum ESTABLISH_ACK
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user