From 7b09634461bee5ce62fa016b609beaf25f4fe742 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 17 May 2024 17:15:52 +0200 Subject: [PATCH] Modifica nomi variabili che non rispettavano lo standard --- LuaLibs/MachiningLib.lua | 37 ++++++++++++++++----------- Strategies/STR0002/STR0002.lua | 46 ++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index c52a2f8..249e302 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -53,25 +53,25 @@ local function GetToolEntryAngle( Proc, vtTool) end -------------------------------------------------------------------------------------------------------------- + ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo FRESA con certe caratteristiche -function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, vtToolDir) +function MachiningLib.FindMill( Proc, ToolSearchParameters) local ToolInfo = {} for nCurrIndex=1, #TOOLS do -- prima verifico che utensile sia compatibile local bCompatibleTool = true - if TOOLS[nCurrIndex].sType ~= sMillType then + if TOOLS[nCurrIndex].sType ~= ToolSearchParameters.sType then bCompatibleTool = false - elseif TOOLS[nCurrIndex].dDiameter > dMaxToolDiameter then + elseif TOOLS[nCurrIndex].dDiameter > ToolSearchParameters.dMaxToolDiameter then bCompatibleTool = false - elseif sMillShape == 'STANDARD' and ( TOOLS[nCurrIndex].dSideAngle ~= 0 or TOOLS[nCurrIndex].bIsPen) then + elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[nCurrIndex].dSideAngle ~= 0 or TOOLS[nCurrIndex].bIsPen) then bCompatibleTool = false - elseif sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then + elseif ToolSearchParameters.sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then bCompatibleTool = false - elseif sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then + elseif ToolSearchParameters.sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then bCompatibleTool = false - elseif sMillShape == 'PEN' and not TOOLS[nCurrIndex].bIsPen then + elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[nCurrIndex].bIsPen then bCompatibleTool = false -- TODO controllare montaggio e verificare se direzione utensile raggiungibile. Serve funzione in BeamData end @@ -79,7 +79,7 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d -- scelgo il migliore if bCompatibleTool then -- calcolo riduzione del massimo materiale utilizzabile - local dToolEntryAngle = GetToolEntryAngle( Proc, vtToolDir) + local dToolEntryAngle = GetToolEntryAngle( Proc, ToolSearchParameters.vtToolDir) -- se ToolHolder più grande dell'utensile, il primo oggetto in collisione è il ToolHolder. Altrimenti il motore. -- TODO Per il momento il motore ha un valore fisso: diametro di 180. Vedere se scrivere il diametro corretto in BeamData local dDimObjToCheck = EgtIf( TOOLS[nCurrIndex].ToolHolder.dDiameter > TOOLS[nCurrIndex].dDiameter, TOOLS[nCurrIndex].ToolHolder.dDiameter, 180) @@ -90,26 +90,26 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d dCurrMaxMatReduction = dCurrMaxMatReduction / cos( 90 - dToolEntryAngle) + ( ( dDimObjToCheck - TOOLS[nCurrIndex].dDiameter) / 2) / tan( dToolEntryAngle) end -- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili - local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - dElevation - dCurrMaxMatReduction + local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - ToolSearchParameters.dElevation - dCurrMaxMatReduction -- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore - if not ToolInfo.idTool or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then - ToolInfo.idTool = nCurrIndex + if not ToolInfo.nToolIndex or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then + ToolInfo.nToolIndex = nCurrIndex ToolInfo.dMaxMatReduction = dCurrMachReduction -- altrimenti scelgo il migliore else -- se entrambi completi if ToolInfo.dMaxMatReduction > 0 and dCurrMachReduction > 0 then -- scelgo utensile con rapporto lunghezza / diametro minore - if ( TOOLS[nCurrIndex].dLength / pow( TOOLS[nCurrIndex].dDiameter, 1.5)) < ( TOOLS[ToolInfo.idTool].dLength / pow( TOOLS[ToolInfo.idTool].dDiameter, 1.5)) then - ToolInfo.idTool = nCurrIndex + if ( TOOLS[nCurrIndex].dLength / pow( TOOLS[nCurrIndex].dDiameter, 1.5)) < ( TOOLS[ToolInfo.nToolIndex].dLength / pow( TOOLS[ToolInfo.nToolIndex].dDiameter, 1.5)) then + ToolInfo.nToolIndex = nCurrIndex ToolInfo.dMaxMatReduction = dCurrMachReduction end -- se entrambi incompleti elseif ToolInfo.dMaxMatReduction < 0 and dCurrMachReduction < 0 then --scelgo quello che lavora di più if dCurrMachReduction > ToolInfo.dMaxMatReduction then - ToolInfo.idTool = nCurrIndex + ToolInfo.nToolIndex = nCurrIndex ToolInfo.dMaxMatReduction = dCurrMachReduction end end @@ -137,5 +137,12 @@ end -- TODO da fare function MachiningLib.FindChainSaw() end + +------------------------------------------------------------------------------------------------------------- +-- funzione per aggiungere una nuova lavorazione +-- TODO da fare +function MachiningLib.AddNewMachining( Machining) +end + ------------------------------------------------------------------------------------------------------------- return MachiningLib diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index d130fdb..12db181 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -50,21 +50,23 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) local ToolInfo = {} -- serve utensile che possa lavorare di testa - local sMillType = 'MILL_STD' - local sMillShape = 'STANDARD' - local dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth) - local dElevation = Proc.MainFaces.BottomFace.dElevation + local ToolSearchParameters = {} + ToolSearchParameters.sType = 'MILL_STD' + ToolSearchParameters.sMillShape = 'STANDARD' + ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth) + ToolSearchParameters.dElevation = Proc.MainFaces.BottomFace.dElevation + ToolSearchParameters.vtToolDir = Proc.MainFaces.BottomFace.vtN -- cerco utensile - ToolInfo = MachLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, Proc.MainFaces.BottomFace.vtN) + ToolInfo = MachLib.FindMill( Proc, ToolSearchParameters) - if ToolInfo.idTool and TOOLS[ToolInfo.idTool].sName then + if ToolInfo.nToolIndex and TOOLS[ToolInfo.nToolIndex].sName then if ToolInfo.dMaxMatReduction < 0 then Strategy.RatingResult.sStatus = 'Not-Completed' else Strategy.RatingResult.sStatus = 'Completed' end - Strategy.RatingResult.dCompletionIndex = min( 100, ( ( dElevation + ToolInfo.dMaxMatReduction) / dElevation) * 100) + Strategy.RatingResult.dCompletionIndex = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation + ToolInfo.dMaxMatReduction) / Proc.MainFaces.BottomFace.dElevation) * 100) Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'Mill', Strategy.RatingResult.dCompletionIndex) Strategy.RatingResult.sInfo = '' @@ -93,8 +95,8 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) local dNewRest = Proc.b3Box:getDimX() -- creo primo spezzone sulla sinistra if bStartLeft then - local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL - dNewMinX = max( ( Proc.b3Box:getMin():getX() + TOOLS[ToolInfo.idTool].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN) + local AddId = EgtCopyGlob( Proc.iod, nAddGrpId) or GDB_ID.NULL + dNewMinX = max( ( Proc.b3Box:getMin():getX() + TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN) local ptOn = Point3d( dNewMinX, 0, 0) dNewRest = abs( dNewMaxX - dNewMinX) -- taglio della superficie lato sinistro @@ -104,8 +106,8 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) end -- creo spezzone sulla destra if bStartRight then - local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL - dNewMaxX = min( ( Proc.b3Box:getMax():getX() - TOOLS[ToolInfo.idTool].dDiameter * 2), Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN) + local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL + dNewMaxX = min( ( Proc.b3Box:getMax():getX() - TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN) local ptOn = Point3d( dNewMaxX, 0, 0) dNewRest = abs( dNewMaxX - dNewMinX) -- taglio della superficie lato destro @@ -117,7 +119,7 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) local nSplitParts = max( ceil( dNewRest / BeamData.LONGCUT_MAXLEN + 10 * GEO.EPS_SMALL), 2) local dSplitPartsLen = dNewRest / nSplitParts for i = 1, nSplitParts do - local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL local ptOn -- eseguo trim sinistro if i ~= 1 or bStartLeft then @@ -139,14 +141,14 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) end -- si applicano le lavorazioni for i = 1, #vAddId do - EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.idTool].sName) - EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.idTool].dStep) + EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName) + EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep) EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction)) - EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.idTool].dSideStep) + EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep) EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG) - EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.idTool].dDiameter/2) - EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.idTool].dDiameter/2) + EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2) + EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2) for j=1, Proc.nFct do local vtNSplitFace _, vtNSplitFace = EgtSurfTmFacetCenter( vAddId[i], j - 1, GDB_ID.ROOT) @@ -158,14 +160,14 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) end end else - EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.idTool].sName) - EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.idTool].dStep) + EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName) + EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep) EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction)) - EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.idTool].dSideStep) + EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep) EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG) - EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.idTool].dDiameter/2) - EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.idTool].dDiameter/2) + EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2) + EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2) EgtSetMachiningGeometry( {{ Proc.id, Proc.MainFaces.BottomFace.id}}) EgtApplyMachining( true, true) end