automatic reactor scram functionality for future use

This commit is contained in:
Mikayla Fischler 2022-11-11 16:15:44 -05:00
parent c221ffa129
commit af57c3b1fc
8 changed files with 48 additions and 13 deletions

View File

@ -16,7 +16,7 @@ local config = require("coordinator.config")
local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer")
local COORDINATOR_VERSION = "alpha-v0.6.6"
local COORDINATOR_VERSION = "alpha-v0.6.7"
local print = util.print
local println = util.println

View File

@ -111,6 +111,7 @@ local function init(parent, id)
-- annunciator fields
local r_scram = IndicatorLight{parent=annunciator,label="Reactor SCRAM",colors=cpair(colors.red,colors.gray)}
local r_mscrm = IndicatorLight{parent=annunciator,label="Manual Reactor SCRAM",colors=cpair(colors.red,colors.gray)}
local r_ascrm = IndicatorLight{parent=annunciator,label="Auto Reactor SCRAM",colors=cpair(colors.red,colors.gray)}
local r_rtrip = IndicatorLight{parent=annunciator,label="RCP Trip",colors=cpair(colors.red,colors.gray)}
local r_cflow = IndicatorLight{parent=annunciator,label="RCS Flow Low",colors=cpair(colors.yellow,colors.gray)}
local r_temp = IndicatorLight{parent=annunciator,label="Reactor Temp. High",colors=cpair(colors.red,colors.gray)}
@ -121,6 +122,7 @@ local function init(parent, id)
r_ps.subscribe("ReactorSCRAM", r_scram.update)
r_ps.subscribe("ManualReactorSCRAM", r_mscrm.update)
r_ps.subscribe("AutoReactorSCRAM", r_ascrm.update)
r_ps.subscribe("RCPTrip", r_rtrip.update)
r_ps.subscribe("RCSFlowLow", r_cflow.update)
r_ps.subscribe("ReactorTempHigh", r_temp.update)

View File

@ -789,10 +789,15 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
self.scrammed = false
_send_ack(packet.type, rps.activate())
elseif packet.type == RPLC_TYPES.RPS_SCRAM then
-- disable the reactor
-- disable the reactor per manual request
self.scrammed = true
rps.trip_manual()
_send_ack(packet.type, true)
elseif packet.type == RPLC_TYPES.RPS_ASCRAM then
-- disable the reactor per automatic request
self.scrammed = true
rps.trip_auto()
_send_ack(packet.type, true)
elseif packet.type == RPLC_TYPES.RPS_RESET then
-- reset the RPS status
rps.reset()

View File

@ -13,7 +13,7 @@ local config = require("reactor-plc.config")
local plc = require("reactor-plc.plc")
local threads = require("reactor-plc.threads")
local R_PLC_VERSION = "beta-v0.9.3"
local R_PLC_VERSION = "beta-v0.9.4"
local print = util.print
local println = util.println

View File

@ -9,6 +9,7 @@ local types = require("scada-common.types")
local comms = {}
local rtu_t = types.rtu_t
local insert = table.insert
---@alias PROTOCOLS integer
@ -27,10 +28,11 @@ local RPLC_TYPES = {
MEK_STRUCT = 2, -- mekanism build structure
MEK_BURN_RATE = 3, -- set burn rate
RPS_ENABLE = 4, -- enable reactor
RPS_SCRAM = 5, -- SCRAM reactor
RPS_STATUS = 6, -- RPS status
RPS_ALARM = 7, -- RPS alarm broadcast
RPS_RESET = 8 -- clear RPS trip (if in bad state, will trip immediately)
RPS_SCRAM = 5, -- SCRAM reactor (manual request)
RPS_ASCRAM = 6, -- SCRAM reactor (automatic request)
RPS_STATUS = 7, -- RPS status
RPS_ALARM = 8, -- RPS alarm broadcast
RPS_RESET = 9 -- clear RPS trip (if in bad state, will trip immediately)
}
---@alias RPLC_LINKING integer
@ -290,6 +292,7 @@ function comms.rplc_packet()
self.type == RPLC_TYPES.MEK_BURN_RATE or
self.type == RPLC_TYPES.RPS_ENABLE or
self.type == RPLC_TYPES.RPS_SCRAM or
self.type == RPLC_TYPES.RPS_ASCRAM or
self.type == RPLC_TYPES.RPS_ALARM or
self.type == RPLC_TYPES.RPS_STATUS or
self.type == RPLC_TYPES.RPS_RESET

View File

@ -24,8 +24,9 @@ local RETRY_PERIOD = 1000
local PLC_S_CMDS = {
SCRAM = 1,
ENABLE = 2,
RPS_RESET = 3
ASCRAM = 2,
ENABLE = 3,
RPS_RESET = 4
}
local PLC_S_DATA = {
@ -56,6 +57,7 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
commanded_state = false,
commanded_burn_rate = 0.0,
ramping_rate = false,
auto_scram = false,
-- connection properties
seq_num = 0,
r_seq_num = nil,
@ -368,13 +370,13 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
ack = ack
})
elseif pkt.type == RPLC_TYPES.RPS_SCRAM then
-- SCRAM acknowledgement
-- manual SCRAM acknowledgement
local ack = _get_ack(pkt)
if ack then
self.acks.scram = true
self.sDB.control_state = false
elseif ack == false then
log.debug(log_header .. "SCRAM failed!")
log.debug(log_header .. "manual SCRAM failed!")
end
-- send acknowledgement to coordinator
@ -383,6 +385,15 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
cmd = CRDN_COMMANDS.SCRAM,
ack = ack
})
elseif pkt.type == RPLC_TYPES.RPS_ASCRAM then
-- automatic SCRAM acknowledgement
local ack = _get_ack(pkt)
if ack then
self.acks.scram = true
self.sDB.control_state = false
elseif ack == false then
log.debug(log_header .. " automatic SCRAM failed!")
end
elseif pkt.type == RPLC_TYPES.RPS_STATUS then
-- RPS status packet received, copy data
if pkt.length == 12 then
@ -540,9 +551,16 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
_send(RPLC_TYPES.RPS_ENABLE, {})
elseif cmd == PLC_S_CMDS.SCRAM then
-- SCRAM reactor
self.auto_scram = false
self.acks.scram = false
self.retry_times.scram_req = util.time() + INITIAL_WAIT
_send(RPLC_TYPES.RPS_SCRAM, {})
elseif cmd == PLC_S_CMDS.ASCRAM then
-- SCRAM reactor
self.auto_scram = true
self.acks.scram = false
self.retry_times.scram_req = util.time() + INITIAL_WAIT
_send(RPLC_TYPES.RPS_ASCRAM, {})
elseif cmd == PLC_S_CMDS.RPS_RESET then
-- reset RPS
self.acks.rps_reset = false
@ -647,7 +665,12 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
if not self.acks.scram then
if rtimes.scram_req - util.time() <= 0 then
_send(RPLC_TYPES.RPS_SCRAM, {})
if self.auto_scram then
_send(RPLC_TYPES.RPS_ASCRAM, {})
else
_send(RPLC_TYPES.RPS_SCRAM, {})
end
rtimes.scram_req = util.time() + RETRY_PERIOD
end
end

View File

@ -44,6 +44,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
PLCHeartbeat = false, -- alternate true/false to blink, each time there is a keep_alive
ReactorSCRAM = false,
ManualReactorSCRAM = false,
AutoReactorSCRAM = false,
RCPTrip = false,
RCSFlowLow = false,
ReactorTempHigh = false,
@ -186,6 +187,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
-- update other annunciator fields
self.db.annunciator.ReactorSCRAM = plc_db.rps_tripped
self.db.annunciator.ManualReactorSCRAM = plc_db.rps_trip_cause == types.rps_status_t.manual
self.db.annunciator.AutoReactorSCRAM = plc_db.rps_trip_cause == types.rps_status_t.automatic
self.db.annunciator.RCPTrip = plc_db.rps_tripped and (plc_db.rps_status.ex_hcool or plc_db.rps_status.no_cool)
self.db.annunciator.RCSFlowLow = plc_db.mek_status.ccool_fill < 0.75 or plc_db.mek_status.hcool_fill > 0.25
self.db.annunciator.ReactorTempHigh = plc_db.mek_status.temp > 1000

View File

@ -13,7 +13,7 @@ local svsessions = require("supervisor.session.svsessions")
local config = require("supervisor.config")
local supervisor = require("supervisor.supervisor")
local SUPERVISOR_VERSION = "beta-v0.7.1"
local SUPERVISOR_VERSION = "beta-v0.7.2"
local print = util.print
local println = util.println