diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index ff71024..bbae76a 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -979,10 +979,23 @@ end -- esegue le strategie migliori che ha precedentemente scelto local function CalculateMachinings( vProc, Part) local bAreAllApplyOk = true + local CurrRotation = 1 -- applico le strategie scelte for i = 1, #vProc do -- processo tutte le feature attive applicando le lavorazioni local Proc = vProc[i] + -- si sistemano i pezzi per le rotazioni + if Proc.bDown and CurrRotation ~= 3 then + BeamLib.RotatePart( Part, 3 - CurrRotation) + CurrRotation = 3 + elseif Proc.bSide and CurrRotation ~= 2 then + BeamLib.RotatePart( Part, 2 - CurrRotation) + CurrRotation = 2 + elseif CurrRotation ~= 1 then + BeamLib.RotatePart( Part, 1 - CurrRotation) + CurrRotation = 1 + end + -- 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) local StrategyScriptName = Proc.ChosenStrategy.sStrategyId .. '\\' .. Proc.ChosenStrategy.sStrategyId @@ -1032,20 +1045,8 @@ function BeamExec.GetProcessings( PARTS) -- inserisco una tabella vuota table.insert( vProcRot, {}) end - - -- ruoto il grezzo per calcolare la fattibilità delle lavorazioni nella prossima rotazione - -- vettore movimento grezzi per rotazione di 90deg ogni step - local dDeltaYZ = PARTS[nPart].b3Raw:getDimY() - PARTS[nPart].b3Raw:getDimZ() - local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) - local bPreMove = ( dDeltaYZ < 0) - -- ruoto le travi della fase corrente - if bPreMove then - EgtMoveRawPart( PARTS[nPart].idRaw, vtMove) - end - EgtRotateRawPart( PARTS[nPart].idRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) - if not bPreMove then - EgtMoveRawPart( PARTS[nPart].idRaw, vtMove) - end + -- rotazione pezzo di 90° per volta + BeamLib.RotatePart( PARTS[nPart], 1) -- aggiorno info pezzo PARTS[nPart].b3Raw = EgtGetRawPartBBox( PARTS[nPart].idRaw) PARTS[nPart].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[nPart].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) @@ -1314,6 +1315,11 @@ function BeamExec.ProcessMachinings( PARTS) PROCESSINGS[nPart].Rotation[dRotIndex] = CalculateStrategies( PROCESSINGS[nPart].Rotation[dRotIndex], PARTS[nPart]) -- tra le calcolate, sceglie la migliore PROCESSINGS[nPart].Rotation[dRotIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[dRotIndex]) + -- rotazione pezzo di 90° per volta + BeamLib.RotatePart( PARTS[nPart], 1) + -- aggiorno info pezzo + PARTS[nPart].b3Raw = EgtGetRawPartBBox( PARTS[nPart].idRaw) + PARTS[nPart].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[nPart].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) end -- scrittura nel log del risultato della scelta della strategia migliore tra quelle disponibili @@ -1360,10 +1366,12 @@ function BeamExec.ProcessMachinings( PARTS) EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( PARTS[nPart].idRaw) .. ' Part=' .. tostring( PARTS[nPart].id) .. ' ***', 1) -- creazione effettiva delle lavorazioni + local nCurrPosition = 1 -- se c'è almeno una lavorazione in posizionamento con trave ribaltata if bSomeFeatureDown then local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2) - BeamLib.RotatePart( PARTS[nPart], nRotation) + BeamLib.RotatePart( PARTS[nPart], nRotation - nCurrPosition) + nCurrPosition = nRotation EgtSetInfo( nDispId, 'ROT', -2) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'DOWN') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1385,7 +1393,8 @@ function BeamExec.ProcessMachinings( PARTS) end end local nRotation = EgtIf( nInitialPosition + 1 > 4, nInitialPosition + 1 - 4, nInitialPosition + 1) - BeamLib.RotatePart( PARTS[nPart], nRotation) + BeamLib.RotatePart( PARTS[nPart], nRotation - nCurrPosition) + nCurrPosition = nRotation EgtSetInfo( nDispId, 'ROT', -1) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'SIDE') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1405,7 +1414,7 @@ function BeamExec.ProcessMachinings( PARTS) end end - BeamLib.RotatePart( PARTS[nPart], nInitialPosition) + BeamLib.RotatePart( PARTS[nPart], nInitialPosition - 1) -- aggiunta lavorazioni in ultima fase MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 27a275b..15b74cf 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -143,12 +143,12 @@ end ------------------------------------------------------------------------------------------------------------- --- funzione che ruota il pezzo, da lanciare per creare la disposizione corretta -function BeamLib.RotatePart( Part, nPosition) +function BeamLib.RotatePart( Part, nNumberOfRotations) -- primo posizionamento - if nPosition == 1 then + if nNumberOfRotations == 0 then ; -- il pezzo è già in posizione -- rotazione 90° - elseif nPosition == 2 then + elseif abs( nNumberOfRotations) == 1 then local dDeltaYZ = EgtGetRawPartBBox( Part.idRaw):getDimY() - EgtGetRawPartBBox( Part.idRaw):getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = dDeltaYZ < 0 @@ -161,7 +161,7 @@ function BeamLib.RotatePart( Part, nPosition) nRId = EgtGetNextRawPart( nRId) end -- rotazione 180° - elseif nPosition == 3 then + elseif abs( nNumberOfRotations) == 2 then -- ribalto le travi della fase corrente local nRId = Part.idRaw while nRId do @@ -169,7 +169,7 @@ function BeamLib.RotatePart( Part, nPosition) nRId = EgtGetNextRawPart( nRId) end -- rotazione 270° - elseif nPosition == 4 then + elseif abs( nNumberOfRotations) == 3 then local dDeltaYZ = EgtGetRawPartBBox( Part.idRaw):getDimY() - EgtGetRawPartBBox( Part.idRaw):getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = dDeltaYZ < 0 diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 791abf9..c58b7c2 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -351,11 +351,16 @@ function FeatureLib.GetFeatureQuality( sTypeTools) end ------------------------------------------------------------------------------------------------------------- +-- TODO rivedere affidabilità del calcolo del composite rating -- funzione che calcola il 'CompositeRating' di ogni strategia function FeatureLib.CalculateCompositeRating( StrategyResult) -- se ho tutti i dati che mi servono calcolo il rating della strategia applicato alla feature if StrategyResult and StrategyResult.nQuality and StrategyResult.nCompletionIndex and StrategyResult.dMRR then - StrategyResult.dCompositeRating = ceil( StrategyResult.nQuality * StrategyResult.nCompletionIndex * StrategyResult.dMRR) + -- indice bonta lavorazione feature in rotazione è opzionale, se non settato viene messo a 3 + if not StrategyResult.nFeatureRotationIndex then + StrategyResult.nFeatureRotationIndex = 3 + end + StrategyResult.dCompositeRating = ceil( StrategyResult.nQuality * StrategyResult.nCompletionIndex * StrategyResult.dMRR * StrategyResult.nFeatureRotationIndex) else StrategyResult.dCompositeRating = 0 end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index cf9f535..eea32ce 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -710,18 +710,12 @@ function MachiningLib.AddOperations( vProc, Part, sRotation) local nDispId = EgtGetPhaseDisposition( nPhase) if sRotation == 'DOWN' then - local nRotation = EgtIf( Part.nInitialPosition + 2 > 4, Part.nInitialPosition + 2 - 4, Part.nInitialPosition + 2) - BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'ROT', -2) EgtSetInfo( nDispId, 'TYPE', 'MID2') elseif sRotation == 'SIDE' then - local nRotation = EgtIf( Part.nInitialPosition + 1 > 4, Part.nInitialPosition + 1 - 4, Part.nInitialPosition + 1) - BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'ROT', -1) EgtSetInfo( nDispId, 'TYPE', 'MID2') else - local nRotation = Part.nInitialPosition - BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'TYPE', 'END') end EgtSetInfo( nDispId, 'ORD', MACHININGS[i].Proc.nIndexPartInParts)