feat(kæde): flows kan tilhøre en kæde

This commit is contained in:
2026-09-30 13:34:09 +02:00
parent 6dd1b5cac0
commit 49eed51202
3 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ end
local RUN_FIELDS = {
"id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products",
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops",
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons",
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons", "chain",
}
local function draftFrom(run, isNew)
+5
View File
@@ -97,6 +97,7 @@ local function copyRun(run)
vehicleIds = copyList(run.vehicleIds),
stopped = run.stopped == true,
wagons = ADRuns.copyWagons(run.wagons),
chain = run.chain or "",
}
end
@@ -145,6 +146,7 @@ function ADRuns.createRun(store, name, kind)
loops = 0,
returnBelowPercent = ADRuns.DEFAULT_RETURN_BELOW_PERCENT,
vehicleIds = {},
chain = "",
}
new.nextId = new.nextId + 1
table.insert(new.runs, run)
@@ -204,6 +206,7 @@ function ADRuns.updateRun(store, runId, changes)
if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end
if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end
if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end
if changes.chain ~= nil then run.chain = tostring(changes.chain) end
return new
end
@@ -440,6 +443,7 @@ function ADRuns.toRecords(store)
collectRound = run.collectRound and 1 or 0,
stopped = run.stopped and 1 or 0,
wagons = ADRuns.serializeWagons(run.wagons),
chain = run.chain or "",
}
end
return records
@@ -494,6 +498,7 @@ function ADRuns.fromRecords(records)
vehicleIds = copyList(record.vehicleIds),
stopped = tonumber(record.stopped) == 1,
wagons = ADRuns.parseWagons(record.wagons),
chain = record.chain or "",
})
store.nextId = math.max(store.nextId, id + 1)
end
+2
View File
@@ -51,6 +51,7 @@ function ADRunsStorage.writeRecords(xmlFile, records)
-- maskinpulje: flowet stoppet + husket vogn pr. traktor
xmlFile:setInt(key .. "#stopped", record.stopped or 0)
xmlFile:setString(key .. "#wagons", record.wagons or "")
xmlFile:setString(key .. "#chain", record.chain or "")
for vehicleIndex, vehicleId in ipairs(record.vehicleIds) do
xmlFile:setString(string.format("%s.vehicle(%d)#id", key, vehicleIndex - 1), vehicleId)
end
@@ -82,6 +83,7 @@ function ADRunsStorage.readRecords(xmlFile)
collectRound = xmlFile:getInt(key .. "#collectRound"),
stopped = xmlFile:getInt(key .. "#stopped"),
wagons = xmlFile:getString(key .. "#wagons"),
chain = xmlFile:getString(key .. "#chain"),
vehicleIds = {},
}
xmlFile:iterate(key .. ".vehicle", function(_, vehicleKey)