From 7e21b84bb944db472a1fd181a3d933f2e91707f0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 2 Nov 2022 18:59:14 +0100 Subject: [PATCH] =?UTF-8?q?Improvement/Ticket#855:=20-=20in=20MachiningLib?= =?UTF-8?q?=20modificata=20scelta=20utensile=20ottimizzata.=20Ora=20se=20c?= =?UTF-8?q?'=C3=A8=20un=20utensile=20pi=C3=B9=20grande=20disponibile=20si?= =?UTF-8?q?=20d=C3=A0=20preferenza=20a=20quello.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/MachiningLib.lua | 45 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 3daa60b..8d1bc16 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -2,6 +2,7 @@ -- Libreria ricerca lavorazioni per Travi -- 2022/05/07 ES Profonde modifiche per scelta ottimale lavorazioni in macchine con più teste. -- 2022/07/27 Aggiunta la gestione del tipo di foratura "AngleDrill" per fori molto inclinati +-- 2022/11/02 Modificata scelta utensile ottimizzata. Ora se c'è un utensile più grande disponibile si dà preferenza a quello. -- Tabella per definizione modulo local MachiningLib = {} @@ -263,6 +264,8 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) -- se posso usare entrambe le teste, la gestisco come una macchina a due teste da sopra MachineHeadUse = TWO_EQUAL_HEADS end + -- variabile che definisce quando un utensile ha un diametro sostanzialmente più grande di un altro + local dBiggerToolTolerance = 1.25 for i = ForStart, ForEnd, ForStep do local Machining = Machinings[i] local sMachiningType = Machining.Type @@ -284,22 +287,24 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) return ReturnParams( MachiningType, Machining.Name, Machining.Type, ToolParams) -- verifico se posso usare lo stesso utensile della testa attiva elseif ( nActiveHead == 1 and not bH2 and sToolName == H1_TOOL) or ( nActiveHead == 2 and bH2 and sToolName == H2_TOOL) then - SetNextMachining( sToolName, nActiveHead, bFixed) - return ReturnParams( MachiningType, Machining.Name, Machining.Type, ToolParams) + -- se l'utensile sulla testa attiva è molto più piccolo rispetto a quelli salvati non lo scelgo + if ( not sH1Param or not sH1Param.TDiam or sH1Param.TDiam < dBiggerToolTolerance * ToolParams.TDiam) and ( not sH2Param or not sH2Param.TDiam or sH2Param.TDiam < 1.25 * ToolParams.TDiam) then + SetNextMachining( sToolName, nActiveHead, bFixed) + return ReturnParams( MachiningType, Machining.Name, Machining.Type, ToolParams) + end + end + -- segno le lavorazioni disponibili per entrambe le teste + if bH2 then + if not sH2Mach or sH2Mach == '' then + sH2Mach = Machining.Name + sH2Tool = sToolName + sH2Param = ToolParams + end else - -- segno le lavorazioni disponibili per entrambe le teste - if bH2 then - if not sH2Mach or sH2Mach == '' then - sH2Mach = Machining.Name - sH2Tool = sToolName - sH2Param = ToolParams - end - else - if not sH1Mach or sH1Mach == '' then - sH1Mach = Machining.Name - sH1Tool = sToolName - sH1Param = ToolParams - end + if not sH1Mach or sH1Mach == '' then + sH1Mach = Machining.Name + sH1Tool = sToolName + sH1Param = ToolParams end end elseif MachineHeadUse == TWO_UP_DOWN_HEADS then @@ -315,6 +320,16 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) end end if MachineHeadUse == TWO_EQUAL_HEADS then + -- se uno dei due utensili è molto più grande dell'altro scelgo quello senza fare altre analisi + if sH1Mach ~= "" and sH1Param.TDiam and sH2Mach ~= "" and sH2Param.TDiam then + if sH1Param.TDiam > dBiggerToolTolerance * sH2Param.TDiam then + SetNextMachining( sH1Tool, 1, bFixed) + return ReturnParams( MachiningType, sH1Mach, sType, sH1Param) + elseif sH2Param.TDiam > dBiggerToolTolerance * sH1Param.TDiam then + SetNextMachining( sH2Tool, 2, bFixed) + return ReturnParams( MachiningType, sH2Mach, sType, sH2Param) + end + end -- verifico se cambiare testa o cambiare utensile su quella corrente if nActiveHead == 1 then if sH2Mach ~= "" then