fix(flows): gamle rå markører ryddes når de ikke er kilde eller dublerer en valgt bygning (v1.13.5.0)
This commit is contained in:
@@ -314,12 +314,32 @@ function ADRunsController.resolveMarkers(adEnv, run)
|
|||||||
table.insert(missing, building ~= nil and building.name or (tostring(buildingId) .. " (mangler)"))
|
table.insert(missing, building ~= nil and building.name or (tostring(buildingId) .. " (mangler)"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Rå markører (fra før flow-tavlen): beholdes kun hvis de er en genkendelig kilde og ikke hører til
|
||||||
|
-- en bygning der allerede er valgt (så ville de dublere bygningens egne markører).
|
||||||
|
local chosenPlaceables = {}
|
||||||
|
for _, buildingId in ipairs(buildingIds or {}) do
|
||||||
|
local building = ADBuildings.find(adEnv, farmId, buildingId)
|
||||||
|
if building ~= nil and building.placeable ~= nil then chosenPlaceables[building.placeable] = true end
|
||||||
|
end
|
||||||
|
local pruned = {}
|
||||||
for _, wayPointId in ipairs(existing or {}) do
|
for _, wayPointId in ipairs(existing or {}) do
|
||||||
if not seen[wayPointId] and ADBuildings.byMarker(adEnv, farmId, wayPointId, role) == nil then
|
if not seen[wayPointId] and ADBuildings.byMarker(adEnv, farmId, wayPointId, role) == nil then
|
||||||
|
local keep = true
|
||||||
|
if role == "load" and ADSources ~= nil and ADSources.identify ~= nil then
|
||||||
|
local source = ADSources.identify(adEnv, wayPointId, farmId)
|
||||||
|
keep = source ~= nil and not (source.placeable ~= nil and chosenPlaceables[source.placeable])
|
||||||
|
end
|
||||||
seen[wayPointId] = true
|
seen[wayPointId] = true
|
||||||
table.insert(resolved, wayPointId)
|
if keep then
|
||||||
|
table.insert(resolved, wayPointId)
|
||||||
|
else
|
||||||
|
table.insert(pruned, tostring(wayPointId))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if #pruned > 0 then
|
||||||
|
Logging.info(ADRunsController.LOG_PREFIX .. "run '%s': gamle markører fjernet (ingen kilde eller dublet af valgt bygning): %s", tostring(run.name), table.concat(pruned, " "))
|
||||||
|
end
|
||||||
if not listEquals(resolved, existing or {}) then
|
if not listEquals(resolved, existing or {}) then
|
||||||
local changes = run.kind == "outbound" and {sourceWayPointIds = resolved} or {targetWayPointIds = resolved}
|
local changes = run.kind == "outbound" and {sourceWayPointIds = resolved} or {targetWayPointIds = resolved}
|
||||||
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, run.id, changes)
|
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, run.id, changes)
|
||||||
|
|||||||
@@ -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.13.4.0</version>
|
<version>1.13.5.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
@@ -619,6 +619,21 @@ check("CF1 manglende markør", resolved.missing[1], "Palleskur")
|
|||||||
ADRunsController.updateRun(flowOut.id, {sourceWayPointIds = {12694, 555}})
|
ADRunsController.updateRun(flowOut.id, {sourceWayPointIds = {12694, 555}})
|
||||||
ADRunsController.resolveMarkers(adEnv, ADRuns.getRun(ADRunsController.store, flowOut.id))
|
ADRunsController.resolveMarkers(adEnv, ADRuns.getRun(ADRunsController.store, flowOut.id))
|
||||||
check("CF1 fravalgt bygnings markør fjernes", table.concat(ADRuns.getRun(ADRunsController.store, flowOut.id).sourceWayPointIds, ","), "10,11,555")
|
check("CF1 fravalgt bygnings markør fjernes", table.concat(ADRuns.getRun(ADRunsController.store, flowOut.id).sourceWayPointIds, ","), "10,11,555")
|
||||||
|
-- CF1b: gamle rå markører ryddes: ikke-kilde (identify = nil) og markør der hører til en valgt bygning
|
||||||
|
ADSources.identify = function(_, id)
|
||||||
|
if id == 10 or id == 12694 or id == 555 then return {kind = "x", wayPointId = id, name = "k"} end
|
||||||
|
if id == 556 then return {kind = "husbandry", wayPointId = id, name = "Kostald 1", placeable = "barn1-placeable"} end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
buildings[1].placeable = "barn1-placeable"
|
||||||
|
ADRunsController.updateRun(flowOut.id, {sourceBuildingIds = {"barn1"}, sourceWayPointIds = {10, 11, 555, 556, 999}})
|
||||||
|
logLines = {}
|
||||||
|
ADRunsController.resolveMarkers(adEnv, ADRuns.getRun(ADRunsController.store, flowOut.id))
|
||||||
|
check("CF1b rå ikke-kilde og dublet-bygning fjernet", table.concat(ADRuns.getRun(ADRunsController.store, flowOut.id).sourceWayPointIds, ","), "10,11,555")
|
||||||
|
local pruneLogged = false
|
||||||
|
for _, line in ipairs(logLines) do if line:find("gamle markører fjernet", 1, true) then pruneLogged = true end end
|
||||||
|
check("CF1b logget", pruneLogged, true)
|
||||||
|
|
||||||
-- CF2: forsyning: mål-bygninger -> targetWayPointIds + targetWayPointId
|
-- CF2: forsyning: mål-bygninger -> targetWayPointIds + targetWayPointId
|
||||||
local flowIn = ADRunsController.createRun("Foder", "supply")
|
local flowIn = ADRunsController.createRun("Foder", "supply")
|
||||||
ADRunsController.updateRun(flowIn.id, {targetBuildingIds = {"barn1", "mill"}})
|
ADRunsController.updateRun(flowIn.id, {targetBuildingIds = {"barn1", "mill"}})
|
||||||
|
|||||||
Reference in New Issue
Block a user