diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 1da3b8d..868b44d 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -96,7 +96,7 @@ end function MachiningLib.GetMachiningSteps( dMachiningDepth, dStep) local MachiningSteps = {} MachiningSteps.dStep = 0 - MachiningSteps.nCount = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) + MachiningSteps.nCount = ceil( ( dMachiningDepth - 50 * GEO.EPS_SMALL) / dStep) if MachiningSteps.nCount > 1 then MachiningSteps.dStep = ( dMachiningDepth - dStep) / ( MachiningSteps.nCount - 1) else diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index c4e62be..3f88e6d 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -46,30 +46,6 @@ local function IsTopologyOk( Proc) end -local function GetCompletionPercentage( Proc, Result) - local dNotMachinedArea = 0 - local dCompletionPercentage = 0 - - if Proc.Topology.sFamily == 'Tunnel' then - dNotMachinedArea = Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - if #Result == 2 then - dNotMachinedArea = dNotMachinedArea - Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[2].dDepthMachined) - end - else - if #Result == 1 then - dNotMachinedArea = Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - elseif #Result == 2 then - dNotMachinedArea = ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength - Result[2].dDepthMachined) * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - elseif #Result == 3 then - dNotMachinedArea = ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength - Result[2].dDepthMachined - Result[3].dDepthMachined) * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - end - end - dCompletionPercentage = 100 - dNotMachinedArea / Proc.MainFaces.LongFaces[1].dArea * 100 - - return dCompletionPercentage -end - - -- TODO si può unificare con eguale funzione in STR0004 local function SortMachiningsBySegment( MachiningA, MachiningB) if MachiningA.nFeatureSegment > MachiningB.nFeatureSegment then @@ -161,25 +137,21 @@ local function AddResult( Machining, Result) end -local function AddMachinings( Proc, Machinings, bAddMachining) - local nIsApplicableCount = 0 +local function AddMachinings( Proc, Machinings) local bAreAllMachiningsAdded = true for i = 1, #Machinings do if Machinings[i].bIsApplicable then - nIsApplicableCount = nIsApplicableCount + 1 - if bAddMachining then - local bIsMachiningAdded - bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Machinings[i]) - if not bIsMachiningAdded then - bAreAllMachiningsAdded = false - end + local bIsMachiningAdded + bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Machinings[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false end Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Machinings[i].sMessage end end - return bAreAllMachiningsAdded, nIsApplicableCount + return bAreAllMachiningsAdded end @@ -225,6 +197,9 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dExtendAfterTail = 10000 end + -- volume della feature + local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) + -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) local bIsSplitFeature = false @@ -285,6 +260,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) OptionalParameters.bOppositeToolDirection = true Cutting = FaceByBlade.Make( Proc, Part, LongFace, SideEdge1, OptionalParameters) + Cutting.dAreaToMachine = Cutting.dDepthToMachine * ( Cutting.dEdgeLength - Blade.Result.Bottom[1].dDepthToMachine) Blade.AddResult( Cutting) end @@ -293,6 +269,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) OptionalParameters.bOppositeToolDirection = true Cutting = FaceByBlade.Make( Proc, Part, LongFace, SideEdge2, OptionalParameters) + Cutting.dAreaToMachine = Cutting.dDepthToMachine * ( Cutting.dEdgeLength - Blade.Result.Bottom[1].dDepthToMachine) Blade.AddResult( Cutting) end @@ -303,16 +280,27 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end end - -- lama - lavorazioni raggruppate in unica lista + -- lama - lavorazioni raggruppate in unica lista, escluse le lavorazioni non applicabili Blade.Result.Sorted = MergeResults( Blade.Result) + -- lama - nessuna lavorazione successiva - calcolo qualità e completamento + if not Strategy.Parameters.bFinishWithChainSaw then + Strategy.Result.nQuality = FeatureLib.GetStrategyQuality( Blade.Result.Sorted) + local dTotalAreaToMachine = 0 + for i = 1, #Blade.Result.Sorted do + local Machining = Blade.Result.Sorted[i] + dTotalAreaToMachine = dTotalAreaToMachine + Machining.dAreaToMachine + end + Strategy.Result.dCompletionPercentage = dTotalAreaToMachine / LongFace.dArea * 100 + Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Strategy.Result.dCompletionPercentage) + end + -- lama - aggiunta eventuali lavorazioni splittate if bIsSplitFeature then Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end -- lama - nessuna lavorazione successiva - aggiunta lavorazioni e calcolo risultati - -- TODO bisogna uscire se la lama non può fare alcuna lavorazione; non ha senso che STR0003 lama+catena sia scelta se la lama non può lavorare, in quel caso deve essere scelta la STR0004 solo catena if not Strategy.Parameters.bFinishWithChainSaw then -- ordinamento @@ -323,33 +311,25 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- aggiunta lavorazioni - local nIsApplicableCount = 0 local bAreAllMachiningsAdded = true - local dFinalCompletionPercentage = 100 - bAreAllMachiningsAdded, nIsApplicableCount = AddMachinings( Proc, Blade.Result.Sorted, bAddMachining) + if bAddMachining then + bAreAllMachiningsAdded = AddMachinings( Proc, Blade.Result.Sorted) + end - if nIsApplicableCount > 0 then - -- TODO sistemare il calcolo completamento - implementare calcolo area lavorata + -- calcolo MRR e esito strategia + local dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( Blade.Result.Sorted) + Strategy.Result.dMRR = ( dFeatureVolume / dTimeToMachine) / pow( 10, 6) + if #Blade.Result.Sorted > 0 then if not Strategy.Parameters.bNotCompleteWithBladeRadius and Cutting.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then Strategy.Result.sStatus = 'Completed' else Strategy.Result.sStatus = 'Not-Completed' - -- TODO al momento si assume che la percentuale di completamento dell'ultima lavorazione sia quella rilevante - dFinalCompletionPercentage = Cutting.dCompletionPercentage end + -- non ha senso che STR0003 lama+catena sia applicabile se la lama non può lavorare, in quel caso deve essere scelta la STR0004 solo catena else - Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Result = FeatureLib.GetStrategyResultNotApplicable() Strategy.Parameters.bFinishWithChainSaw = false end - Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage) - Strategy.Result.nQuality = TOOLS[Cutting.nToolIndex].nQuality - local MRRParametersBlade = { - dStep = TOOLS[Cutting.nToolIndex].dThickness, - dSideStep = min( TOOLS[Cutting.nToolIndex].dSideStep, SideEdge1.dLength), - dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed - } - local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) - Strategy.Result.dMRR = dMRRBlade return bAreAllMachiningsAdded, Strategy.Result end @@ -650,13 +630,14 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- aggiunta lavorazioni per tutti gli utensili - local nIsApplicableCount = 0 local bAreAllMachiningsAdded = true local dFinalCompletionPercentage = 100 - bAreAllMachiningsAdded, nIsApplicableCount = AddMachinings( Proc, Result, bAddMachining) + if bAddMachining then + bAreAllMachiningsAdded = AddMachinings( Proc, Result) + end -- calcolo risultati - if nIsApplicableCount > 0 then + if #Result > 0 then if Mortising.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then Strategy.Result.sStatus = 'Completed' else diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 972f2b9..f76ed32 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -43,30 +43,6 @@ local function IsTopologyOk( Proc) end -local function GetCompletionPercentage( Proc, Result) - local dNotMachinedArea = 0 - local dCompletionPercentage = 0 - - if Proc.Topology.sFamily == 'Tunnel' then - dNotMachinedArea = Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - if #Result == 2 then - dNotMachinedArea = dNotMachinedArea - Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[2].dDepthMachined) - end - else - if #Result == 1 then - dNotMachinedArea = Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - elseif #Result == 2 then - dNotMachinedArea = ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength - Result[2].dDepthMachined) * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - elseif #Result == 3 then - dNotMachinedArea = ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength - Result[2].dDepthMachined - Result[3].dDepthMachined) * ( Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength - Result[1].dDepthMachined) - end - end - dCompletionPercentage = 100 - dNotMachinedArea / Proc.MainFaces.LongFaces[1].dArea * 100 - - return dCompletionPercentage -end - - -- TODO si può unificare con Sorting generale local function SortMachiningsBySegment( MachiningA, MachiningB) if MachiningA.nFeatureSegment > MachiningB.nFeatureSegment then diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 0593231..4d46259 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -143,6 +143,8 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) dExtendAfterTail = dExtendAfterTail } Blade.Result, BladeToWasteResult = BladeToWaste.Make( idAddedTmFace, Part, OptionalParameters) + + -- TODO calcolo risultati da aggiornare con funzioni nuove dMRRBladeAddedFace = BladeToWasteResult.dMRR dCompletionPercentageAddedFace = BladeToWasteResult.dCompletionPercentage nQualityAddedFace = BladeToWasteResult.nQuality @@ -155,7 +157,6 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- aggiunta lavorazioni local nIsApplicableCount = 0 - local dFinalCompletionPercentage = 100 local bAreAllMachiningsAdded = true for i = 1, #Blade.Result do if Blade.Result[i].bIsApplicable then diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 592168c..57824ef 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -256,7 +256,7 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- ordinamento table.sort( Machinings, SortMachiningsBySegment) - -- calcolo risultati + -- calcolo MRR e esito strategia if Cutting1.bIsApplicable or Cutting2.bIsApplicable then local dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( Machinings) Result.dMRR = ( dFeatureVolume / dTimeToMachine) / pow( 10, 6)