fix(flows): tømning ved stop giver ikke længere 10 min ved et fuldt mål — 45 s ved målet uden at læsset falder -> silo, ellers parkering med last; Wait-pulje/læs-bytte slået fra under tømning (v1.55.1.0)

This commit is contained in:
2026-09-29 14:18:11 +02:00
parent 5cf093c3f1
commit 6af89c3034
4 changed files with 46 additions and 3 deletions
+32 -2
View File
@@ -105,6 +105,14 @@ end
-- -> "home" | "target" | "dump" | "wait" | "giveUp"
ADFlowWagons.EMPTY_MIN_LITERS = 100
ADFlowWagons.EMPTY_TIMEOUT_MS = 600000
ADFlowWagons.EMPTY_STALL_MS = 45000 -- ved målet uden at læsset falder så længe = målet er fuldt
ADFlowWagons.EMPTY_NEAR_M = 40 -- m fra aflæsningsmarkøren tæller som "ved målet"
-- s = {nearTarget, sinceChangeMs}
function ADFlowWagons.isStalled(s)
return s.nearTarget == true and (s.sinceChangeMs or 0) >= ADFlowWagons.EMPTY_STALL_MS
end
function ADFlowWagons.emptyStep(stage, s)
local cargo = s.cargo or 0
if stage == "start" then
@@ -112,6 +120,7 @@ function ADFlowWagons.emptyStep(stage, s)
return s.hasTarget and "target" or "dump"
end
if (s.elapsedMs or 0) >= ADFlowWagons.EMPTY_TIMEOUT_MS then return "giveUp" end
if s.stalled and cargo >= ADFlowWagons.EMPTY_MIN_LITERS then return stage == "target" and "dump" or "giveUp" end
if s.adActive then return "wait" end
if cargo < ADFlowWagons.EMPTY_MIN_LITERS then return "home" end
if stage == "target" then return "dump" end
@@ -363,6 +372,7 @@ local function startDump(adEnv, vehicle, state)
return
end
state.stage, state.since = "dump", nowMs
state.markerId, state.markerName, state.lastCargo = marker.id, marker.name, nil
ADFieldWork.startAd(adEnv, vehicle, adEnv.AutoDrive.MODE_DELIVERTO, marker.id, nil, fillType)
Logging.info(ADFlowWagons.LOG_PREFIX .. "'%s' aflæsser resten (%d l %s) ved %s før parkering",
tostring(ADRuns.vehicleLabel(vehicle)), math.floor(cargo), fillName(fillType), tostring(marker.name))
@@ -384,7 +394,8 @@ function ADFlowWagons.homeVehicle(adEnv, vehicle, runName)
local cargo, fillType = cargoOf(adEnv, vehicle)
local action = ADFlowWagons.emptyStep("start", {cargo = cargo, hasTarget = target ~= nil})
if action == "home" then return goHome(adEnv, vehicle) end
local state = {stage = action, since = nowMs, runName = runName}
local state = {stage = action, since = nowMs, runName = runName,
markerId = target ~= nil and target.id or nil, markerName = target ~= nil and target.name or nil}
emptying[vehicle] = state
if action == "target" then
ADFieldWork.startAd(adEnv, vehicle, adEnv.AutoDrive.MODE_DELIVERTO, target.id, nil, fillType)
@@ -412,6 +423,20 @@ function ADFlowWagons.sendHome(adEnv, run)
end
end
-- Står traktoren ved tømningens markør, uden at læsset er faldet i EMPTY_STALL_MS?
local function stalledAt(adEnv, vehicle, state, cargo)
if state.lastCargo == nil or cargo < state.lastCargo - 1 then
state.lastCargo, state.changedAt = cargo, nowMs
end
local wayPoint = state.markerId ~= nil and adEnv.ADGraphManager:getWayPointById(state.markerId) or nil
local near = false
if wayPoint ~= nil and vehicle.rootNode ~= nil then
local x, _, z = getWorldTranslation(vehicle.rootNode)
near = math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2) <= ADFlowWagons.EMPTY_NEAR_M
end
return ADFlowWagons.isStalled({nearTarget = near, sinceChangeMs = nowMs - (state.changedAt or nowMs)})
end
local function tickEmptying(adEnv)
local list = {}
for vehicle, state in pairs(emptying) do table.insert(list, {vehicle = vehicle, state = state}) end
@@ -423,8 +448,13 @@ local function tickEmptying(adEnv)
if controlled then
emptying[vehicle] = nil -- spilleren har overtaget
else
local stalled = stalledAt(adEnv, vehicle, state, cargo)
local action = ADFlowWagons.emptyStep(state.stage, {cargo = cargo, adActive = module ~= nil and module:isActive(),
elapsedMs = nowMs - state.since})
elapsedMs = nowMs - state.since, stalled = stalled})
if stalled and action ~= "wait" then
Logging.info(ADFlowWagons.LOG_PREFIX .. "'%s' kan ikke aflæsse ved %s (fuldt?) — videre", tostring(ADRuns.vehicleLabel(vehicle)),
tostring(state.markerName))
end
if action == "home" then
goHome(adEnv, vehicle)
elseif action == "dump" then