fix(udsendelse): fælles udsendelsesport for Start alle, markarbejde, marksiloer og flow-genstart; én indstilling under Indstillinger (v1.62.237)

This commit is contained in:
2026-10-16 02:01:12 +02:00
parent 7f063cbb06
commit fbc0b448f5
13 changed files with 97 additions and 69 deletions
+12 -2
View File
@@ -29,6 +29,8 @@ ADFieldSilos.lastPlan = nil
local loans = setmetatable({}, {__mode = "k"}) -- vehicle -> {siloId, siloName, fillType, liters, startedMs, lastProgressMs, lastFill}
local paused = {} -- key -> untilMs
local planTimerMs, checkTimerMs, nowMs = ADFieldSilos.PLAN_INTERVAL_MS, 0, 0
-- en udsendelse ventede på den fælles port: planlæg igen, så snart den åbner (ikke først om et minut)
local gateBlocked = false
-- ---- ren frigivelsesregel ----
@@ -651,6 +653,11 @@ function ADFieldSilos.planNow(adEnv)
for _, silo in ipairs(silos) do silosById[silo.id] = silo end
for _, store in ipairs(stores) do storesById[store.id] = store end
for _, order in ipairs(plan.dispatch) do
-- fælles udsendelsesport: én maskine ad gangen; resten planlægges igen om lidt
if ADLaunchGate ~= nil and not ADLaunchGate.isOpen() then
gateBlocked = true
break
end
local vehicle = vehiclesById[order.vehicleId]
if vehicle ~= nil and not hasRoutes(adEnv, vehicle, order) then
vehicle = nil
@@ -658,12 +665,14 @@ function ADFieldSilos.planNow(adEnv)
local pair = poolById ~= nil and poolById[order.vehicleId] or nil
if vehicle ~= nil and pair ~= nil then
local ok, err = pcall(dispatchPool, adEnv, order, pair, silosById, storesById)
if ok and ADLaunchGate ~= nil then ADLaunchGate.markLaunched() end
if not ok then
loans[vehicle] = nil
Logging.warning(ADFieldSilos.LOG_PREFIX .. "kunne ikke sende '%s' efter puljevogn: %s", tostring(ADRuns.vehicleLabel(vehicle)), tostring(err))
end
elseif vehicle ~= nil then
local ok, err = pcall(dispatchOne, adEnv, order, vehicle, silosById, storesById)
if ok and ADLaunchGate ~= nil then ADLaunchGate.markLaunched() end
if not ok then
loans[vehicle] = nil
Logging.warning(ADFieldSilos.LOG_PREFIX .. "kunne ikke sende '%s': %s", tostring(ADRuns.vehicleLabel(vehicle)), tostring(err))
@@ -683,8 +692,9 @@ function ADFieldSilos.tick(adEnv, dt)
checkLoans(adEnv)
end
planTimerMs = planTimerMs + (dt or 0)
if planTimerMs >= ADFieldSilos.PLAN_INTERVAL_MS then
planTimerMs = 0
local gateReady = gateBlocked and ADLaunchGate ~= nil and ADLaunchGate.isOpen()
if planTimerMs >= ADFieldSilos.PLAN_INTERVAL_MS or gateReady then
planTimerMs, gateBlocked = 0, false
ADFieldSilos.planNow(adEnv)
end
end