cleanup and constants
This commit is contained in:
parent
a6a1a61954
commit
dfc1ee6497
@ -75,12 +75,25 @@ constants.FLOW_STABILITY_DELAY_MS = 10000
|
|||||||
-- - background radiation 0.0000001 Sv/h (99.99 nSv/h)
|
-- - background radiation 0.0000001 Sv/h (99.99 nSv/h)
|
||||||
-- - "green tint" radiation 0.00001 Sv/h (10 uSv/h)
|
-- - "green tint" radiation 0.00001 Sv/h (10 uSv/h)
|
||||||
-- - damaging radiation 0.00006 Sv/h (60 uSv/h)
|
-- - damaging radiation 0.00006 Sv/h (60 uSv/h)
|
||||||
constants.LOW_RADIATION = 0.00001
|
constants.LOW_RADIATION = 0.00001
|
||||||
constants.HAZARD_RADIATION = 0.00006
|
constants.HAZARD_RADIATION = 0.00006
|
||||||
constants.HIGH_RADIATION = 0.001
|
constants.HIGH_RADIATION = 0.001
|
||||||
constants.VERY_HIGH_RADIATION = 0.1
|
constants.VERY_HIGH_RADIATION = 0.1
|
||||||
constants.SEVERE_RADIATION = 8.0
|
constants.SEVERE_RADIATION = 8.0
|
||||||
constants.EXTREME_RADIATION = 100.0
|
constants.EXTREME_RADIATION = 100.0
|
||||||
|
|
||||||
|
--#endregion
|
||||||
|
|
||||||
|
--#region Mekanism Configuration Constants
|
||||||
|
|
||||||
|
---@class _mek_constants
|
||||||
|
local mek = {}
|
||||||
|
|
||||||
|
mek.TURBINE_GAS_PER_TANK = 64000 -- mekanism: turbineGasPerTank
|
||||||
|
mek.TURBINE_DISPERSER_FLOW = 1280 -- mekanism: turbineDisperserGasFlow
|
||||||
|
mek.TURBINE_VENT_FLOW = 32000 -- mekanism: turbineVentGasFlow
|
||||||
|
|
||||||
|
constants.mek = mek
|
||||||
|
|
||||||
--#endregion
|
--#endregion
|
||||||
|
|
||||||
|
|||||||
@ -500,7 +500,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
self.saturated = output ~= out_c
|
self.saturated = output ~= out_c
|
||||||
|
|
||||||
-- stop idling early if the output is zero, we are at or above the setpoint, and are not losing charge
|
-- stop idling early if the output is zero, we are at or above the setpoint, and are not losing charge
|
||||||
_set_idling(not ((out_c == 0) and (error <= 0) and (avg_outflow < avg_inflow)))
|
_set_idling(not ((out_c == 0) and (error <= 0) and (avg_outflow <= 0)))
|
||||||
|
|
||||||
-- log.debug(util.sprintf("CHARGE[%f] { CHRG[%f] ERR[%f] INT[%f] => OUT[%f] OUT_C[%f] <= P[%f] I[%f] D[%f] }",
|
-- log.debug(util.sprintf("CHARGE[%f] { CHRG[%f] ERR[%f] INT[%f] => OUT[%f] OUT_C[%f] <= P[%f] I[%f] D[%f] }",
|
||||||
-- runtime, avg_charge, error, integral, output, out_c, P, I, D))
|
-- runtime, avg_charge, error, integral, output, out_c, P, I, D))
|
||||||
|
|||||||
@ -255,14 +255,13 @@ function unit.new(reactor_id, num_boilers, num_turbines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- init turbine table fields
|
-- init turbine table fields
|
||||||
for t = 1, num_turbines do
|
for _ = 1, num_turbines do
|
||||||
table.insert(self.db.annunciator.TurbineOnline, false)
|
table.insert(self.db.annunciator.TurbineOnline, false)
|
||||||
table.insert(self.db.annunciator.SteamDumpOpen, TRI_FAIL.OK)
|
table.insert(self.db.annunciator.SteamDumpOpen, TRI_FAIL.OK)
|
||||||
table.insert(self.db.annunciator.TurbineOverSpeed, false)
|
table.insert(self.db.annunciator.TurbineOverSpeed, false)
|
||||||
table.insert(self.db.annunciator.GeneratorTrip, false)
|
table.insert(self.db.annunciator.GeneratorTrip, false)
|
||||||
table.insert(self.db.annunciator.TurbineTrip, false)
|
table.insert(self.db.annunciator.TurbineTrip, false)
|
||||||
|
table.insert(self.turbine_stability_data, { time_state = 0, time_tanks = 0, rotation = 1 })
|
||||||
self.turbine_stability_data[t] = { time_state = 0, time_tanks = 0, rotation = 1 }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- PRIVATE FUNCTIONS --
|
-- PRIVATE FUNCTIONS --
|
||||||
@ -542,6 +541,13 @@ function unit.new(reactor_id, num_boilers, num_turbines)
|
|||||||
|
|
||||||
-- re-engage auto lock if it reconnected without it
|
-- re-engage auto lock if it reconnected without it
|
||||||
if self.auto_engaged and not self.plc_i.is_auto_locked() then self.plc_i.auto_lock(true) end
|
if self.auto_engaged and not self.plc_i.is_auto_locked() then self.plc_i.auto_lock(true) end
|
||||||
|
|
||||||
|
-- stop idling when completed
|
||||||
|
if self.auto_idling and ((util.time_ms() - self.auto_idle_start) > IDLE_TIME) then
|
||||||
|
log.info(util.c("UNIT ", self.r_id, ": completed idling period"))
|
||||||
|
self.auto_idling = false
|
||||||
|
self.plc_i.auto_set_burn(0, false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update deltas
|
-- update deltas
|
||||||
@ -591,9 +597,9 @@ function unit.new(reactor_id, num_boilers, num_turbines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- set automatic control idling mode to change behavior when given a burn rate command of zero<br>
|
-- set automatic control idling mode to change behavior when given a burn rate command of zero<br>
|
||||||
-- - enabling will hold the reactor at 0.01 mB/t for a period before disabling when commanded zero
|
-- - enabling it will hold the reactor at 0.01 mB/t for a period when commanded zero before disabling
|
||||||
-- - disabling will stop the reactor when commanded zero
|
-- - disabling it will stop the reactor when commanded zero
|
||||||
---@param idle boolean true to enable, false to disable and stop right away
|
---@param idle boolean true to enable, false to disable (and stop)
|
||||||
function public.auto_set_idle(idle)
|
function public.auto_set_idle(idle)
|
||||||
if not (idle and self.auto_idle) then
|
if not (idle and self.auto_idle) then
|
||||||
self.auto_idling = false
|
self.auto_idling = false
|
||||||
|
|||||||
@ -44,9 +44,9 @@ local logic = {}
|
|||||||
local function turbine_rotation(turbine)
|
local function turbine_rotation(turbine)
|
||||||
local build = turbine.build
|
local build = turbine.build
|
||||||
|
|
||||||
local inner_vol = build.steam_cap / 64000
|
local inner_vol = build.steam_cap / const.mek.TURBINE_GAS_PER_TANK
|
||||||
local disp_rate = (build.dispersers * 1280) * inner_vol
|
local disp_rate = (build.dispersers * const.mek.TURBINE_DISPERSER_FLOW) * inner_vol
|
||||||
local vent_rate = build.vents * 32000
|
local vent_rate = build.vents * const.mek.TURBINE_VENT_FLOW
|
||||||
|
|
||||||
local max_rate = math.min(disp_rate, vent_rate)
|
local max_rate = math.min(disp_rate, vent_rate)
|
||||||
local flow = math.min(max_rate, turbine.tanks.steam.amount)
|
local flow = math.min(max_rate, turbine.tanks.steam.amount)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user