feat: diagnose i loggen når ingen autoload findes på traktorens enheder (v1.12.7.0)
This commit is contained in:
@@ -280,13 +280,33 @@ local function intersects(listA, listB)
|
|||||||
return false
|
return false
|
||||||
end
|
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 function hasAutoload(adEnv, vehicle)
|
||||||
local trailers = adEnv.AutoDrive.getAllUnits ~= nil and adEnv.AutoDrive.getAllUnits(vehicle) or nil
|
local trailers = adEnv.AutoDrive.getAllUnits ~= nil and adEnv.AutoDrive.getAllUnits(vehicle) or nil
|
||||||
for _, trailer in ipairs(trailers or {}) do
|
for _, trailer in ipairs(trailers or {}) do
|
||||||
if adEnv.AutoDrive.hasAL ~= nil and adEnv.AutoDrive:hasAL(trailer) then
|
if adEnv.AutoDrive.hasAL ~= nil and adEnv.AutoDrive:hasAL(trailer) then
|
||||||
|
autoloadDiagnosed[vehicle] = nil
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
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
|
return false
|
||||||
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.12.6.0</version>
|
<version>1.12.7.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
@@ -474,6 +474,10 @@ check("Cout1 første kilde-markør", ADRunsController.getSourceMarkers(adEnv, 1)
|
|||||||
|
|
||||||
-- Cout2: validering
|
-- Cout2: validering
|
||||||
local outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
local outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
||||||
|
-- diagnose: hvad moden ser på enhederne, når ingen autoload findes (logges én gang pr. traktor,
|
||||||
|
-- første gang varerne slås op — dvs. allerede ved noProducts-tjekket nedenfor)
|
||||||
|
logLines = {}
|
||||||
|
bulkTractor.trailers[1] = {spec_universalAutoload = {isAutoloadAvailable = false, autoloadDisabled = true}, getName = function() return "Vogn" end}
|
||||||
check("Cout2 ingen kilder -> noSource", ADRunsController.validateVehicle(adEnv, outRun, bulkTractor).reason, "noSource")
|
check("Cout2 ingen kilder -> noSource", ADRunsController.validateVehicle(adEnv, outRun, bulkTractor).reason, "noSource")
|
||||||
ADRunsController.store = ADRuns.toggleSource(ADRunsController.store, out.id, 1)
|
ADRunsController.store = ADRuns.toggleSource(ADRunsController.store, out.id, 1)
|
||||||
ADRunsController.store = ADRuns.toggleSource(ADRunsController.store, out.id, 3)
|
ADRunsController.store = ADRuns.toggleSource(ADRunsController.store, out.id, 3)
|
||||||
@@ -482,6 +486,14 @@ check("Cout2 ingen vare valgt -> noProducts", ADRunsController.validateVehicle(a
|
|||||||
ADRunsController.store = ADRuns.setProductPolicy(ADRunsController.store, out.id, "STRAW_BASKET", "sell")
|
ADRunsController.store = ADRuns.setProductPolicy(ADRunsController.store, out.id, "STRAW_BASKET", "sell")
|
||||||
outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
||||||
check("Cout2 kun paller uden UAL -> needsAutoload", ADRunsController.validateVehicle(adEnv, outRun, bulkTractor).reason, "needsAutoload")
|
check("Cout2 kun paller uden UAL -> needsAutoload", ADRunsController.validateVehicle(adEnv, outRun, bulkTractor).reason, "needsAutoload")
|
||||||
|
local diag = nil
|
||||||
|
for _, line in ipairs(logLines) do if line:find("ingen autoload", 1, true) then diag = line end end
|
||||||
|
check("Cout2 diagnose logges", diag ~= nil, true)
|
||||||
|
check("Cout2 diagnose viser UAL-flag", diag ~= nil and diag:find("isAutoloadAvailable=false", 1, true) ~= nil, true)
|
||||||
|
logLines = {}
|
||||||
|
ADRunsController.validateVehicle(adEnv, outRun, bulkTractor)
|
||||||
|
check("Cout2 diagnose kun én gang", #logLines, 0)
|
||||||
|
bulkTractor.trailers[1] = nil
|
||||||
check("Cout2 UAL-vogn ok", ADRunsController.validateVehicle(adEnv, outRun, ualTractor).ok, true)
|
check("Cout2 UAL-vogn ok", ADRunsController.validateVehicle(adEnv, outRun, ualTractor).ok, true)
|
||||||
ADRunsController.store = ADRuns.setProductPolicy(ADRunsController.store, out.id, "FORAGE", "store")
|
ADRunsController.store = ADRuns.setProductPolicy(ADRunsController.store, out.id, "FORAGE", "store")
|
||||||
outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
outRun = ADRuns.getRun(ADRunsController.store, out.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user