- Prima versione per riprocessare il calcolo lavorazioni in caso l'applicazione di una (o più lavorazioni) abbia dato errore.

- Per ora cancella la ChosenStrategy, come se non avesse trovato alcuna strategia di sponibile
This commit is contained in:
andrea.villa
2026-02-09 15:20:21 +01:00
parent 70cfdd056f
commit 1c24f1046d
4 changed files with 251 additions and 209 deletions
+205 -189
View File
@@ -1146,7 +1146,6 @@ end
-------------------------------------------------------------------------------------------------------------
-- esegue le strategie migliori che ha precedentemente scelto
local function CalculateMachinings( vProc, Part, nInitialRotation)
local bAreAllApplyOk = true
local n0Rotation = nInitialRotation
local n90Rotation = nInitialRotation + 1
if n90Rotation > 4 then n90Rotation = n90Rotation - 4 end
@@ -1200,7 +1199,7 @@ local function CalculateMachinings( vProc, Part, nInitialRotation)
Part.b3Raw = EgtGetRawPartBBox( Part.idRaw)
Part.b3Part = EgtGetBBoxGlob( Part.idBoxTm, GDB_BB.STANDARD)
end
return MACHININGS, bAreAllApplyOk
return MACHININGS
end
-------------------------------------------------------------------------------------------------------------
@@ -1430,7 +1429,6 @@ end
-------------------------------------------------------------------------------------------------------------
-- funzione che calcola le combinazioni di rotazione per lavorare la trave e sceglie la migliore
local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
local BestCombination = {}
local CombinationsList = { dAllCombinationsTotalTime = 0}
-- calcolo per tutte le combinazioni disponibili precedentemente verificate
@@ -1580,191 +1578,219 @@ function BeamExec.ProcessMachinings( PARTS)
local nTotErr = 0
local Stats = {}
local nOrd = 1
local nMaxReprocessCycles = EgtClamp( GENERAL_PARAMETERS.PROJECT.GEN_nMaxReprocessCycles, 1, 3)
local bTryToReProcess = false
-- ricerca strategia di lavorazione per ogni pezzo e applicazione lavorazioni
for nPart = 1, #PARTS do
local nCycles = 1
local bProcess = true
-- scrittura nel log del risultato della scelta della strategia migliore tra quelle disponibili
if EgtGetDebugLevel() >= 3 then
Logs.WriteFeaturesLog( PROCESSINGS[nPart], PARTS[nPart])
end
local bAllStrategiesApplied = false
-- si ricavano tutte le combinazioni possibili
local CombinationListFromMatrix = GetCombinationListFromMatrix( PROCESSINGS[nPart], PARTS[nPart])
-- ci deve essere almeno una combinazione, altrimenti errore
if #CombinationListFromMatrix < 1 then
error( 'UNEXPECTED ERROR: NO combinations available')
end
-- scelta delal migliore combinazione
local BestCombination = GetBestCombination( CombinationListFromMatrix, PARTS[nPart])
PARTS[nPart].ChosenCombination = BestCombination.sBitIndexCombination
PARTS[nPart].bPartInCombiIsInverted = BestCombination.bPartInCombiIsInverted
-- scrittura nel log delle combinazioni possibili
if EgtGetDebugLevel() >= 3 then
Logs.WriteCombinationLog( CombinationListFromMatrix, BestCombination)
end
-- compilazione della vProc finale contenente le feature da lavorare nella giusta rotazione
local vProc, MatrixResult = GetProcessingListFromCombination( BestCombination)
-- si mette subito il pezzo nella fase
if nOrd == 1 then
EgtSetCurrPhase( 1)
local nPhase = EgtGetCurrPhase()
-- salvo info nuova fase aggiunta
local MachExtraInfo = { sType = 'DISP',
nPhase = nPhase}
table.insert( DB_MACH_APPLIED, MachExtraInfo)
else
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
end
-- si sposta il pezzo nella posizione originale, di quando è stata fatta la collect. In questo modo tutti i dati calcolati nella collect restano validi.
-- Altrimenti bisognava ricalcolare tutto, aumentando tempo di calcolo.
local vtRawOffsetPos = PARTS[nPart].b3Raw:getMin() - EgtGetRawPartBBox( PARTS[nPart].idRaw):getMin()
local nRawId = PARTS[nPart].idRaw
while nRawId and abs( vtRawOffsetPos:len()) > 0 do
EgtKeepRawPart( nRawId)
EgtMoveRawPart( nRawId, vtRawOffsetPos)
nRawId = EgtGetNextRawPart( nRawId)
end
-- se combinazione prevede inversione, si gira il pezzo
if PARTS[nPart].bPartInCombiIsInverted then
BeamLib.InvertRawPart( PARTS[nPart], 2)
end
-- debug
if EgtGetDebugLevel() >= 1 then
PrintFeatures( vProc, PARTS[nPart])
end
EgtOutLog( ' *** AddMachinings ***', 1)
-- se la posizione iniziale non è calcolata, significa che non ci sono feature da eseguire. Solo taglio testa/coda
if not MatrixResult.nInitialPosition then
MatrixResult.nInitialPosition = 1
MACHININGS.Info.nHeadCutRotation = 1
MACHININGS.Info.nSplitCutRotation = 1
-- anche se non ci sono feature da eseguire, bisogna comunque scrivrere i risultati
for nProc = 1, #vProc do
AddFeatureResultToGlobalList( vProc[nProc])
while bProcess do
-- scrittura nel log del risultato della scelta della strategia migliore tra quelle disponibili
if EgtGetDebugLevel() >= 3 then
Logs.WriteFeaturesLog( PROCESSINGS[nPart], PARTS[nPart])
end
-- altrimenti si fanno tutti i calcoli
else
-- TODO serve ancora ordinare le feature con nuovo metodo di calcolo ottimizzazione lavorazioni?
-- ordinamento di base delle feature
vProc = OrderFeatures( vProc)
-- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale
bAllStrategiesApplied = false
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProc, PARTS[nPart], MatrixResult.nInitialPosition)
-- se non sono sono settate le rotazioni di lavorazione di testa e coda, significa che le feature da eseguire non sono state eseguite per qualche problema. Si forza rotazione 1
if not MACHININGS.Info.nHeadCutRotation or not MACHININGS.Info.nSplitCutRotation then
-- si ricavano tutte le combinazioni possibili
local CombinationListFromMatrix = GetCombinationListFromMatrix( PROCESSINGS[nPart], PARTS[nPart])
-- ci deve essere almeno una combinazione, altrimenti errore
if #CombinationListFromMatrix < 1 then
error( 'UNEXPECTED ERROR: NO combinations available')
end
-- scelta della migliore combinazione
local BestCombination = GetBestCombination( CombinationListFromMatrix, PARTS[nPart])
PARTS[nPart].ChosenCombination = BestCombination.sBitIndexCombination
PARTS[nPart].bPartInCombiIsInverted = BestCombination.bPartInCombiIsInverted
-- scrittura nel log delle combinazioni possibili
if EgtGetDebugLevel() >= 3 then
Logs.WriteCombinationLog( CombinationListFromMatrix, BestCombination)
end
-- compilazione della vProc finale contenente le feature da lavorare nella giusta rotazione
local vProc, MatrixResult = GetProcessingListFromCombination( BestCombination)
-- si mette subito il pezzo nella fase
if nOrd == 1 then
EgtSetCurrPhase( 1)
local nPhase = EgtGetCurrPhase()
-- salvo info nuova fase aggiunta
local MachExtraInfo = { sType = 'DISP',
nPhase = nPhase}
table.insert( DB_MACH_APPLIED, MachExtraInfo)
else
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
end
-- si sposta il pezzo nella posizione originale, di quando è stata fatta la collect. In questo modo tutti i dati calcolati nella collect restano validi.
-- Altrimenti bisognava ricalcolare tutto, aumentando tempo di calcolo.
local vtRawOffsetPos = PARTS[nPart].b3Raw:getMin() - EgtGetRawPartBBox( PARTS[nPart].idRaw):getMin()
local nRawId = PARTS[nPart].idRaw
while nRawId and abs( vtRawOffsetPos:len()) > 0 do
EgtKeepRawPart( nRawId)
EgtMoveRawPart( nRawId, vtRawOffsetPos)
nRawId = EgtGetNextRawPart( nRawId)
end
-- se combinazione prevede inversione, si gira il pezzo
if PARTS[nPart].bPartInCombiIsInverted then
BeamLib.InvertRawPart( PARTS[nPart], 2)
end
-- debug
if EgtGetDebugLevel() >= 1 then
PrintFeatures( vProc, PARTS[nPart])
end
EgtOutLog( ' *** AddMachinings ***', 1)
-- se la posizione iniziale non è calcolata, significa che non ci sono feature da eseguire. Solo taglio testa/coda
if not MatrixResult.nInitialPosition then
MatrixResult.nInitialPosition = 1
MACHININGS.Info.nHeadCutRotation = 1
MACHININGS.Info.nSplitCutRotation = 1
-- anche se non ci sono feature da eseguire, bisogna comunque scrivrere i risultati
for nProc = 1, #vProc do
AddFeatureResultToGlobalList( vProc[nProc])
end
-- altrimenti si fanno tutti i calcoli
else
-- TODO serve ancora ordinare le feature con nuovo metodo di calcolo ottimizzazione lavorazioni?
-- 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], MatrixResult.nInitialPosition)
-- se non sono sono settate le rotazioni di lavorazione di testa e coda, significa che le feature da eseguire non sono state eseguite per qualche problema. Si forza rotazione 1
if not MACHININGS.Info.nHeadCutRotation or not MACHININGS.Info.nSplitCutRotation then
MACHININGS.Info.nHeadCutRotation = 1
MACHININGS.Info.nSplitCutRotation = 1
end
end
end
-- salvo sul PART la posizione di partenza che è stata scelta
PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition
-- salvo sul PART la posizione di partenza che è stata scelta
PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition
local nOffsetIndex = EgtIf( PARTS[nPart].bPartInCombiIsInverted, 4, 0)
-- aggiunge tagli testa e coda in fasi opportune
local nRotHeadCut = MatrixResult.nInitialPosition + MACHININGS.Info.nHeadCutRotation - 1
if nRotHeadCut > 4 then
nRotHeadCut = nRotHeadCut - 4
end
nRotHeadCut = nRotHeadCut + nOffsetIndex
local nRotSplitCut = MatrixResult.nInitialPosition + MACHININGS.Info.nSplitCutRotation - 1
if nRotSplitCut > 4 then
nRotSplitCut = nRotSplitCut - 4
end
nRotSplitCut = nRotSplitCut + nOffsetIndex
-- setto nella Proc l'indice rotazione nella quale deve essere lavorata
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut
local nOffsetIndex = EgtIf( PARTS[nPart].bPartInCombiIsInverted, 4, 0)
-- aggiunge tagli testa e coda in fasi opportune
local nRotHeadCut = MatrixResult.nInitialPosition + MACHININGS.Info.nHeadCutRotation - 1
if nRotHeadCut > 4 then
nRotHeadCut = nRotHeadCut - 4
end
nRotHeadCut = nRotHeadCut + nOffsetIndex
local nRotSplitCut = MatrixResult.nInitialPosition + MACHININGS.Info.nSplitCutRotation - 1
if nRotSplitCut > 4 then
nRotSplitCut = nRotSplitCut - 4
end
nRotSplitCut = nRotSplitCut + nOffsetIndex
-- setto nella Proc l'indice rotazione nella quale deve essere lavorata
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut
-- 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
else
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = 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
else
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = true
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
else
PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = 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
else
PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = true
end
local vProcHeadTail = {}
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc])
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc])
local vProcHeadTail = {}
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc])
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc])
bAllStrategiesApplied = false
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProcHeadTail, PARTS[nPart], MatrixResult.nInitialPosition)
MACHININGS = CalculateMachinings( vProcHeadTail, PARTS[nPart], MatrixResult.nInitialPosition)
-- si preparano le lavorazioni assegnandole al proprio stage
MACHININGS = MachiningLib.PrepareMachiningsForSorting( PARTS[nPart])
-- si preparano le lavorazioni assegnandole al proprio stage
MACHININGS = MachiningLib.PrepareMachiningsForSorting( PARTS[nPart])
-- TODO queste funzioni andrebbero rimosse e utilizzato algoritmo di sorting dedicato
-- #### #### #### #### #### #### #### #### #### ####
-- ordinamento lavorazioni per stage (N.B.: potrebbe compromettere ordine lavorazioni della feature, che non può essere cambiato)
MACHININGS = BeamLib.StableSort( MACHININGS, MachiningLib.CompareMachinings)
-- dopo il sorting bisogna riverificare che ordine delle lavorazioni della feature non sia compromesso
MACHININGS = MachiningLib.FinalizeSorting()
-- #### #### #### #### #### #### #### #### #### ####
-- TODO queste funzioni andrebbero rimosse e utilizzato algoritmo di sorting dedicato
-- #### #### #### #### #### #### #### #### #### ####
-- ordinamento lavorazioni per stage (N.B.: potrebbe compromettere ordine lavorazioni della feature, che non può essere cambiato)
MACHININGS = BeamLib.StableSort( MACHININGS, MachiningLib.CompareMachinings)
-- dopo il sorting bisogna riverificare che ordine delle lavorazioni della feature non sia compromesso
MACHININGS = MachiningLib.FinalizeSorting()
-- #### #### #### #### #### #### #### #### #### ####
-- finiti i calcoli di applicazione delle lavorazioni, si riporta il pezzo nello zero della fase
nRawId = PARTS[nPart].idRaw
while nRawId and abs( vtRawOffsetPos:len()) > 0 do
EgtKeepRawPart( nRawId)
EgtMoveRawPart( nRawId, -vtRawOffsetPos)
nRawId = EgtGetNextRawPart( nRawId)
end
-- finiti i calcoli di applicazione delle lavorazioni, si riporta il pezzo nello zero della fase
nRawId = PARTS[nPart].idRaw
while nRawId and abs( vtRawOffsetPos:len()) > 0 do
EgtKeepRawPart( nRawId)
EgtMoveRawPart( nRawId, -vtRawOffsetPos)
nRawId = EgtGetNextRawPart( nRawId)
end
local bAreAllMachiningApplyOk
local sErr
local bSplitAlreadyExecuted = false
local bSplitExecutedOnRot = false
local nPhase = EgtGetCurrPhase()
local idDisp = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( idDisp, 'TYPE', 'START')
EgtSetInfo( idDisp, 'ORD', nOrd)
EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( PARTS[nPart].idRaw) .. ' Part=' .. tostring( PARTS[nPart].id) .. ' ***', 1)
local bAreAllMachiningApplyOk
local sErr
local bSplitAlreadyExecuted = false
local bSplitExecutedOnRot = false
local nPhase = EgtGetCurrPhase()
local idDisp = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( idDisp, 'TYPE', 'START')
EgtSetInfo( idDisp, 'ORD', nOrd)
EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( PARTS[nPart].idRaw) .. ' Part=' .. tostring( PARTS[nPart].id) .. ' ***', 1)
-- creazione effettiva delle lavorazioni
MACHININGS.Info = {}
local nCurrPosition = 1
local nInitialPosition = MatrixResult.nInitialPosition
-- se c'è almeno una lavorazione in posizionamento con trave ribaltata
if MatrixResult.bSomeFeatureDown then
local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2)
BeamLib.RotateRawPart( PARTS[nPart], nRotation - nCurrPosition)
nCurrPosition = nRotation
EgtSetInfo( idDisp, 'ROT', -2)
bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'DOWN')
bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot
end
-- se c'è almeno una lavorazione in posizionamento con trave ruotata
if MatrixResult.bSomeFeatureSide then
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
-- creazione effettiva delle lavorazioni
MACHININGS.Info = {}
local nCurrPosition = 1
local nInitialPosition = MatrixResult.nInitialPosition
-- se c'è almeno una lavorazione in posizionamento con trave ribaltata
if MatrixResult.bSomeFeatureDown then
local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2)
BeamLib.RotateRawPart( PARTS[nPart], nRotation - nCurrPosition)
nCurrPosition = nRotation
EgtSetInfo( idDisp, 'ROT', -2)
bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot, bTryToReProcess = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'DOWN')
bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot
bProcess = bProcess or bTryToReProcess
end
-- se c'è almeno una lavorazione in posizionamento con trave ruotata
if MatrixResult.bSomeFeatureSide then
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
if MatrixResult.bSomeFeatureDown then
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, EgtIf( bSplitAlreadyExecuted, BeamData.RAW_OFFSET, 0))
nPhase = EgtGetCurrPhase()
idDisp = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( idDisp, 'ORD', nOrd)
-- se c'è già stata separazione
if bSplitAlreadyExecuted then
EgtSetInfo( idDisp, 'TYPE', 'MID2')
else
EgtSetInfo( idDisp, 'TYPE', 'MID')
end
-- se combinazione prevede inversione, si gira il pezzo
if PARTS[nPart].bPartInCombiIsInverted and not PARTS[nPart].bIsInverted then
BeamLib.InvertRawPart( PARTS[nPart], 2)
end
end
local nRotation = EgtIf( nInitialPosition + 1 > 4, nInitialPosition + 1 - 4, nInitialPosition + 1)
BeamLib.RotateRawPart( PARTS[nPart], nRotation - nCurrPosition)
nCurrPosition = nRotation
EgtSetInfo( idDisp, 'ROT', -1)
bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot, bTryToReProcess = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'SIDE')
bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot
bProcess = bProcess or bTryToReProcess
end
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
if MatrixResult.bSomeFeatureDown or MatrixResult.bSomeFeatureSide then
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, EgtIf( bSplitAlreadyExecuted, BeamData.RAW_OFFSET, 0))
nPhase = EgtGetCurrPhase()
idDisp = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( idDisp, 'ORD', nOrd)
-- se c'è già stata separazione
if bSplitAlreadyExecuted then
EgtSetInfo( idDisp, 'TYPE', 'MID2')
EgtSetInfo( idDisp, 'TYPE', 'END2')
else
EgtSetInfo( idDisp, 'TYPE', 'MID')
end
@@ -1773,37 +1799,27 @@ function BeamExec.ProcessMachinings( PARTS)
BeamLib.InvertRawPart( PARTS[nPart], 2)
end
end
local nRotation = EgtIf( nInitialPosition + 1 > 4, nInitialPosition + 1 - 4, nInitialPosition + 1)
BeamLib.RotateRawPart( PARTS[nPart], nRotation - nCurrPosition)
nCurrPosition = nRotation
EgtSetInfo( idDisp, 'ROT', -1)
bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'SIDE')
bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot
end
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
if MatrixResult.bSomeFeatureDown or MatrixResult.bSomeFeatureSide then
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, EgtIf( bSplitAlreadyExecuted, BeamData.RAW_OFFSET, 0))
nPhase = EgtGetCurrPhase()
idDisp = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( idDisp, 'ORD', nOrd)
-- se c'è già stata separazione
if bSplitAlreadyExecuted then
EgtSetInfo( idDisp, 'TYPE', 'END2')
BeamLib.RotateRawPart( PARTS[nPart], nInitialPosition - 1)
-- aggiunta lavorazioni in ultima fase
_, _, _, bTryToReProcess = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD')
bProcess = bProcess or bTryToReProcess
-- se bisogna riprocessare, si annulla tutto
if bProcess and nCycles <= nMaxReprocessCycles then
nCycles = nCycles + 1
-- azzero liste
MACHININGS = {}
DB_MACH_APPLIED = {}
MACHININGS.Info = {}
RESULT = {}
EgtRemoveAllOperations()
else
EgtSetInfo( idDisp, 'TYPE', 'MID')
end
-- se combinazione prevede inversione, si gira il pezzo
if PARTS[nPart].bPartInCombiIsInverted and not PARTS[nPart].bIsInverted then
BeamLib.InvertRawPart( PARTS[nPart], 2)
bProcess = false
end
end
BeamLib.RotateRawPart( PARTS[nPart], nInitialPosition - 1)
-- aggiunta lavorazioni in ultima fase
MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD')
-- ottimizzazione con algoritmo ShortestPath
TIMER:startElapsed( 'Sorting')
MachiningLib.ShortestPathSorting()