From 362f3fd2b0756b8894dc6bde391d4afac0403722 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 9 Aug 2024 16:46:51 +0200 Subject: [PATCH] - Prima implementazione creazioni fasi - Piccole migliorie varie - Corretta lettura info utensile profilato - Su Proc, aggiunte alcune note pezzo --- LuaLibs/BeamExec.lua | 22 ++++++++++++++++----- LuaLibs/BeamLib.lua | 3 +-- LuaLibs/MachiningLib.lua | 18 +++++++++++++++++ Strategies/Core/FACEBYBLADE.lua | 24 ++++++++++++----------- Strategies/Standard/SPLITCUT/SPLITCUT.lua | 8 +++++++- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index a7ff528..7c1e95d 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -131,7 +131,7 @@ function BeamExec.GetToolsFromDB() Tool.ToolHolder.dLength = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63 -- parametri scritti nelle note Tool.nDouble = EgtGetValInNotes( Tool.sUserNotes, 'DOUBLE') - Tool.bIsProfiledTool = EgtTdbIsCurrToolStandardDraw() + Tool.bIsProfiledTool = not EgtTdbIsCurrToolStandardDraw() -- lettura parametri non comuni ( famiglia DRILLBIT non ha parametri specifici) if sToolFamily ~= 'DRILLBIT' then @@ -348,6 +348,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS) PARTS[i].dWidth = PARTS[i].b3Raw:getDimY() PARTS[i].dHeight = PARTS[i].b3Raw:getDimZ() PARTS[i].b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + PARTS[i].nIndexInParts = i else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut @@ -485,6 +486,8 @@ local function CollectFeatures( Part) if nGrp and nPrc and nDo == 1 then local Proc = {} Proc.idPart = Part.id + Proc.idRaw = Part.idRaw + Proc.nIndexPartInParts = Part.nIndexInParts Proc.id = ProcId -- id della feature btl ( se non presente info, si prende id dell'entità geometrica) Proc.idFeature = EgtGetInfo( Proc.id, 'PRID', 's') or Proc.id @@ -885,7 +888,6 @@ function BeamExec.ProcessFeatures( PARTS) local vProcRot = {} -- lista contenente le feature da eseguire local vProc = {} - -- TODO da rimuovere o lasciare solo per debug if EgtGetDebugLevel() >= 3 then @@ -942,11 +944,11 @@ end if nOrd == 1 then EgtSetCurrPhase( 1) else - BeamLib.AddPhaseWithRawParts( PARTS[nPart], BeamData.ptOriXR, BeamData.dPosXR, 0) + BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0) end local nPhase = EgtGetCurrPhase() local nDispId = EgtGetPhaseDisposition( nPhase) - EgtSetInfo( nDispId, 'TYPE', EgtIf( PARTS[nPart].id, 'START', 'REST')) + EgtSetInfo( nDispId, 'TYPE', 'START') EgtSetInfo( nDispId, 'ORD', nOrd) EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( PARTS[nPart].idRaw) .. ' Part=' .. tostring( PARTS[nPart].id) .. ' ***', 1) @@ -984,10 +986,20 @@ end EgtOutLog( ' *** End AddMachinings ***', 1) - -- passo al grezzo successivo + -- indice pezzo successivo nOrd = nOrd + 1 end +-- ===== finiti i pezzi, si scarica il restante ===== + local idRestPart = EgtGetNextRawPart( PARTS[#PARTS].idRaw) + if idRestPart and EgtGetRawPartBBox( idRestPart):getDimX() >= BeamData.dMinRaw then + BeamLib.AddPhaseWithRawParts( idRestPart, BeamData.ptOriXR, BeamData.dPosXR, 0) + local nPhase = EgtGetCurrPhase() + local nDispId = EgtGetPhaseDisposition( nPhase) + EgtSetInfo( nDispId, 'TYPE', 'REST') + EgtSetInfo( nDispId, 'ORD', nOrd) + end + -- Aggiornamento finale di tutto EgtSetCurrPhase( 1) local bApplOk, sApplErrors, sApplWarns = EgtApplyAllMachinings() diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 3b2f76e..fa9b14e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -91,9 +91,8 @@ function BeamLib.AddPartEndFace( PartId, b3Solid) end ------------------------------------------------------------------------------------------------------------- -function BeamLib.AddPhaseWithRawParts( Part, OriXR, PosXR, dDeltaSucc) +function BeamLib.AddPhaseWithRawParts( nRawId, OriXR, PosXR, dDeltaSucc) EgtAddPhase() - local nRawId = Part.idRaw local dRawMove = 0 while nRawId do EgtKeepRawPart( nRawId) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 809deda..757f574 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -10,6 +10,7 @@ require( 'EgtBase') -- Carico i dati globali local BeamData = require( 'BeamData') +local BeamLib = require( 'BeamLib') EgtOutLog( ' MachiningLib started', 1) @@ -519,6 +520,23 @@ function MachiningLib.AddOperations( vProc, Part) nErr, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nOperationId, false) end + + + -- TODO è giusto inserire queste info alla fine della lavorazione? oppure conviene creare un record in MACHININGS apposito per la disposizione? + -- se era taglio di separazione, aggiungo nuova fase + if MACHININGS[i].AuxiliaryData.bAddNewPhase then + BeamLib.AddPhaseWithRawParts( MACHININGS[i].Proc.idRaw, BeamData.ptOriXR, BeamData.dPosXR, BeamData.RAW_OFFSET) + -- se grezzo successivo senza pezzi e finale, va tolto + local nNextRawId = EgtGetNextRawPart( MACHININGS[i].Proc.idRaw) + if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BeamData.dMinRaw then + EgtRemoveRawPartFromCurrPhase( nNextRawId) + end + local nPhase = EgtGetCurrPhase() + local nDispId = EgtGetPhaseDisposition( nPhase) + EgtSetInfo( nDispId, 'TYPE', 'END') + EgtSetInfo( nDispId, 'ORD', MACHININGS[i].Proc.nIndexPartInParts) + end + else return false, 'UNEXPECTED ERROR: Error on creating machining' end diff --git a/Strategies/Core/FACEBYBLADE.lua b/Strategies/Core/FACEBYBLADE.lua index 6c8f15d..b2fba40 100644 --- a/Strategies/Core/FACEBYBLADE.lua +++ b/Strategies/Core/FACEBYBLADE.lua @@ -69,30 +69,32 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local vtMachiningDirection = EdgeToMachine.Norm local vtN = Proc.Faces[FaceToMachine+1].vtN - Cutting.nFaceuse = OptionalParameters.nFaceuse Cutting.sDepth = OptionalParameters.sDepth - -- utilizzo i parametri di collegamento passati, altrimenti ricalcolo - if OptionalParameters.LeadIn and OptionalParameters.LeadOut then - Cutting.LeadIn, Cutting.LeadOut = OptionalParameters.LeadIn, OptionalParameters.LeadOut - else - Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( EdgeToMachine) - end - Cutting.nType = MCH_MY.MILLING Cutting.nToolIndex = OptionalParameters.nToolIndex Cutting.Geometry = {{ Proc.id, FaceToMachine}} Cutting.id = Proc.id + + -- ===== calcolo LeadIn/out ===== + if OptionalParameters.LeadIn and OptionalParameters.LeadOut then + Cutting.LeadIn, Cutting.LeadOut = OptionalParameters.LeadIn, OptionalParameters.LeadOut + else + Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( EdgeToMachine) + end + + -- ===== scelta soluzione braccio C del motore ===== Cutting.nSCC = GetSCC( vtMachiningDirection) - Cutting.sUserNotes = EgtSetValInNotes( sUserNotes, 'VtFaceUse', vtMachiningDirection) - + -- ===== parametri da settare in UserNotes ===== + Cutting.nFaceuse = OptionalParameters.nFaceuse + Cutting.sUserNotes = EgtSetValInNotes( Cutting.sUserNotes, 'VtFaceUse', vtMachiningDirection) if OptionalParameters.sUserNotes then Cutting.sUserNotes = Cutting.sUserNotes .. OptionalParameters.sUserNotes end - + -- ===== scelta senso di lavorazione ===== local bIsSawCCW = TOOLS[Cutting.nToolIndex].bIsCCW local bInvert -- se la lama ruota in senso antiorario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento diff --git a/Strategies/Standard/SPLITCUT/SPLITCUT.lua b/Strategies/Standard/SPLITCUT/SPLITCUT.lua index d9f20a0..4a6cd6f 100644 --- a/Strategies/Standard/SPLITCUT/SPLITCUT.lua +++ b/Strategies/Standard/SPLITCUT/SPLITCUT.lua @@ -236,6 +236,7 @@ function SPLITCUT.Make( bAddMachining, Proc, Part, CustomParameters) Strategy = LoadStrategyParameters( CustomParameters) local bAreAllMachiningsAdded = true local Splitting = {} + local AuxiliaryData = {} Strategy.sSplitStrategy = GetSplitStrategy( Proc, Part) if bAddMachining then @@ -250,16 +251,21 @@ function SPLITCUT.Make( bAddMachining, Proc, Part, CustomParameters) OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK OptionalParameters.sDepth = 0 + + -- TODO gestire lavorazione a cubetti + if Strategy.bSplit then OptionalParameters.sUserNotes = 'Split;' else OptionalParameters.sUserNotes = 'Cut;' end + AuxiliaryData.bAddNewPhase = true + local EdgeToMachine = GetEdgeToMachine( Proc, -Y_AX()) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) - MachiningLib.AddNewMachining( Proc, Splitting) + MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeSideDouble' then ; -- TODO elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalSingle' then