Merge branch 'master' into develop

This commit is contained in:
luca.mazzoleni
2022-07-06 08:52:45 +02:00
+10 -4
View File
@@ -163,7 +163,7 @@ for nIndex, nQty in pairs( QTY) do
Raws[tonumber(nIndex)].Count = nQty
end
local nTotRaws = Raws.Count
--local nTotRaws = Raws.Count
-- Pezzi
local Parts = {}
@@ -181,7 +181,7 @@ local dTotPartLen = TotPartLen( Parts)
-- calcolo media delle barre necessarie
local NeededRawsForType = {}
for RawIndex = 1, #Raws do
NeededRawsForType[RawIndex] = ceil( dTotPartLen / Raws[RawIndex].LenToFill)
NeededRawsForType[RawIndex] = min( ceil( dTotPartLen / Raws[RawIndex].LenToFill), Raws[RawIndex].Count)
end
local RawQtySum = 0
for NeededRawIndex = 1, #NeededRawsForType do
@@ -256,20 +256,26 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do
-- Eseguo ottimizzazione per ogni lunghezza di barra
local Results = {}
for RawIndex = 1, #Raws do
if Raws[RawIndex].Count > 0 then
Results[RawIndex] = ExecMaximumFilling( Raws[RawIndex], PartsToNest)
else
Results[RawIndex] = { FillRatio = 0.001, LenToFill = 1000}
end
end
-- verifico quale e' quella con meno scarto
local nMinWasteRawIndex = GDB_ID.NULL
local dMinWaste = 100000
for ResultIndex = 1, #Results do
if Results[ResultIndex] then
local dWaste = (1 - Results[ResultIndex].FillRatio) * Raws[ResultIndex].LenToFill
if dWaste < dMinWaste then
dMinWaste = dWaste
nMinWasteRawIndex = ResultIndex
end
end
end
-- verifico se ci sono pezzi
if Results[nMinWasteRawIndex].DiffParts > 0 then
if nMinWasteRawIndex > 0 and Results[nMinWasteRawIndex] and Results[nMinWasteRawIndex].DiffParts > 0 then
-- creo gruppo di lavorazione
local MachGroupName = NewMachGroupName()
nMachGroup = EgtAddMachGroup( MachGroupName)
@@ -295,12 +301,12 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do
end
end
nRawTot = nRawTot + 1
end
-- Aggiorno per prossima iterazione
Raws[nMinWasteRawIndex].Count = Raws[nMinWasteRawIndex].Count - 1
for i = 1, Results[nMinWasteRawIndex].DiffParts do
local PartId = Results[nMinWasteRawIndex].Data[i].Id
PartsToNest[PartId].Cnt = PartsToNest[PartId].Cnt - Results[nMinWasteRawIndex].Data[i].Count
end
end
nCycle = nCycle + 1
end