feat: bulk-vare der også står på paller (sukkerfabrik) tages som paller af en UAL-vogn, som bulk af en tipvogn (v1.12.3.0)
This commit is contained in:
@@ -195,17 +195,24 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
|
|||||||
for _, source in ipairs(sources) do
|
for _, source in ipairs(sources) do
|
||||||
for _, item in ipairs(ADSources.getProducts(adEnv, source, farmId)) do
|
for _, item in ipairs(ADSources.getProducts(adEnv, source, farmId)) do
|
||||||
local policy = ADRuns.getProductPolicy(run, item.name)
|
local policy = ADRuns.getProductPolicy(run, item.name)
|
||||||
local canCarry = (item.isPallet and hasAutoload) or (not item.isPallet and carriable[item.fillType] == true)
|
-- bulk hvis vognen kan bære varen; ellers paller hvis varen står på paller og vognen har UAL
|
||||||
|
-- (en pallebil ved sukkerfabrikken tager sukkerpallerne, en tipvogn tager bulk)
|
||||||
|
local usePallets = item.isPallet or (carriable[item.fillType] ~= true and hasAutoload and item.canPallet == true)
|
||||||
|
local canCarry = usePallets and hasAutoload or (not usePallets and carriable[item.fillType] == true)
|
||||||
|
local available = item.available
|
||||||
|
if usePallets and not item.isPallet then
|
||||||
|
available = item.palletLiters or 0
|
||||||
|
end
|
||||||
local emptyKey = tostring(source.wayPointId) .. ":" .. tostring(item.fillType)
|
local emptyKey = tostring(source.wayPointId) .. ":" .. tostring(item.fillType)
|
||||||
local isMarkedEmpty = emptyUntil[emptyKey] ~= nil and emptyUntil[emptyKey] > time
|
local isMarkedEmpty = emptyUntil[emptyKey] ~= nil and emptyUntil[emptyKey] > time
|
||||||
if policy ~= "off" and canCarry and not isMarkedEmpty then
|
if policy ~= "off" and canCarry and not isMarkedEmpty then
|
||||||
local product = byName[item.name]
|
local product = byName[item.name]
|
||||||
if product == nil then
|
if product == nil then
|
||||||
product = {fillType = item.fillType, name = item.name, policy = policy, isPallet = item.isPallet, sources = {}}
|
product = {fillType = item.fillType, name = item.name, policy = policy, isPallet = usePallets, sources = {}}
|
||||||
byName[item.name] = product
|
byName[item.name] = product
|
||||||
table.insert(products, product)
|
table.insert(products, product)
|
||||||
end
|
end
|
||||||
table.insert(product.sources, {wayPointId = source.wayPointId, available = item.available, level = item.level, capacity = item.capacity})
|
table.insert(product.sources, {wayPointId = source.wayPointId, available = available, level = item.level, capacity = item.capacity})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ function ADRunsController.getRunProducts(adEnv, run)
|
|||||||
for _, item in ipairs(ADSources.getProducts(adEnv, source, farmId)) do
|
for _, item in ipairs(ADSources.getProducts(adEnv, source, farmId)) do
|
||||||
local product = byName[item.name]
|
local product = byName[item.name]
|
||||||
if product == nil then
|
if product == nil then
|
||||||
product = {fillType = item.fillType, name = item.name, title = item.title or item.name, policy = ADRuns.getProductPolicy(run, item.name), isPallet = item.isPallet, available = 0, level = 0, capacity = 0}
|
product = {fillType = item.fillType, name = item.name, title = item.title or item.name, policy = ADRuns.getProductPolicy(run, item.name), isPallet = item.isPallet, canPallet = item.canPallet, available = 0, level = 0, capacity = 0}
|
||||||
byName[item.name] = product
|
byName[item.name] = product
|
||||||
table.insert(result, product)
|
table.insert(result, product)
|
||||||
end
|
end
|
||||||
@@ -356,6 +356,9 @@ local function getOutboundFillTypes(adEnv, run, vehicle)
|
|||||||
if canLoadPallets then table.insert(result, product.fillType) end
|
if canLoadPallets then table.insert(result, product.fillType) end
|
||||||
elseif carriable[product.fillType] then
|
elseif carriable[product.fillType] then
|
||||||
table.insert(result, product.fillType)
|
table.insert(result, product.fillType)
|
||||||
|
elseif product.canPallet and canLoadPallets then
|
||||||
|
-- bulk-vare der også står på paller (sukkerfabrik): pallebilen tager pallerne
|
||||||
|
table.insert(result, product.fillType)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -184,10 +184,12 @@ local function getPalletsNearSpawner(placeable, fillType, farmId)
|
|||||||
return total
|
return total
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- canPallet: varen er en palletype (kan stå på paller); palletLiters: liter på paller ved
|
||||||
|
-- kilden når varen ELLERS læsses som bulk (fabrik med både læssestation og pallespawner).
|
||||||
local function newProduct(fillType, available, level, capacity, isPallet)
|
local function newProduct(fillType, available, level, capacity, isPallet)
|
||||||
local name = g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(fillType) or tostring(fillType)
|
local name = g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(fillType) or tostring(fillType)
|
||||||
local title = g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeTitleByIndex ~= nil and g_fillTypeManager:getFillTypeTitleByIndex(fillType) or nil
|
local title = g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeTitleByIndex ~= nil and g_fillTypeManager:getFillTypeTitleByIndex(fillType) or nil
|
||||||
return {fillType = fillType, name = name, title = title or name, available = available, level = level, capacity = capacity, isPallet = isPallet}
|
return {fillType = fillType, name = name, title = title or name, available = available, level = level, capacity = capacity, isPallet = isPallet, canPallet = isPallet or ADSources.isPalletFillType(fillType), palletLiters = 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getFactoryProducts(source, farmId)
|
local function getFactoryProducts(source, farmId)
|
||||||
@@ -202,8 +204,11 @@ local function getFactoryProducts(source, farmId)
|
|||||||
local level = storage ~= nil and storage.getFillLevel ~= nil and (storage:getFillLevel(fillType) or 0) or 0
|
local level = storage ~= nil and storage.getFillLevel ~= nil and (storage:getFillLevel(fillType) or 0) or 0
|
||||||
local capacity = storage ~= nil and storage.getCapacity ~= nil and (storage:getCapacity(fillType) or 0) or 0
|
local capacity = storage ~= nil and storage.getCapacity ~= nil and (storage:getCapacity(fillType) or 0) or 0
|
||||||
local isPallet = ADSources.isPalletAt(source, fillType)
|
local isPallet = ADSources.isPalletAt(source, fillType)
|
||||||
local available = level + (isPallet and getPalletsNearSpawner(source.placeable, fillType, farmId) or 0)
|
local palletLiters = ADSources.isPalletFillType(fillType) and getPalletsNearSpawner(source.placeable, fillType, farmId) or 0
|
||||||
table.insert(products, newProduct(fillType, available, level, capacity, isPallet))
|
local available = level + (isPallet and palletLiters or 0)
|
||||||
|
local product = newProduct(fillType, available, level, capacity, isPallet)
|
||||||
|
product.palletLiters = palletLiters
|
||||||
|
table.insert(products, product)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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.12.2.0</version>
|
<version>1.12.3.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
@@ -413,6 +413,22 @@ local input18 = ADOutbound.buildPlanInput(adEnv, runs[v18], v18)
|
|||||||
check("O18 palle-lager som store-mål", input18.products[1].store ~= nil and input18.products[1].store.wayPointId, 40)
|
check("O18 palle-lager som store-mål", input18.products[1].store ~= nil and input18.products[1].store.wayPointId, 40)
|
||||||
check("O18 reserve spørges ikke for lager-politik", demandCalls[#demandCalls] ~= BASKET, true)
|
check("O18 reserve spørges ikke for lager-politik", demandCalls[#demandCalls] ~= BASKET, true)
|
||||||
|
|
||||||
|
-- O19: pallebil (kun UAL) ved en fabrik der både har bulk-læssestation og sukkerpaller -> paller
|
||||||
|
local v19 = newVehicle("Dragon", 0, 0, 6000, true)
|
||||||
|
v19.carriable = {}
|
||||||
|
runs[v19] = outboundRun(19, {1}, {{fillType = "SUGAR", policy = "sell"}})
|
||||||
|
products[1] = {{fillType = SUGAR, name = "SUGAR", available = 150000, level = 150000, capacity = 180000, isPallet = false, canPallet = true, palletLiters = 3000}}
|
||||||
|
quotes["selling station"][SUGAR].percent = 92
|
||||||
|
local input19 = ADOutbound.buildPlanInput(adEnv, runs[v19], v19)
|
||||||
|
check("O19 varen tages som paller", input19.products[1] ~= nil and input19.products[1].isPallet, true)
|
||||||
|
check("O19 mængde = paller ved spawner", input19.products[1].sources[1].available, 3000)
|
||||||
|
local v19b = newVehicle("Tipvogn", 0, 0, 20000)
|
||||||
|
runs[v19b] = outboundRun(20, {1}, {{fillType = "SUGAR", policy = "sell"}})
|
||||||
|
local input19b = ADOutbound.buildPlanInput(adEnv, runs[v19b], v19b)
|
||||||
|
check("O19 tipvogn tager bulk", input19b.products[1].isPallet, false)
|
||||||
|
check("O19 bulk-mængde", input19b.products[1].sources[1].available, 150000)
|
||||||
|
products[1] = {{fillType = SUGAR, name = "SUGAR", available = 5000, level = 5000, capacity = 180000, isPallet = false}}
|
||||||
|
|
||||||
-- O10: install wrapper: fejl i hook stopper ikke AD
|
-- O10: install wrapper: fejl i hook stopper ikke AD
|
||||||
local calls = {}
|
local calls = {}
|
||||||
adEnv.LoadAtDestinationTask.update = function(self, dt) calls.update = (calls.update or 0) + 1 end
|
adEnv.LoadAtDestinationTask.update = function(self, dt) calls.update = (calls.update or 0) + 1 end
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ check("S1 SUGAR available", products1[1].available, 150000)
|
|||||||
check("S1 SUGAR level", products1[1].level, 150000)
|
check("S1 SUGAR level", products1[1].level, 150000)
|
||||||
check("S1 SUGAR capacity", products1[1].capacity, 180000)
|
check("S1 SUGAR capacity", products1[1].capacity, 180000)
|
||||||
check("S1 SUGAR bulk", products1[1].isPallet, false)
|
check("S1 SUGAR bulk", products1[1].isPallet, false)
|
||||||
|
check("S1 SUGAR kan også stå på paller", products1[1].canPallet, true)
|
||||||
|
check("S1 SUGAR paller ved spawner (ingen endnu)", products1[1].palletLiters, 0)
|
||||||
|
check("S1 TMR-lignende bulk kan ikke paller", products1[2].canPallet, true)
|
||||||
check("S1 BASKET er palle", products1[2].isPallet, true)
|
check("S1 BASKET er palle", products1[2].isPallet, true)
|
||||||
check("S1 BASKET tomt", products1[2].available, 0)
|
check("S1 BASKET tomt", products1[2].available, 0)
|
||||||
|
|
||||||
@@ -155,6 +158,10 @@ addPallet(BASKET, 1000, 112, 102, 2) -- anden farm: tæller ikke
|
|||||||
local products4 = ADSources.getProducts(adEnv, source1, 1)
|
local products4 = ADSources.getProducts(adEnv, source1, 1)
|
||||||
check("S4 paller ved spawner", products4[2].available, 2000)
|
check("S4 paller ved spawner", products4[2].available, 2000)
|
||||||
check("S4 bulk uændret", products4[1].available, 150000)
|
check("S4 bulk uændret", products4[1].available, 150000)
|
||||||
|
addPallet(SUGAR, 2000, 111, 101)
|
||||||
|
local products4b = ADSources.getProducts(adEnv, source1, 1)
|
||||||
|
check("S4 sukkerpaller tælles separat", products4b[1].palletLiters, 2000)
|
||||||
|
check("S4 bulk-mængde uden paller", products4b[1].available, 150000)
|
||||||
|
|
||||||
-- S5: salgssteder = kun markører hvis aflæsningsstation er et rigtigt salgssted
|
-- S5: salgssteder = kun markører hvis aflæsningsstation er et rigtigt salgssted
|
||||||
local sells = ADSources.getSellMarkers(adEnv, 1)
|
local sells = ADSources.getSellMarkers(adEnv, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user