#87 check if the reactor is active on startup/reconnect before scram'ing, rps now ignores scram errors if the error is due to the reactor being inactive

This commit is contained in:
Mikayla Fischler 2022-09-29 11:02:03 -04:00
parent 4f7775ccb6
commit 7a90ea7e4e
2 changed files with 8 additions and 4 deletions

View File

@ -18,6 +18,10 @@ local println = util.println
local print_ts = util.print_ts local print_ts = util.print_ts
local println_ts = util.println_ts local println_ts = util.println_ts
-- I sure hope the devs don't change this error message, not that it would have safety implications
-- I wish they didn't change it to error on SCRAM calls if the reactor was already inactive
local PCALL_SCRAM_MSG = "pcall: Scram requires the reactor to be active."
--- RPS: Reactor Protection System --- RPS: Reactor Protection System
--- ---
--- identifies dangerous states and SCRAMs reactor if warranted --- identifies dangerous states and SCRAMs reactor if warranted
@ -169,7 +173,7 @@ function plc.rps_init(reactor)
log.info("RPS: reactor SCRAM") log.info("RPS: reactor SCRAM")
self.reactor.scram() self.reactor.scram()
if self.reactor.__p_is_faulted() then if self.reactor.__p_is_faulted() and (self.reactor.__p_last_fault() ~= PCALL_SCRAM_MSG) then
log.error("RPS: failed reactor SCRAM") log.error("RPS: failed reactor SCRAM")
return false return false
else else

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 = "beta-v0.8.5" local R_PLC_VERSION = "beta-v0.8.6"
local print = util.print local print = util.print
local println = util.println local println = util.println
@ -114,7 +114,7 @@ if __shared_memory.networked and smem_dev.modem == nil then
println("boot> wireless modem not found") println("boot> wireless modem not found")
log.warning("no wireless modem on startup") log.warning("no wireless modem on startup")
if smem_dev.reactor ~= nil then if smem_dev.reactor ~= nil and smem_dev.reactor.getStatus() then
smem_dev.reactor.scram() smem_dev.reactor.scram()
end end
@ -127,7 +127,7 @@ end
local function init() local function init()
if plc_state.init_ok then if plc_state.init_ok then
-- just booting up, no fission allowed (neutrons stay put thanks) -- just booting up, no fission allowed (neutrons stay put thanks)
smem_dev.reactor.scram() if smem_dev.reactor.getStatus() then smem_dev.reactor.scram() end
-- init reactor protection system -- init reactor protection system
smem_sys.rps = plc.rps_init(smem_dev.reactor) smem_sys.rps = plc.rps_init(smem_dev.reactor)