- Corrette rotazioni pezzo durante le varie fasi di calcolo
- Prima versione tagli testa/split in fase corretta
This commit is contained in:
+122
-60
@@ -31,6 +31,7 @@ EgtMdbSave()
|
||||
TOOLS = {} -- tabella contenente tutti gli utensili
|
||||
STRATEGIES = nil -- tabella contenente le strategie disponibili per ogni feature
|
||||
MACHININGS = {} -- tabella contenente le lavorazioni da applicare
|
||||
MACHININGS.Info = {}
|
||||
PROCESSINGS = {} -- tabella contenente tutte le informazioni di ogni feature, processate per ogni rotazione
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -995,6 +996,10 @@ local function CalculateMachinings( vProc, Part)
|
||||
BeamLib.RotatePart( Part, 1 - CurrRotation)
|
||||
CurrRotation = 1
|
||||
end
|
||||
-- aggiorno info pezzo
|
||||
Part.b3Raw = EgtGetRawPartBBox( Part.idRaw)
|
||||
Part.b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Part.id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
|
||||
-- si applicano le strategie
|
||||
if Proc.nFlg ~= 0 and Proc.ChosenStrategy then
|
||||
-- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia)
|
||||
@@ -1005,6 +1010,11 @@ local function CalculateMachinings( vProc, Part)
|
||||
end
|
||||
end
|
||||
|
||||
-- ripristino pezzo in posizione originale
|
||||
if CurrRotation ~= 1 then
|
||||
BeamLib.RotatePart( Part, 1 - CurrRotation)
|
||||
CurrRotation = 1
|
||||
end
|
||||
return MACHININGS
|
||||
end
|
||||
|
||||
@@ -1114,13 +1124,18 @@ end
|
||||
-- funzione che decide le combinazioni di rotazione per lavorare la trave
|
||||
local function GetProcessingListFromCombination( BestCombination)
|
||||
local vProc = {}
|
||||
local bSomeFeatureDown = false
|
||||
local bSomeFeatureSide = false
|
||||
local nInitialPosition = BestCombination.nIndexRotation
|
||||
local ProcessingResult = {}
|
||||
ProcessingResult.bSomeFeatureDown = false
|
||||
ProcessingResult.bSomeFeatureSide = false
|
||||
ProcessingResult.nInitialPosition = BestCombination.nIndexRotation
|
||||
ProcessingResult.nIndexInCombinationList = BestCombination.nIndexInCombinationList
|
||||
ProcessingResult.nIndexHeadCutInVProc = BestCombination.nIndexHeadCutInVProc
|
||||
ProcessingResult.nIndexTailCutInVProc = BestCombination.nIndexTailCutInVProc
|
||||
|
||||
|
||||
-- aggiungo processing da fare in fase ribaltata
|
||||
if #BestCombination.Rot180 > 0 then
|
||||
bSomeFeatureDown = true
|
||||
ProcessingResult.bSomeFeatureDown = true
|
||||
for i = 1, #BestCombination.Rot180 do
|
||||
BestCombination.Rot180[i].bDown = true
|
||||
table.insert( vProc, BestCombination.Rot180[i])
|
||||
@@ -1129,7 +1144,7 @@ local function GetProcessingListFromCombination( BestCombination)
|
||||
|
||||
-- aggiungo processing da fare in fase ruotata
|
||||
if #BestCombination.Rot90 > 0 then
|
||||
bSomeFeatureSide = true
|
||||
ProcessingResult.bSomeFeatureSide = true
|
||||
for i = 1, #BestCombination.Rot90 do
|
||||
BestCombination.Rot90[i].bSide = true
|
||||
table.insert( vProc, BestCombination.Rot90[i])
|
||||
@@ -1143,7 +1158,7 @@ local function GetProcessingListFromCombination( BestCombination)
|
||||
end
|
||||
end
|
||||
|
||||
return vProc, nInitialPosition, bSomeFeatureDown, bSomeFeatureSide
|
||||
return vProc, ProcessingResult
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -1183,6 +1198,7 @@ end
|
||||
local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo)
|
||||
local BestCombination = {}
|
||||
local CombinationsList = {}
|
||||
local HeadTailProc = {}
|
||||
|
||||
-- scrittura nel log della matrice delle rotazioni
|
||||
if EgtGetDebugLevel() >= 3 then
|
||||
@@ -1209,46 +1225,56 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo)
|
||||
SingleCombination.Rot90 = {}
|
||||
SingleCombination.Rot180 = {}
|
||||
|
||||
-- ciclo su tutte le feature
|
||||
-- ciclo su tutte le feature, ad eccezione dei tagli testa/coda che dipendono dal risultato delle altre
|
||||
-- tagli testa e coda vengono aggiunti sempre alla fine
|
||||
for nProc = 1, #ProcessingsOnPart.Rotation[1] do
|
||||
-- ciclo sulle rotazioni
|
||||
local nNextRot = nUnloadPos
|
||||
local ResultsList = {}
|
||||
for nRotation = 1, 3 do
|
||||
-- se rotazione abilitata da combinazione
|
||||
if string.sub( PartInfo.CombinationList[i].sBitIndexCombination, nNextRot, nNextRot) == '1' then
|
||||
-- controllo se è stata scelta una strategia
|
||||
if ProcessingsOnPart.Rotation[nNextRot][nProc].ChosenStrategy then
|
||||
local Proc = {}
|
||||
Proc.nRotation = nNextRot
|
||||
table.insert( Proc, ProcessingsOnPart.Rotation[nNextRot][nProc])
|
||||
table.insert( ResultsList, Proc)
|
||||
if ProcessingsOnPart.Rotation[1][nProc].nPrc ~= 340 and ProcessingsOnPart.Rotation[1][nProc].nPrc ~= 350 then
|
||||
-- ciclo sulle rotazioni
|
||||
local nNextRot = nUnloadPos
|
||||
local ResultsList = {}
|
||||
for nRotation = 1, 3 do
|
||||
-- se rotazione abilitata da combinazione
|
||||
if string.sub( PartInfo.CombinationList[i].sBitIndexCombination, nNextRot, nNextRot) == '1' then
|
||||
-- controllo se è stata scelta una strategia
|
||||
if ProcessingsOnPart.Rotation[nNextRot][nProc].ChosenStrategy then
|
||||
local Proc = {}
|
||||
Proc.nRotation = nNextRot
|
||||
table.insert( Proc, ProcessingsOnPart.Rotation[nNextRot][nProc])
|
||||
table.insert( ResultsList, Proc)
|
||||
end
|
||||
end
|
||||
nNextRot = EgtIf( nNextRot + 1 > 4, nNextRot + 1 - 4, nNextRot + 1)
|
||||
end
|
||||
nNextRot = EgtIf( nNextRot + 1 > 4, nNextRot + 1 - 4, nNextRot + 1)
|
||||
end
|
||||
|
||||
-- se la feature può essere lavorata in almeno una rotazione
|
||||
if #ResultsList > 0 then
|
||||
local Proc, Data = GetProcBestMachRotationFromList( ResultsList)
|
||||
-- inserisco la Proc nell'apposita lista
|
||||
if Data.nIndexRotation == nUnloadPos then
|
||||
table.insert( SingleCombination.Rot0, Proc)
|
||||
elseif Data.nIndexRotation == nUnloadPos + 1 then
|
||||
table.insert( SingleCombination.Rot90, Proc)
|
||||
bRot90 = true
|
||||
-- se la feature può essere lavorata in almeno una rotazione
|
||||
if #ResultsList > 0 then
|
||||
local Proc, Data = GetProcBestMachRotationFromList( ResultsList)
|
||||
-- inserisco la Proc nell'apposita lista
|
||||
if Data.nIndexRotation == nUnloadPos then
|
||||
table.insert( SingleCombination.Rot0, Proc)
|
||||
elseif Data.nIndexRotation == nUnloadPos + 1 then
|
||||
table.insert( SingleCombination.Rot90, Proc)
|
||||
bRot90 = true
|
||||
else
|
||||
table.insert( SingleCombination.Rot180, Proc)
|
||||
bRot180 = true
|
||||
end
|
||||
|
||||
SingleCombination.dTotalRating = SingleCombination.dTotalRating + Data.dCompositeRating
|
||||
SingleCombination.nComplete = SingleCombination.nComplete + EgtIf( Data.bComplete, 1, 0)
|
||||
SingleCombination.nNotComplete = SingleCombination.nNotComplete + EgtIf( Data.bNotComplete, 1, 0)
|
||||
SingleCombination.nNotExecute = SingleCombination.nNotExecute + EgtIf( Data.bNotApplicable, 1, 0)
|
||||
SingleCombination.nIndexInCombinationList = i
|
||||
SingleCombination.nIndexRotation = nUnloadPos
|
||||
else
|
||||
table.insert( SingleCombination.Rot180, Proc)
|
||||
bRot180 = true
|
||||
SingleCombination.nNotExecute = SingleCombination.nNotExecute + 1
|
||||
end
|
||||
|
||||
SingleCombination.dTotalRating = SingleCombination.dTotalRating + Data.dCompositeRating
|
||||
SingleCombination.nComplete = SingleCombination.nComplete + EgtIf( Data.bComplete, 1, 0)
|
||||
SingleCombination.nNotComplete = SingleCombination.nNotComplete + EgtIf( Data.bNotComplete, 1, 0)
|
||||
SingleCombination.nNotExecute = SingleCombination.nNotExecute + EgtIf( Data.bNotApplicable, 1, 0)
|
||||
SingleCombination.nIndexRotation = nUnloadPos
|
||||
else
|
||||
SingleCombination.nNotExecute = SingleCombination.nNotExecute + 1
|
||||
if ProcessingsOnPart.Rotation[1][nProc].nPrc == 340 then
|
||||
SingleCombination.nIndexHeadCutInVProc = nProc
|
||||
elseif ProcessingsOnPart.Rotation[1][nProc].nPrc == 350 then
|
||||
SingleCombination.nIndexTailCutInVProc = nProc
|
||||
end
|
||||
end
|
||||
end
|
||||
-- aggiungo rotazioni
|
||||
@@ -1270,9 +1296,9 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo)
|
||||
Logs.WriteCombinationLog( CombinationsList, BestCombination)
|
||||
end
|
||||
|
||||
local vFinalProc, nInitialPosition, bSomeFeatureDown, bSomeFeatureSide = GetProcessingListFromCombination( BestCombination)
|
||||
local vFinalProc, BestCombinationResult = GetProcessingListFromCombination( BestCombination)
|
||||
|
||||
return vFinalProc, nInitialPosition, bSomeFeatureDown, bSomeFeatureSide
|
||||
return vFinalProc, BestCombinationResult
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -1327,23 +1353,57 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
Logs.WriteFeaturesLog( PROCESSINGS[nPart], PARTS[nPart])
|
||||
end
|
||||
|
||||
-- si calcola la combinazione di lavorazione migliore
|
||||
local vProc, nInitialPosition, bSomeFeatureDown, bSomeFeatureSide = GetBestResultFromCombinationsMatrix( PROCESSINGS[nPart], PARTS[nPart])
|
||||
-- salvo sul PART la posizione di partenza che è stata scelta
|
||||
PARTS[nPart].nInitialPosition = nInitialPosition
|
||||
local bIsCombinationMachinable = false
|
||||
local vProc, MatrixResult
|
||||
while not bIsCombinationMachinable do
|
||||
-- si calcola la combinazione di lavorazione migliore
|
||||
vProc, MatrixResult = GetBestResultFromCombinationsMatrix( PROCESSINGS[nPart], PARTS[nPart])
|
||||
-- salvo sul PART la posizione di partenza che è stata scelta
|
||||
PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition
|
||||
|
||||
-- debug
|
||||
if EgtGetDebugLevel() >= 1 then
|
||||
PrintFeatures( vProc, PARTS[nPart])
|
||||
-- debug
|
||||
if EgtGetDebugLevel() >= 1 then
|
||||
PrintFeatures( vProc, PARTS[nPart])
|
||||
end
|
||||
EgtOutLog( ' *** AddMachinings ***', 1)
|
||||
|
||||
-- ordinamento di base delle feature
|
||||
vProc = OrderFeatures( vProc)
|
||||
|
||||
-- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale
|
||||
MACHININGS = CalculateMachinings( vProc, PARTS[nPart])
|
||||
|
||||
-- TODO applicare taglio testa e coda. DA COMPLETARE
|
||||
-- aggiunge tagli testa e coda in fasi opportune
|
||||
local nRotHeadCut = MatrixResult.nInitialPosition + MACHININGS.Info.nHeadCutRotation - 1
|
||||
if nRotHeadCut > 4 then
|
||||
nRotHeadCut = nRotHeadCut - 4
|
||||
end
|
||||
local nRotSplitCut = MatrixResult.nInitialPosition + MACHININGS.Info.nSplitCutRotation - 1
|
||||
if nRotSplitCut > 4 then
|
||||
nRotSplitCut = nRotSplitCut - 4
|
||||
end
|
||||
|
||||
-- si imposta flag rotazione per taglio di testa
|
||||
if MACHININGS.Info.nHeadCutRotation == 2 then
|
||||
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bSide = true
|
||||
elseif MACHININGS.Info.nHeadCutRotation == 3 then
|
||||
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bDown = true
|
||||
end
|
||||
-- si imposta flag rotazione per taglio di coda
|
||||
if MACHININGS.Info.nSplitCutRotation == 2 then
|
||||
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bSide = true
|
||||
elseif MACHININGS.Info.nSplitCutRotation == 3 then
|
||||
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bDown = true
|
||||
end
|
||||
|
||||
local vProcHeadTail = {}
|
||||
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc])
|
||||
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc])
|
||||
|
||||
MACHININGS = CalculateMachinings( vProcHeadTail, PARTS[nPart])
|
||||
bIsCombinationMachinable = true
|
||||
end
|
||||
EgtOutLog( ' *** AddMachinings ***', 1)
|
||||
|
||||
-- ordinamento di base delle feature
|
||||
vProc = OrderFeatures( vProc)
|
||||
|
||||
-- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale
|
||||
MACHININGS = CalculateMachinings( vProc, PARTS[nPart])
|
||||
|
||||
-- ordinamento lavorazioni
|
||||
MACHININGS = MachiningLib.PrepareMachiningsForSorting( PARTS[nPart])
|
||||
-- TODO completare ordinamento. Mancano le dipendenze.
|
||||
@@ -1367,8 +1427,9 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
|
||||
-- creazione effettiva delle lavorazioni
|
||||
local nCurrPosition = 1
|
||||
local nInitialPosition = MatrixResult.nInitialPosition
|
||||
-- se c'è almeno una lavorazione in posizionamento con trave ribaltata
|
||||
if bSomeFeatureDown then
|
||||
if MatrixResult.bSomeFeatureDown then
|
||||
local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2)
|
||||
BeamLib.RotatePart( PARTS[nPart], nRotation - nCurrPosition)
|
||||
nCurrPosition = nRotation
|
||||
@@ -1378,9 +1439,9 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
end
|
||||
|
||||
-- se c'è almeno una lavorazione in posizionamento con trave ribaltata
|
||||
if bSomeFeatureSide then
|
||||
if MatrixResult.bSomeFeatureSide then
|
||||
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
|
||||
if bSomeFeatureDown then
|
||||
if MatrixResult.bSomeFeatureDown then
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
|
||||
nPhase = EgtGetCurrPhase()
|
||||
nDispId = EgtGetPhaseDisposition( nPhase)
|
||||
@@ -1401,7 +1462,7 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
end
|
||||
|
||||
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
|
||||
if bSomeFeatureDown or bSomeFeatureSide then
|
||||
if MatrixResult.bSomeFeatureDown or MatrixResult.bSomeFeatureSide then
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
|
||||
nPhase = EgtGetCurrPhase()
|
||||
nDispId = EgtGetPhaseDisposition( nPhase)
|
||||
@@ -1422,6 +1483,7 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
EgtOutLog( ' *** End AddMachinings ***', 1)
|
||||
-- azzero lavorazioni per pezzo successivo
|
||||
MACHININGS = {}
|
||||
MACHININGS.Info = {}
|
||||
-- indice pezzo successivo
|
||||
nOrd = nOrd + 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user