#367 RTU fail enum and logging messages
This commit is contained in:
@@ -9,6 +9,7 @@ local rsctl = require("supervisor.session.rsctl")
|
||||
local svsessions = require("supervisor.session.svsessions")
|
||||
|
||||
local PROCESS = types.PROCESS
|
||||
local RTU_ID_FAIL = types.RTU_ID_FAIL
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local WASTE = types.WASTE_PRODUCT
|
||||
|
||||
@@ -254,14 +255,16 @@ function facility.new(config)
|
||||
---@return boolean linked induction matrix accepted (max 1)
|
||||
function public.add_imatrix(imatrix)
|
||||
local fail_code, fail_str = svsessions.check_rtu_id(imatrix, self.induction, 1)
|
||||
local ok = fail_code == RTU_ID_FAIL.OK
|
||||
|
||||
if fail_code == 0 then
|
||||
if ok then
|
||||
table.insert(self.induction, imatrix)
|
||||
log.debug(util.c("FAC: linked induction matrix [", imatrix.get_unit_id(), "@", imatrix.get_session_id(), "]"))
|
||||
else
|
||||
log.warning(util.c("FAC: rejected induction matrix linking due to failure code ", fail_code, " (", fail_str, ")"))
|
||||
end
|
||||
|
||||
return fail_code == 0
|
||||
return ok
|
||||
end
|
||||
|
||||
-- link an SPS RTU session
|
||||
@@ -269,33 +272,40 @@ function facility.new(config)
|
||||
---@return boolean linked SPS accepted (max 1)
|
||||
function public.add_sps(sps)
|
||||
local fail_code, fail_str = svsessions.check_rtu_id(sps, self.sps, 1)
|
||||
local ok = fail_code == RTU_ID_FAIL.OK
|
||||
|
||||
if fail_code == 0 then
|
||||
if ok then
|
||||
table.insert(self.sps, sps)
|
||||
log.debug(util.c("FAC: linked SPS [", sps.get_unit_id(), "@", sps.get_session_id(), "]"))
|
||||
else
|
||||
log.warning(util.c("FAC: rejected SPS linking due to failure code ", fail_code, " (", fail_str, ")"))
|
||||
end
|
||||
|
||||
return fail_code == 0
|
||||
return ok
|
||||
end
|
||||
|
||||
-- link a dynamic tank RTU session
|
||||
---@param dynamic_tank unit_session
|
||||
function public.add_tank(dynamic_tank) table.insert(self.tanks, dynamic_tank) end
|
||||
function public.add_tank(dynamic_tank)
|
||||
table.insert(self.tanks, dynamic_tank)
|
||||
log.debug(util.c("FAC: linked dynamic tank #", dynamic_tank.get_device_idx(), " [", dynamic_tank.get_unit_id(), "@", dynamic_tank.get_session_id(), "]"))
|
||||
end
|
||||
|
||||
-- link an environment detector RTU session
|
||||
---@param envd unit_session
|
||||
---@return boolean linked environment detector accepted
|
||||
function public.add_envd(envd)
|
||||
local fail_code, fail_str = svsessions.check_rtu_id(envd, self.envd, 99)
|
||||
local ok = fail_code == RTU_ID_FAIL.OK
|
||||
|
||||
if fail_code == 0 then
|
||||
if ok then
|
||||
table.insert(self.envd, envd)
|
||||
log.debug(util.c("FAC: linked environment detector #", envd.get_device_idx(), " [", envd.get_unit_id(), "@", envd.get_session_id(), "]"))
|
||||
else
|
||||
log.warning(util.c("FAC: rejected environment detector linking due to failure code ", fail_code, " (", fail_str, ")"))
|
||||
end
|
||||
|
||||
return fail_code == 0
|
||||
return ok
|
||||
end
|
||||
|
||||
-- purge devices associated with the given RTU session ID
|
||||
|
||||
Reference in New Issue
Block a user