4ba4ddb698
- Nello split con sega a catena ora si cerca di preferenza una lavorazione di tipo 'SawingForSplitting'. Se non trovata si cerca il tipo 'Sawing' come in precedenza. - In split con sega a catena aggiunta estensione start/end del percorso se utensile lungo, per evitare collisioni con il pezzo durante rotazione.
512 lines
24 KiB
Lua
512 lines
24 KiB
Lua
-- MachiningLib.lua by Egaltech s.r.l. 2023/11/06
|
|
-- 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.
|
|
-- 2022/11/25 Per FindMilling implementata la possibilità di escludere la testa H3 dalla ricerca utensile.
|
|
-- 2022/12/28 Per FindMilling e FindDrilling possibilità di escludere la testa H2 dalla ricerca utensile.
|
|
-- 2023/01/31 Per FindPocketing implementata la possibilità di escludere le teste H2 o H3 dalla ricerca utensile.
|
|
-- 2023/07/28 Aggiunta gestione del tipo di foratura "Drill_AT".
|
|
-- 2023/11/06 Migliorie e correzioni alle forature con AngularTransmission ("_AT").
|
|
-- 2024/01/18 In FindSawing aggiunto il parametro opzionale dDepth.
|
|
-- 2024/01/19 In FindSawing aggiunto parametro opzionale bConsiderCSimmEncumberance per considerare l'ingombro dell'asse C nel massimo materiale (default false).
|
|
-- 2024/01/23 Nella GetMachinings vengono ora raccolti i parametri utensile necessari per i VerifyTool, scritti direttamente nella tabella Machining.Tool.
|
|
-- Le lavorazioni possono essere ora ordinate per dimensioni utensile (Longest, Shortest, Biggest, Smallest) se passato l'apposito parametro SortingCriterion in FindMachining. Al momento implementato solo per FindSawing.
|
|
|
|
-- Tabella per definizione modulo
|
|
local MachiningLib = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' MachiningLib started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local Cuttings = require( 'CutData')
|
|
local Millings = require( 'MillingData')
|
|
local Pocketings = require( 'PocketingData')
|
|
local Sawings = require( 'SawingData')
|
|
local Drillings = require( 'DrillData')
|
|
|
|
-- tipo di teste macchina
|
|
local ONE_HEAD = 1 -- una testa (Fast, One, Turn1T)
|
|
local TWO_EQUAL_HEADS = 2 -- due teste uguali (PF, Turn)
|
|
local TWO_UP_DOWN_HEADS = 3 -- due teste una sopra l'altra sotto (PF1250)
|
|
local MachineHeadType = 0
|
|
|
|
-- testa correntementa attiva, e utensili correnti per ogni testa
|
|
local nActiveHead = 0
|
|
local H1_TOOL = ''
|
|
local H2_TOOL = ''
|
|
|
|
-- testa e utensile della lavorazione restituita ma non ancora confermata
|
|
local nNextMachHead = 0
|
|
local H1_NEXT_TOOL = ''
|
|
local H2_NEXT_TOOL = ''
|
|
|
|
-- teste con utensili fissi
|
|
local vFixedHeads = {}
|
|
|
|
---------------------------------------------------------------------
|
|
-- funzione che imposta il tipo di macchina corrente
|
|
local function SetCurrMachineHeadType()
|
|
-- se già inizializzato, esco
|
|
if MachineHeadType and MachineHeadType >= 1 and MachineHeadType <= 3 then return end
|
|
-- altrimenti, lo imposto
|
|
if BD.DOWN_HEAD then
|
|
MachineHeadType = TWO_UP_DOWN_HEADS
|
|
elseif BD.TWO_EQUAL_HEADS then
|
|
MachineHeadType = TWO_EQUAL_HEADS
|
|
else
|
|
MachineHeadType = ONE_HEAD
|
|
end
|
|
-- imposto eventuali teste con utensili fissi
|
|
if BD.C_SIMM then
|
|
vFixedHeads = { [31] = true}
|
|
elseif BD.TURN then
|
|
vFixedHeads = { [12] = true, [22] = true}
|
|
else -- FAST
|
|
vFixedHeads = { [2] = true}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- funzione che conferma e rende attivi testa e utensile ipotizzati
|
|
local function ConfirmNextMachining()
|
|
-- se non definita testa successiva, esco
|
|
if not nNextMachHead or nNextMachHead < 1 or nNextMachHead > 2 then return end
|
|
-- altrimenti, la confermo come attiva
|
|
nActiveHead = nNextMachHead
|
|
if nNextMachHead == 1 then
|
|
H1_TOOL = H1_NEXT_TOOL
|
|
elseif nNextMachHead == 2 then
|
|
H2_TOOL = H2_NEXT_TOOL
|
|
end
|
|
-- reset prossima testa
|
|
nNextMachHead = 0
|
|
H1_NEXT_TOOL = ''
|
|
H2_NEXT_TOOL = ''
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- funzione che traccia testa e utensile ipotizzati
|
|
local function SetNextMachining( sToolName, nHead, bFixed)
|
|
if nHead < 1 or nHead > 2 then return end
|
|
if bFixed then
|
|
nNextMachHead = 0
|
|
H1_NEXT_TOOL = ''
|
|
H2_NEXT_TOOL = ''
|
|
end
|
|
nNextMachHead = nHead
|
|
if nHead == 1 then
|
|
H1_NEXT_TOOL = sToolName
|
|
elseif nHead == 2 then
|
|
H2_NEXT_TOOL = sToolName
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
local function SetCurrMachiningAndTool( Machining)
|
|
EgtMdbSetCurrMachining( Machining.Name)
|
|
EgtTdbSetCurrTool( Machining.Tool.Name)
|
|
local bActive = EgtFindToolInCurrSetup( Machining.Tool.Name)
|
|
local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
|
|
local nHead = tonumber( sHead:sub( 2, #sHead))
|
|
local bH2 = ( nHead >= 21 and nHead <= 29)
|
|
local bH3 = ( nHead >= 31 and nHead <= 39)
|
|
local bFixed = ( vFixedHeads[nHead])
|
|
return bActive, Machining.Tool.Name, bH2, bFixed, bH3
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyDrill( Machining, dDiam, dDepth, bH2)
|
|
local dFreeLen = Machining.Tool.Length - Machining.Tool.ToolHolderLength - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE)
|
|
if Machining.Tool.Diameter < dDiam + 10 * GEO.EPS_SMALL and
|
|
Machining.Tool.Diameter > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL and
|
|
( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) then
|
|
return true, { TMaxMat = Machining.Tool.MaxMat, MaxToolLength = Machining.Tool.TotalLength, ToolDiam = Machining.Tool.Diameter, DiamTh = Machining.Tool.ToolHolderDiameter, FreeLen = dFreeLen, H2 = bH2}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyDrillPocket( Machining, dDiam, dDepth, bH2)
|
|
if Machining.Tool.Diameter < dDiam - 10 * GEO.EPS_SMALL and
|
|
( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) then
|
|
return true, { TMaxDepth = Machining.Tool.MaxMat, MaxToolLength = Machining.Tool.TotalLength, ToolDiam = Machining.Tool.Diameter, DiamTh = Machining.Tool.ToolHolderDiameter, FreeLen = Machining.Tool.MaxMat, H2 = bH2}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyMill( Machining, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bH2)
|
|
if ( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) and
|
|
( not sTuuidMstr or sTuuidMstr == Machining.Tool.UUID) and
|
|
( not dMaxDiam or Machining.Tool.Diameter < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dMaxTotLen or Machining.Tool.TotalLength < dMaxTotLen + GEO.EPS_SMALL) then
|
|
return true, { TMaxDepth = Machining.Tool.MaxMat, TDiam = Machining.Tool.Diameter, H2 = bH2}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyPocket( Machining, dMaxDiam, dDepth, dMaxTotLen, bH2)
|
|
if ( not dMaxDiam or Machining.Tool.Diameter < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) and
|
|
( not dMaxTotLen or Machining.Tool.TotalLength < dMaxTotLen + GEO.EPS_SMALL) then
|
|
return true, { TDiam = Machining.Tool.Diameter, TMaxDepth = Machining.Tool.MaxMat, H2 = bH2}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyChainSaw( Machining, dDepth, CSimmEncumberance, bH2)
|
|
-- riduco il massimo materiale dell'ingombro asse C. Se non richiesto, arriverà un valore di CSimmEncumberance nullo
|
|
Machining.Tool.MaxMat = min( Machining.Tool.MaxMat, Machining.Tool.TotalLength - CSimmEncumberance)
|
|
if not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL then
|
|
return true, { H2 = bH2}
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function VerifyTool( Machining, MachiningType, Params, bH2)
|
|
if MachiningType == MCH_MY.DRILLING then
|
|
if Machining.SubType == 'Drill' or Machining.SubType == 'AngleDrill' then
|
|
return VerifyDrill( Machining, Params.Diam, Params.Depth, bH2)
|
|
elseif Machining.SubType == 'DrillPocket' then
|
|
return VerifyDrillPocket( Machining, Params.Diam, Params.Depth, bH2)
|
|
end
|
|
elseif MachiningType == MCH_MY.SAWING then
|
|
return true, { H2 = bH2}
|
|
elseif MachiningType == MCH_MY.MILLING then
|
|
return VerifyMill( Machining, Params.Depth, Params.TuuidMstr, Params.MaxDiam, Params.MaxTotLen, bH2)
|
|
elseif MachiningType == MCH_MY.POCKETING then
|
|
return VerifyPocket( Machining, Params.MaxDiam, Params.Depth, Params.MaxTotLen, bH2)
|
|
elseif MachiningType == MCH_MY.MORTISING then
|
|
return VerifyChainSaw( Machining, Params.Depth, Params.CSimmEncumberance, bH2)
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function GetMachinings( MachiningType, sType)
|
|
local Machinings
|
|
-- leggo le lavorazioni disponibili
|
|
if MachiningType == MCH_MY.DRILLING then
|
|
Machinings = Drillings
|
|
elseif MachiningType == MCH_MY.SAWING then
|
|
Machinings = Cuttings
|
|
elseif MachiningType == MCH_MY.MILLING then
|
|
Machinings = Millings
|
|
elseif MachiningType == MCH_MY.POCKETING then
|
|
Machinings = Pocketings
|
|
elseif MachiningType == MCH_MY.MORTISING then
|
|
Machinings = Sawings
|
|
end
|
|
-- scrivo i parametri utensile nella lavorazione
|
|
local validMachinings = {}
|
|
for i = 1, #Machinings do
|
|
local Machining = Machinings[i]
|
|
if EgtMdbSetCurrMachining( Machining.Name) then
|
|
Machining.Tool = {}
|
|
Machining.Tool.UUID = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
Machining.Tool.Name = EgtTdbGetToolFromUUID( Machining.Tool.UUID)
|
|
if Machining.Tool.Name then
|
|
if EgtTdbSetCurrTool( Machining.Tool.Name) then
|
|
table.insert( validMachinings, Machining)
|
|
if ( MachiningType == MCH_MY.MILLING) or ( MachiningType == MCH_MY.POCKETING) or ( MachiningType == MCH_MY.DRILLING and EgtStartsWith( sType, 'Pocket')) then
|
|
Machining.Tool.MaxMat = EgtTdbGetCurrToolMaxDepth()
|
|
else
|
|
Machining.Tool.MaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
|
|
end
|
|
if MachiningType == MCH_MY.DRILLING then
|
|
if EgtStartsWith( Machining.Type, 'Drill') then
|
|
Machining.SubType = 'Drill'
|
|
elseif EgtStartsWith( Machining.Type, 'AngleDrill') then
|
|
Machining.SubType = 'AngleDrill'
|
|
elseif EgtStartsWith( Machining.Type, 'Pocket') then
|
|
Machining.SubType = 'DrillPocket'
|
|
end
|
|
end
|
|
Machining.Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN)
|
|
Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
|
|
Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam()
|
|
Machining.Tool.ToolHolderLength = EgtTdbGetCurrToolThLength() or 72
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-- ritorno la lista delle sole lavorazioni valide
|
|
return validMachinings
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
---restituisce la lista delle lavorazioni ordinata secondo il criterio *sCriterion*
|
|
---@param Machinings table lista della lavorazioni da riordinare
|
|
---@param sCriterion string criterio di ordinamento ('Longest', 'Shortest', 'Biggest', 'Smallest')
|
|
function ReorderMachinings( Machinings, sCriterion)
|
|
|
|
-- funzioni di ordinamento
|
|
local function SortMachiningsByLongestTool( Machining1, Machining2)
|
|
if Machining1.Tool.MaxMat > Machining2.Tool.MaxMat + 10 * GEO.EPS_SMALL then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
local function SortMachiningsByShortestTool( Machining1, Machining2)
|
|
if Machining1.Tool.MaxMat < Machining2.Tool.MaxMat - 10 * GEO.EPS_SMALL then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
local function SortMachiningsByBiggestTool( Machining1, Machining2)
|
|
if Machining1.Tool.Diameter > Machining2.Tool.Diameter + 10 * GEO.EPS_SMALL then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
local function SortMachiningsBySmallestTool( Machining1, Machining2)
|
|
if Machining1.Tool.Diameter < Machining2.Tool.Diameter - 10 * GEO.EPS_SMALL then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
-- ordinamento in base al criterio
|
|
-- ordine di default, ossia quello che arriva dal database
|
|
if not sCriterion then
|
|
return
|
|
-- prima gli utensili più lunghi
|
|
elseif sCriterion == 'Longest' then
|
|
table.sort( Machinings, SortMachiningsByLongestTool)
|
|
-- prima gli utensili più corti
|
|
elseif sCriterion == 'Shortest' then
|
|
table.sort( Machinings, SortMachiningsByShortestTool)
|
|
-- prima gli utensili con diametro più grande
|
|
elseif sCriterion == 'Biggest' then
|
|
table.sort( Machinings, SortMachiningsByBiggestTool)
|
|
-- prima gli utensili con diametro più piccolo
|
|
elseif sCriterion == 'Smallest' then
|
|
table.sort( Machinings, SortMachiningsBySmallestTool)
|
|
end
|
|
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function ReturnParams( MachiningType, MachiningName, sType, ToolParams)
|
|
if MachiningType == MCH_MY.DRILLING then
|
|
local _, sOrigType = EgtEndsWith( sType, '_H2')
|
|
return MachiningName, sType, EgtIf( sOrigType == 'Drill' or sOrigType == 'Drill_AT' or sOrigType == 'AngleDrill' , ToolParams.TMaxMat, ToolParams.TMaxDepth), ToolParams.MaxToolLength, ToolParams.ToolDiam, ToolParams.DiamTh, ToolParams.FreeLen
|
|
elseif MachiningType == MCH_MY.SAWING then
|
|
return MachiningName, ToolParams.H2
|
|
elseif MachiningType == MCH_MY.MILLING then
|
|
return MachiningName, ToolParams.TMaxDepth, ToolParams.TDiam, ToolParams.H2
|
|
elseif MachiningType == MCH_MY.POCKETING then
|
|
return MachiningName, ToolParams.TDiam, ToolParams.TMaxDepth, ToolParams.H2
|
|
elseif MachiningType == MCH_MY.MORTISING then
|
|
return MachiningName
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion)
|
|
if bTopHead == nil and bDownHead == nil then
|
|
bTopHead = true
|
|
bDownHead = false
|
|
elseif bTopHead == nil then
|
|
bTopHead = not bDownHead
|
|
elseif bDownHead == nil then
|
|
bDownHead = not bTopHead
|
|
end
|
|
if bExcludeH2 == nil then
|
|
bExcludeH2 = false
|
|
end
|
|
if bExcludeH3 == nil then
|
|
bExcludeH3 = false
|
|
end
|
|
SetCurrMachineHeadType()
|
|
-- verifico se non richiesta testa sopra e macchina ha solo teste sopra
|
|
if not bTopHead and MachineHeadType ~= TWO_UP_DOWN_HEADS and not BD.TURN then
|
|
return nil
|
|
end
|
|
-- verifico se testa attiva va bene
|
|
local sH1Mach = ''
|
|
local sH1Tool = ''
|
|
local sH1Param
|
|
local sH2Mach = ''
|
|
local sH2Tool = ''
|
|
local sH2Param
|
|
local Machinings = GetMachinings( MachiningType, sType)
|
|
ReorderMachinings( Machinings, sSortingCriterion)
|
|
local ForStart = 1
|
|
local ForEnd = #Machinings
|
|
local ForStep = 1
|
|
-- le forature vanno scorse dal diametro maggiore al minore
|
|
if MachiningType == MCH_MY.DRILLING then
|
|
ForStart = #Machinings
|
|
ForEnd = 1
|
|
ForStep = -1
|
|
end
|
|
if ( BEAM and BEAM.BW) or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then
|
|
_, sType = EgtEndsWith( sType, '_H2')
|
|
elseif ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bDownHead then
|
|
if not EgtEndsWith( sType, '_H2') then
|
|
sType = sType .. '_H2'
|
|
end
|
|
end
|
|
local MachineHeadUse = MachineHeadType
|
|
if not BEAM or not BEAM.BW then
|
|
MachineHeadUse = ONE_HEAD
|
|
end
|
|
if BEAM and BEAM.BW and MachineHeadUse == TWO_UP_DOWN_HEADS and bTopHead and bDownHead then
|
|
-- 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
|
|
if BEAM and BEAM.BW then
|
|
_, sMachiningType = EgtEndsWith( Machining.Type, '_H2')
|
|
end
|
|
-- recupero dati utensile
|
|
local bToolActive, sToolName, bH2, bFixed, bH3 = SetCurrMachiningAndTool( Machining)
|
|
if Machining.On and sMachiningType == sType and bToolActive and ( not bH2 or bH2 == not bExcludeH2) and ( not bH3 or bH3 == not bExcludeH3) then
|
|
local bOk, ToolParams = VerifyTool( Machining, MachiningType, Params, bH2)
|
|
if bOk then
|
|
if MachineHeadUse == ONE_HEAD then
|
|
SetNextMachining( sToolName, 1, bFixed)
|
|
return ReturnParams(MachiningType, Machining.Name, Machining.Type, ToolParams)
|
|
elseif MachineHeadUse == TWO_EQUAL_HEADS then
|
|
-- se nessuna testa attiva, prendo la prima lavorazione disponibile
|
|
if nActiveHead == 0 then
|
|
SetNextMachining( sToolName, EgtIf( bH2, 2, 1), bFixed)
|
|
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
|
|
-- 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
|
|
if not sH1Mach or sH1Mach == '' then
|
|
sH1Mach = Machining.Name
|
|
sH1Tool = sToolName
|
|
sH1Param = ToolParams
|
|
end
|
|
end
|
|
elseif MachineHeadUse == TWO_UP_DOWN_HEADS then
|
|
if bTopHead and not bH2 then
|
|
SetNextMachining( sToolName, 1, bFixed)
|
|
return ReturnParams( MachiningType, Machining.Name, Machining.Type, ToolParams)
|
|
elseif bDownHead and bH2 then
|
|
SetNextMachining( sToolName, 2, bFixed)
|
|
return ReturnParams( MachiningType, Machining.Name, Machining.Type, ToolParams)
|
|
end
|
|
end
|
|
end
|
|
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
|
|
SetNextMachining( sH2Tool, 2, bFixed)
|
|
return ReturnParams( MachiningType, sH2Mach, sType, sH2Param)
|
|
--return sH2Mach, sH2Param.Type, sH2Param.TMaxMat, sH2Param.MaxToolLength, sH2Param.ToolDiam, sH2Param.DiamTh, sH2Param.FreeLen
|
|
elseif sH1Mach ~= "" then
|
|
SetNextMachining( sH1Tool, 1, bFixed)
|
|
return ReturnParams( MachiningType, sH1Mach, sType, sH1Param)
|
|
--return sH1Mach, sH1Param.Type, sH1Param.TMaxMat, sH1Param.MaxToolLength, sH1Param.ToolDiam, sH1Param.DiamTh, sH1Param.FreeLen
|
|
end
|
|
elseif nActiveHead == 2 then
|
|
if sH1Mach ~= "" then
|
|
SetNextMachining( sH1Tool, 1, bFixed)
|
|
return ReturnParams( MachiningType, sH1Mach, sType, sH1Param)
|
|
--return sH1Mach, sH1Param.Type, sH1Param.TMaxMat, sH1Param.MaxToolLength, sH1Param.ToolDiam, sH1Param.DiamTh, sH1Param.FreeLen
|
|
elseif sH2Mach ~= "" then
|
|
SetNextMachining( sH2Tool, 2, bFixed)
|
|
return ReturnParams( MachiningType, sH2Mach, sType, sH2Param)
|
|
--return sH2Mach, sH2Param.Type, sH2Param.TMaxMat, sH2Param.MaxToolLength, sH2Param.ToolDiam, sH2Param.DiamTh, sH2Param.FreeLen
|
|
end
|
|
end
|
|
end
|
|
local bH2, sOrigType = EgtEndsWith( sType, '_H2')
|
|
if ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then
|
|
return FindMachining( MachiningType, sOrigType, Params, true, false)
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindCutting( sType, bTopHead, bDownHead)
|
|
return FindMachining( MCH_MY.SAWING, sType, nil, bTopHead, bDownHead)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindDrilling( dDiam, dDepth, bTopHead, bDownHead, bExcludeH2, bAngleTransmission)
|
|
local MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5 = FindMachining( MCH_MY.DRILLING, EgtIf( bAngleTransmission, 'Drill_AT', 'Drill'), { Diam = dDiam, Depth = dDepth}, bTopHead, bDownHead, bExcludeH2)
|
|
if ( not MachiningName or MachiningName == '') then
|
|
MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5 = FindMachining( MCH_MY.DRILLING, EgtIf( bAngleTransmission, 'Pocket_AT', 'Pocket'), { Diam = dDiam, Depth = dDepth}, bTopHead, bDownHead)
|
|
end
|
|
if MachiningName and MachiningName ~= '' then
|
|
return MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindAngleDrilling( dDiam, dDepth, bTopHead, bDownHead)
|
|
local MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5 = FindMachining( MCH_MY.DRILLING, 'AngleDrill', { Diam = dDiam, Depth = dDepth}, bTopHead, bDownHead)
|
|
if MachiningName and MachiningName ~= '' then
|
|
return MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3)
|
|
return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3)
|
|
return FindMachining( MCH_MY.POCKETING, sType, { MaxDiam = dMaxDiam, Depth = dDepth, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindSawing( sType, dDepth, bConsiderCSimmEncumberance, sSortingCriterion)
|
|
if not BD.C_SIMM_ENC then BD.C_SIMM_ENC = EgtIf( BD.C_SIMM, 180, 90) end
|
|
return FindMachining( MCH_MY.MORTISING, sType, { Depth = dDepth, CSimmEncumberance = EgtIf( bConsiderCSimmEncumberance, BD.C_SIMM_ENC, 0)}, nil, nil, nil, nil, sSortingCriterion)
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function MachiningLib.ApplyMachining( bRecalc, bApplyPost)
|
|
local bResult = EgtApplyMachining( bRecalc, bApplyPost)
|
|
if bResult then ConfirmNextMachining() end
|
|
return bResult
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return MachiningLib
|