fix: stoppede flows styrer ikke deres traktorer via AD-krogene — 1.62.183

This commit is contained in:
2026-10-10 08:35:03 +02:00
parent fdfdc7af59
commit e041c47d48
6 changed files with 53 additions and 13 deletions
+14 -4
View File
@@ -8,6 +8,16 @@
-- Kun den aktuelle aflæsningsopgaves destination ændres; AutoDrives mål,
-- rotation og loop-tæller røres ikke.
-- Flowet der styrer traktoren nu (et stoppet flow styrer intet — ADRunsController.getActiveRunForVehicle)
local function activeRunOf(vehicle)
local controller = ADRunsController
if controller == nil or controller.getRunForVehicle == nil then return nil end
local run = controller.getRunForVehicle(vehicle)
if run ~= nil and run.stopped then return nil end
return run
end
ADUnloadWait = {}
-- Under dette regnes vognen som tom (AutoDrive selv bruger 0,1 l).
@@ -38,7 +48,7 @@ local function getRestLoad(adEnv, vehicle)
end
local function getWaitPoolGroup(vehicle)
local run = ADRunsController ~= nil and ADRunsController.getRunForVehicle(vehicle) or nil
local run = ADRunsController ~= nil and activeRunOf(vehicle) or nil
return run ~= nil and run.waitPoolGroup or nil
end
@@ -123,7 +133,7 @@ ADUnloadWait.MIN_FREE_FOR_OTHER_TARGET = 1000
-- Det af run'ets ANDRE mål der tager varen og har mest fri plads (≥ MIN_FREE_FOR_OTHER_TARGET) og vej.
local function findOtherTargetForRest(adEnv, vehicle, fillType, currentId)
local run = ADRunsController ~= nil and ADRunsController.getRunForVehicle ~= nil and ADRunsController.getRunForVehicle(vehicle) or nil
local run = ADRunsController ~= nil and ADRunsController.getRunForVehicle ~= nil and activeRunOf(vehicle) or nil
if run == nil or (run.kind or "supply") ~= "supply" or vehicle.ad.stateModule.setSecondMarkerByWayPointId == nil then
return nil
end
@@ -275,7 +285,7 @@ local function updateWaiting(adEnv, task, wait, dt)
wait.waitedMs = 0 -- intet lager tager resten lige nu: prøv igen efter endnu en periode
end
-- run'ets "kør hjem under X %" (fri ≥ (100-X) % af kapaciteten), ellers standardreglen
local run = ADRunsController ~= nil and ADRunsController.getRunForVehicle(vehicle) or nil
local run = ADRunsController ~= nil and activeRunOf(vehicle) or nil
local freeFraction = run ~= nil and run.returnBelowPercent ~= nil and (1 - run.returnBelowPercent / 100) or nil
if free == nil or not ADSupplyPlanner.canUnloadRest(free, rest, capacity, freeFraction) then
if ADLoadSwap ~= nil then
@@ -394,7 +404,7 @@ function ADUnloadWait.adoptOrphans(adEnv)
for _, vehicle in ipairs(ADRunsController.getFarmVehicles(adEnv)) do
local stateModule = vehicle.ad ~= nil and vehicle.ad.stateModule or nil
local isActive = stateModule ~= nil and stateModule.isActive ~= nil and stateModule:isActive()
local run = isActive and waits[vehicle] == nil and ADRunsController.getRunForVehicle(vehicle) or nil
local run = isActive and waits[vehicle] == nil and activeRunOf(vehicle) or nil
if run ~= nil and (run.kind or "supply") == "supply" and stateModule.getSecondMarker ~= nil then
local marker = stateModule:getSecondMarker()
local task = vehicle.ad.taskModule ~= nil and vehicle.ad.taskModule.getActiveTask ~= nil and vehicle.ad.taskModule:getActiveTask() or nil