debug: diagnose-log ved mål med last (AD-aflæsningstilstand, fri plads, dischargeState) (v1.11.11.0)
This commit is contained in:
@@ -236,7 +236,43 @@ local function updateWaiting(adEnv, task, wait, dt)
|
||||
Logging.info(ADUnloadWait.LOG_PREFIX .. "'%s' kører tilbage fra %s og læsser %.0f l af (målet har %.0f l fri)", tostring(vehicle:getName()), tostring(wait.waitMarker.name), rest, free)
|
||||
end
|
||||
|
||||
-- Diagnose (midlertidig): mens en traktor holder ved sit mål med last, logges hvert 15. s hvad
|
||||
-- AD ser — vognens indhold, målets fri plads, AD's aflæsningstilstand og vognens dischargeState.
|
||||
ADUnloadWait.DEBUG_INTERVAL_MS = 15000
|
||||
local debugTimers = setmetatable({}, {__mode = "k"})
|
||||
local function debugAtTarget(adEnv, task, dt)
|
||||
local vehicle = task.vehicle
|
||||
local targetReached = vehicle.ad.drivePathModule:isTargetReached()
|
||||
debugTimers[vehicle] = (debugTimers[vehicle] or ADUnloadWait.DEBUG_INTERVAL_MS) + (dt or 0)
|
||||
if debugTimers[vehicle] < ADUnloadWait.DEBUG_INTERVAL_MS then
|
||||
return
|
||||
end
|
||||
debugTimers[vehicle] = 0
|
||||
local fillType, rest = getRestLoad(adEnv, vehicle)
|
||||
if fillType == nil or rest < ADUnloadWait.MIN_REST_LITERS then
|
||||
return
|
||||
end
|
||||
local free, capacity = ADSmartPickup.getTargetFreeCapacity(adEnv, vehicle, fillType)
|
||||
local trailerModule = vehicle.ad.trailerModule
|
||||
local states = {}
|
||||
for _, unit in ipairs(adEnv.AutoDrive.getAllDischargeableUnits(vehicle) or {}) do
|
||||
local object = unit.object
|
||||
local state = object ~= nil and object.getDischargeState ~= nil and object:getDischargeState() or "?"
|
||||
local canDischarge = "?"
|
||||
if object ~= nil and object.getCanDischargeToObject ~= nil and object.getCurrentDischargeNode ~= nil then
|
||||
local ok, value = pcall(function() return object:getCanDischargeToObject(object:getCurrentDischargeNode()) end)
|
||||
canDischarge = ok and tostring(value) or "err"
|
||||
end
|
||||
table.insert(states, string.format("dischargeState=%s canDischargeToObject=%s", tostring(state), canDischarge))
|
||||
end
|
||||
local fillTypeName = g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(fillType) or tostring(fillType)
|
||||
local distance = adEnv.AutoDrive.getDistanceToUnloadPosition ~= nil and adEnv.AutoDrive.getDistanceToUnloadPosition(vehicle) or -1
|
||||
local secondMarker = vehicle.ad.stateModule.getSecondMarker ~= nil and vehicle.ad.stateModule:getSecondMarker() or nil
|
||||
Logging.info(ADUnloadWait.LOG_PREFIX .. "DEBUG '%s': targetReached=%s taskDest=%s adMål=%s; %.0f l %s på vognen; målet fri=%s/kap=%s; AD isUnloading=%s isLoading=%s afstandTilAflæsning=%.1f; venter=%s; %s", tostring(vehicle:getName()), tostring(targetReached), tostring(task.destinationID), tostring(secondMarker ~= nil and secondMarker.id or nil), rest, tostring(fillTypeName), tostring(free), tostring(capacity), tostring(trailerModule ~= nil and trailerModule.isUnloading), tostring(trailerModule ~= nil and trailerModule.isLoading), tonumber(distance) or -1, tostring(waits[vehicle] ~= nil), table.concat(states, " | "))
|
||||
end
|
||||
|
||||
function ADUnloadWait.beforeUpdate(adEnv, task, dt)
|
||||
pcall(debugAtTarget, adEnv, task, dt)
|
||||
local wait = waits[task.vehicle]
|
||||
if wait ~= nil then
|
||||
updateWaiting(adEnv, task, wait, dt)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.11.10.0</version>
|
||||
<version>1.11.11.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user