mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
cleanup and fixes
This commit is contained in:
parent
78ad6d5457
commit
68754977b0
@ -783,12 +783,12 @@ function iocontrol.update_facility_status(status)
|
|||||||
fac.radiation = types.new_zero_radiation_reading()
|
fac.radiation = types.new_zero_radiation_reading()
|
||||||
fac.ps.publish("rad_computed_status", 1)
|
fac.ps.publish("rad_computed_status", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fac.ps.publish("radiation", fac.radiation)
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "radiation monitor list not a table")
|
log.debug(log_header .. "radiation monitor list not a table")
|
||||||
valid = false
|
valid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
fac.ps.publish("radiation", fac.radiation)
|
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "rtu statuses not a table")
|
log.debug(log_header .. "rtu statuses not a table")
|
||||||
valid = false
|
valid = false
|
||||||
@ -1081,12 +1081,12 @@ function iocontrol.update_unit_statuses(statuses)
|
|||||||
else
|
else
|
||||||
unit.radiation = types.new_zero_radiation_reading()
|
unit.radiation = types.new_zero_radiation_reading()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unit.unit_ps.publish("radiation", unit.radiation)
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "radiation monitor list not a table")
|
log.debug(log_header .. "radiation monitor list not a table")
|
||||||
valid = false
|
valid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
unit.unit_ps.publish("radiation", unit.radiation)
|
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "rtu list not a table")
|
log.debug(log_header .. "rtu list not a table")
|
||||||
valid = false
|
valid = false
|
||||||
|
@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
|
|||||||
|
|
||||||
local apisessions = require("coordinator.session.apisessions")
|
local apisessions = require("coordinator.session.apisessions")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.0.16"
|
local COORDINATOR_VERSION = "v1.0.17"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -40,10 +40,12 @@ local function handle_unit_mount(smem, println_ts, iface, type, device, unit)
|
|||||||
-- find disconnected device to reconnect
|
-- find disconnected device to reconnect
|
||||||
-- note: cannot check isFormed as that would yield this coroutine and consume events
|
-- note: cannot check isFormed as that would yield this coroutine and consume events
|
||||||
if unit.name == iface then
|
if unit.name == iface then
|
||||||
local resend_advert = false
|
local resend_advert, faulted, unknown, invalid = false, false, false, false
|
||||||
local faulted = false
|
|
||||||
local unknown = false
|
local function fail(msg)
|
||||||
local invalid = false
|
invalid = true
|
||||||
|
log.error(msg .. " in config")
|
||||||
|
end
|
||||||
|
|
||||||
-- found, re-link
|
-- found, re-link
|
||||||
unit.device = device
|
unit.device = device
|
||||||
@ -52,79 +54,45 @@ local function handle_unit_mount(smem, println_ts, iface, type, device, unit)
|
|||||||
resend_advert = true
|
resend_advert = true
|
||||||
if type == "boilerValve" then
|
if type == "boilerValve" then
|
||||||
-- boiler multiblock
|
-- boiler multiblock
|
||||||
if unit.reactor < 1 or unit.reactor > 4 then
|
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("boiler '", unit.name, "' cannot init, not assigned to a valid unit")) end
|
||||||
invalid = true
|
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
|
||||||
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
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.BOILER_VALVE
|
unit.type = RTU_UNIT_TYPE.BOILER_VALVE
|
||||||
elseif type == "turbineValve" then
|
elseif type == "turbineValve" then
|
||||||
-- turbine multiblock
|
-- turbine multiblock
|
||||||
if unit.reactor < 1 or unit.reactor > 4 then
|
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("turbine '", unit.name, "' cannot init, not assigned to a valid unit")) end
|
||||||
invalid = true
|
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
|
||||||
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
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.TURBINE_VALVE
|
unit.type = RTU_UNIT_TYPE.TURBINE_VALVE
|
||||||
elseif type == "dynamicValve" then
|
elseif type == "dynamicValve" then
|
||||||
-- dynamic tank multiblock
|
-- dynamic tank multiblock
|
||||||
if unit.reactor < 0 or unit.reactor > 4 then
|
if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("dynamic tank '", unit.name, "' cannot init, no valid assignment provided")) end
|
||||||
invalid = true
|
|
||||||
log.error(util.c("dynamic tank '", unit.name, "' cannot init, no valid assignment provided in config"))
|
|
||||||
end
|
|
||||||
|
|
||||||
if (unit.reactor == 0 and ((unit.index == false) or unit.index < 1 or unit.index > 4)) or
|
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
|
(unit.reactor > 0 and unit.index ~= 1) then
|
||||||
invalid = true
|
fail(util.c("dynamic tank '", unit.name, "' cannot init, invalid index provided"))
|
||||||
log.error(util.c("dynamic tank '", unit.name, "' cannot init, invalid index provided in config"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.DYNAMIC_VALVE
|
unit.type = RTU_UNIT_TYPE.DYNAMIC_VALVE
|
||||||
elseif type == "inductionPort" then
|
elseif type == "inductionPort" then
|
||||||
-- induction matrix multiblock
|
-- induction matrix multiblock
|
||||||
if unit.reactor ~= 0 then
|
if unit.reactor ~= 0 then fail(util.c("induction matrix '", unit.name, "' cannot init, not assigned to facility")) end
|
||||||
invalid = true
|
|
||||||
log.error(util.c("induction matrix '", unit.name, "' cannot init, not assigned to facility in config"))
|
|
||||||
end
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.IMATRIX
|
unit.type = RTU_UNIT_TYPE.IMATRIX
|
||||||
elseif type == "spsPort" then
|
elseif type == "spsPort" then
|
||||||
-- SPS multiblock
|
-- SPS multiblock
|
||||||
if unit.reactor ~= 0 then
|
if unit.reactor ~= 0 then fail(util.c("SPS '", unit.name, "' cannot init, not assigned to facility")) end
|
||||||
invalid = true
|
|
||||||
log.error(util.c("SPS '", unit.name, "' cannot init, not assigned to facility in config"))
|
|
||||||
end
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.SPS
|
unit.type = RTU_UNIT_TYPE.SPS
|
||||||
elseif type == "solarNeutronActivator" then
|
elseif type == "solarNeutronActivator" then
|
||||||
-- SNA
|
-- SNA
|
||||||
if unit.reactor < 1 or unit.reactor > 4 then
|
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit")) end
|
||||||
invalid = true
|
|
||||||
log.error(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit in config"))
|
|
||||||
end
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.SNA
|
unit.type = RTU_UNIT_TYPE.SNA
|
||||||
elseif type == "environmentDetector" then
|
elseif type == "environmentDetector" then
|
||||||
-- advanced peripherals environment detector
|
-- advanced peripherals environment detector
|
||||||
if unit.reactor < 0 or unit.reactor > 4 then
|
if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("environment detector '", unit.name, "' cannot init, no valid assignment provided")) end
|
||||||
invalid = true
|
if (unit.index == false) or unit.index < 1 then fail(util.c("environment detector '", unit.name, "' cannot init, invalid index provided")) end
|
||||||
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
|
|
||||||
|
|
||||||
unit.type = RTU_UNIT_TYPE.ENV_DETECTOR
|
unit.type = RTU_UNIT_TYPE.ENV_DETECTOR
|
||||||
else
|
else
|
||||||
|
@ -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
|
if e_db.radiation_raw > max_rad then max_rad = e_db.radiation_raw end
|
||||||
end
|
end
|
||||||
|
|
||||||
astatus.radiation = max_rad > ALARM_LIMS.FAC_HIGH_RAD
|
astatus.radiation = max_rad >= ALARM_LIMS.FAC_HIGH_RAD
|
||||||
else
|
else
|
||||||
-- don't clear, if it is true then we lost it with high radiation, so just keep alarming
|
-- 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
|
-- operator can restart the system or hit the stop/reset button
|
||||||
|
@ -41,9 +41,6 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
|||||||
if advert.type ~= RTU_UNIT_TYPE.IMATRIX then
|
if advert.type ~= RTU_UNIT_TYPE.IMATRIX then
|
||||||
log.error("attempt to instantiate imatrix RTU for type " .. types.rtu_type_to_string(advert.type))
|
log.error("attempt to instantiate imatrix RTU for type " .. types.rtu_type_to_string(advert.type))
|
||||||
return nil
|
return nil
|
||||||
elseif not util.is_int(advert.index) then
|
|
||||||
log.error("attempt to instantiate dynamicv RTU without index")
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local log_tag = util.c("session.rtu(", session_id, ").imatrix[@", unit_id, "]: ")
|
local log_tag = util.c("session.rtu(", session_id, ").imatrix[@", unit_id, "]: ")
|
||||||
|
Loading…
Reference in New Issue
Block a user