fix(kæde): palle-varer får egen status og linjen med frie marker passer i fanen

This commit is contained in:
2026-09-30 14:27:48 +02:00
parent 83394aabfd
commit 817fc388a2
5 changed files with 34 additions and 11 deletions
+6 -3
View File
@@ -22,7 +22,8 @@ ADChain.last = nil
ADChain.prevEnabled = nil
-- true fra indlæsning til første tick: kædens produktioner der er slukket, glemmes (spillet blev ikke gemt)
ADChain.afterLoad = false
-- run-id -> true: flows kæden oprettede stoppet, fordi der ikke var traktor/vogn (kun i hukommelsen)
-- run-id -> "noVehicle"|"pallet" (true = "noVehicle"): flows kæden oprettede stoppet, fordi der ikke var
-- traktor/vogn eller varen er på paller (kun i hukommelsen)
ADChain.noVehicle = {}
ADChain.switchCount = 0
ADChain.now = 0
@@ -227,7 +228,7 @@ function ADChain.stillNeeded(runView, edges)
return nil
end
-- {[forbruger|vare] = "ok"|"missing"|"stopped"|"noVehicle"} for hver kant.
-- {[forbruger|vare] = "ok"|"missing"|"stopped"|"noVehicle"|"pallet"} for hver kant.
function ADChain.flowStatus(edges, runs, noVehicle)
local result = {}
for _, edge in ipairs(edges or {}) do
@@ -235,7 +236,9 @@ function ADChain.flowStatus(edges, runs, noVehicle)
for _, run in ipairs(runs or {}) do
if run.kind == "supply" and covers(run, edge) then
if not run.stopped then status = "ok"; break end
if (noVehicle or {})[run.id] then status = "noVehicle"
local reason = (noVehicle or {})[run.id]
if reason == "pallet" then status = "pallet"
elseif reason then status = "noVehicle"
elseif status == "missing" then status = "stopped" end
end
end
+5 -4
View File
@@ -118,9 +118,10 @@ local function collectPool(adEnv)
return implements or {}, tractors or {}
end
local function createStopped(run, reason, ...)
-- kind = "noVehicle"|"pallet": vises som status på kanten i fanen Kæder
local function createStopped(run, kind, reason, ...)
run.stopped = true
ADChain.noVehicle[run.id] = true
ADChain.noVehicle[run.id] = kind
log("flow '%s' oprettet stoppet: " .. reason, tostring(run.name), ...)
end
@@ -134,14 +135,14 @@ local function createFlow(adEnv, data, edge, pool, used)
local run = ADRuns.getRun(ADRunsController.store, runId)
local fillIndex = data.fillIndex[edge.fillType]
if fillIndex ~= nil and ADSources.isPalletFillType(fillIndex) then
createStopped(run, "palle-vare: vælg vogn med Universal Autoload (%s)", tostring(title))
createStopped(run, "pallet", "palle-vare: vælg vogn med Universal Autoload (%s)", tostring(title))
return
end
if pool.implements == nil then pool.implements, pool.tractors = collectPool(adEnv) end
if pool.blocked == nil then pool.blocked = ADPool.blocked(ADFieldJobs.now or 0) end
local pair = ADChainRun.choosePair(pool.implements, pool.tractors, fillIndex, used, pool.blocked)
if pair == nil then
createStopped(run, "ingen ledig traktor/vogn til %s", tostring(title))
createStopped(run, "noVehicle", "ingen ledig traktor/vogn til %s", tostring(title))
return
end
used[pair.tractor.id], used[pair.implement.id] = true, true
+21 -4
View File
@@ -13,17 +13,20 @@ ADChainView.INDENT = " "
-- Antaget ~11,5 px pr. tegn (spuInfoText: 800 px ~ 70 tegn), fed ~12,5 px; c3 har kun tal (~10 px pr. tegn).
ADChainView.CELL_CHARS = {15, 14, 6, 21, 8}
ADChainView.MAX_SOURCE_NAMES = 2
-- Tegnbudget for en tekstlinje (addTextRow/spuInfoText: 800 px ~ 70 tegn), fx linjen med frie marker.
ADChainView.TEXT_ROW_CHARS = 70
-- "stramt": lager for en mark-afgrøde under så mange måneders behov -> gul
ADChainView.TIGHT_MONTHS = 3
-- nøgler rækkerne bruger (til l10n-testen)
ADChainView.TEXT_KEYS = {"spu_chain_empty", "spu_chain_approve", "spu_chain_dismiss", "spu_chain_auto",
"spu_chain_flowOk", "spu_chain_flowMissing", "spu_chain_flowNone", "spu_chain_flowStopped", "spu_chain_bottleneck",
"spu_chain_flowOk", "spu_chain_flowMissing", "spu_chain_flowPallet", "spu_chain_flowNone", "spu_chain_flowStopped", "spu_chain_bottleneck",
"spu_chain_buy", "spu_chain_cycle", "spu_chain_fieldShort", "spu_chain_tight", "spu_chain_noField", "spu_chain_buySource",
"spu_chain_pause", "spu_chain_resume", "spu_chain_scanning", "spu_chain_rootOk", "spu_chain_rootError", "spu_chain_rootWaiting",
"spu_chain_rootPaused", "spu_chain_rootSummary", "spu_chain_free", "spu_chain_switches", "spu_chain_gone", "spu_chain_col_item",
"spu_chain_col_source", "spu_chain_col_perMonth", "spu_chain_col_status", "spu_chain_col_stock"}
local FLOW_KEYS = {ok = "spu_chain_flowOk", missing = "spu_chain_flowNone", stopped = "spu_chain_flowStopped", noVehicle = "spu_chain_flowMissing"}
local FLOW_KEYS = {ok = "spu_chain_flowOk", missing = "spu_chain_flowNone", stopped = "spu_chain_flowStopped", noVehicle = "spu_chain_flowMissing",
pallet = "spu_chain_flowPallet"}
local ROOT_STATUS = {running = "spu_chain_rootOk", error = "spu_chain_rootError", waiting = "spu_chain_rootWaiting", stopped = "spu_chain_rootPaused"}
local function identity(value) return tostring(value) end
@@ -259,6 +262,21 @@ local function pausedRows(rows, last, ctx)
return #keys
end
-- "Marker fri til kæden: F1, F2 +k" — så mange navne som tekstlinjen kan rumme, resten talt.
function ADChainView.freeText(names, textOf)
local format = textOf("spu_chain_free")
if #names == 0 then return string.format(format, "-") end
for count = #names, 1, -1 do
local shown = {}
for index = 1, count do shown[index] = names[index] end
local list = table.concat(shown, ", ")
if count < #names then list = list .. " +" .. tostring(#names - count) end
local text = string.format(format, list)
if ADChainView.textLength(text) <= ADChainView.TEXT_ROW_CHARS then return text end
end
return ADChainView.fit(string.format(format, "+" .. tostring(#names)), ADChainView.TEXT_ROW_CHARS)
end
local function footerRows(rows, last, textOf)
local free = {}
for _, field in ipairs(last.fields or {}) do
@@ -267,8 +285,7 @@ local function footerRows(rows, last, textOf)
table.sort(free)
local names = {}
for _, id in ipairs(free) do table.insert(names, "F" .. tostring(id)) end
local freeText = string.format(textOf("spu_chain_free"), #names > 0 and table.concat(names, ", ") or "-")
table.insert(rows, {kind = "info", indent = 0, text = freeText})
table.insert(rows, {kind = "info", indent = 0, text = ADChainView.freeText(names, textOf)})
table.insert(rows, {kind = "info", indent = 0, text = string.format(textOf("spu_chain_switches"), last.switchCount or 0)})
if last.fieldsIncomplete then table.insert(rows, {kind = "info", indent = 0, text = textOf("spu_chain_scanning")}) end
end
+1
View File
@@ -589,6 +589,7 @@
<text name="spu_chain_flowOk" text="flow kører"/>
<text name="spu_chain_flowMissing" text="mangler traktor/vogn"/>
<text name="spu_chain_flowNone" text="intet flow"/>
<text name="spu_chain_flowPallet" text="palle: vælg UAL-vogn"/>
<text name="spu_chain_flowStopped" text="flow stoppet"/>
<text name="spu_chain_bottleneck" text="flaskehals: -%s/md"/>
<text name="spu_chain_buy" text="skal købes: %s/md"/>
+1
View File
@@ -589,6 +589,7 @@
<text name="spu_chain_flowOk" text="flow running"/>
<text name="spu_chain_flowMissing" text="no tractor/trailer"/>
<text name="spu_chain_flowNone" text="no flow"/>
<text name="spu_chain_flowPallet" text="pallet: UAL trailer"/>
<text name="spu_chain_flowStopped" text="flow stopped"/>
<text name="spu_chain_bottleneck" text="bottleneck: -%s/mo"/>
<text name="spu_chain_buy" text="must buy: %s/mo"/>