feat: frontklipper alene og front+bag som ét sæt; puljen henter/parkerer frontredskaber (v1.62.74)
This commit is contained in:
@@ -547,21 +547,36 @@ function ADFieldWork.dispatchPool(adEnv, field, info, role, roleAccept, decision
|
||||
return false, why, args
|
||||
end
|
||||
local tractor, implement = pair.tractor, pair.implement
|
||||
-- kombi (front + bag slåmaskine, in-game 8/10): begge hentes, bag først — ét sæt, der altid følges ad
|
||||
local fetchList, names, ids, connectIds = {}, {}, {}, {}
|
||||
for _, item in ipairs(pair.implements or {implement}) do
|
||||
table.insert(fetchList, {id = item.id, name = item.name, connectId = item.connectId})
|
||||
table.insert(names, tostring(item.name))
|
||||
table.insert(ids, item.id)
|
||||
table.insert(connectIds, item.connectId)
|
||||
end
|
||||
table.insert(ids, tractor.id)
|
||||
local implementName = table.concat(names, " + ")
|
||||
local assignment = {
|
||||
vehicleId = tractor.id, vehicle = tractor.vehicle, fieldId = field.id, role = role, stage = field.stage,
|
||||
helper = decision ~= nil and decision.helper == true, phase = "fetching", since = now(), width = implement.width,
|
||||
groupSize = 1, leader = true, fillType = decision ~= nil and decision.helper and info.harvestFillType or nil,
|
||||
startX = tractor.x, startZ = tractor.z,
|
||||
pool = {implementId = implement.id, implementName = implement.name, connectId = implement.connectId},
|
||||
pool = {implementId = implement.id, implementName = implementName, connectId = implement.connectId, implements = fetchList},
|
||||
hitch = {done = false},
|
||||
}
|
||||
ADFieldJobs.state.assignments[tractor.id] = assignment
|
||||
ADPool.reserve(assignment, {implement.id, tractor.id})
|
||||
ADHitch.fetch(adEnv, tractor.vehicle, implement.connectId, function(_, ok, detail)
|
||||
assignment.hitch = {done = true, ok = ok, detail = detail}
|
||||
end)
|
||||
note(field.id, {reason = {key = "spu_field_reason_fetching", name = implement.name}})
|
||||
log(field.id, "%s: '%s' henter '%s' (%s)", role, tractor.name, implement.name, "pulje")
|
||||
ADPool.reserve(assignment, ids)
|
||||
local function onFetched(_, ok, detail, failedIndex)
|
||||
assignment.hitch = {done = true, ok = ok, detail = detail, failedIndex = failedIndex}
|
||||
end
|
||||
if #connectIds > 1 then
|
||||
ADHitch.route(adEnv, tractor.vehicle, connectIds, onFetched)
|
||||
else
|
||||
ADHitch.fetch(adEnv, tractor.vehicle, implement.connectId, onFetched)
|
||||
end
|
||||
note(field.id, {reason = {key = "spu_field_reason_fetching", name = implementName}})
|
||||
log(field.id, "%s: '%s' henter '%s' (%s)", role, tractor.name, implementName, "pulje")
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1565,15 +1580,20 @@ function ADFieldWork.follow(adEnv, assignment)
|
||||
return
|
||||
end
|
||||
if not hitch.ok then
|
||||
-- koblingen fejlede: den skyldige i karantæne (kom traktoren ikke frem, er det traktoren), hjem, prøv igen
|
||||
local blamed = ADPool.failureBlames(hitch.detail) == "tractor" and assignment.vehicleId or assignment.pool.implementId
|
||||
-- koblingen fejlede: den skyldige i karantæne (kom traktoren ikke frem, er det traktoren), hjem, prøv igen.
|
||||
-- Kombi: det trin der fejlede afgør redskabet (8/10)
|
||||
local pool = assignment.pool
|
||||
local blamed, failed = ADPool.blame(hitch.detail, assignment.vehicleId,
|
||||
pool.implements or {{id = pool.implementId, name = pool.implementName}}, hitch.failedIndex)
|
||||
ADPool.quarantine(blamed, now())
|
||||
ADFieldWork.release(assignment)
|
||||
note(assignment.fieldId, {retryAt = ADPool.alignedRetry(now(), ADFieldWork.NO_RIG_RETRY_MS),
|
||||
reason = {text = string.format("kunne ikke koble '%s' på (%s) — prøver et andet om lidt",
|
||||
tostring(assignment.pool.implementName), tostring(hitch.detail))}})
|
||||
tostring(failed.name), tostring(hitch.detail))}})
|
||||
-- er bagslåmaskinen allerede på (fronten fejlede), sættes den af på sin P før traktoren kører hjem
|
||||
local dropped = (hitch.failedIndex or 1) > 1 and ADHitch.returnHome(adEnv, vehicle)
|
||||
local park = parkMarkerId(adEnv, vehicle)
|
||||
if park ~= nil then startAd(adEnv, vehicle, adEnv.AutoDrive.MODE_DRIVETO, park, nil) end
|
||||
if not dropped and park ~= nil then startAd(adEnv, vehicle, adEnv.AutoDrive.MODE_DRIVETO, park, nil) end
|
||||
return
|
||||
end
|
||||
-- koblet på: variabel bredde stilles (Unrealistic), sammenfoldet til vejen, bredden med redskabet på
|
||||
@@ -1586,7 +1606,9 @@ function ADFieldWork.follow(adEnv, assignment)
|
||||
-- redskabet passer ikke til opgaven: karantæne, ellers hentes det igen og igen (in-game 6/10: Servo 25 til F9)
|
||||
log(assignment.fieldId, "%s: '%s' med '%s' passer ikke (%s, bredde %.1f m) — redskabet sættes tilbage og prøves ikke foreløbig",
|
||||
tostring(assignment.role), ADRuns.vehicleLabel(vehicle), tostring(assignment.pool.implementName), tostring(widthReason), tonumber(width) or -1)
|
||||
ADPool.quarantine(assignment.pool.implementId, now())
|
||||
for _, item in ipairs(assignment.pool.implements or {{id = assignment.pool.implementId}}) do
|
||||
ADPool.quarantine(item.id, now())
|
||||
end
|
||||
ADFieldWork.release(assignment)
|
||||
note(assignment.fieldId, {retryAt = now() + ADFieldModel.RETRY_MS, reason = {key = "spu_field_reason_" .. tostring(widthReason), role = assignment.role, args = widthArgs}})
|
||||
ADHitch.returnHome(adEnv, vehicle)
|
||||
|
||||
Reference in New Issue
Block a user