From 00237060240b94f490400e6a44dcae448e4bf794 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Mon, 7 Apr 2025 17:07:54 +0200 Subject: [PATCH] Prima versione nuova strategia per Arco --- LuaLibs/BasicCustomerStrategies.lua | 2 + Strategies/Standard/STR0009/STR0009.lua | 235 ++++++++++++++++++ Strategies/Standard/STR0009/STR0009Config.lua | 17 ++ 3 files changed, 254 insertions(+) create mode 100644 Strategies/Standard/STR0009/STR0009.lua create mode 100644 Strategies/Standard/STR0009/STR0009Config.lua diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index c067550..5b4775a 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -297,6 +297,7 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Round Arch (0-104) elseif ID.IsRoundArch( Proc) then + Strategies = { { sStrategyId = 'STR0009'}} --------------------------------------------------------------------- -- Feature : Head Profile (0-106) elseif ID.IsHeadProfile( Proc) then @@ -596,6 +597,7 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Round Arch (0-104) elseif ID.IsRoundArch( Proc) then + Strategies = { { sStrategyId = 'STR0009'}} --------------------------------------------------------------------- -- Feature : Head Profile (0-106) elseif ID.IsHeadProfile( Proc) then diff --git a/Strategies/Standard/STR0009/STR0009.lua b/Strategies/Standard/STR0009/STR0009.lua new file mode 100644 index 0000000..db7f079 --- /dev/null +++ b/Strategies/Standard/STR0009/STR0009.lua @@ -0,0 +1,235 @@ +-- Strategia: STR0009 +-- Descrizione +-- Fresatura di contorno +-- Feature tipo Arco + + +-- carico librerie +local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureLib = require( 'FeatureLib') +-- strategie di base +local BladeToWaste = require('BLADETOWASTE') + +-- Tabella per definizione modulo +local STR0009 = {} +local Strategy = {} + +------------------------------------------------------------------------------------------------------------- +local function GetArcStrategy( Proc, Part) + local Machining = {} + local ToolSearchParameters = {} + + -- recupero e verifico l'entità curva + local idAux = EgtGetInfo( Proc.id, 'AUXID', 'i') + if idAux then idAux = idAux + Proc.id end + if not idAux or ( EgtGetType( idAux) & GDB_FY.GEO_CURVE) == 0 then + local sErr = 'Error on process ' .. tostring( Proc.id) .. ' missing profile geometry' + EgtOutLog( sErr) + return false, sErr + end + Proc.idAddAuxGeom = idAux + + -- recupero i dati della curva e del profilo + local dDepth = abs( EgtCurveThickness( idAux)) + local vtExtr = EgtCurveExtrusion( idAux, GDB_RT.GLOB) + local bToolInvert = ( vtExtr:getZ() < -0.1) + local bIsHorizontal = abs( vtExtr:getZ()) < 10 * GEO.EPS_SMALL + local bIsFeatureDown = Proc.AffectedFaces.bBottom and not Proc.AffectedFaces.bTop + local bIsFeatureBack = Proc.AffectedFaces.bBack and not Proc.AffectedFaces.bFront + local bForceStrip = Strategy.Parameters.bForceStrip + local dDimStrip = EgtIf( Strategy.Parameters.dStripWidth < 100 * GEO.EPS_SMALL, nil, Strategy.Parameters.dStripWidth) + + local bExecStrip = false + -- se la lavorazione si trova nella parte inferiore o in battuta dietro, il codolo va sempre lasciato + if bIsFeatureDown or bIsFeatureBack or bForceStrip then + if bIsFeatureDown or bIsFeatureBack then + dDimStrip = dDimStrip or max( BeamData.DIM_STRIP or 5, 5) + else + dDimStrip = dDimStrip or max( BeamData.DIM_STRIP_SMALL or 5, 1) + end + bExecStrip = true + end + if not bExecStrip then + dDimStrip = 0 + end + + -- se lavorazione orizzontale + if bIsHorizontal then + local bDouble + local Milling = {} + Milling.bIsApplicable = false + ToolSearchParameters = {} + ToolSearchParameters.sMillShape = 'STANDARD' + ToolSearchParameters.dElevation = EgtIf( bExecStrip, ( dDepth - dDimStrip) / 2, dDepth + BeamData.MILL_OVERLAP) + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + -- se posso lavorare in una passata, ma utensile trovato non completa la lavorazione, + -- allora provo a cercare utensile con massimo materiale sufficiente per fare le due passate, magari trova un utensile più prestante + if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then + bDouble = true + ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2 + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + end + Milling.bToolInvert = bToolInvert + Milling.vtToolDirection = vtExtr + + if bDouble or bExecStrip then + if bDouble then + Milling.sDepth = ( dDepth + BeamData.MILL_OVERLAP) / 2 + else + Milling.sDepth = ( dDepth - dDimStrip) / 2 + end + table.insert( Machining, Milling) + local Milling2 = BeamLib.TableCopyDeep( Milling) + table.insert( Machining, Milling2) + else + Milling.sDepth = dDepth + BeamData.MILL_OVERLAP + table.insert( Machining, Milling) + end + -- se lavorazione verticale + else + -- si cerca utensile 1 + local Milling = {} + Milling.bIsApplicable = false + ToolSearchParameters = {} + ToolSearchParameters.sMillShape = 'STANDARD' + ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + -- si cerca utensile 2 + local Milling2 = {} + Milling2.bIsApplicable = false + ToolSearchParameters = {} + ToolSearchParameters.sMillShape = 'STANDARD' + ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) + Milling2.ToolInfo = {} + Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + + -- se serve codolo + if bExecStrip then + -- se a disposizione entrambi gli utensili + if Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + table.insert( Machining, Milling2) + -- se disponibile solo primo utensile + elseif Milling.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + -- se disponibile solo secondo utensile + elseif Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling2) + -- nessun utensile disponibile + else + -- non si fa nulla + end + -- altrimenti senmza codolo + else + -- se utensile 1 esegue completamente + if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + table.insert( Machining, Milling) + -- se utensile 2 esegue completamente + elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + table.insert( Machining, Milling2) + -- se possono lavorare entrambi + elseif Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + table.insert( Machining, Milling2) + -- se utensile 2 esegue completamente + elseif Milling.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + -- se utensile 2 esegue completamente + elseif Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling2) + end + end + end + + -- TODO VOTO DA FARE!!!! + Strategy.Result.sStatus = 'Completed' + Strategy.Result.nCompletionIndex = 5 + Strategy.Result.dMRR = MachiningLib.GetToolMRR( Machining[1].ToolInfo or Machining[2].ToolInfo) + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + Strategy.Result.sInfo = '' + + return Machining +end + +------------------------------------------------------------------------------------------------------------- +function STR0009.Make( bAddMachining, Proc, Part, CustomParameters) + -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0009\\STR0009Config') + Strategy.sName = StrategyLib.Config.sStrategyId + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Machining = {} + Strategy.Result = {} + + local bAreAllMachiningsAdded = true + local Milling = {} + + Strategy.Machining = GetArcStrategy( Proc, Part) + + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local bIsSplitFeature = false + if #FeatureSplittingPoints > 0 then + bIsSplitFeature = true + end + + if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then + for i = 1, #Strategy.Machining do + -- local dDepthToMachineMill = BottomFace.MainEdges.LongEdges[i].dElevation - dMillingOffsetFromSide + -- local dBladeMarkLength = max( Cutting1.dBladeMarkLength, Cutting2.dBladeMarkLength) + -- local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, + -- dHorizontalStepSpan = dBladeMarkLength, dDepthToMachine = dDepthToMachineMill + -- } + -- local Milling = FaceByMill.Make( Proc, Part, BottomFace, BottomFace.MainEdges.LongEdges[i], OptionalParametersFaceByMill) + + Strategy.Machining[i].Geometry = {{ Proc.idAddAuxGeom, -1}} + Strategy.Machining[i].nToolIndex = Strategy.Machining[i].ToolInfo.nToolIndex + Strategy.Machining[i].nType = MCH_MY.MILLING + Strategy.Machining[i].Steps = {} + Strategy.Machining[i].Steps.dStep = TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].dStep + + -- LeadIn / LeadOut + Strategy.Machining[i].LeadIn = {} + Strategy.Machining[i].LeadOut = {} + Strategy.Machining[i].LeadIn.nType = MCH_MILL_LI.TANGENT + Strategy.Machining[i].LeadOut.nType = MCH_MILL_LI.TANGENT + Strategy.Machining[i].LeadIn.dTangentDistance = TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Machining[i].LeadIn.dPerpDistance = 0 + Strategy.Machining[i].LeadOut.dTangentDistance = TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Machining[i].LeadOut.dPerpDistance = 0 + + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Strategy.Machining[i].sStage = 'AfterTail' + end + + -- sistemo il lato e la direzione di lavoro + if i == 1 then + Strategy.Machining[i].bInvert = EgtIf( TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].bIsCCW, false, true) + Strategy.Machining[i].nWorkside = EgtIf( TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + else + Strategy.Machining[i].bToolInvert = true + Strategy.Machining[i].bInvert = EgtIf( TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].bIsCCW, true, false) + Strategy.Machining[i].nWorkside = EgtIf( TOOLS[Strategy.Machining[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + end + + -- aggiunge lavorazione + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Strategy.Machining[i]) + end + + else + bAreAllMachiningsAdded = false + end + + return bAreAllMachiningsAdded, Strategy.Result +end + +------------------------------------------------------------------------------------------------------------- + + return STR0009 \ No newline at end of file diff --git a/Strategies/Standard/STR0009/STR0009Config.lua b/Strategies/Standard/STR0009/STR0009Config.lua new file mode 100644 index 0000000..e240028 --- /dev/null +++ b/Strategies/Standard/STR0009/STR0009Config.lua @@ -0,0 +1,17 @@ +-- Parametri configurabili da cliente per strategia: STR0009 + +local STR0009Data = { + sStrategyId = 'STR0009', + Parameters = { + { sName = 'dDepthChamfer', sNameNge = 'DEPTH_CHAMFER', sValue = '0', sDescriptionShort = 'Depth Chamfer', sDescriptionLong = 'Depth of the V-Mill to execute chamfers on cut-edges', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dOverMaterial', sNameNge = 'OVERMAT', sValue = '0', sDescription = 'Overmaterial', sType = 'd'}, + { sName = 'bForceStrip', sNameNge = 'FORCE_STRIP', sValue = '0', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dStripWidth', sNameNge = 'STRIP_WIDTH', sValue = '0', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dExtendArc', sNameNge = 'EXTEND_ARC', sValue = '0', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'sActivateDouble', sNameNge = 'DOUBLE', sValue = 'AUTO', sType = 'combo', sMinUserLevel = '1', + Choices = { { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}}, + } +} + +return STR0009Data \ No newline at end of file