fix(markarbejde): genstart efter indlæsning kun når maskinen står på en mark i gang med dens trin eller ≤30 m fra sit huskede waypoint — to ROPA'er kørte ad vejene mod et gammelt kursus (v1.38.5.0)

This commit is contained in:
2026-09-27 14:47:52 +02:00
parent bcfa237321
commit 490eecc25e
4 changed files with 29 additions and 3 deletions
+11 -2
View File
@@ -933,12 +933,21 @@ function ADFieldWork.resumeAfterLoad(adEnv)
local vehicle = rig.vehicle
local wasWorking = vehicle.startCpAtLastWp ~= nil and vehicle.hasCpCourse ~= nil and vehicle:hasCpCourse()
and vehicle.getCpLastRememberedWaypointIx ~= nil and vehicle:getCpLastRememberedWaypointIx() ~= nil
if wasWorking and not rig.busy and not rig.controlled then
local fieldId, distance = nil, nil
if wasWorking then
fieldId = ADFieldJobs.resumeField(rig.x, rig.z, rig.role, fields)
local course = ADCpBridge.getCourse(vehicle)
local okWp, wp = pcall(function() return course ~= nil and course:getWaypoint(vehicle:getCpLastRememberedWaypointIx()) or nil end)
if okWp and wp ~= nil and wp.x ~= nil then distance = math.sqrt((wp.x - rig.x) ^ 2 + (wp.z - rig.z) ^ 2) end
end
if wasWorking and not rig.busy and not rig.controlled and not ADFieldJobs.shouldResume({fieldId = fieldId, distance = distance}) then
Logging.info(ADFieldJobs.LOG_PREFIX .. "'%s' genstartes ikke: husket waypoint fra et gammelt job (%s væk, ikke på en mark i gang)",
tostring(rig.label), distance ~= nil and string.format("%.0f m", distance) or "ukendt afstand")
elseif wasWorking and not rig.busy and not rig.controlled then
local ok, started = pcall(vehicle.startCpAtLastWp, vehicle)
if not ok then
Logging.warning(ADFieldJobs.LOG_PREFIX .. "'%s' kunne ikke genstartes: %s", tostring(rig.label), tostring(started))
elseif started then
local fieldId = ADFieldJobs.resumeField(rig.x, rig.z, rig.role, fields)
if fieldId ~= nil then
ADFieldJobs.state.assignments[rig.id] = {vehicleId = rig.id, vehicle = vehicle, fieldId = fieldId, role = rig.role,
stage = stageById[fieldId], helper = false, phase = "working", since = now(), width = rig.width,