#48 only log every 20 PPM faults (per function)
This commit is contained in:
@@ -13,7 +13,7 @@ local config = require("reactor-plc.config")
|
|||||||
local plc = require("reactor-plc.plc")
|
local plc = require("reactor-plc.plc")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "alpha-v0.6.8"
|
local R_PLC_VERSION = "alpha-v0.6.9"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
|||||||
local turbine_rtu = require("rtu.dev.turbine_rtu")
|
local turbine_rtu = require("rtu.dev.turbine_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "alpha-v0.6.7"
|
local RTU_VERSION = "alpha-v0.6.8"
|
||||||
|
|
||||||
local rtu_t = types.rtu_t
|
local rtu_t = types.rtu_t
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ ppm.ACCESS_FAULT = ACCESS_FAULT
|
|||||||
-- PRIVATE DATA/FUNCTIONS --
|
-- PRIVATE DATA/FUNCTIONS --
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
local REPORT_FREQUENCY = 20 -- log every 20 faults per function
|
||||||
|
|
||||||
local _ppm_sys = {
|
local _ppm_sys = {
|
||||||
mounts = {},
|
mounts = {},
|
||||||
auto_cf = false,
|
auto_cf = false,
|
||||||
@@ -34,6 +36,7 @@ local peri_init = function (iface)
|
|||||||
local self = {
|
local self = {
|
||||||
faulted = false,
|
faulted = false,
|
||||||
last_fault = "",
|
last_fault = "",
|
||||||
|
fault_counts = {},
|
||||||
auto_cf = true,
|
auto_cf = true,
|
||||||
type = peripheral.getType(iface),
|
type = peripheral.getType(iface),
|
||||||
device = peripheral.wrap(iface)
|
device = peripheral.wrap(iface)
|
||||||
@@ -42,6 +45,7 @@ local peri_init = function (iface)
|
|||||||
-- initialization process (re-map)
|
-- initialization process (re-map)
|
||||||
|
|
||||||
for key, func in pairs(self.device) do
|
for key, func in pairs(self.device) do
|
||||||
|
self.fault_counts[key] = 0
|
||||||
self.device[key] = function (...)
|
self.device[key] = function (...)
|
||||||
local status, result = pcall(func, ...)
|
local status, result = pcall(func, ...)
|
||||||
|
|
||||||
@@ -49,6 +53,9 @@ local peri_init = function (iface)
|
|||||||
-- auto fault clear
|
-- auto fault clear
|
||||||
if self.auto_cf then self.faulted = false end
|
if self.auto_cf then self.faulted = false end
|
||||||
if _ppm_sys.auto_cf then _ppm_sys.faulted = false end
|
if _ppm_sys.auto_cf then _ppm_sys.faulted = false end
|
||||||
|
|
||||||
|
self.fault_counts[key] = 0
|
||||||
|
|
||||||
return result
|
return result
|
||||||
else
|
else
|
||||||
-- function failed
|
-- function failed
|
||||||
@@ -58,10 +65,17 @@ local peri_init = function (iface)
|
|||||||
_ppm_sys.faulted = true
|
_ppm_sys.faulted = true
|
||||||
_ppm_sys.last_fault = result
|
_ppm_sys.last_fault = result
|
||||||
|
|
||||||
if not _ppm_sys.mute then
|
if not _ppm_sys.mute and (self.fault_counts[key] % REPORT_FREQUENCY == 0) then
|
||||||
log.error("PPM: protected " .. key .. "() -> " .. result)
|
local count_str = ""
|
||||||
|
if self.fault_counts[key] > 0 then
|
||||||
|
count_str = " [" .. self.fault_counts[key] .. " total faults]"
|
||||||
|
end
|
||||||
|
|
||||||
|
log.error("PPM: protected " .. key .. "() -> " .. result .. count_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.fault_counts[key] = self.fault_counts[key] + 1
|
||||||
|
|
||||||
if result == "Terminated" then
|
if result == "Terminated" then
|
||||||
_ppm_sys.terminate = true
|
_ppm_sys.terminate = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local svsessions = require("supervisor.session.svsessions")
|
|||||||
local config = require("supervisor.config")
|
local config = require("supervisor.config")
|
||||||
local supervisor = require("supervisor.supervisor")
|
local supervisor = require("supervisor.supervisor")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "alpha-v0.3.9"
|
local SUPERVISOR_VERSION = "alpha-v0.3.10"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
Reference in New Issue
Block a user