diff --git a/reactor-plc/databus.lua b/reactor-plc/databus.lua
index ba7a68e..937b954 100644
--- a/reactor-plc/databus.lua
+++ b/reactor-plc/databus.lua
@@ -70,9 +70,9 @@ function databus.tx_link_state(state)
end
-- transmit reactor enable state across the bus
----@param active boolean reactor active
+---@param active boolean|nil reactor active
function databus.tx_reactor_state(active)
- databus.ps.publish("reactor_active", active)
+ databus.ps.publish("reactor_active", active == true)
end
-- transmit RPS data across the bus
diff --git a/reactor-plc/plc.lua b/reactor-plc/plc.lua
index 64cff92..eec1e4d 100644
--- a/reactor-plc/plc.lua
+++ b/reactor-plc/plc.lua
@@ -469,13 +469,22 @@ function plc.rps_init(reactor, is_formed)
self.tripped = false
self.trip_cause = RPS_TRIP_CAUSE.OK
- for i = 1, #self.state do
- self.state[i] = false
- end
+ for i = 1, #self.state do self.state[i] = false end
if not quiet then log.info("RPS: reset") end
end
+ -- partial RPS reset that only clears fault and sys_fail
+ function public.reset_formed()
+ self.tripped = false
+ self.trip_cause = RPS_TRIP_CAUSE.OK
+
+ self.state[state_keys.fault] = false
+ self.state[state_keys.sys_fail] = false
+
+ log.info("RPS: partial reset on formed")
+ end
+
-- reset the automatic and timeout trip flags, then clear trip if that was the trip cause
function public.auto_reset()
self.state[state_keys.automatic] = false
diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua
index dd18301..f67e60f 100644
--- a/reactor-plc/startup.lua
+++ b/reactor-plc/startup.lua
@@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
local renderer = require("reactor-plc.renderer")
local threads = require("reactor-plc.threads")
-local R_PLC_VERSION = "v1.6.12"
+local R_PLC_VERSION = "v1.6.13"
local println = util.println
local println_ts = util.println_ts
diff --git a/reactor-plc/threads.lua b/reactor-plc/threads.lua
index 85e2a86..afe6acb 100644
--- a/reactor-plc/threads.lua
+++ b/reactor-plc/threads.lua
@@ -125,9 +125,8 @@ function threads.thread__main(smem, init)
plc_comms.reconnect_reactor(plc_dev.reactor)
end
- -- reset RPS for newly connected reactor
- -- without this, is_formed will be out of date and cause it to think its no longer formed again
- rps.reset()
+ -- partial reset of RPS, specific to becoming formed
+ rps.reset_formed()
else
-- fully lost the reactor now :(
println_ts("reactor lost (failed reconnect)!")
@@ -231,9 +230,8 @@ function threads.thread__main(smem, init)
plc_comms.reconnect_reactor(plc_dev.reactor)
end
- -- reset RPS for newly connected reactor
- -- without this, is_formed will be out of date and cause it to think its no longer formed again
- rps.reset()
+ -- partial reset of RPS, specific to becoming formed
+ rps.reset_formed()
end
elseif networked and type == "modem" then
-- note, check init_ok first since nic will be nil if it is false
diff --git a/scada-common/ppm.lua b/scada-common/ppm.lua
index b11e203..fb98161 100644
--- a/scada-common/ppm.lua
+++ b/scada-common/ppm.lua
@@ -155,7 +155,7 @@ local function peri_init(iface)
self.fault_counts[key] = self.fault_counts[key] + 1
- return (function () return ACCESS_FAULT end)
+ return (function () return UNDEFINED_FIELD end)
end
}
@@ -306,7 +306,7 @@ function ppm.log_mounts()
log.info(util.c("PPM: had found a ", mount.type, " (", iface, ")"))
end
- if #ppm_sys.mounts == 0 then
+ if util.table_len(ppm_sys.mounts) == 0 then
log.warning("PPM: no devices had been found")
end
end
diff --git a/scada-common/util.lua b/scada-common/util.lua
index c694fd5..c72d62e 100644
--- a/scada-common/util.lua
+++ b/scada-common/util.lua
@@ -22,7 +22,7 @@ local t_pack = table.pack
local util = {}
-- scada-common version
-util.version = "1.1.17"
+util.version = "1.1.18"
util.TICK_TIME_S = 0.05
util.TICK_TIME_MS = 50
@@ -284,11 +284,13 @@ function util.cancel_timer(timer) os.cancelTimer(timer) end
--#region PARALLELIZATION
--- protected sleep call so we still are in charge of catching termination
----@param t integer seconds
+-- protected sleep call so we still are in charge of catching termination
+-- returns the result of pcall
+---@param t number seconds
+---@return boolean success, any result, any ...
--- EVENT_CONSUMER: this function consumes events
---@diagnostic disable-next-line: undefined-field
-function util.psleep(t) pcall(os.sleep, t) end
+function util.psleep(t) return pcall(os.sleep, t) end
-- no-op to provide a brief pause (1 tick) to yield
--- EVENT_CONSUMER: this function consumes events