@@ -40,8 +40,9 @@ function facility.new(num_reactors, cooling_conf)
|
||||
units = {},
|
||||
induction = {},
|
||||
redstone = {},
|
||||
status_text = { "IDLE", "control inactive" },
|
||||
status_text = { "START UP", "initializing..." },
|
||||
-- process control
|
||||
units_ready = false,
|
||||
mode = PROCESS.INACTIVE,
|
||||
last_mode = PROCESS.INACTIVE,
|
||||
mode_set = PROCESS.SIMPLE,
|
||||
@@ -234,7 +235,10 @@ function facility.new(num_reactors, cooling_conf)
|
||||
log.debug(util.c("FAC: starting auto control: chg_conv = ", self.charge_conversion, ", blade_count = ", blade_count, ", max_burn = ", self.max_burn_combined))
|
||||
elseif self.mode == PROCESS.INACTIVE then
|
||||
for i = 1, #self.prio_defs do
|
||||
-- SCRAM reactors and disengage auto control
|
||||
-- use manual SCRAM since inactive was requested, and automatic SCRAM trips an alarm
|
||||
for _, u in pairs(self.prio_defs[i]) do
|
||||
u.scram()
|
||||
u.a_disengage()
|
||||
end
|
||||
end
|
||||
@@ -249,7 +253,21 @@ function facility.new(num_reactors, cooling_conf)
|
||||
self.initial_ramp = false
|
||||
end
|
||||
|
||||
if self.mode == PROCESS.SIMPLE then
|
||||
if self.mode == PROCESS.INACTIVE then
|
||||
-- check if we are ready to start when that time comes
|
||||
self.units_ready = true
|
||||
for i = 1, #self.prio_defs do
|
||||
for _, u in pairs(self.prio_defs[i]) do
|
||||
self.units_ready = self.units_ready and u.get_control_inf().ready
|
||||
end
|
||||
end
|
||||
|
||||
if self.units_ready then
|
||||
self.status_text = { "IDLE", "control disengaged" }
|
||||
else
|
||||
self.status_text = { "NOT READY", "assigned units not ready" }
|
||||
end
|
||||
elseif self.mode == PROCESS.SIMPLE then
|
||||
-- run units at their last configured set point
|
||||
if state_changed then
|
||||
self.time_start = now
|
||||
@@ -504,6 +522,8 @@ function facility.new(num_reactors, cooling_conf)
|
||||
ready = false
|
||||
end
|
||||
|
||||
ready = ready and self.units_ready
|
||||
|
||||
if ready then self.mode = self.mode_set end
|
||||
end
|
||||
|
||||
@@ -550,6 +570,7 @@ function facility.new(num_reactors, cooling_conf)
|
||||
-- get automatic process control status
|
||||
function public.get_control_status()
|
||||
return {
|
||||
self.units_ready,
|
||||
self.mode,
|
||||
self.waiting_on_ramp,
|
||||
self.ascram,
|
||||
|
||||
@@ -448,6 +448,7 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
|
||||
|
||||
self.acks.burn_rate = ack ~= PLC_AUTO_ACK.FAIL
|
||||
|
||||
---@todo implement error handling here
|
||||
if ack == PLC_AUTO_ACK.FAIL then
|
||||
elseif ack == PLC_AUTO_ACK.DIRECT_SET_OK then
|
||||
elseif ack == PLC_AUTO_ACK.RAMP_SET_OK then
|
||||
|
||||
@@ -174,6 +174,8 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
-- fields for facility control
|
||||
---@class unit_control
|
||||
control = {
|
||||
ready = false,
|
||||
degraded = false,
|
||||
blade_count = 0,
|
||||
br10 = 0,
|
||||
lim_br10 = 0
|
||||
@@ -398,7 +400,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
if self.plc_i ~= nil then
|
||||
self.plc_i.auto_set_burn(self.db.control.br10 / 10, ramp)
|
||||
|
||||
if ramp then self.ramp_target_br10 = self.db.control.br10 / 10 end
|
||||
if ramp then self.ramp_target_br10 = self.db.control.br10 end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -407,8 +409,9 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
---@return boolean complete
|
||||
function public.a_ramp_complete()
|
||||
if self.plc_i ~= nil then
|
||||
return (math.floor(self.plc_i.get_db().mek_status.burn_rate * 10) == self.ramp_target_br10) or (self.ramp_target_br10 == 0)
|
||||
else return false end
|
||||
local cur_rate = math.floor(self.plc_i.get_db().mek_status.burn_rate * 10)
|
||||
return (cur_rate == self.ramp_target_br10) or (self.ramp_target_br10 == 0)
|
||||
else return true end
|
||||
end
|
||||
|
||||
-- perform an automatic SCRAM
|
||||
@@ -428,6 +431,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
if self.plc_s ~= nil and not self.plc_s.open then
|
||||
self.plc_s = nil
|
||||
self.plc_i = nil
|
||||
self.db.control.br10 = 0
|
||||
self.db.control.lim_br10 = 0
|
||||
end
|
||||
|
||||
@@ -436,6 +440,9 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
_unlink_disconnected_units(self.turbines)
|
||||
_unlink_disconnected_units(self.redstone)
|
||||
|
||||
-- update degraded state for auto control
|
||||
self.db.control.degraded = (#self.boilers ~= num_boilers) or (#self.turbines ~= num_turbines) or (self.plc_i == nil)
|
||||
|
||||
-- update deltas
|
||||
_dt__compute_all()
|
||||
|
||||
@@ -606,9 +613,9 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
-- get information required for automatic reactor control
|
||||
function public.get_control_inf() return self.db.control end
|
||||
|
||||
-- get unit state (currently only waste mode)
|
||||
-- get unit state
|
||||
function public.get_state()
|
||||
return { self.status_text[1], self.status_text[2], self.waste_mode }
|
||||
return { self.status_text[1], self.status_text[2], self.waste_mode, self.db.control.ready, self.db.control.degraded }
|
||||
end
|
||||
|
||||
-- get the reactor ID
|
||||
|
||||
@@ -38,9 +38,17 @@ function logic.update_annunciator(self)
|
||||
-- check PLC status
|
||||
self.db.annunciator.PLCOnline = self.plc_i ~= nil
|
||||
|
||||
local plc_ready = self.db.annunciator.PLCOnline
|
||||
|
||||
if self.db.annunciator.PLCOnline then
|
||||
local plc_db = self.plc_i.get_db()
|
||||
|
||||
-- update ready state
|
||||
-- - can't be tripped
|
||||
-- - must have received status at least once
|
||||
-- - must have received struct at least once
|
||||
plc_ready = (not plc_db.rps_tripped) and (plc_db.last_status_update > 0) and (plc_db.mek_struct.length > 0)
|
||||
|
||||
-- update auto control limit
|
||||
if (self.db.control.lim_br10 == 0) or ((self.db.control.lim_br10 / 10) > plc_db.mek_struct.max_burn) then
|
||||
self.db.control.lim_br10 = math.floor(plc_db.mek_struct.max_burn * 10)
|
||||
@@ -106,6 +114,8 @@ function logic.update_annunciator(self)
|
||||
-- BOILERS --
|
||||
-------------
|
||||
|
||||
local boilers_ready = num_boilers == #self.boilers
|
||||
|
||||
-- clear boiler online flags
|
||||
for i = 1, num_boilers do self.db.annunciator.BoilerOnline[i] = false end
|
||||
|
||||
@@ -119,6 +129,14 @@ function logic.update_annunciator(self)
|
||||
local session = self.boilers[i] ---@type unit_session
|
||||
local boiler = session.get_db() ---@type boilerv_session_db
|
||||
|
||||
-- update ready state
|
||||
-- - must be formed
|
||||
-- - must have received build, state, and tanks at least once
|
||||
boilers_ready = boilers_ready and boiler.formed and
|
||||
(boiler.build.last_update > 0) and
|
||||
(boiler.state.last_update > 0) and
|
||||
(boiler.tanks.last_update > 0)
|
||||
|
||||
total_boil_rate = total_boil_rate + boiler.state.boil_rate
|
||||
boiler_steam_dt_sum = _get_dt(DT_KEYS.BoilerSteam .. self.boilers[i].get_device_idx())
|
||||
boiler_water_dt_sum = _get_dt(DT_KEYS.BoilerWater .. self.boilers[i].get_device_idx())
|
||||
@@ -185,6 +203,8 @@ function logic.update_annunciator(self)
|
||||
-- TURBINES --
|
||||
--------------
|
||||
|
||||
local turbines_ready = num_turbines == #self.turbines
|
||||
|
||||
-- clear turbine online flags
|
||||
for i = 1, num_turbines do self.db.annunciator.TurbineOnline[i] = false end
|
||||
|
||||
@@ -201,6 +221,14 @@ function logic.update_annunciator(self)
|
||||
local session = self.turbines[i] ---@type unit_session
|
||||
local turbine = session.get_db() ---@type turbinev_session_db
|
||||
|
||||
-- update ready state
|
||||
-- - must be formed
|
||||
-- - must have received build, state, and tanks at least once
|
||||
turbines_ready = turbines_ready and turbine.formed and
|
||||
(turbine.build.last_update > 0) and
|
||||
(turbine.state.last_update > 0) and
|
||||
(turbine.tanks.last_update > 0)
|
||||
|
||||
total_flow_rate = total_flow_rate + turbine.state.flow_rate
|
||||
total_input_rate = total_input_rate + turbine.state.steam_input_rate
|
||||
max_water_return_rate = max_water_return_rate + turbine.build.max_water_output
|
||||
@@ -257,6 +285,9 @@ function logic.update_annunciator(self)
|
||||
local has_steam = db.state.steam_input_rate > 0 or db.tanks.steam_fill > 0.01
|
||||
self.db.annunciator.TurbineTrip[turbine.get_device_idx()] = has_steam and db.state.flow_rate == 0
|
||||
end
|
||||
|
||||
-- update auto control ready state for this unit
|
||||
self.db.control.ready = plc_ready and boilers_ready and turbines_ready
|
||||
end
|
||||
|
||||
-- update an alarm state given conditions
|
||||
|
||||
@@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
||||
local config = require("supervisor.config")
|
||||
local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local SUPERVISOR_VERSION = "beta-v0.9.8"
|
||||
local SUPERVISOR_VERSION = "beta-v0.9.9"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
||||
Reference in New Issue
Block a user