feat: diagnose i loggen når ingen autoload findes på traktorens enheder (v1.12.7.0)

This commit is contained in:
2026-09-23 11:44:45 +02:00
parent e09daadf93
commit 058795d4c3
3 changed files with 33 additions and 1 deletions
+20
View File
@@ -280,13 +280,33 @@ local function intersects(listA, listB)
return false
end
-- Autoload = AutoDrives eget tjek (Universal Autoload med isAutoloadAvailable og ikke autoloadDisabled,
-- eller aPalletAutoLoader). Findes ingen, logges én gang pr. traktor hvad enhederne har, så det kan
-- ses i log.txt hvorfor (fx UAL uden konfiguration for køretøjet).
local autoloadDiagnosed = setmetatable({}, {__mode = "k"})
local function describeAutoloadUnit(unit)
local name = unit.getName ~= nil and tostring(unit:getName()) or "?"
local spec = unit.spec_universalAutoload
if spec == nil then
return string.format("%s (ingen spec_universalAutoload%s)", name, unit.spec_aPalletAutoLoader ~= nil and ", aPalletAutoLoader" or "")
end
return string.format("%s (isAutoloadAvailable=%s, autoloadDisabled=%s)", name, tostring(spec.isAutoloadAvailable), tostring(spec.autoloadDisabled))
end
local function hasAutoload(adEnv, vehicle)
local trailers = adEnv.AutoDrive.getAllUnits ~= nil and adEnv.AutoDrive.getAllUnits(vehicle) or nil
for _, trailer in ipairs(trailers or {}) do
if adEnv.AutoDrive.hasAL ~= nil and adEnv.AutoDrive:hasAL(trailer) then
autoloadDiagnosed[vehicle] = nil
return true
end
end
if not autoloadDiagnosed[vehicle] then
autoloadDiagnosed[vehicle] = true
local parts = {}
for _, unit in ipairs(trailers or {}) do table.insert(parts, describeAutoloadUnit(unit)) end
Logging.info(ADRunsController.LOG_PREFIX .. "'%s': ingen autoload fundet på enhederne: %s", tostring(vehicle:getName()), #parts > 0 and table.concat(parts, "; ") or "(ingen enheder)")
end
return false
end