#54 don't trip RPS fault on terminate as it ends up being redundant with shutdown sequence

This commit is contained in:
Mikayla Fischler
2022-05-19 09:19:51 -04:00
parent 62d5490dc8
commit dd553125d6
3 changed files with 19 additions and 5 deletions

View File

@ -51,8 +51,10 @@ plc.rps_init = function (reactor)
-- set reactor access fault flag -- set reactor access fault flag
local _set_fault = function () local _set_fault = function ()
if self.reactor.__p_last_fault() ~= "Terminated" then
self.state[state_keys.fault] = true self.state[state_keys.fault] = true
end end
end
-- clear reactor access fault flag -- clear reactor access fault flag
local _clear_fault = function () local _clear_fault = function ()

View File

@ -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.6" local R_PLC_VERSION = "alpha-v0.6.7"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -19,6 +19,7 @@ local _ppm_sys = {
mounts = {}, mounts = {},
auto_cf = false, auto_cf = false,
faulted = false, faulted = false,
last_fault = "",
terminate = false, terminate = false,
mute = false mute = false
} }
@ -32,6 +33,7 @@ local _ppm_sys = {
local peri_init = function (iface) local peri_init = function (iface)
local self = { local self = {
faulted = false, faulted = false,
last_fault = "",
auto_cf = true, auto_cf = true,
type = peripheral.getType(iface), type = peripheral.getType(iface),
device = peripheral.wrap(iface) device = peripheral.wrap(iface)
@ -51,7 +53,10 @@ local peri_init = function (iface)
else else
-- function failed -- function failed
self.faulted = true self.faulted = true
self.last_fault = result
_ppm_sys.faulted = true _ppm_sys.faulted = true
_ppm_sys.last_fault = result
if not _ppm_sys.mute then if not _ppm_sys.mute then
log.error("PPM: protected " .. key .. "() -> " .. result) log.error("PPM: protected " .. key .. "() -> " .. result)
@ -69,6 +74,7 @@ local peri_init = function (iface)
-- fault management functions -- fault management functions
local clear_fault = function () self.faulted = false end local clear_fault = function () self.faulted = false end
local get_last_fault = function () return self.last_fault end
local is_faulted = function () return self.faulted end local is_faulted = function () return self.faulted end
local is_ok = function () return not self.faulted end local is_ok = function () return not self.faulted end
@ -78,6 +84,7 @@ local peri_init = function (iface)
-- append to device functions -- append to device functions
self.device.__p_clear_fault = clear_fault self.device.__p_clear_fault = clear_fault
self.device.__p_last_fault = get_last_fault
self.device.__p_is_faulted = is_faulted self.device.__p_is_faulted = is_faulted
self.device.__p_is_ok = is_ok self.device.__p_is_ok = is_ok
self.device.__p_enable_afc = enable_afc self.device.__p_enable_afc = enable_afc
@ -117,14 +124,19 @@ ppm.disable_afc = function ()
_ppm_sys.auto_cf = false _ppm_sys.auto_cf = false
end end
-- clear fault flag
ppm.clear_fault = function ()
_ppm_sys.faulted = false
end
-- check fault flag -- check fault flag
ppm.is_faulted = function () ppm.is_faulted = function ()
return _ppm_sys.faulted return _ppm_sys.faulted
end end
-- clear fault flag -- get the last fault message
ppm.clear_fault = function () ppm.get_last_fault = function ()
_ppm_sys.faulted = false return _ppm_sys.last_fault
end end
-- TERMINATION -- -- TERMINATION --