chore(diag): log hvorfor aktive AutoDrive-køretøjer står stille >20 s (opgave, forhindring, AD-trafik + blokerer, pause, Smart Pickup-hold) — flows kører ikke efter genstart (v1.35.2.0)
This commit is contained in:
@@ -1248,6 +1248,7 @@ function ADSmartPickup:update(dt)
|
|||||||
Logging.warning(ADSmartPickup.LOG_PREFIX .. "markarbejde fejlede: %s", tostring(errFields))
|
Logging.warning(ADSmartPickup.LOG_PREFIX .. "markarbejde fejlede: %s", tostring(errFields))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ADStuckDiag ~= nil then pcall(ADStuckDiag.tick, dt) end
|
||||||
local ok, err = pcall(restoreStoppedVehicles)
|
local ok, err = pcall(restoreStoppedVehicles)
|
||||||
if not ok then
|
if not ok then
|
||||||
Logging.warning(ADSmartPickup.LOG_PREFIX .. "kunne ikke gendanne varevalg: %s", tostring(err))
|
Logging.warning(ADSmartPickup.LOG_PREFIX .. "kunne ikke gendanne varevalg: %s", tostring(err))
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
-- AD Stuck Diag
|
||||||
|
-- Diagnose: et aktivt AutoDrive-køretøj der har holdt stille længe, logges med AutoDrives egen grund
|
||||||
|
-- (forhindring, AD-trafik på ruten + hvem, pause, mål nået) og om Smart Pickup holder det (Wait/udkørsel).
|
||||||
|
-- Kun læsning — ændrer intet. Logges én gang pr. ændret tilstand.
|
||||||
|
|
||||||
|
ADStuckDiag = {}
|
||||||
|
|
||||||
|
ADStuckDiag.CHECK_INTERVAL_MS = 10000
|
||||||
|
ADStuckDiag.STILL_MS = 20000
|
||||||
|
ADStuckDiag.STILL_SPEED = 0.00028 -- samme grænse som AD's egen stoppedTimer (m/ms)
|
||||||
|
|
||||||
|
local stillMs = setmetatable({}, {__mode = "k"})
|
||||||
|
local lastText = setmetatable({}, {__mode = "k"})
|
||||||
|
local timerMs = 0
|
||||||
|
|
||||||
|
local function name(vehicle)
|
||||||
|
if vehicle == nil then return "-" end
|
||||||
|
local ok, text = pcall(vehicle.getName, vehicle)
|
||||||
|
return ok and tostring(text) or "?"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function taskName(vehicle)
|
||||||
|
local taskModule = vehicle.ad.taskModule
|
||||||
|
local task = taskModule ~= nil and taskModule.activeTask or nil
|
||||||
|
if task == nil then return "ingen" end
|
||||||
|
return tostring(task.taskType or "ukendt")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Tekst der beskriver hvorfor køretøjet står (nil hvis ukendt/ikke relevant).
|
||||||
|
function ADStuckDiag.describe(vehicle)
|
||||||
|
local ad = vehicle.ad
|
||||||
|
local cdm, dpm, sdm = ad.collisionDetectionModule, ad.drivePathModule, ad.specialDrivingModule
|
||||||
|
local wayPoints, current = nil, nil
|
||||||
|
if dpm ~= nil and dpm.getWayPoints ~= nil then wayPoints, current = dpm:getWayPoints() end
|
||||||
|
local parts = {
|
||||||
|
string.format("opgave=%s", taskName(vehicle)),
|
||||||
|
string.format("mål=%s", tostring(ad.stateModule.getFirstMarkerId ~= nil and ad.stateModule:getFirstMarkerId() or "?")),
|
||||||
|
string.format("wp=%s/%s", tostring(current), tostring(wayPoints ~= nil and #wayPoints or nil)),
|
||||||
|
string.format("pause=%s", tostring(dpm ~= nil and dpm.isPaused)),
|
||||||
|
string.format("målNået=%s", tostring(dpm ~= nil and dpm.isTargetReached ~= nil and dpm:isTargetReached())),
|
||||||
|
string.format("forhindring=%s", tostring(cdm ~= nil and cdm.detectedObstable)),
|
||||||
|
string.format("trafik=%s", cdm ~= nil and cdm.trafficVehicle ~= nil and name(cdm.trafficVehicle) or "-"),
|
||||||
|
string.format("stopper=%s blokeret=%s", tostring(sdm ~= nil and sdm.isStoppingVehicle ~= nil and sdm:isStoppingVehicle()),
|
||||||
|
tostring(sdm ~= nil and sdm.isBlocked)),
|
||||||
|
}
|
||||||
|
local wait = ADUnloadWait ~= nil and ADUnloadWait.getWaitFor ~= nil and ADUnloadWait.getWaitFor(vehicle) or nil
|
||||||
|
local hold = ADOutbound ~= nil and ADOutbound.getHoldFor ~= nil and ADOutbound.getHoldFor(vehicle) or nil
|
||||||
|
local pickup = ADSmartPickup ~= nil and ADSmartPickup.getActivePickup ~= nil and ADSmartPickup.getActivePickup(vehicle) or nil
|
||||||
|
table.insert(parts, string.format("SP: wait=%s hold=%s pickup=%s",
|
||||||
|
wait ~= nil and tostring(wait.markerId or wait.wayPointId or "ja") or "-",
|
||||||
|
hold ~= nil and tostring(hold.markerId or "ja") or "-",
|
||||||
|
pickup ~= nil and tostring(pickup.wayPointId or pickup.markerId or "ja") or "-"))
|
||||||
|
return table.concat(parts, " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
function ADStuckDiag.tick(dt)
|
||||||
|
timerMs = timerMs + (dt or 0)
|
||||||
|
if timerMs < ADStuckDiag.CHECK_INTERVAL_MS then return end
|
||||||
|
local elapsed = timerMs
|
||||||
|
timerMs = 0
|
||||||
|
local vehicles = g_currentMission ~= nil and g_currentMission.vehicleSystem ~= nil and g_currentMission.vehicleSystem.vehicles or {}
|
||||||
|
for _, vehicle in pairs(vehicles) do
|
||||||
|
local ad = vehicle.ad
|
||||||
|
local active = ad ~= nil and ad.stateModule ~= nil and ad.stateModule:isActive()
|
||||||
|
if active and (vehicle.lastSpeedReal or 0) < ADStuckDiag.STILL_SPEED then
|
||||||
|
stillMs[vehicle] = (stillMs[vehicle] or 0) + elapsed
|
||||||
|
else
|
||||||
|
stillMs[vehicle], lastText[vehicle] = nil, nil
|
||||||
|
end
|
||||||
|
if (stillMs[vehicle] or 0) >= ADStuckDiag.STILL_MS then
|
||||||
|
local ok, text = pcall(ADStuckDiag.describe, vehicle)
|
||||||
|
text = ok and text or ("diagnose fejlede: " .. tostring(text))
|
||||||
|
if text ~= lastText[vehicle] then
|
||||||
|
lastText[vehicle] = text
|
||||||
|
Logging.info("ADSmartPickup: STÅR STILLE %d s '%s': %s", math.floor(stillMs[vehicle] / 1000), name(vehicle), text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<modDesc descVersion="107">
|
<modDesc descVersion="107">
|
||||||
<author>masterdraco</author>
|
<author>masterdraco</author>
|
||||||
<version>1.35.1.0</version>
|
<version>1.35.2.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<l10n filenamePrefix="l10n/l10n"/>
|
<l10n filenamePrefix="l10n/l10n"/>
|
||||||
<extraSourceFiles>
|
<extraSourceFiles>
|
||||||
<sourceFile filename="adCache.lua"/>
|
<sourceFile filename="adCache.lua"/>
|
||||||
|
<sourceFile filename="adStuckDiag.lua"/>
|
||||||
<sourceFile filename="adSupplyPlanner.lua"/>
|
<sourceFile filename="adSupplyPlanner.lua"/>
|
||||||
<sourceFile filename="adRuns.lua"/>
|
<sourceFile filename="adRuns.lua"/>
|
||||||
<sourceFile filename="adRunsStorage.lua"/>
|
<sourceFile filename="adRunsStorage.lua"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user