This commit is contained in:
Navid Sassan 2025-12-09 22:38:34 +01:00
parent d455e99ed0
commit 1f171b0c6e

View File

@ -583,6 +583,7 @@ local function controlReactor()
-- User requested charge - provide input flux to start charging the field
inputRate = CONFIG.emergency_field_input
outputRate = 0
print("[DEBUG] OFFLINE+chargeRequested: inputRate=" .. inputRate)
else
-- No action needed
inputRate = 0
@ -591,18 +592,19 @@ local function controlReactor()
end
-- 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 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 timeSinceUpdate = now - lastFluxUpdate
-- Update flux gates if: emergency, OR (rates changed AND enough time passed)
if isEmergency or (ratesChanged and timeSinceUpdate >= 0.5) then
-- Update flux gates if: urgent, OR (rates changed AND enough time passed)
if isUrgent or (ratesChanged and timeSinceUpdate >= 0.5) then
lastFluxUpdate = now
lastInputRate = inputRate
lastOutputRate = outputRate
print("[DEBUG] Setting flux gates: input=" .. inputRate .. " output=" .. outputRate)
local inputSuccess = pcall(function()
inputGate.setFlowOverride(math.floor(inputRate))
end)