- 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
|
||||
|
||||
+5
-7
@@ -5,7 +5,7 @@
|
||||
local Logs = {}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function Logs.WriteFeaturesLog( ProcessingsOnPart, PartInfo)
|
||||
function Logs.WriteFeaturesLog( ProcessingsOnPart, PartInfo, nReProcessCycles)
|
||||
|
||||
local nCycles = 1
|
||||
local nOffsetIndex = 0
|
||||
@@ -13,15 +13,13 @@ function Logs.WriteFeaturesLog( ProcessingsOnPart, PartInfo)
|
||||
nCycles = 2
|
||||
end
|
||||
|
||||
EgtOutLog( ' === === === === === === === === === === REPRECESS CYCLES ' .. EgtNumToString( nReProcessCycles) .. ' === === === === === === === === === === === ===')
|
||||
EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===')
|
||||
for nCycle = 1, nCycles do
|
||||
local nStartIndex = 1 + nOffsetIndex
|
||||
local nEndIndex = 4 + nOffsetIndex
|
||||
if nCycle == 1 then
|
||||
EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===')
|
||||
else
|
||||
EgtOutLog( ' === === === === === === === === === === === === === === === === === === === === === === === === === === ===')
|
||||
EgtOutLog( ' === === === === === === === === FEATURES STRATEGIES PIECE INVERTED === === === === === === === === === ===')
|
||||
end
|
||||
EgtOutLog( ' === === === === === === === === === === === === === === === === === === === === === === === === === === ===')
|
||||
EgtOutLog( ' === === === === === === === === FEATURES STRATEGIES PIECE INVERTED === === === === === === === === === ===')
|
||||
EgtOutLog( ' Feature ID | BTL POSITION | 90 ROTATION | 180 ROTATION | 270 ROTATION |')
|
||||
EgtOutLog( '----------------------------------------------------------------------------------------------------------')
|
||||
|
||||
|
||||
@@ -1145,15 +1145,15 @@ end
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che verifica se ha senso riprocessare tutto dall'inizio,
|
||||
-- perchè ci sono buone probabilità che l'errore trovato in fase di applicazione si possa risolvere (escludendo la lavorazione scelta in precedenza)
|
||||
local function IsReprocessWorthIt( nError)
|
||||
local bReprocess = false
|
||||
local function IsReProcessWorthIt( nError)
|
||||
local bReProcess = false
|
||||
|
||||
-- errori di Extra-corsa
|
||||
if nError == 2110 or nError == 2216 or nError == 2318 or nError == 2424 or nError == 2508 then
|
||||
bReprocess = true
|
||||
bReProcess = true
|
||||
end
|
||||
|
||||
return bReprocess
|
||||
return bReProcess
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -1163,7 +1163,7 @@ function MachiningLib.AddOperations( MACHININGS, Part, sRotation)
|
||||
local sErr = ''
|
||||
local bAreAllMachiningApplyOk = true
|
||||
local bSplitExecuted = false
|
||||
local bTryToReprocess = false
|
||||
local bTryToReProcess = false
|
||||
|
||||
-- parametri generali lavorazione
|
||||
local MachiningParameters = {
|
||||
@@ -1366,8 +1366,8 @@ function MachiningLib.AddOperations( MACHININGS, Part, sRotation)
|
||||
CurrProc.AvailableStrategies[CurrProc.nIndexBestStrategy].Result.sStatus = 'Not-Applicable'
|
||||
CurrProc.ChosenStrategy= nil
|
||||
-- si verifica se vale la pena riprocessare tutto (perchè si pensa possa risolvere il problema)
|
||||
if IsReprocessWorthIt( nErr) then
|
||||
bTryToReprocess = true
|
||||
if IsReProcessWorthIt( nErr) then
|
||||
bTryToReProcess = true
|
||||
end
|
||||
-- update risultati
|
||||
-- TODO è corretto mettere non applicabile????? disattivare e dare un'incompleta gialla?
|
||||
@@ -1470,13 +1470,13 @@ function MachiningLib.AddOperations( MACHININGS, Part, sRotation)
|
||||
EgtSetInfo( idDisp, 'TCING', Part.NotClampableLength[sRotation].dTail or 0)
|
||||
end
|
||||
|
||||
return bAreAllMachiningApplyOk, sErr, bSplitExecuted, bTryToReprocess
|
||||
return bAreAllMachiningApplyOk, sErr, bSplitExecuted, bTryToReProcess
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function MachiningLib.ApplyMachining( bRecalc, bApplyPost)
|
||||
local bResult = EgtApplyMachining( bRecalc, bApplyPost)
|
||||
|
||||
|
||||
return bResult
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
EgtEnableDebug( false)
|
||||
|
||||
-- Imposto direttorio libreria specializzata per Travi
|
||||
EgtAddToPackagePath( BEAM.BASEDIR .. '\\LuaLibs\\?.lua')
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
},
|
||||
{
|
||||
"nGroup": "MACHINING STRATEGY",
|
||||
"sName": "GEN_nMaxReprocessCycles",
|
||||
"sName": "GEN_nMaxReProcessCycles",
|
||||
"sNameNge": "MAX_REPROCESS_CYCLES",
|
||||
"sValue": "1",
|
||||
"sDescriptionShort": "Max number of reprocessing cycles",
|
||||
|
||||
Reference in New Issue
Block a user