#574 possible fix for RTU formed checking
This commit is contained in:
parent
849caa2521
commit
019284de7b
@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_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_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_HW_STATE = databus.RTU_HW_STATE
|
local RTU_HW_STATE = databus.RTU_HW_STATE
|
||||||
@ -339,8 +339,7 @@ local function main()
|
|||||||
|
|
||||||
if formed == ppm.ACCESS_FAULT then
|
if formed == ppm.ACCESS_FAULT then
|
||||||
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
|
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"))
|
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed boiler multiblock"))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif type == "turbineValve" then
|
elseif type == "turbineValve" then
|
||||||
-- turbine multiblock
|
-- turbine multiblock
|
||||||
@ -354,8 +353,7 @@ local function main()
|
|||||||
|
|
||||||
if formed == ppm.ACCESS_FAULT then
|
if formed == ppm.ACCESS_FAULT then
|
||||||
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
|
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"))
|
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed turbine multiblock"))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif type == "dynamicValve" then
|
elseif type == "dynamicValve" then
|
||||||
-- dynamic tank multiblock
|
-- dynamic tank multiblock
|
||||||
@ -374,8 +372,7 @@ local function main()
|
|||||||
|
|
||||||
if formed == ppm.ACCESS_FAULT then
|
if formed == ppm.ACCESS_FAULT then
|
||||||
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
|
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"))
|
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed dynamic tank multiblock"))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif type == "inductionPort" then
|
elseif type == "inductionPort" then
|
||||||
-- induction matrix multiblock
|
-- induction matrix multiblock
|
||||||
@ -388,8 +385,7 @@ local function main()
|
|||||||
|
|
||||||
if formed == ppm.ACCESS_FAULT then
|
if formed == ppm.ACCESS_FAULT then
|
||||||
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
|
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"))
|
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed induction matrix multiblock"))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif type == "spsPort" then
|
elseif type == "spsPort" then
|
||||||
-- SPS multiblock
|
-- SPS multiblock
|
||||||
@ -402,8 +398,7 @@ local function main()
|
|||||||
|
|
||||||
if formed == ppm.ACCESS_FAULT then
|
if formed == ppm.ACCESS_FAULT then
|
||||||
println_ts(util.c("sys_config> failed to check if '", name, "' is formed"))
|
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"))
|
log.warning(util.c("sys_config> failed to check if '", name, "' is a formed SPS multiblock"))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif type == "solarNeutronActivator" then
|
elseif type == "solarNeutronActivator" then
|
||||||
-- SNA
|
-- SNA
|
||||||
@ -431,7 +426,9 @@ local function main()
|
|||||||
|
|
||||||
if is_multiblock then
|
if is_multiblock then
|
||||||
if not formed 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
|
elseif faulted then
|
||||||
-- sometimes there is a race condition on server boot where it reports formed, but
|
-- 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
|
-- the other functions are not yet defined (that's the theory at least). mark as unformed to attempt connection later
|
||||||
|
|||||||
@ -466,6 +466,9 @@ end
|
|||||||
---@param smem rtu_shared_memory
|
---@param smem rtu_shared_memory
|
||||||
---@param unit rtu_registry_entry
|
---@param unit rtu_registry_entry
|
||||||
function threads.thread__unit_comms(smem, unit)
|
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
|
---@class parallel_thread
|
||||||
local public = {}
|
local public = {}
|
||||||
|
|
||||||
@ -538,6 +541,15 @@ function threads.thread__unit_comms(smem, unit)
|
|||||||
rtu_comms.send_remounted(unit.uid)
|
rtu_comms.send_remounted(unit.uid)
|
||||||
elseif (is_formed == false) and unit.formed then
|
elseif (is_formed == false) and unit.formed then
|
||||||
log.warning(util.c(detail_name, " is no longer formed"))
|
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
|
end
|
||||||
|
|
||||||
unit.formed = is_formed
|
unit.formed = is_formed
|
||||||
|
|||||||
@ -242,7 +242,7 @@ function ppm.mount_all()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mount a particular device
|
-- mount a specified device
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@param iface string CC peripheral interface
|
---@param iface string CC peripheral interface
|
||||||
---@return string|nil type, table|nil device
|
---@return string|nil type, table|nil device
|
||||||
@ -266,6 +266,33 @@ function ppm.mount(iface)
|
|||||||
return pm_type, pm_dev
|
return pm_type, pm_dev
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- unmount and remount a specified device
|
||||||
|
---@nodiscard
|
||||||
|
---@param iface string CC peripheral interface
|
||||||
|
---@return string|nil type, table|nil device
|
||||||
|
function ppm.remount(iface)
|
||||||
|
local ifaces = peripheral.getNames()
|
||||||
|
local pm_dev = nil
|
||||||
|
local pm_type = nil
|
||||||
|
|
||||||
|
for i = 1, #ifaces do
|
||||||
|
if iface == ifaces[i] then
|
||||||
|
log.info(util.c("PPM: remount(", iface, ") -> is a ", pm_type))
|
||||||
|
ppm.unmount(ppm_sys.mounts[iface].dev)
|
||||||
|
|
||||||
|
ppm_sys.mounts[iface] = peri_init(iface)
|
||||||
|
|
||||||
|
pm_type = ppm_sys.mounts[iface].type
|
||||||
|
pm_dev = ppm_sys.mounts[iface].dev
|
||||||
|
|
||||||
|
log.info(util.c("PPM: remount(", iface, ") -> remounted a ", pm_type))
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return pm_type, pm_dev
|
||||||
|
end
|
||||||
|
|
||||||
-- mount a virtual, placeholder device (specifically designed for RTU startup with missing devices)
|
-- mount a virtual, placeholder device (specifically designed for RTU startup with missing devices)
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@return string type, table device
|
---@return string type, table device
|
||||||
|
|||||||
@ -24,7 +24,7 @@ local t_pack = table.pack
|
|||||||
local util = {}
|
local util = {}
|
||||||
|
|
||||||
-- scada-common version
|
-- scada-common version
|
||||||
util.version = "1.4.6"
|
util.version = "1.4.7"
|
||||||
|
|
||||||
util.TICK_TIME_S = 0.05
|
util.TICK_TIME_S = 0.05
|
||||||
util.TICK_TIME_MS = 50
|
util.TICK_TIME_MS = 50
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user