diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 5aedbaa..5efd0c0 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1340,10 +1340,11 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo) local BestCombination = {} local CombinationsList = {} + -- -- scrittura nel log della matrice delle rotazioni - if EgtGetDebugLevel() >= 3 then - Logs.WriteMatrixLog( ProcessingsOnPart, PartInfo) - end + --if EgtGetDebugLevel() >= 3 then + -- Logs.WriteMatrixLog( ProcessingsOnPart, PartInfo) + --end -- calcolo per tutte le combinazioni disponibili precedentemente verificate for i = 1, #PartInfo.CombinationList do @@ -1518,6 +1519,7 @@ function BeamExec.ProcessMachinings( PARTS) -- scelta delal migliore combinazione local BestCombination = GetBestCombination( CombinationListFromMatrix) PARTS[nPart].ChosenCombination = BestCombination.sBitIndexCombination + PARTS[nPart].bPartIsInverted = BestCombination.bPartIsInverted -- scrittura nel log delle combinazioni possibili if EgtGetDebugLevel() >= 3 then @@ -1544,6 +1546,11 @@ function BeamExec.ProcessMachinings( PARTS) nRawId = EgtGetNextRawPart( nRawId) end + -- se combinazione prevede inversione, si gira il pezzo + if PARTS[nPart].bPartIsInverted then + BeamLib.InvertRawPart( PARTS[nPart], 2) + end + -- debug if EgtGetDebugLevel() >= 1 then PrintFeatures( vProc, PARTS[nPart]) @@ -1672,6 +1679,10 @@ function BeamExec.ProcessMachinings( PARTS) else EgtSetInfo( idDisp, 'TYPE', 'MID') end + -- se combinazione prevede inversione, si gira il pezzo + if PARTS[nPart].bPartIsInverted 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) @@ -1693,6 +1704,10 @@ function BeamExec.ProcessMachinings( PARTS) else EgtSetInfo( idDisp, 'TYPE', 'MID') end + -- se combinazione prevede inversione, si gira il pezzo + if PARTS[nPart].bPartIsInverted then + BeamLib.InvertRawPart( PARTS[nPart], 2) + end end BeamLib.RotateRawPart( PARTS[nPart], nInitialPosition - 1) diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 5dba2d0..cdb49a5 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -269,7 +269,7 @@ function FeatureLib.GetAdditionalInfo( Proc, Part) Proc.FeatureInfo = FeatureLib.GetDrillingData( Proc) -- se tenone o tenone a coda di rondine elseif ID.IsTenon( Proc) or ID.IsDovetailTenon( Proc) then - Proc.FeatureInfo = FeatureLib.GetTenonData( Proc) + Proc.FeatureInfo, Proc.AffectedFaces = FeatureLib.GetTenonData( Proc) -- se mortasa a coda di rondine o mortasa frontale a coda di rondine elseif ID.IsDovetailMortise( Proc) or ID.IsFrontDovetailMortise( Proc) then Proc.FeatureInfo = FeatureLib.GetDTMortiseData( Proc) @@ -363,8 +363,15 @@ function FeatureLib.GetTenonData( Proc) FeatureExtraInfo.ptTenonCenter = ptC FeatureExtraInfo.idAddAuxGeom = idAux - return FeatureExtraInfo + -- aggiorno AffectedFaces in base al tipo di feature + local UpdatedAffectedFaces = Proc.AffectedFaces + if vtN:getX() > 0 then + UpdatedAffectedFaces.bRight = true + else + UpdatedAffectedFaces.bLeft = true + end + return FeatureExtraInfo, UpdatedAffectedFaces end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/Logs.lua b/LuaLibs/Logs.lua index a0e9067..76bdfa7 100644 --- a/LuaLibs/Logs.lua +++ b/LuaLibs/Logs.lua @@ -6,92 +6,108 @@ local Logs = {} ------------------------------------------------------------------------------------------------------------- function Logs.WriteFeaturesLog( ProcessingsOnPart, PartInfo) - EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===') - EgtOutLog( ' Feature ID | BTL POSITION | 90 ROTATION | 180 ROTATION | 270 ROTATION |') - EgtOutLog( '----------------------------------------------------------------------------------------------------------') - local nProcessingsNumber - local nFirstAvailableRotation - -- ricerco prima rotazione effettivamente calcolata. In genere è sempre la prima - for i = 1, 4 do - if PartInfo.CombinationList.Rotations[i] == 1 then - nProcessingsNumber = #ProcessingsOnPart.Rotation[i] - nFirstAvailableRotation = i - break - end + local nCycles = 1 + local nOffsetIndex = 0 + if #ProcessingsOnPart.Rotation > 4 then + nCycles = 2 end - -- per ogni feature - for ProcLog = 1, nProcessingsNumber do - -- ricavo il massimo numero di strategie per feature - local nMaxStrategiesPerFeature = 0 - for nRotLog = 1, 4 do - if PartInfo.CombinationList.Rotations[nRotLog] == 1 and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies then - nMaxStrategiesPerFeature = max( nMaxStrategiesPerFeature, #ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies) + for nCycle = 1, nCycles do + local nStartIndex = 1 + nOffsetIndex + local nEndIndex = 4 + nOffsetIndex + if nCycle == 1 then + EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===') + else + EgtOutLog( ' === === === === === === === === FEATURES STRATEGIES PIECE INVERTED === === === === === === === === === ===') + end + EgtOutLog( ' Feature ID | BTL POSITION | 90 ROTATION | 180 ROTATION | 270 ROTATION |') + EgtOutLog( '----------------------------------------------------------------------------------------------------------') + + local nProcessingsNumber + local nFirstAvailableRotation + -- ricerco prima rotazione effettivamente calcolata. In genere è sempre la prima + for i = nStartIndex, nEndIndex do + if PartInfo.CombinationList.Rotations[i-nOffsetIndex] == 1 then + nProcessingsNumber = #ProcessingsOnPart.Rotation[i] + nFirstAvailableRotation = i + break end end - -- ciclo su tutte le strategie - for nCountStrategies = 1, nMaxStrategiesPerFeature do - local sLogLine = '' - -- al primo ciclo scrivo ID feature - if nCountStrategies == 1 then - sLogLine = ' ' .. tostring( ProcessingsOnPart.Rotation[nFirstAvailableRotation][ProcLog].id) - while string.len( sLogLine) <= 20 do - sLogLine = sLogLine .. ' ' + -- per ogni feature + for ProcLog = 1, nProcessingsNumber do + -- ricavo il massimo numero di strategie per feature + local nMaxStrategiesPerFeature = 0 + for nRotLog = nStartIndex, nEndIndex do + if PartInfo.CombinationList.Rotations[nRotLog-nOffsetIndex] == 1 and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies then + nMaxStrategiesPerFeature = max( nMaxStrategiesPerFeature, #ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies) end - sLogLine = sLogLine .. '|' - else - sLogLine = ' |' end - for nRotLog = 1, 4 do - -- se rotazione abilitata - if PartInfo.CombinationList.Rotations[nRotLog] == 1 then - -- se ci sono strategie - if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies] then - -- se la strategia è stat processata e ha un risultato - if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result then - -- leggo lo stato della strategia per aggiungere un suffisso - local sStatusStrategy = ' ' - if not ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus or - ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Applicable' then - sStatusStrategy = 'N' - elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Completed' then - sStatusStrategy = 'C' - elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Completed' then - sStatusStrategy = 'P' - end - -- se c'è una chosen strategy, si aggiunge prefisso '*' per indicare nel log qual è la strategia che è stata scelta - local nIndexBestStrategy = ProcessingsOnPart.Rotation[nRotLog][ProcLog].nIndexBestStrategy or 0 - local sLogLineProc = EgtIf( nIndexBestStrategy == nCountStrategies, '*', '') .. - tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dCompositeRating) ..' (' .. - tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].sStrategyId) .. ')' .. - sStatusStrategy .. ' |' - while string.len( sLogLineProc) <= 20 do - sLogLineProc = ' ' .. sLogLineProc - end - sLogLine = sLogLine .. sLogLineProc - else - sLogLine = sLogLine .. ' 0 (STR----)- |' - end - else - sLogLine = sLogLine .. ' |' + -- ciclo su tutte le strategie + for nCountStrategies = 1, nMaxStrategiesPerFeature do + local sLogLine = '' + -- al primo ciclo scrivo ID feature + if nCountStrategies == 1 then + sLogLine = ' ' .. tostring( ProcessingsOnPart.Rotation[nFirstAvailableRotation][ProcLog].id) + while string.len( sLogLine) <= 20 do + sLogLine = sLogLine .. ' ' end - -- rotazione non presa in considerazione + sLogLine = sLogLine .. '|' else - if nCountStrategies == 1 then - sLogLine = sLogLine .. ' ---------- |' + sLogLine = ' |' + end + + for nRotLog = nStartIndex, nEndIndex do + -- se rotazione abilitata + if PartInfo.CombinationList.Rotations[nRotLog-nOffsetIndex] == 1 then + -- se ci sono strategie + if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies] then + -- se la strategia è stat processata e ha un risultato + if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result then + -- leggo lo stato della strategia per aggiungere un suffisso + local sStatusStrategy = ' ' + if not ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus or + ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Applicable' then + sStatusStrategy = 'N' + elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Completed' then + sStatusStrategy = 'C' + elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Completed' then + sStatusStrategy = 'P' + end + -- se c'è una chosen strategy, si aggiunge prefisso '*' per indicare nel log qual è la strategia che è stata scelta + local nIndexBestStrategy = ProcessingsOnPart.Rotation[nRotLog][ProcLog].nIndexBestStrategy or 0 + local sLogLineProc = EgtIf( nIndexBestStrategy == nCountStrategies, '*', '') .. + tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dCompositeRating) ..' (' .. + tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].sStrategyId) .. ')' .. + sStatusStrategy .. ' |' + while string.len( sLogLineProc) <= 20 do + sLogLineProc = ' ' .. sLogLineProc + end + sLogLine = sLogLine .. sLogLineProc + else + sLogLine = sLogLine .. ' 0 (STR----)- |' + end + else + sLogLine = sLogLine .. ' |' + end + -- rotazione non presa in considerazione else - sLogLine = sLogLine .. ' |' + if nCountStrategies == 1 then + sLogLine = sLogLine .. ' ---------- |' + else + sLogLine = sLogLine .. ' |' + end end end + EgtOutLog( sLogLine) end - EgtOutLog( sLogLine) - end + end + EgtOutLog( '----------------------------------------------------------------------------------------------------------') + nOffsetIndex = 4 end - EgtOutLog( '----------------------------------------------------------------------------------------------------------') end ------------------------------------------------------------------------------------------------------------- @@ -142,11 +158,12 @@ end ------------------------------------------------------------------------------------------------------------- function Logs.WriteCombinationLog( CombinationsList, BestCombination) EgtOutLog( ' === === === === === === === === === === COMBINATIONS === === === === === === ') - EgtOutLog( ' COMBI (UNL) | RATING | COMPLETE | NO COMPL | NO EXEC | ROTATE |') - EgtOutLog( '---------------------------------------------------------------------------') + EgtOutLog( ' COMBI (UNL) | RATING | COMPLETE | NO COMPL | NO EXEC | ROTATE |') + EgtOutLog( '------------------------------------------------------------------------------') for CombiLog = 1, #CombinationsList do - local sLogLine = ' ' .. CombinationsList[CombiLog].sBitIndexCombination .. ' (' .. CombinationsList[CombiLog].nUnloadPos .. ') |' + local sPartPosition = EgtIf( CombinationsList[CombiLog].bPartIsInverted, 'INV', 'ORI') + local sLogLine = ' ' .. CombinationsList[CombiLog].sBitIndexCombination .. ' (' .. CombinationsList[CombiLog].nUnloadPos .. ') ' .. sPartPosition .. ' |' -- rating local sOtherField = tostring( CombinationsList[CombiLog].dTotalRating) .. ' |' while string.len( sOtherField) <= 11 do @@ -180,8 +197,9 @@ function Logs.WriteCombinationLog( CombinationsList, BestCombination) EgtOutLog( sLogLine) end - EgtOutLog( '---------------------------------------------------------------------------') - EgtOutLog( ' BEST ROTATION : ' .. BestCombination.sBitIndexCombination .. ' (' .. BestCombination.nUnloadPos .. ')') + local sPartPosition = EgtIf( BestCombination.bPartIsInverted, 'INV', 'ORI') + EgtOutLog( '------------------------------------------------------------------------------') + EgtOutLog( ' BEST ROTATION : ' .. BestCombination.sBitIndexCombination .. ' (' .. BestCombination.nUnloadPos .. ') ' .. sPartPosition) EgtOutLog( '---------------------------') end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index deb655b..41f3f4d 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1027,6 +1027,11 @@ function MachiningLib.AddOperations( vProc, Part, sRotation) end MACHININGS.Info.bSplitPhase = EgtGetCurrPhase() + -- se combinazione prevede inversione, si gira il pezzo + if Part.bPartIsInverted then + BeamLib.InvertRawPart( Part, 2) + end + local nPhase = EgtGetCurrPhase() local idDisp = EgtGetPhaseDisposition( nPhase)