diff --git a/Process.lua b/Process.lua index cd14639..af3ba4a 100644 --- a/Process.lua +++ b/Process.lua @@ -53,7 +53,7 @@ _G.package.loaded['TAILCUT\\TAILCUT'] = nil -- Infatti difficile ci siano 9999 strategie. -- reset strategie caricate come librerie for i = 1, 9999 do - local IdSTRTemp = EgtReplaceString( tostring( i/10000, 4), '0.', '') + local IdSTRTemp = EgtReplaceString( EgtNumToString( i/10000, -4), '0.', '') local sLibraryToReload = "STR" .. IdSTRTemp .. "\\STR" .. IdSTRTemp if _G.package.loaded[sLibraryToReload] then _G.package.loaded[sLibraryToReload] = nil diff --git a/Strategies/AvailableStrategyList.json b/Strategies/AvailableStrategyList.json index 36b2ba8..e724bf8 100644 --- a/Strategies/AvailableStrategyList.json +++ b/Strategies/AvailableStrategyList.json @@ -16,7 +16,7 @@ "nGrp": "0", "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ { "sStrategyID": "STR0005" } ] + "StrategyList" : [ { "sStrategyID": "STR0005" }, { "sStrategyID": "STR0010" } ] } ] }, @@ -36,7 +36,7 @@ "nGrp": "0", "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ ] + "StrategyList" : [ { "sStrategyID": "STR0010" }] } ] }, diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index 9288c71..7438929 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -8,11 +8,44 @@ local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') +-- strategie di base +local FaceByMill = require('FACEBYMILL') -- Tabella per definizione modulo local STR0010 = {} local Strategy = {} +------------------------------------------------------------------------------------------------------------- +local function GetStrategyCompletionPercentage( Machinings) + local dCompletionPercentage = 0 + + local dCompletionPercentageNumerator = 0 + local dCompletionPercentageDenominator = 0 + local nWeightsCount = 0 + for i = 1, #Machinings do + local Machining = Machinings[i] + local dWeight = Machining.dResultWeight + if not dWeight or ( dWeight < 10 * GEO.EPS_SMALL) then + dWeight = 1 + else + nWeightsCount = nWeightsCount + 1 + end + -- il peso deve essere settato in tutte le lavorazioni o in nessuna + if ( nWeightsCount ~= 0) and ( nWeightsCount ~= i) then + error( 'GetWeightedCompletionPercentage : inconsistent weights') + end + local dWeightedCompletionPercentage = Machining.dCompletionPercentage / 100 * dWeight + if Machining.bIsApplicable then + dCompletionPercentageNumerator = dCompletionPercentageNumerator + dWeightedCompletionPercentage + end + dCompletionPercentageDenominator = dCompletionPercentageDenominator + dWeight + end + + dCompletionPercentage = min( 100 * dCompletionPercentageNumerator / dCompletionPercentageDenominator, 100) + + return dCompletionPercentage +end + ------------------------------------------------------------------------------------------------------------- local function CompareEdges( EdgeA, EdgeB) -- prima i lati orientati lungo X @@ -47,39 +80,9 @@ local function CompareEdges( EdgeA, EdgeB) end end -------------------------------------------------------------------------------------------------------------- -local function GetBevelStrategy( Proc, Part) - local Milling = {} - -- estensione oltre la coda - local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0) - if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then - dExtendAfterTail = 10000 - end - - ToolSearchParameters = {} - ToolSearchParameters.dElevation = Proc.MainFaces.BottomFaces[1].dElevation - ToolSearchParameters.vtToolDirection = Proc.MainFaces.BottomFaces[1].vtN - - -- se feature limitata, si setta dimensione massima utensile - if ( Proc.Topology.sFamily == 'Bevel' and Proc.nFct == 3) or ( Proc.Topology.sFamily == 'DoubleBevel' and Proc.nFct == 6) then - -- si trova il lato della faccia di fondo da lavorare - local BottomEdgeToMachine = {} - local BottomEdgesSorted = {} - for i = 1, #Proc.MainFaces.BottomFaces[1].Edges do - table.insert( BottomEdgesSorted, Proc.MainFaces.BottomFaces[1].Edges[i]) - end - table.sort( BottomEdgesSorted, CompareEdges) - BottomEdgeToMachine = BottomEdgesSorted[1] - ToolSearchParameters.dMaxToolDiameter = BottomEdgeToMachine.dLength - end - Milling.ToolInfo = {} - Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) - -end - ------------------------------------------------------------------------------------------------------------- local function IsTopologyOk( Proc) - if Proc.Topology.sFamily == 'Bevel' or Proc.Topology.sFamily == 'DoubleBevel' then + if Proc.Topology.sFamily == 'Bevel' then return true else return false @@ -128,12 +131,67 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) return false, Strategy.Result end - Strategy.Machinings = GetBevelStrategy( Proc, Part) + -- volume della feature + local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) + + -- TODO taglio su eventuali facce di chiusura + + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local bIsSplitFeature = false + if #FeatureSplittingPoints > 0 then + bIsSplitFeature = true + end + + local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0) + if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then + dExtendAfterTail = 10000 + end + + -- si trova il lato della faccia di fondo da lavorare + local BottomEdgesSorted = {} + for i = 1, #Proc.MainFaces.BottomFaces[1].Edges do + table.insert( BottomEdgesSorted, Proc.MainFaces.BottomFaces[1].Edges[i]) + end + table.sort( BottomEdgesSorted, CompareEdges) + + -- lavorazione faccia bottom con fresa + local dDepthToMachine = BottomEdgesSorted[1].dElevation + 5 + local OptionalParametersFaceByMill = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} + -- primo lato + local Milling = {} + Milling = FaceByMill.Make( Proc, Part, Proc.MainFaces.BottomFaces[1], BottomEdgesSorted[1], OptionalParametersFaceByMill) + + -- lavorazioni da applicare spostate in lista finale + table.insert( Strategy.Machinings, Milling) + + -- calcolo completamento, serve la lista di lavorazioni che comprende le non applicabili + Strategy.Result.dCompletionPercentage = GetStrategyCompletionPercentage( Strategy.Machinings) + Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Strategy.Result.dCompletionPercentage) + + local MachiningResult = MachiningLib.GetSplitMachinings( Strategy.Machinings, FeatureSplittingPoints, Part) + + -- calcolo risultati + if Strategy.Machinings[1].bIsApplicable then + Strategy.Result.nQuality = FeatureLib.GetStrategyQuality( MachiningResult) + Strategy.Result.dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( MachiningResult) + Strategy.Result.dMRR = ( dFeatureVolume / Strategy.Result.dTimeToMachine) / pow( 10, 6) + if Strategy.Result.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then + Strategy.Result.sStatus = 'Completed' + else + Strategy.Result.sStatus = 'Not-Completed' + end + else + Strategy.Result = FeatureLib.GetStrategyResultNotApplicable() + end local bAreAllMachiningsAdded = true - -- aggiunta lavorazioni if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then + -- aggiunge lavorazione + for j = 1, #MachiningResult do + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, MachiningResult[j]) + end end return bAreAllMachiningsAdded, Strategy.Result diff --git a/StrategyLibs/FACEBYMILL.lua b/StrategyLibs/FACEBYMILL.lua index e735eef..c748a43 100644 --- a/StrategyLibs/FACEBYMILL.lua +++ b/StrategyLibs/FACEBYMILL.lua @@ -80,8 +80,8 @@ local function CalculateLeadInOut( Machining, EdgeToMachine, Part) LeadOut.dTangentDistance = 0 if Machining.bIsStartClosed or Machining.bIsEndClosed - or Machining.Steps.nCount > 1 then - + or Machining.CloneStepsRadial.nCount > 1 then + Machining.sLeadInOutType = 'Perpendicular' if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset