- GetBestStrategy suddivisa in : GetBestStrategyFromProcList e GetFeatureBestStrategy
- Se si deve riprocessare, si riporta il pezzo in posizione originale - in GetCombinationListFromMatrix si ricalcola la migliore strategia in caso ChosenStrategy non presente (solo se ReProcess) - Piccole migliorie
This commit is contained in:
+48
-29
@@ -905,26 +905,34 @@ end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che trova la strategia migliore tra quelle disponibili
|
||||
local function GetBestStrategy( vProcSingleRot, Part)
|
||||
local function GetFeatureBestStrategy( Proc, Part)
|
||||
if Proc.nFlg ~= 0 then
|
||||
local nIndexBestStrategy = 0
|
||||
-- controllo se ci sono strategie disponibili
|
||||
if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then
|
||||
-- ciclo tutte le strategie della feature
|
||||
for nIndexCurrentStrategy = 1, #Proc.AvailableStrategies do
|
||||
-- scelgo la migliore strategia tra le due
|
||||
nIndexBestStrategy = GetIndexBestStrategyFromComparison( Proc.AvailableStrategies, Part, nIndexCurrentStrategy, nIndexBestStrategy)
|
||||
-- salvo sulla proc la migliore strategia
|
||||
end
|
||||
if nIndexBestStrategy ~= 0 then
|
||||
Proc.ChosenStrategy = BeamLib.TableCopyDeep( Proc.AvailableStrategies[nIndexBestStrategy])
|
||||
Proc.nIndexBestStrategy = nIndexBestStrategy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Proc
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che trova la strategia migliore tra quelle disponibili
|
||||
local function GetBestStrategyFromProcList( vProcSingleRot, Part)
|
||||
for i = 1, #vProcSingleRot do
|
||||
-- processo tutte le feature attive
|
||||
local Proc = vProcSingleRot[i]
|
||||
if Proc.nFlg ~= 0 then
|
||||
local nIndexBestStrategy = 0
|
||||
-- controllo se ci sono strategie disponibili
|
||||
if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then
|
||||
-- ciclo tutte le strategie della feature
|
||||
for nIndexCurrentStrategy = 1, #Proc.AvailableStrategies do
|
||||
-- scelgo la migliore strategia tra le due
|
||||
nIndexBestStrategy = GetIndexBestStrategyFromComparison( Proc.AvailableStrategies, Part, nIndexCurrentStrategy, nIndexBestStrategy)
|
||||
-- salvo sulla proc la migliore strategia
|
||||
end
|
||||
if nIndexBestStrategy ~= 0 then
|
||||
Proc.ChosenStrategy = BeamLib.TableCopyDeep( Proc.AvailableStrategies[nIndexBestStrategy])
|
||||
Proc.nIndexBestStrategy = nIndexBestStrategy
|
||||
end
|
||||
end
|
||||
end
|
||||
Proc = GetFeatureBestStrategy( Proc, Part)
|
||||
end
|
||||
return vProcSingleRot
|
||||
end
|
||||
@@ -1428,7 +1436,7 @@ end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che calcola le combinazioni di rotazione per lavorare la trave e sceglie la migliore
|
||||
local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo, bReProcessEmptyChosenStrategy)
|
||||
local CombinationsList = { dAllCombinationsTotalTime = 0}
|
||||
|
||||
-- calcolo per tutte le combinazioni disponibili precedentemente verificate
|
||||
@@ -1470,13 +1478,18 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
for nRotation = 1, 3 do
|
||||
-- se rotazione abilitata da combinazione
|
||||
if string.sub( PartInfo.CombinationList[i].sBitIndexCombination, nNextRot, nNextRot) == '1' then
|
||||
local CurrProc = ProcessingsOnPart.Rotation[nNextRot+nOffsetIndex][nProc]
|
||||
-- se è ultima rotazione oppure se feature non impatta su misura laser, allora è valida e può essere effettivamente considerata
|
||||
if nNextRot == nUnloadPos or not( ProcessingsOnPart.Rotation[nNextRot+nOffsetIndex][nProc].bHindersLaserMeasure) then
|
||||
if nNextRot == nUnloadPos or not( CurrProc.bHindersLaserMeasure) then
|
||||
-- se non è settata la ChosenStrtegy, provo a cercare comunque tra quelle disponibili
|
||||
if not CurrProc.ChosenStrategy and bReProcessEmptyChosenStrategy then
|
||||
CurrProc = GetFeatureBestStrategy( CurrProc, PartInfo)
|
||||
end
|
||||
-- controllo se è stata scelta una strategia
|
||||
if ProcessingsOnPart.Rotation[nNextRot+nOffsetIndex][nProc].ChosenStrategy then
|
||||
if CurrProc.ChosenStrategy then
|
||||
local Proc = {}
|
||||
Proc.nRotation = nNextRot
|
||||
table.insert( Proc, ProcessingsOnPart.Rotation[nNextRot+nOffsetIndex][nProc])
|
||||
table.insert( Proc, CurrProc)
|
||||
table.insert( ResultsList, Proc)
|
||||
end
|
||||
end
|
||||
@@ -1554,7 +1567,7 @@ function BeamExec.GetCombinationMatrix( PARTS, bCalcBestPieceUnloadPosition)
|
||||
-- calcola le strategie applicabili
|
||||
PROCESSINGS[nPart].Rotation[nIndex] = CalculateStrategies( PROCESSINGS[nPart].Rotation[nIndex], PARTS[nPart])
|
||||
-- tra le calcolate, sceglie la migliore
|
||||
PROCESSINGS[nPart].Rotation[nIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[nIndex], PARTS[nPart])
|
||||
PROCESSINGS[nPart].Rotation[nIndex] = GetBestStrategyFromProcList( PROCESSINGS[nPart].Rotation[nIndex], PARTS[nPart])
|
||||
-- rotazione pezzo di 90° per volta
|
||||
BeamLib.RotateRawPart( PARTS[nPart], 1)
|
||||
-- aggiorno info pezzo
|
||||
@@ -1578,22 +1591,23 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
local nTotErr = 0
|
||||
local Stats = {}
|
||||
local nOrd = 1
|
||||
local nMaxReprocessCycles = EgtClamp( GENERAL_PARAMETERS.PROJECT.GEN_nMaxReprocessCycles, 1, 3)
|
||||
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
|
||||
|
||||
-- la parte di applicazione lavorazioni può essere lanciata più volte in caso della presenza di errori
|
||||
local bProcess = true
|
||||
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])
|
||||
Logs.WriteFeaturesLog( PROCESSINGS[nPart], PARTS[nPart], nCycles)
|
||||
end
|
||||
|
||||
-- si ricavano tutte le combinazioni possibili
|
||||
local CombinationListFromMatrix = GetCombinationListFromMatrix( PROCESSINGS[nPart], PARTS[nPart])
|
||||
local CombinationListFromMatrix = GetCombinationListFromMatrix( PROCESSINGS[nPart], PARTS[nPart], nCycles > 1)
|
||||
-- ci deve essere almeno una combinazione, altrimenti errore
|
||||
if #CombinationListFromMatrix < 1 then
|
||||
error( 'UNEXPECTED ERROR: NO combinations available')
|
||||
@@ -1612,7 +1626,6 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
-- 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)
|
||||
@@ -1807,14 +1820,20 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
bProcess = bProcess or bTryToReProcess
|
||||
|
||||
-- se bisogna riprocessare, si annulla tutto
|
||||
if bProcess and nCycles <= nMaxReprocessCycles then
|
||||
nCycles = nCycles + 1
|
||||
nCycles = nCycles + 1
|
||||
if bProcess and nCycles <= nMaxReProcessCycles then
|
||||
-- azzero liste
|
||||
MACHININGS = {}
|
||||
DB_MACH_APPLIED = {}
|
||||
MACHININGS.Info = {}
|
||||
RESULT = {}
|
||||
EgtRemoveAllOperations()
|
||||
-- se combinazione prevedeva inversione, si rigira il pezzo
|
||||
if PARTS[nPart].bPartInCombiIsInverted then
|
||||
BeamLib.InvertRawPart( PARTS[nPart], -2)
|
||||
end
|
||||
-- si ribalta il pezzo in posizione iniziale
|
||||
BeamLib.RotateRawPart( PARTS[nPart], 1 - nInitialPosition)
|
||||
else
|
||||
bProcess = false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user