cleanup and fixes

This commit is contained in:
Mikayla Fischler 2023-11-12 14:21:48 -05:00
parent 78ad6d5457
commit 68754977b0
5 changed files with 23 additions and 58 deletions

View File

@ -783,12 +783,12 @@ function iocontrol.update_facility_status(status)
fac.radiation = types.new_zero_radiation_reading()
fac.ps.publish("rad_computed_status", 1)
end
fac.ps.publish("radiation", fac.radiation)
else
log.debug(log_header .. "radiation monitor list not a table")
valid = false
end
fac.ps.publish("radiation", fac.radiation)
else
log.debug(log_header .. "rtu statuses not a table")
valid = false
@ -1081,12 +1081,12 @@ function iocontrol.update_unit_statuses(statuses)
else
unit.radiation = types.new_zero_radiation_reading()
end
unit.unit_ps.publish("radiation", unit.radiation)
else
log.debug(log_header .. "radiation monitor list not a table")
valid = false
end
unit.unit_ps.publish("radiation", unit.radiation)
else
log.debug(log_header .. "rtu list not a table")
valid = false

View File

@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
local apisessions = require("coordinator.session.apisessions")
local COORDINATOR_VERSION = "v1.0.16"
local COORDINATOR_VERSION = "v1.0.17"
local println = util.println
local println_ts = util.println_ts

View File

@ -40,10 +40,12 @@ local function handle_unit_mount(smem, println_ts, iface, type, device, unit)
-- find disconnected device to reconnect
-- note: cannot check isFormed as that would yield this coroutine and consume events
if unit.name == iface then
local resend_advert = false
local faulted = false
local unknown = false
local invalid = false
local resend_advert, faulted, unknown, invalid = false, false, false, false
local function fail(msg)
invalid = true
log.error(msg .. " in config")
end
-- found, re-link
unit.device = device
@ -52,79 +54,45 @@ local function handle_unit_mount(smem, println_ts, iface, type, device, unit)
resend_advert = true
if type == "boilerValve" then
-- boiler multiblock
if unit.reactor < 1 or unit.reactor > 4 then
invalid = true
log.error(util.c("boiler '", unit.name, "' cannot init, not assigned to a valid unit in config"))
end
if (unit.index == false) or unit.index < 1 or unit.index > 2 then
invalid = true
log.error(util.c("boiler '", unit.name, "' cannot init, invalid index provided in config"))
end
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("boiler '", unit.name, "' cannot init, not assigned to a valid unit")) end
if (unit.index == false) or unit.index < 1 or unit.index > 2 then fail(util.c("boiler '", unit.name, "' cannot init, invalid index provided")) end
unit.type = RTU_UNIT_TYPE.BOILER_VALVE
elseif type == "turbineValve" then
-- turbine multiblock
if unit.reactor < 1 or unit.reactor > 4 then
invalid = true
log.error(util.c("turbine '", unit.name, "' cannot init, not assigned to a valid unit in config"))
end
if (unit.index == false) or unit.index < 1 or unit.index > 3 then
invalid = true
log.error(util.c("turbine '", unit.name, "' cannot init, invalid index provided in config"))
end
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("turbine '", unit.name, "' cannot init, not assigned to a valid unit")) end
if (unit.index == false) or unit.index < 1 or unit.index > 3 then fail(util.c("turbine '", unit.name, "' cannot init, invalid index provided")) end
unit.type = RTU_UNIT_TYPE.TURBINE_VALVE
elseif type == "dynamicValve" then
-- dynamic tank multiblock
if unit.reactor < 0 or unit.reactor > 4 then
invalid = true
log.error(util.c("dynamic tank '", unit.name, "' cannot init, no valid assignment provided in config"))
end
if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("dynamic tank '", unit.name, "' cannot init, no valid assignment provided")) end
if (unit.reactor == 0 and ((unit.index == false) or unit.index < 1 or unit.index > 4)) or
(unit.reactor > 0 and unit.index ~= 1) then
invalid = true
log.error(util.c("dynamic tank '", unit.name, "' cannot init, invalid index provided in config"))
fail(util.c("dynamic tank '", unit.name, "' cannot init, invalid index provided"))
end
unit.type = RTU_UNIT_TYPE.DYNAMIC_VALVE
elseif type == "inductionPort" then
-- induction matrix multiblock
if unit.reactor ~= 0 then
invalid = true
log.error(util.c("induction matrix '", unit.name, "' cannot init, not assigned to facility in config"))
end
if unit.reactor ~= 0 then fail(util.c("induction matrix '", unit.name, "' cannot init, not assigned to facility")) end
unit.type = RTU_UNIT_TYPE.IMATRIX
elseif type == "spsPort" then
-- SPS multiblock
if unit.reactor ~= 0 then
invalid = true
log.error(util.c("SPS '", unit.name, "' cannot init, not assigned to facility in config"))
end
if unit.reactor ~= 0 then fail(util.c("SPS '", unit.name, "' cannot init, not assigned to facility")) end
unit.type = RTU_UNIT_TYPE.SPS
elseif type == "solarNeutronActivator" then
-- SNA
if unit.reactor < 1 or unit.reactor > 4 then
invalid = true
log.error(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit in config"))
end
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit")) end
unit.type = RTU_UNIT_TYPE.SNA
elseif type == "environmentDetector" then
-- advanced peripherals environment detector
if unit.reactor < 0 or unit.reactor > 4 then
invalid = true
log.error(util.c("environment detector '", unit.name, "' cannot init, no valid assignment provided in config"))
end
if (unit.index == false) or unit.index < 1 then
invalid = true
log.error(util.c("environment detector '", unit.name, "' cannot init, invalid index provided in config"))
end
if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("environment detector '", unit.name, "' cannot init, no valid assignment provided")) end
if (unit.index == false) or unit.index < 1 then fail(util.c("environment detector '", unit.name, "' cannot init, invalid index provided")) end
unit.type = RTU_UNIT_TYPE.ENV_DETECTOR
else

View File

@ -638,7 +638,7 @@ function facility.new(num_reactors, cooling_conf)
if e_db.radiation_raw > max_rad then max_rad = e_db.radiation_raw end
end
astatus.radiation = max_rad > ALARM_LIMS.FAC_HIGH_RAD
astatus.radiation = max_rad >= ALARM_LIMS.FAC_HIGH_RAD
else
-- don't clear, if it is true then we lost it with high radiation, so just keep alarming
-- operator can restart the system or hit the stop/reset button

View File

@ -41,9 +41,6 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
if advert.type ~= RTU_UNIT_TYPE.IMATRIX then
log.error("attempt to instantiate imatrix RTU for type " .. types.rtu_type_to_string(advert.type))
return nil
elseif not util.is_int(advert.index) then
log.error("attempt to instantiate dynamicv RTU without index")
return nil
end
local log_tag = util.c("session.rtu(", session_id, ").imatrix[@", unit_id, "]: ")