feat: regel 'Hent først når kilden er over X %' for salgsflows (v1.62.68)

This commit is contained in:
2026-10-07 23:24:55 +02:00
parent 31b8b19b9c
commit c5da46e876
11 changed files with 41 additions and 6 deletions
+1
View File
@@ -8,6 +8,7 @@ står i [docs/BRUGERMANUAL.md](docs/BRUGERMANUAL.md) (dansk) og [docs/USER_MANUA
## 1.62 — Kæder slås selv til
- **1.62.68** Nyt: reglen "Hent først når kilden er over" (udkørsel med salg). Et salg venter, til den fyldeste kilde er mindst X % fuld (10–90 %), eller til et fuldt læs ligger klar. Standard er *Fra* som før. Holdebegrundelsen siger fx "MILK: lager 2 % (henter fra 25 % eller fuldt læs)". Brugerønske 7/10: mælkebilen kørte efter 2.305 l.
- **1.62.67** Nyt: markørvagten tjekker hvert 30. sekund, om et køretøj i et kørende flow (i læs og aflever) har en parkerings- eller koblingsmarkør ("P …", "Connect …") som læsse- eller aflæsningsmål, og genstarter det i så fald i flowet (højst hvert 5. minut). Det fanger forkerte mål, der er gemt fra før en genindlæsning. Før kørte 'Chicken Food' mod "P Sprøjte 1" efter genindlæsning.
- **1.62.66** Rettet: markmarkører genkendes også på navnet (F21 osv.), så de heller ikke lige efter indlæsning, før markskanningen har fundet dem, bruges som salgssted. I 1.62.65 fik 'Oil Mill' stadig F21.
- **1.62.65** Rettet: falsk opvågning. Vågner et flow og går i dvale igen uden at have fået last på, venter det længere før næste vågn-tjek (10 → 30 → 60 min), så traktoren ikke henter vognen hvert kvarter til ingen nytte. Opvågningen logger vare, mængde og vogn ("hent STRAW ved Silo 4 (… l der, mål mangler … l)"). Før vågnede 'Sheep Food' "hent ved Silo 4", men fandt intet, da vognen var koblet på.
+12 -2
View File
@@ -68,7 +68,7 @@ end
local RUN_FIELDS = {
"id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products",
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops",
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "minSourcePercent", "collectRound", "loops",
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons", "chain",
}
@@ -83,6 +83,7 @@ local function draftFrom(run, isNew)
draft.sellAtPercent = draft.sellAtPercent or ADRuns.DEFAULT_SELL_AT_PERCENT
draft.storeAbovePercent = draft.storeAbovePercent or ADRuns.DEFAULT_STORE_ABOVE_PERCENT
draft.sellAbovePercent = draft.sellAbovePercent or ADRuns.DEFAULT_SELL_ABOVE_PERCENT
draft.minSourcePercent = draft.minSourcePercent or ADRuns.DEFAULT_MIN_SOURCE_PERCENT
draft.returnBelowPercent = draft.returnBelowPercent or ADRuns.DEFAULT_RETURN_BELOW_PERCENT
draft.loops = draft.loops or 0
draft.waitPoolGroup = draft.waitPoolGroup or ""
@@ -169,7 +170,7 @@ end
-- ---- valg ----
local SET_VALUES = {
kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, loops = true,
kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, minSourcePercent = true, loops = true,
returnBelowPercent = true, waitPoolGroup = true,
}
local BOOL_VALUES = {showAllBuildings = true, storeAuto = true, collectRound = true}
@@ -246,6 +247,12 @@ local function sellAboveOptions()
return options
end
local function minSourceOptions()
local options = {{label = L("spu_minSource_off"), value = 0}}
for _, option in ipairs(percentOptions(10, 90, 10)) do table.insert(options, option) end
return options
end
local function chosenSet(list)
local set = {}
for _, value in ipairs(list or {}) do set[value] = true end
@@ -347,6 +354,7 @@ local function rowsRules(guide)
end
if stores then table.insert(rows, choice("storeAbovePercent", L("spu_storeAbove"), percentOptions(ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT, 5), draft.storeAbovePercent)) end
if sells then table.insert(rows, choice("sellAbovePercent", L("spu_sellAbove"), sellAboveOptions(), draft.sellAbovePercent)) end
if sells then table.insert(rows, choice("minSourcePercent", L("spu_minSource"), minSourceOptions(), draft.minSourcePercent or 0)) end
table.insert(rows, toggle("collectRound", L("spu_collectRound"), draft.collectRound))
return rows
end
@@ -504,6 +512,7 @@ local SUMMARY = {
if sells then table.insert(parts, draft.sellAtPercent == 0 and L("spu_guide_flow_sumSellAlways") or L("spu_guide_flow_sumSellAt", {draft.sellAtPercent})) end
if stores then table.insert(parts, L("spu_guide_flow_sumStoreAbove", {draft.storeAbovePercent})) end
if sells and (draft.sellAbovePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumSellAbove", {draft.sellAbovePercent})) end
if sells and (draft.minSourcePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumMinSource", {draft.minSourcePercent})) end
if draft.collectRound then table.insert(parts, L("spu_guide_flow_sumRound")) end
return parts
end
@@ -552,6 +561,7 @@ function ADFlowGuide.result(guide)
products = ADGuide.deepCopy(draft.products), ingredientMode = draft.ingredientMode,
ingredients = ADGuide.deepCopy(draft.ingredients), sellAtPercent = draft.sellAtPercent,
storeAbovePercent = draft.storeAbovePercent, sellAbovePercent = draft.sellAbovePercent or 0,
minSourcePercent = draft.minSourcePercent or 0,
collectRound = draft.collectRound, loops = draft.loops,
returnBelowPercent = draft.returnBelowPercent, waitPoolGroup = draft.waitPoolGroup or "",
}
+1
View File
@@ -365,6 +365,7 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
sellAtPercent = run.sellAtPercent,
storeAbovePercent = run.storeAbovePercent,
sellAbovePercent = run.sellAbovePercent,
minSourcePercent = run.minSourcePercent,
collectRound = run.collectRound == true,
products = products,
}
+7 -1
View File
@@ -71,6 +71,8 @@ function ADOutboundPlanner.evaluate(product, input)
priceOk = input.sellAtPercent == 0 or (percent ~= nil and percent >= (input.sellAtPercent or 90)),
-- "sælg altid over X %": kilden er så fuld, at der sælges uanset pris
overflow = (input.sellAbovePercent or 0) > 0 and storagePercent >= input.sellAbovePercent,
-- "hent først ved X %": salg venter til kilden er så fuld, eller et fuldt læs ligger klar (0 = fra)
minSourceOk = (input.minSourcePercent or 0) <= 0 or fullLoad or storagePercent >= input.minSourcePercent,
}
end
@@ -101,6 +103,10 @@ local function reasonFor(product, e, input)
local names = table.concat(product.reservedFor or {}, ", ")
return string.format("%s: %s reserveret til %s", product.name, formatLiters(e.reserve), names ~= "" and names or "gårdens eget forbrug")
end
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and not e.minSourceOk then
return string.format("%s: lager %d %% (henter fra %d %% eller fuldt læs)", product.name,
math.floor(e.storagePercent + 0.5), input.minSourcePercent)
end
local canStore = wantsStore(product.policy) and product.store ~= nil
if wantsSell(product.policy) and product.quote == nil and not canStore then
return product.name .. ": intet nåeligt salgssted"
@@ -126,7 +132,7 @@ local function collectCandidates(input)
local e = ADOutboundPlanner.evaluate(product, input)
local added = false
if e.available >= ADOutboundPlanner.MIN_AVAILABLE_LITERS then
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and canSellWithoutReserve(e, input) then
if wantsSell(product.policy) and (e.priceOk or e.overflow) and e.minSourceOk and product.quote ~= nil and canSellWithoutReserve(e, input) then
table.insert(sell, {product = product, e = e, kind = "sell", targetWayPointId = product.quote.wayPointId, targetName = product.quote.stationName, percent = e.percent})
added = true
elseif wantsStore(product.policy) and (e.fullLoad or e.storageHigh or (input.feedMode and e.available >= ADOutboundPlanner.FEED_MIN_LITERS)) and product.store ~= nil then
+7
View File
@@ -20,6 +20,8 @@ ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_S
-- "Sælg altid over X %": kildens lager over grænsen sælges uanset pris (0 = fra). Så hober f.eks. gylle
-- ved BGA'en sig ikke op, når prisen er lav.
ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT = 0, 0, 100
-- "hent først ved X % i kilden" (0 = fra): salg venter til kilden er så fuld eller et fuldt læs ligger klar
ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT = 0, 0, 95
local function copyList(list)
local copy = {}
@@ -86,6 +88,7 @@ local function copyRun(run)
sellAtPercent = run.sellAtPercent,
storeAbovePercent = run.storeAbovePercent,
sellAbovePercent = run.sellAbovePercent,
minSourcePercent = run.minSourcePercent,
collectRound = run.collectRound,
targetWayPointId = run.targetWayPointId,
targetWayPointIds = copyList(run.targetWayPointIds),
@@ -138,6 +141,7 @@ function ADRuns.createRun(store, name, kind)
sellAtPercent = ADRuns.DEFAULT_SELL_AT_PERCENT,
storeAbovePercent = ADRuns.DEFAULT_STORE_ABOVE_PERCENT,
sellAbovePercent = ADRuns.DEFAULT_SELL_ABOVE_PERCENT,
minSourcePercent = ADRuns.DEFAULT_MIN_SOURCE_PERCENT,
collectRound = false,
targetWayPointId = nil,
targetWayPointIds = {},
@@ -207,6 +211,7 @@ function ADRuns.updateRun(store, runId, changes)
if changes.sellAtPercent ~= nil then run.sellAtPercent = tonumber(changes.sellAtPercent) == 0 and 0 or clampRange(changes.sellAtPercent, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT) end
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.minSourcePercent ~= nil then run.minSourcePercent = clampRange(changes.minSourcePercent, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_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
@@ -442,6 +447,7 @@ function ADRuns.toRecords(store)
sellAt = run.sellAtPercent,
storeAbove = run.storeAbovePercent,
sellAbove = run.sellAbovePercent or 0,
minSource = run.minSourcePercent or 0,
collectRound = run.collectRound and 1 or 0,
stopped = run.stopped and 1 or 0,
sleeping = run.sleeping and 1 or 0,
@@ -490,6 +496,7 @@ function ADRuns.fromRecords(records)
sellAtPercent = tonumber(record.sellAt) == 0 and 0 or clampRange(record.sellAt, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT),
storeAbovePercent = clampRange(record.storeAbove, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT),
sellAbovePercent = clampRange(record.sellAbove, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT),
minSourcePercent = clampRange(record.minSource, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT),
collectRound = tonumber(record.collectRound) == 1,
targetWayPointId = targets[1],
targetWayPointIds = targets,
+2
View File
@@ -47,6 +47,7 @@ function ADRunsStorage.writeRecords(xmlFile, records)
xmlFile:setInt(key .. "#sellAt", record.sellAt or ADRuns.DEFAULT_SELL_AT_PERCENT)
xmlFile:setInt(key .. "#storeAbove", record.storeAbove or ADRuns.DEFAULT_STORE_ABOVE_PERCENT)
xmlFile:setInt(key .. "#sellAbove", record.sellAbove or 0)
xmlFile:setInt(key .. "#minSource", record.minSource or 0)
xmlFile:setInt(key .. "#collectRound", record.collectRound or 0)
-- maskinpulje: flowet stoppet + husket vogn pr. traktor
xmlFile:setInt(key .. "#stopped", record.stopped or 0)
@@ -81,6 +82,7 @@ function ADRunsStorage.readRecords(xmlFile)
sellAt = xmlFile:getInt(key .. "#sellAt"),
storeAbove = xmlFile:getInt(key .. "#storeAbove"),
sellAbove = xmlFile:getInt(key .. "#sellAbove"),
minSource = xmlFile:getInt(key .. "#minSource"),
collectRound = xmlFile:getInt(key .. "#collectRound"),
stopped = xmlFile:getInt(key .. "#stopped"),
sleeping = xmlFile:getInt(key .. "#sleeping"),
+3
View File
@@ -317,6 +317,8 @@
<text name="spu_storeAbove" text="Kør til lager over"/>
<text name="spu_sellAbove" text="Sælg altid når kilden er over"/>
<text name="spu_sellAbove_off" text="Fra"/>
<text name="spu_minSource" text="Hent først når kilden er over"/>
<text name="spu_minSource_off" text="Fra (hent alt)"/>
<text name="spu_storeAbove_tooltip" text="Varer med Lager-politik køres til silo når kildens lager er over denne fyldning (eller der er et fuldt læs)."/>
<text name="spu_collectRound" text="Saml op på én tur"/>
<text name="spu_collectRound_tooltip" text="Tipvogn: samme vare fra flere kilder til vognen er fuld. Autoload-vogn: flere pallevarer med samme mål på én tur."/>
@@ -526,6 +528,7 @@
<text name="spu_guide_flow_sumSellAt" text="sælg fra %d %%"/>
<text name="spu_guide_flow_sumStoreAbove" text="lager over %d %%"/>
<text name="spu_guide_flow_sumSellAbove" text="sælg altid over %d %%"/>
<text name="spu_guide_flow_sumMinSource" text="henter først ved %d %% (eller fuldt læs)"/>
<text name="spu_guide_flow_sumRound" text="samlerunde"/>
<text name="spu_guide_flow_sumLoops" text="%d ture"/>
<text name="spu_guide_flow_sumLoopsInf" text="uendelige ture"/>
+3
View File
@@ -317,6 +317,8 @@
<text name="spu_storeAbove" text="Drive to storage above"/>
<text name="spu_sellAbove" text="Always sell when source is above"/>
<text name="spu_sellAbove_off" text="Off"/>
<text name="spu_minSource" text="Only fetch when source is above"/>
<text name="spu_minSource_off" text="Off (fetch any amount)"/>
<text name="spu_storeAbove_tooltip" text="Goods with the Store policy are driven to a silo when the source storage is above this fill level (or a full load is available)."/>
<text name="spu_collectRound" text="Collect in one trip"/>
<text name="spu_collectRound_tooltip" text="Tipper: same good from several sources until full. Autoload trailer: several pallet goods with the same destination in one trip."/>
@@ -526,6 +528,7 @@
<text name="spu_guide_flow_sumSellAt" text="sell from %d %%"/>
<text name="spu_guide_flow_sumStoreAbove" text="store above %d %%"/>
<text name="spu_guide_flow_sumSellAbove" text="always sell above %d %%"/>
<text name="spu_guide_flow_sumMinSource" text="fetches from %d %% (or a full load)"/>
<text name="spu_guide_flow_sumRound" text="collection round"/>
<text name="spu_guide_flow_sumLoops" text="%d trips"/>
<text name="spu_guide_flow_sumLoopsInf" text="endless trips"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.67.0</version>
<version>1.62.68.0</version>
<title>
<en>AD Smart Pickup</en>
</title>
+2 -1
View File
@@ -316,7 +316,7 @@ flow har op til 9 trin. Knapperne er **Næste**, **Tilbage** og **Annullér**. I
| **Til** / **Fra** | altid | Bygningerne (se *Bygningslisten* nedenfor) |
| **Varer** | altid | Forsyning: *Automatisk (det bygningen mangler)* eller *Vælg selv*. Udkørsel: pr. vare *Fra*, *Lager*, *Salg* eller *Salg, ellers lager* |
| **Lager** | udkørsel med en vare på Lager | *Automatisk (nærmeste med plads)* eller *Vælg selv* blandt lagrene |
| **Regler** | altid | Forsyning: ture og *Kør hjem fra Wait under*. Udkørsel: *Sælg fra*, *Kør til lager over*, *Sælg altid når kilden er over* og *Saml op på én tur*, men kun de regler, varernes politik bruger (se [kapitel 6](#regler-for-udkørsel)) |
| **Regler** | altid | Forsyning: ture og *Kør hjem fra Wait under*. Udkørsel: *Sælg fra*, *Kør til lager over*, *Sælg altid når kilden er over*, *Hent først når kilden er over* og *Saml op på én tur*, men kun de regler, varernes politik bruger (se [kapitel 6](#regler-for-udkørsel)) |
| **Vent ved** | altid | *Alle (nærmeste ledige)* eller en bestemt Wait-mappe |
| **Traktorer** | altid | Se nedenfor |
| **Oversigt** | altid | Resuméet. Klik på en linje for at rette den. **Start flow** eller **Gem uden at starte** |
@@ -526,6 +526,7 @@ medmindre du selv vælger fabrikken under **Lager**.
| **Sælg fra** | Der sælges, når prisen er mindst denne andel af varens toppris i året | 50–100 %, standard 90 % |
| **Kør til lager over** | Lager-varer køres væk, når kilden er fyldt over denne andel | 50–95 %, standard 80 % |
| **Sælg altid når kilden er over** | Sælger uanset pris, når den fyldeste kilde er over denne andel. Reserven røres stadig ikke | *Fra* eller 50–100 %, standard *Fra* |
| **Hent først når kilden er over** | Et salg venter, til den fyldeste kilde er mindst så fuld, eller til et fuldt læs ligger klar. Så kører mælke- og gyllebiler ikke efter få liter | *Fra (hent alt)* eller 10–90 %, standard *Fra* |
| **Saml op på én tur** | Opsamlingsrunde, se nedenfor | Ja/Nej |
Reglerne vises kun, når en vare bruger dem. **Sælg fra** og **Sælg altid når kilden er over** vises, når
+2 -1
View File
@@ -319,7 +319,7 @@ press **Start flow** or **Save without starting** on the last step.
| **To** / **From** | always | The buildings (see *The building list* below) |
| **Goods** | always | Supply: *Automatic (what the building needs)* or *Choose myself*. Outbound: per good *Off*, *Store*, *Sell* or *Sell, else store* |
| **Storage** | outbound with a good on Store | *Automatic (nearest with room)* or *Choose myself* among the storages |
| **Rules** | always | Supply: loops and *Return from Wait below*. Outbound: *Sell from*, *Drive to storage above*, *Always sell when source is above* and *Collect in one trip*, but only the rules the goods' policies use (see [chapter 6](#outbound-rules)) |
| **Rules** | always | Supply: loops and *Return from Wait below*. Outbound: *Sell from*, *Drive to storage above*, *Always sell when source is above*, *Only fetch when source is above* and *Collect in one trip*, but only the rules the goods' policies use (see [chapter 6](#outbound-rules)) |
| **Wait at** | always | *All (nearest free)* or a specific Wait folder |
| **Tractors** | always | See below |
| **Summary** | always | The summary. Click a line to change it. **Start flow** or **Save without starting** |
@@ -531,6 +531,7 @@ and tanks, unless you choose the factory yourself under **Storage**.
| **Sell from** | Sell when the price is at least this share of the good's top price of the year | 50–100 %, default 90 % |
| **Drive to storage above** | Store goods are hauled away when the source is filled above this share | 50–95 %, default 80 % |
| **Always sell when source is above** | Sells regardless of price when the fullest source is above this share. The reserve is still not touched | *Off* or 50–100 %, default *Off* |
| **Only fetch when source is above** | A sale waits until the fullest source is at least this full, or a full load is ready, so milk and slurry trucks don't drive for a few litres | *Off (fetch any amount)* or 10–90 %, default *Off* |
| **Collect in one trip** | Collection round, see below | Yes/No |
The rules are only shown when a good uses them. **Sell from** and **Always sell when source is above** are