From 8e151758b136d0cf0cfc0de55e8542c2a5ef049d Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 5 Nov 2024 18:30:11 +0100 Subject: [PATCH] - creata STR0004 copiando do STR0003. Da implementare --- Strategies/Standard/STR0003/STR0003Config.lua | 2 +- Strategies/Standard/STR0004/STR0004.lua | 459 ++++++++++++++++++ Strategies/Standard/STR0004/STR0004Config.lua | 10 + 3 files changed, 470 insertions(+), 1 deletion(-) create mode 100644 Strategies/Standard/STR0004/STR0004.lua create mode 100644 Strategies/Standard/STR0004/STR0004Config.lua diff --git a/Strategies/Standard/STR0003/STR0003Config.lua b/Strategies/Standard/STR0003/STR0003Config.lua index 39bba39..952ee82 100644 --- a/Strategies/Standard/STR0003/STR0003Config.lua +++ b/Strategies/Standard/STR0003/STR0003Config.lua @@ -1,4 +1,4 @@ --- Parametri configurabili da cliente per strategia: STR0001 +-- Parametri configurabili da cliente per strategia: STR0003 local STR0003Data = { sStrategyId = 'STR0003', diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua new file mode 100644 index 0000000..767b6a5 --- /dev/null +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -0,0 +1,459 @@ +-- Strategia: STR0004 +-- Descrizione +-- motosega per slot +-- Feature: tipo lapjoint + +-- carico librerie +local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureData = require( 'FeatureData') +-- strategie di base +local SlotByChainSaw = require( 'SLOTBYCHAINSAW') + +-- Tabella per definizione modulo +local STR0004 = {} +local Strategy = {} +local Chainsaw = {} +Chainsaw.Result = {} + +------------------------------------------------------------------------------------------------------------- + +local function IsTopologyOk( Proc) + if Proc.Topology.bAllRightAngles and + ( Proc.Topology.sName == 'Pocket-5-Blind' or + Proc.Topology.sName == 'Groove-3-Through' or + Proc.Topology.sName == 'Groove-4-Blind' or + Proc.Topology.sName == 'Tunnel-4-Through') then + + return true + else + return false + end +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 + + +local function AddResult( Machining, Result) + table.insert( Result, {}) + if not Result.Bottom then + Result.Bottom = {} + end + if not Result.Side then + Result.Side = {} + end + if not Result.Opposite then + Result.Opposite = {} + end + if Machining.sEdgeType == 'Bottom' then + table.insert( Result.Bottom, Machining) + elseif Machining.sEdgeType == 'Side' then + table.insert( Result.Side, Machining) + elseif Machining.sEdgeType == 'Opposite' then + table.insert( Result.Opposite, Machining) + else + error('AddResult : unknown edge type') + end + + return Result +end + + +function Chainsaw.AddResult( Mortising) + AddResult( Mortising, Chainsaw.Result) +end + + +function Chainsaw.AddMachiningAllSteps( Proc, Mortising, AuxiliaryData) + local bMachiningAdded = false + if not AuxiliaryData then + AuxiliaryData = {} + end + AuxiliaryData.Clones = {} + + local dOriginalRadialOffsetMortising = Mortising.dRadialOffset + for i = Mortising.VerticalSteps.nCount, 1, -1 do + AuxiliaryData.Clones[i] = {} + AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.dStep * ( i - 1) + end + bMachiningAdded = MachiningLib.AddNewMachining( Proc, Mortising, AuxiliaryData) + + return bMachiningAdded +end + + +function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) + -- TODO da implementare gestione feature lunghe e spezzatura + -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0004\\STR0004Config') + Strategy.sName = StrategyLib.Config.sStrategyId + CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + Strategy.Result = {} + Strategy.Result.sInfo = '' + Chainsaw.Result = {} + + if not IsTopologyOk( Proc) then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' + EgtOutLog( sErr) + Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Result.sInfo = 'Topology' + return false, Strategy.Result + end + + -- se tasca su faccia sotto la strategia non è applicabile (la sega a catena in generale non può lavorare da sotto) + -- TODO se OnlySaw questo test è da rimuovere ma bisogna considerare anche la lama da sotto + if Proc.AffectedFaces.bBottom and ( Proc.nFct > 3 or not Proc.AffectedFaces.bTop) then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket on bottom face' + EgtOutLog( sErr) + Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Result.sInfo = 'Direction' + return false, Strategy.Result + end + + -- lama - calcolo lavorazioni + local Cutting = {} + local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade} + if Proc.Topology.sFamily == 'Tunnel' then + Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + else + Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + end + Blade.AddResult( Cutting) + -- lato opposto del tunnel + if Proc.Topology.sFamily == 'Tunnel' then + Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Blade.AddResult( Cutting) + else + -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato + if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then + -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then + Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Blade.AddResult( Cutting) + end + -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then + Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Blade.AddResult( Cutting) + end + -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni + elseif #( Proc.MainFaces.SideFaces) == 0 then + Strategy.Parameters.bFinishWithChainSaw = false + Strategy.Parameters.bNotCompleteWithBladeRadius = false + end + end + -- lama - aggiunta lavorazioni + local nIsApplicableCount = 0 + local dFinalCompletionPercentage = 100 + local bAreAllMachiningsAdded = true + for i = 1, #Blade.Result.Bottom do + if Blade.Result.Bottom[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Blade.AddMachiningAllSteps( Proc, Blade.Result.Bottom[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result.Bottom[i].sMessage + end + end + for i = 1, #Blade.Result.Side do + if Blade.Result.Side[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Blade.AddMachiningAllSteps( Proc, Blade.Result.Side[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result.Side[i].sMessage + end + end + for i = 1, #Blade.Result.Opposite do + if Blade.Result.Opposite[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Blade.AddMachiningAllSteps( Proc, Blade.Result.Opposite[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result.Opposite[i].sMessage + end + end + if nIsApplicableCount > 0 then + -- TODO sistemare il calcolo completamento - implementare calcolo area lavorata + 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 + else + Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Parameters.bFinishWithChainSaw = false + end + + if not Strategy.Parameters.bFinishWithChainSaw then + Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( dFinalCompletionPercentage) + Strategy.Result.nQuality = FeatureData.GetFeatureQuality( 'Blade') + local MRRParametersBlade = { + dStep = TOOLS[Cutting.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting.nToolIndex].dSideStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength), + dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed} + local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) + Strategy.Result.dMRR = dMRRBlade + + return bAreAllMachiningsAdded, Strategy.Result + end + + -- sega a catena - calcolo lavorazioni + local Mortising = {} + OptionalParameters = {} + if Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Pocket-5-Blind' then + -- si lavora solamente l'impronta lama sui lati chiusi + if ( Blade.Result.Bottom[1].dResidualDepth < 10 * GEO.EPS_SMALL) and + ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength > 3 * Blade.Result.Bottom[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then + + if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Chainsaw.AddResult( Mortising) + end + if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Chainsaw.AddResult( Mortising) + end + -- si lavora tutto il fondo + else + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Chainsaw.AddResult( Mortising) + end + -- ancora materiale residuo - se possibile si lavora dal lato + if Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].dResidualDepth > 10 * GEO.EPS_SMALL and #Proc.MainFaces.SideFaces == 1 then + -- si lavora solamente l'impronta lama sul fondo + if ( #Blade.Result.Side > 0) and Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL then + if ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + elseif ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + end + -- si lavora tutto il lato + else + local dBladeResidualDepth + if #Blade.Result.Side > 0 then + dBladeResidualDepth = Blade.Result.Side[1].dResidualDepth + else + dBladeResidualDepth = Blade.Result.Bottom[1].dResidualDepth + end + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + end + end + Chainsaw.AddResult( Mortising) + end + elseif Proc.Topology.sName == 'Groove-3-Through' then + if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then + -- si lavora tutto il fondo + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Chainsaw.AddResult( Mortising) + -- ancora materiale residuo - si lavorano i lati + if Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then + -- si lavora solamente l'impronta lama sul fondo + if ( Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and + ( Blade.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then + + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + -- ancora materiale residuo - si lavora da entrambi i lati + if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Chainsaw.AddResult( Mortising) + -- lavorando dai due lati non c'è materiale residuo - si può eliminare la lavorazione del fondo + if Chainsaw.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL then + Chainsaw.Result.Bottom[1].bIsApplicable = false + end + end + -- si lavora tutto il lato + else + local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + -- ancora materiale residuo - si lavora da entrambi i lati + if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then + Chainsaw.Result.Side[1].bIsApplicable = false + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Chainsaw.AddResult( Mortising) + -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo + if Chainsaw.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL then + Chainsaw.Result.Bottom[1].bIsApplicable = false + end + end + end + end + end + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + -- si lavora solamente l'impronta lama sul lato opposto + if ( Blade.Result.Opposite[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength > 3 * Blade.Result.Opposite[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and + ( Blade.Result.Opposite[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2].dLength > 3 * Blade.Result.Opposite[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then + + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + if Chainsaw.Result.Opposite[1].dResidualDepth > GEO.EPS_SMALL or Chainsaw.Result.Opposite[2].dResidualDepth > GEO.EPS_SMALL then + Chainsaw.Result.Opposite[1].bIsApplicable = false + Chainsaw.Result.Opposite[2].bIsApplicable = false + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dMaxElev = 0} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Chainsaw.AddResult( Mortising) + end + else + local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA} + Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + if Chainsaw.Result.Opposite[1].dResidualDepth > GEO.EPS_SMALL then + Chainsaw.Result.Opposite[1].bIsApplicable = false + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA} + SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Chainsaw.AddResult( Mortising) + OptionalParameters = {} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA} + SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Chainsaw.AddResult( Mortising) + end + end + end + -- sega a catena - aggiunta lavorazioni + local nIsApplicableCount = 0 + local dFinalCompletionPercentage = 100 + local bAreAllMachiningsAdded = true + for i = 1, #Chainsaw.Result.Bottom do + if Chainsaw.Result.Bottom[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Chainsaw.AddMachiningAllSteps( Proc, Chainsaw.Result.Bottom[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Chainsaw.Result.Bottom[i].sMessage + end + end + for i = 1, #Chainsaw.Result.Side do + if Chainsaw.Result.Side[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Chainsaw.AddMachiningAllSteps( Proc, Chainsaw.Result.Side[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Chainsaw.Result.Side[i].sMessage + end + end + for i = 1, #Chainsaw.Result.Opposite do + if Chainsaw.Result.Opposite[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Chainsaw.AddMachiningAllSteps( Proc, Chainsaw.Result.Opposite[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Chainsaw.Result.Opposite[i].sMessage + end + end + if nIsApplicableCount > 0 then + if Mortising.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 = Mortising.dCompletionPercentage + end + else + Strategy.Result.sStatus = 'Not-Applicable' + end + Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( dFinalCompletionPercentage) + Strategy.Result.nQuality = FeatureData.GetFeatureQuality( 'Chainsaw') + local MRRParametersBlade = { + dStep = TOOLS[Cutting.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting.nToolIndex].dSideStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength), + dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed} + local MRRParametersChainsaw = { + dStep = min( TOOLS[Mortising.nToolIndex].dStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength), + dSideStep = TOOLS[Mortising.nToolIndex].dThickness, + dFeed = TOOLS[Mortising.nToolIndex].Feeds.dFeed} + local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) + local dMRRChainsaw = MachiningLib.GetToolMRR( MRRParametersChainsaw) + Strategy.Result.dMRR = ( dMRRBlade + dMRRChainsaw) / 2 + + return bAreAllMachiningsAdded, Strategy.Result +end + +------------------------------------------------------------------------------------------------------------- + + return STR0004 \ No newline at end of file diff --git a/Strategies/Standard/STR0004/STR0004Config.lua b/Strategies/Standard/STR0004/STR0004Config.lua new file mode 100644 index 0000000..958c429 --- /dev/null +++ b/Strategies/Standard/STR0004/STR0004Config.lua @@ -0,0 +1,10 @@ +-- Parametri configurabili da cliente per strategia: STR0004 + +local STR0004Data = { + sStrategyId = 'STR0004', + Parameters = { + { sName = 'bUseZigZagMortising', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'} + } +} + +return STR0004Data \ No newline at end of file