#574 possible fix for RTU formed checking

This commit is contained in:
Mikayla
2024-12-12 03:18:21 +00:00
parent 849caa2521
commit 019284de7b
4 changed files with 50 additions and 14 deletions

View File

@@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "v1.10.17"
local RTU_VERSION = "v1.10.18"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local RTU_HW_STATE = databus.RTU_HW_STATE
@@ -339,8 +339,7 @@ local function main()
if formed == ppm.ACCESS_FAULT then
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
log.fatal(util.c("sys_config> failed to check if '", name, "' is a formed boiler multiblock"))
return false
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed boiler multiblock"))
end
elseif type == "turbineValve" then
-- turbine multiblock
@@ -354,8 +353,7 @@ local function main()
if formed == ppm.ACCESS_FAULT then
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
log.fatal(util.c("sys_config> failed to check if '", name, "' is a formed turbine multiblock"))
return false
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed turbine multiblock"))
end
elseif type == "dynamicValve" then
-- dynamic tank multiblock
@@ -374,8 +372,7 @@ local function main()
if formed == ppm.ACCESS_FAULT then
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
log.fatal(util.c("sys_config> failed to check if '", name, "' is a formed dynamic tank multiblock"))
return false
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed dynamic tank multiblock"))
end
elseif type == "inductionPort" then
-- induction matrix multiblock
@@ -388,8 +385,7 @@ local function main()
if formed == ppm.ACCESS_FAULT then
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
log.fatal(util.c("sys_config> failed to check if '", name, "' is a formed induction matrix multiblock"))
return false
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed induction matrix multiblock"))
end
elseif type == "spsPort" then
-- SPS multiblock
@@ -402,8 +398,7 @@ local function main()
if formed == ppm.ACCESS_FAULT then
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
log.fatal(util.c("sys_config> failed to check if '", name, "' is a formed SPS multiblock"))
return false
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed SPS multiblock"))
end
elseif type == "solarNeutronActivator" then
-- SNA
@@ -431,7 +426,9 @@ local function main()
if is_multiblock then
if not formed then
log.info(util.c("sys_config> device '", name, "' is not formed"))
if formed == false then
log.info(util.c("sys_config> device '", name, "' is not formed"))
end
elseif faulted then
-- sometimes there is a race condition on server boot where it reports formed, but
-- the other functions are not yet defined (that's the theory at least). mark as unformed to attempt connection later

View File

@@ -466,6 +466,9 @@ end
---@param smem rtu_shared_memory
---@param unit rtu_registry_entry
function threads.thread__unit_comms(smem, unit)
-- print a log message to the terminal as long as the UI isn't running
local function println_ts(message) if not smem.rtu_state.fp_ok then util.println_ts(message) end end
---@class parallel_thread
local public = {}
@@ -538,6 +541,15 @@ function threads.thread__unit_comms(smem, unit)
rtu_comms.send_remounted(unit.uid)
elseif (is_formed == false) and unit.formed then
log.warning(util.c(detail_name, " is no longer formed"))
elseif is_formed == nil then
log.error(util.c(detail_name, " failed to check if formed, attempting remount..."))
local type, dev = ppm.remount(unit.name)
if type and dev then
handle_unit_mount(smem, println_ts, unit.name, type, dev, unit)
else
log.error(util.c(detail_name, " failed to remount"))
end
end
unit.formed = is_formed