.
This commit is contained in:
parent
d455e99ed0
commit
1f171b0c6e
@ -583,6 +583,7 @@ local function controlReactor()
|
|||||||
-- User requested charge - provide input flux to start charging the field
|
-- User requested charge - provide input flux to start charging the field
|
||||||
inputRate = CONFIG.emergency_field_input
|
inputRate = CONFIG.emergency_field_input
|
||||||
outputRate = 0
|
outputRate = 0
|
||||||
|
print("[DEBUG] OFFLINE+chargeRequested: inputRate=" .. inputRate)
|
||||||
else
|
else
|
||||||
-- No action needed
|
-- No action needed
|
||||||
inputRate = 0
|
inputRate = 0
|
||||||
@ -591,18 +592,19 @@ local function controlReactor()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Apply the flow rates with rate limiting
|
-- Apply the flow rates with rate limiting
|
||||||
-- Emergency/Error states bypass rate limiting for safety
|
-- Emergency/Error/Charging states bypass rate limiting for safety
|
||||||
local now = os.clock()
|
local now = os.clock()
|
||||||
local isEmergency = (state == STATES.EMERGENCY or state == STATES.ERROR)
|
local isUrgent = (state == STATES.EMERGENCY or state == STATES.ERROR or chargeRequested)
|
||||||
local ratesChanged = (inputRate ~= lastInputRate) or (outputRate ~= lastOutputRate)
|
local ratesChanged = (inputRate ~= lastInputRate) or (outputRate ~= lastOutputRate)
|
||||||
local timeSinceUpdate = now - lastFluxUpdate
|
local timeSinceUpdate = now - lastFluxUpdate
|
||||||
|
|
||||||
-- Update flux gates if: emergency, OR (rates changed AND enough time passed)
|
-- Update flux gates if: urgent, OR (rates changed AND enough time passed)
|
||||||
if isEmergency or (ratesChanged and timeSinceUpdate >= 0.5) then
|
if isUrgent or (ratesChanged and timeSinceUpdate >= 0.5) then
|
||||||
lastFluxUpdate = now
|
lastFluxUpdate = now
|
||||||
lastInputRate = inputRate
|
lastInputRate = inputRate
|
||||||
lastOutputRate = outputRate
|
lastOutputRate = outputRate
|
||||||
|
|
||||||
|
print("[DEBUG] Setting flux gates: input=" .. inputRate .. " output=" .. outputRate)
|
||||||
local inputSuccess = pcall(function()
|
local inputSuccess = pcall(function()
|
||||||
inputGate.setFlowOverride(math.floor(inputRate))
|
inputGate.setFlowOverride(math.floor(inputRate))
|
||||||
end)
|
end)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user