diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index dec5c30..fc9a76f 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -280,6 +280,8 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) bIsToolCompatible = false elseif ToolSearchParameters.dMinToolDiameter and TOOLS[i].dDiameter < ToolSearchParameters.dMinToolDiameter then bIsToolCompatible = false + elseif ( ToolSearchParameters.bCCW and not TOOLS[i].bIsCCW) or ( ToolSearchParameters.bCW and TOOLS[i].bIsCCW) then + bIsToolCompatible = false elseif TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) - GEO.EPS_ZERO then bIsToolCompatible = false elseif TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) + GEO.EPS_ZERO then diff --git a/Strategies/Standard/STR0015/STR0015.lua b/Strategies/Standard/STR0015/STR0015.lua index 9755cc4..6657756 100644 --- a/Strategies/Standard/STR0015/STR0015.lua +++ b/Strategies/Standard/STR0015/STR0015.lua @@ -91,7 +91,7 @@ local function GetRoughStrategy( Proc, Part, bSaveAddedGeometries) -- TODO SISTEMARE!!! qui la svuotatura non deve limitare l'elevazione se aperta da tutti i lati. In futuro si deve passare 0 come elevazione ToolSearchParameters.dElevation = EgtSurfTmFacetElevationInBBox( AddId, 0, Part.b3Part, true, GDB_ID.ROOT) - ToolSearchParameters.vtToolDirection = vtNP + ToolSearchParameters.vtToolDirection = vtNF ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sPocketingList, 'Pocketing') Machining.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) @@ -114,7 +114,7 @@ local function GetRoughStrategy( Proc, Part, bSaveAddedGeometries) Machining.LeadIn.dElevation = TOOLS[Machining.ToolInfo.nToolIndex].dDiameter/2 Machining.sDepth = 0 Machining.Geometry = {{ AddId, 0}} - Machining.vtToolDirection = vtNP + Machining.vtToolDirection = vtNF if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then Machining.sStage = 'AfterTail' end @@ -143,6 +143,7 @@ end local function GetChamferStrategy( Proc, Part) local Machining = {} local Result = {} + local ToolSearchParameters = {} local dExtraDepth = 2 local vtExtr = EgtCurveExtrusion( Proc.idAddAuxGeom, GDB_RT.GLOB) local bIsHorizontal = abs( vtExtr:getZ()) < 10 * GEO.EPS_SMALL @@ -152,67 +153,95 @@ local function GetChamferStrategy( Proc, Part) -- controllo conformità affondamento smussi Strategy.Parameters.dDepthChamfer = EgtClamp( Strategy.Parameters.dDepthChamfer, 0.1, 5) + -- si prapara tabella con parametri di base comuni a tutte le lavorazioni + local BasicMach = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) + BasicMach.Geometry = {{ Proc.idAddAuxGeom, -1}} + BasicMach.nType = MCH_MY.MILLING + BasicMach.sDepth = Strategy.Parameters.dDepthChamfer + dExtraDepth + -- LeadIn / LeadOut + BasicMach.LeadIn.nType = MCH_MILL_LI.NONE + BasicMach.LeadOut.nType = MCH_MILL_LI.NONE + BasicMach.LeadIn.dStartAddLength = 5 + BasicMach.LeadOut.dEndAddLength = 5 + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + BasicMach.sStage = 'AfterTail' + end + BasicMach.ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) + BasicMach.vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.dLengthOnX = Proc.b3Box:getDimX() + -- parametri di ricerca utensile comuni a tutte le lavorazioni + ToolSearchParameters.sMillShape = 'VMILL' + ToolSearchParameters.dElevation = Strategy.Parameters.dDepthChamfer + ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, 'MillingSmooth') + -- se lavorazione orizzontale if bIsHorizontal then - local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) - ToolSearchParameters = {} - ToolSearchParameters.sMillShape = 'VMILL' - ToolSearchParameters.dElevation = Strategy.Parameters.dDepthChamfer + local Milling = {} ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) - ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, 'MillingSmooth') 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 + -- se trovato utensile adatto if Milling.ToolInfo.nToolIndex then Milling.vtToolDirection = ToolSearchParameters.vtToolDirection - Milling.Geometry = {{ Proc.idAddAuxGeom, -1}} Milling.nToolIndex = Milling.ToolInfo.nToolIndex - Milling.nType = MCH_MY.MILLING - Milling.sDepth = Strategy.Parameters.dDepthChamfer + dExtraDepth Milling.dRadialOffset = dExtraDepth * cos( TOOLS[Milling.nToolIndex].dSideAngle) - -- LeadIn / LeadOut - Milling.LeadIn.nType = MCH_MILL_LI.NONE - Milling.LeadOut.nType = MCH_MILL_LI.NONE - Milling.LeadIn.dStartAddLength = 5 - Milling.LeadOut.dEndAddLength = 5 - - if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then - Milling.sStage = 'AfterTail' - end - - -- sistemo il lato e la direzione di lavoro - if Milling.bOtherDirection then - Milling.bToolInvert = true - Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, true, false) - Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) - else - Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, false, true) - Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) - end - Milling.ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) - Milling.ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) - Milling.dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) - Milling.vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) - Milling.dLengthOnX = Proc.b3Box:getDimX() - Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, false, true) Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling = BeamLib.MergeTables( BasicMach, Milling) table.insert( Machining, Milling) local Milling2 = BeamLib.TableCopyDeep( Milling) Milling2.bToolInvert = true Milling2.bInvert = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, true, false) Milling2.nWorkside = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) - + table.insert( Machining, Milling2) end - -- TODO LAVORAZIONE VERTICALE DA FARE!!!! -- se lavorazione verticale else - -- prendere stessi controlli da 'GetArcStrategy' per lavorazione verticale + -- si cerca utensile 1 + local Milling = {} + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + Milling.vtToolDirection = ToolSearchParameters.vtToolDirection + + -- si cerca utensile 2 + local Milling2 = {} + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) + Milling2.ToolInfo = {} + Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + Milling2.vtToolDirection = ToolSearchParameters.vtToolDirection + Milling2.bToolInvert = true + + -- se trovato utensile 1 adatto + if Milling.ToolInfo.nToolIndex then + + Milling.nToolIndex = Milling.ToolInfo.nToolIndex + Milling.dRadialOffset = dExtraDepth * cos( TOOLS[Milling.nToolIndex].dSideAngle) + + Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, false, true) + Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling = BeamLib.MergeTables( BasicMach, Milling) + table.insert( Machining, Milling) + end + + -- se trovato utensile 2 adatto + if Milling2.ToolInfo.nToolIndex then + + Milling2.nToolIndex = Milling2.ToolInfo.nToolIndex + Milling2.dRadialOffset = dExtraDepth * cos( TOOLS[Milling2.nToolIndex].dSideAngle) + + Milling2.bToolInvert = true + Milling2.bInvert = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, true, false) + Milling2.nWorkside = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling2 = BeamLib.MergeTables( BasicMach, Milling2) + table.insert( Machining, Milling2) + end end end @@ -311,30 +340,25 @@ local function GetArcStrategy( Proc, Part) end -- se lavorazione verticale else - -- si cerca utensile 1 - local Milling = {} ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP - ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, sTypeTool) ToolSearchParameters.dMaxToolDiameter = nMaxDiamMill + + -- si cerca utensile 1 + local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) Milling.ToolInfo = {} Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) - if nCycle == 2 then Milling.dRadialOffset = Strategy.Parameters.dOverMaterial end Milling.vtToolDirection = ToolSearchParameters.vtToolDirection -- si cerca utensile 2 - local Milling2 = {} - ToolSearchParameters = {} - ToolSearchParameters.sMillShape = 'STANDARD' - ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP + local Milling2 = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) - ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, sTypeTool) - ToolSearchParameters.dMaxToolDiameter = nMaxDiamMill Milling2.ToolInfo = {} Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) Milling2.bOtherDirection = true @@ -345,39 +369,67 @@ local function GetArcStrategy( Proc, Part) -- se serve codolo if bExecStrip then + local sDepthMachined = 0 -- se a disposizione entrambi gli utensili if Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + local dExtraDepth = ( dDepth - dDimStrip - ( Milling.ToolInfo.dResidualDepth + Milling2.ToolInfo.dResidualDepth)) / 2 + Milling.sDepth = dDepth - Milling.ToolInfo.dResidualDepth - dExtraDepth + Milling2.sDepth = dDepth - Milling2.ToolInfo.dResidualDepth - dExtraDepth + sDepthMachined = Milling.sDepth + Milling2.sDepth table.insert( Machining, Milling) table.insert( Machining, Milling2) -- se disponibile solo primo utensile elseif Milling.ToolInfo.nToolIndex then + sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth + Milling.sDepth = min( sMaxDepth, dDepth - dDimStrip) table.insert( Machining, Milling) + sDepthMachined = Milling.sDepth -- se disponibile solo secondo utensile elseif Milling2.ToolInfo.nToolIndex then + sMaxDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth + Milling2.sDepth = min( sMaxDepth, dDepth - dDimStrip) table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth -- nessun utensile disponibile else -- non si fa nulla end + Result.dCompletionPercentage = min( ( sDepthMachined * 100) / ( dDepth - dDimStrip), 100) -- altrimenti senza codolo else - -- se utensile 1 esegue completamente - if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + local sDepthMachined = 0 + local dExtraDepth = ( dDepth - BeamData.MILL_OVERLAP - ( Milling.ToolInfo.dResidualDepth + Milling2.ToolInfo.dResidualDepth)) / 2 + -- se utensile 1 esegue completamente (con almeno 1mm extra) + if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 1000 * GEO.EPS_SMALL then + sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth + Milling.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP) table.insert( Machining, Milling) - -- se utensile 2 esegue completamente - elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + sDepthMachined = Milling.sDepth + -- se utensile 2 esegue completamente (con almeno 1mm extra) + elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 1000 * GEO.EPS_SMALL then + sMaxDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth + Milling2.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP) table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth -- se possono lavorare entrambi elseif Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + Milling.sDepth = dDepth - Milling.ToolInfo.dResidualDepth - dExtraDepth + Milling2.sDepth = dDepth - Milling2.ToolInfo.dResidualDepth - dExtraDepth table.insert( Machining, Milling) table.insert( Machining, Milling2) + sDepthMachined = Milling.sDepth + Milling2.sDepth -- se utensile 1 non completo elseif Milling.ToolInfo.nToolIndex then + Milling.sDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth table.insert( Machining, Milling) + sDepthMachined = Milling.sDepth -- se utensile 2 non completo elseif Milling2.ToolInfo.nToolIndex then + Milling2.sDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth end + Result.dCompletionPercentage = min( ( sDepthMachined * 100) / ( dDepth - dDimStrip), 100) end end end @@ -395,13 +447,13 @@ local function GetFeatureResult( Proc) local dPercentageProfile = 80 -- se non ci sono lavorazioni di smusso - if not Strategy.Chamfer.Machinings or #Strategy.Chamfer.Machinings == 0 then + if not Strategy.Chamfer.Machinings or #Strategy.Chamfer.Machinings < 2 then -- se esclusivo, non applicabile if Strategy.Parameters.bOnlyChamfer then Result = FeatureLib.GetStrategyResultNotApplicable( 'Not possible to machine chamfer only, tool not found!') Result.dCompletionPercentage = 0 -- se non esclusivo, non completo - elseif Strategy.Parameters.dDepthChamfer > 10 * GEO.EPS_SMALL then + elseif Strategy.Parameters.dDepthChamfer > 100 * GEO.EPS_SMALL then Result.dCompletionPercentage = Result.dCompletionPercentage - dPercentageChamfer -- gli smussi incidono per il 10% dPercentageChamfer = 0 Result.sInfo = '- Chamfer not executed, tool not found!\n' @@ -446,7 +498,12 @@ local function GetFeatureResult( Proc) end Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Result.dCompletionPercentage) Result.dMRR = 1 - Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL') + -- se tutte le lavorazioni sono state eseguite, è la massima qualità che si possa ottenere, altrimenti qualità più bassa + if Result.sInfo == '' then + Result.nQuality = FeatureLib.GetStrategyQuality( 'BEST') + else + Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL') + end return Result end