Files
Essetre-WALL_XS0014/Essetre-WALL_XS.TPA.mlpe
luca.mazzoleni 5df48bfe17 primo commit
2024-09-19 09:27:57 +02:00

753 lines
27 KiB
Plaintext

-- Processore macchina Essetre-WallXS by EgalTech s.r.l. 2022/08/03
-- Con controllo numerico TPA
-- 2021/12/10 DS Prima versione
-- 2022/05/05 DS ver 2.4e1 Ora Nailing emette feed di lavoro.
-- 2022/05/12 DS ver 2.4e3 Ora Nailing usa Z di lavorazione come PodBau (affondamento == lughezza utensile).
-- Variabili di modulo
local MLE_INFO = 'Essetre-WallXS.TPA.mlpe ver.'..PP_VER..' by Egalware s.r.l.'
local TEST_USE = false
---------------------------------------------------------------------
-- *** GENERATION ***
---------------------------------------------------------------------
function OnStart()
-- controllo versione programma
if not EMT.VER or EMT.VER < '2.5d1' then
EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel 2.5d1)')
end
EMT.USETO1 = false -- abilitazione uso origine tavola
EMT.MODAL = true -- abilitazione emissione modale
EMT.INCHES = false -- unità di misura mm/inches
EMT.NUM = false -- abilitazione numerazione linee
--EMT.Nt = 'N' -- token per la numerazione di linea
--EMT.LINENBR = 0 -- numero di linea
--EMT.LINEINC = 1 -- incremento numerazione linee
--EMT.Ft = 'F' -- token per feed
--EMT.St = 'S' -- token per speed
end
---------------------------------------------------------------------
function OnEnd()
-- Ripristino fase iniziale come corrente
EgtSetCurrPhase( 1)
end
---------------------------------------------------------------------
function OnProgramStart()
-- Info da gruppo BtlInfo
local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL
EMT.LOAD90 = EgtGetInfo( BtlInfoId, 'LOAD90', 'i') or 0
local nRefPos = EgtClamp( EgtGetInfo( BtlInfoId, 'REFPOS', 'i') or 1, 1, 8)
if nRefPos <= 4 then
EMT.ORIG = nRefPos
else
EMT.ORIG = nRefPos + 6
end
-- Intestazioni
if not TEST_USE then
EMT.PRODID = EgtGetInfo( BtlInfoId, 'PRODID', 'i') or 0
EMT.PATTID = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 0
end
EmtOutput( ';LISTA = ' .. tostring( EMT.PRODID or 0))
if EMT.INFO then
EmtOutput( ';'..EMT.INFO)
else
EmtOutput( ';Program Start')
end
EmtOutput( ';'.. MLE_INFO)
-- Indice lavorazione
EMT.CNT = 0
-- Non effettuate lavorazioni con sega a catena sul fianco
EMT.CSAWFIRST = true
-- Non effettuata pausa per rimozione sfridi
EMT.SCRAPFIRST = true
-- Cerco primo utensile su testa 1
EMT.TOOL_1, EMT.TLEN_1 = FindFirstToolOnHead( 'H1')
-- Inizializzazioni varie
EmtOutput( 'M6 T000000')
EmtOutput( 'G49')
-- Inizio lista utensili
EmtOutput( 'M993 (Tool List Start)')
end
---------------------------------------------------------------------
function OnProgramEnd()
EmtOutput( '; *** Program End ***')
EmitCount( false)
EmtOutput( 'M117 P1=0')
-- Dichiarazione conclusione pezzi
if EMT.PRODID then
local sOut = 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( -1)..' P4=2'
EmtOutput( sOut)
end
-- Arresto mandrino
EmtOutput( 'M05')
-- Tipo di scarico
if not TEST_USE then
EmtOutput( 'M116')
end
-- Termino il programma
EmtOutput( 'M02')
end
---------------------------------------------------------------------
function OnToolData()
-- emissione dati utensili
if EMT.HEAD == 'H1' then
local sOut = 'M992 P1=' .. EMT.TCPOS:gsub( 'T', '') .. ' P2=' .. EmtLenToString( EMT.TLEN, 3) .. ' P3=' .. EmtLenToString( EMT.TDIAM, 3) ..
' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( EMT.TTOTLEN, 3)
EmtOutput( sOut)
-- cerco posizione di attrezzaggio del primo utensile di lavorazione
if EMT.TOOL == EMT.TOOL_1 and EMT.TLEN_1 < 215.5 then
EMT.TCPOS_1 = EMT.TCPOS
end
-- emissione dati lama
elseif EMT.HEAD == 'H2' then
local sOut = 'M992 P1=' .. EMT.TCPOS:gsub( 'T', '') .. ' P2=' .. EmtLenToString( -SawOffsZ + EMT.TLEN, 3) .. ' P3=' .. EmtLenToString( EMT.TDIAM, 3) ..
' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( EMT.TTOTLEN, 3)
EmtOutput( sOut)
-- emissione dati sega a catena
elseif EMT.HEAD == 'H3' then
if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end
local sData = ' P2=' .. EmtLenToString( ( EMT.TDIST or ChSawLen), 3) .. ' P3=' .. EmtLenToString( EMT.TLEN, 3) ..
' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( (EMT.TDIST or ChSawLen), 3)
EmtOutput( 'M992 P1=8' .. sData)
end
end
---------------------------------------------------------------------
function OnDispositionStart()
--EmtOutput( '(Disposition '..EMT.DISPIND..' = '..EMT.DISPID..')')
EMT.OPEISDISP = true
-- Se prima disposizione
if EMT.PHASE == 1 then
-- terminazione lista utensili
EmtOutput( 'G990 (Tool List End)')
-- Parametri macchina
local d1stNailX, d1stNailY, d1stNailZ = 0, 0, 0
if Nail11 ~= 0 then
d1stNailX = DeltaTabY + DimTabY - Nail11DeltaY
d1stNailY = -DeltaTabX + Nail11DeltaX
d1stNailZ = DeltaTabZ - Nail11DeltaZ
end
local d2ndNailX, d2ndNailY, d2ndNailZ = 0, 0, 0
if Nail12 ~= 0 then
d2ndNailX = DeltaTabY + DimTabY - Nail12DeltaY
d2ndNailY = -DeltaTabX + Nail12DeltaX
d2ndNailZ = DeltaTabZ - Nail12DeltaZ
end
local sOut = 'M114'..' P1='..EgtNumToString( DeltaTabY + DimTabY, 2)..' P2='..EgtNumToString( -DeltaTabX, 2)..
' P3='..EgtNumToString( DeltaTabZ - MillOffs, 2)..' P4='..EgtNumToString( d1stNailX, 2)..
' P5='..EgtNumToString( d1stNailY, 2)..' P6='..EgtNumToString( d1stNailZ, 2)..
' P7='..EgtNumToString( d2ndNailX, 2)..' P8='..EgtNumToString( d2ndNailY, 2)..
' P9='..EgtNumToString( d2ndNailZ, 2)..' P10='..EgtNumToString( MillOffs, 2)..
' P11='..EgtNumToString( Orig3DeltaY, 2)..' P12='..EgtNumToString( -Orig3DeltaX, 2)..' P13='..EgtNumToString( Orig3DeltaZ, 2)..
' P14='..EgtNumToString( Orig5DeltaY, 2)..' P15='..EgtNumToString( -Orig5DeltaX, 2)..' P16='..EgtNumToString( Orig5DeltaZ, 2)..
' P17='..EgtNumToString( Orig7DeltaY, 2)..' P18='..EgtNumToString( -Orig7DeltaX, 2)..' P19='..EgtNumToString( Orig7DeltaZ, 2)
EmtOutput( sOut)
end
end
---------------------------------------------------------------------
function OnDispositionEnd()
-- Se prima disposizione
if EMT.PHASE == 1 then
-- Dimensioni grezzo
local b3Raw = EgtGetRawPartBBox( EMT.RAWID)
local sOut = 'M115 P1='..EgtNumToString( b3Raw:getDimY(), 0)..' P2='..EgtNumToString( b3Raw:getDimX(), 0)..
' P3='..EgtNumToString( b3Raw:getDimZ(), 0)..' P4='..EgtNumToString( EMT.ORIG, 0)
EmtOutput( sOut)
EMT.ST = b3Raw:getDimZ()
-- Posizione cuffia
--local dHCuff = b3Raw:getDimZ() + 32
--EmtOutput( 'E30039=' .. EgtNumToString( dHCuff * 1000, 0))
-- Eventuale salto a lavorazione in corso
--EmtOutput( 'G79 NE80000')
-- Lancio del carico
if not TEST_USE then
; --EmtOutput( 'M26 E30054=' .. EgtNumToString( EMT.ORIG, 0))
end
-- Dichiarazione inizio lavorazione pezzi
if EMT.PRODID then
local sOut = 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( -1)..' P4=1'
EmtOutput( sOut)
end
end
EMT.OPEISDISP = false
end
---------------------------------------------------------------------
function OnTableData()
end
---------------------------------------------------------------------
function OnFixtureData()
end
---------------------------------------------------------------------
function OnRawMoveData()
end
---------------------------------------------------------------------
function OnToolSelect()
-- se utensile definito (non definito per disposizioni con movimento)
if EMT.TOOL ~= '' then
-- verifiche su utensile
local sTool = EgtTdbGetToolFromUUID( EgtGetMachiningParam( MCH_MP.TUUID) or "")
if sTool ~= EMT.TOOL then error( "Tool name mismatch") end
-- predefinite EMT.TCPOS EMT.HEAD EMT.EXIT
EMT.TOOLTYPE = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
EMT.TOOLSEL = EMT.TCPOS..' M06'
EMT.TDIAM = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
EMT.TTOTDIAM = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM)
EMT.TLEN = EgtTdbGetCurrToolParam( MCH_TP.LEN)
EMT.TTOTLEN = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
if MCH_TP.DIST then EMT.TDIST = EgtTdbGetCurrToolParam( MCH_TP.DIST) end
if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end
end
end
---------------------------------------------------------------------
function OnToolDeselect()
end
---------------------------------------------------------------------
function OnMachiningStart()
--EMT.MCHLIBNAME = EgtGetMachiningParam( MCH_MP.NAME)
EMT.MCHNAME = EgtGetOperationName( EMT.MCHID)
EMT.MCHTYPE = EgtGetMachiningParam(MCH_MP.TYPE)
-- non ancora iniziata la lavorazione
EMT.MCHFIRST = true
-- primo posizionamento sempre in globale
EMT.REFLOC = nil
EMT.IPLGL = false
end
---------------------------------------------------------------------
function OnMachiningEnd()
if not EMT.ZMAX then
EmtOutput( 'G27')
EmtOutput( 'M6 T000000')
EmtOutput( 'M99')
EmtOutput( 'M117 P1='..tostring( EMT.CNT+1))
end
EMT.PREVTOOL = EMT.TOOL
end
---------------------------------------------------------------------
function OnPathStart()
-- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento)
EmtResetPrev()
EMT.FEED_FIRST = true
end
---------------------------------------------------------------------
function OnPathEnd()
if IsNailingHead( EMT.HEAD) then
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M6 T200000', 'M6 T300000'))
EmtOutput( 'M101 P1='..EmtLenToString( EMT.NAIL_START_L2o, 3)..' P2='..EmtLenToString( -EMT.NAIL_START_L1o, 3)..' P3='..EmtLenToString( EMT.NAIL_START_L3o, 3))
EmtOutput( 'G24'..EMT.NAIL_END)
local bMoreNails = ( abs( EMT.NAIL_END_L1 - EMT.NAIL_START_L1) > 10 or abs( EMT.NAIL_END_L2 - EMT.NAIL_START_L2) > 10)
local dStep = GetValNotes( EgtGetMachiningParam( MCH_MP.USERNOTES), 'Par', 'd') or 100
local dSafeZ = EMT.ST + ( max( EgtGetMachiningParam( MCH_MP.STARTPOS), 10) or 20)
local dDepth = EMT.NAIL_START_L3
EMT.FP = nil
EMT.F = EgtGetMachiningParam( MCH_MP.FEED) or 9876
local sFeed = EmtGetFeed()
EmtOutput( 'G0 X'..EmtLenToString( EMT.NAIL_START_L1, 3)..' Y'..EmtLenToString( EMT.NAIL_START_L2, 3)..' Z'..EmtLenToString( dSafeZ, 3))
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M121', 'M131'))
EmtOutput( 'G1 X'..EmtLenToString( EMT.NAIL_START_L1, 3)..' Y'..EmtLenToString( EMT.NAIL_START_L2, 3)..' Z'..EmtLenToString( dDepth, 3)..sFeed)
if bMoreNails then
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M122', 'M132')..' P1='..EmtLenToString( dStep, 3))
EmtOutput( 'G1 X'..EmtLenToString( EMT.NAIL_END_L1, 3)..' Y'..EmtLenToString( EMT.NAIL_END_L2, 3)..' Z'..EmtLenToString( dDepth, 3)..sFeed)
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M123', 'M133'))
EmtOutput( 'G0 X'..EmtLenToString( EMT.NAIL_END_L1, 3)..' Y'..EmtLenToString( EMT.NAIL_END_L2, 3)..' Z'..EmtLenToString( dSafeZ, 3))
else
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M122', 'M132')..' P1=0')
EmtOutput( EgtIf( EMT.HEAD == 'H11', 'M123', 'M133'))
EmtOutput( 'G0 X'..EmtLenToString( EMT.NAIL_START_L1, 3)..' Y'..EmtLenToString( EMT.NAIL_START_L2, 3)..' Z'..EmtLenToString( dSafeZ, 3))
end
end
EMT.FEED_FIRST = nil
end
---------------------------------------------------------------------
function OnRapid()
-- se primo movimento della lavorazione, gestione speciale
if EMT.MCHFIRST and not EMT.OPEISDISP then
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
EmtOutput( '; *** '..EMT.MCHNAME..'/'..EMT.TOOL..' ***')
EmitCount( true)
-- se lavorazione con sega a catena
if EMT.HEAD == 'H3' then
-- se prima lavorazione sui fianchi con sega a catena
if EMT.CSAWFIRST and string.sub( EMT.MCHNAME, 1, 5) == 'Csaw_' then
EMT.CSAWFIRST = false
-- pausa per rimozione sfridi
local b3Raw = EgtGetRawPartBBox( EMT.RAWID)
local ParkY = min( -( b3Raw:getMin():getX() - 2000), -MinY)
EmtOutput( ';M104 Y' .. EmtLenToString( ParkY, 3) .. ' ET1' .. GetEF())
-- pre-posizionamento
EmtResetPrev()
local sOut = 'M101' .. GetAxisParam( 'R1', 'P5=')
EmtOutput( sOut)
end
-- altrimenti verifico se necessaria pausa
else
if EMT.SCRAPFIRST and EgtExistsInfo( EMT.MCHID, 'MOVE_AFTER') then
EMT.SCRAPFIRST = false
-- pausa per rimozione sfridi
local b3Raw = EgtGetRawPartBBox( EMT.RAWID)
local ParkY = min( -( b3Raw:getMin():getX() - 2000), -MinY)
EmtOutput( ';M104 Y' .. EmtLenToString( ParkY, 3) .. ' ET1' .. GetEF())
end
end
-- dichiarazione testa e utensile
if not IsNailingHead( EMT.HEAD) then
EmtOutput( 'M6 T101' .. AdjustTcPos( true))
local Speed = EMT.S * EgtIf( EMT.HEAD ~= 'H2', 1, 1.65)
if Speed > 0 then
EmtOutput( 'M3 S' .. EgtNumToString( abs( Speed), 0))
else
EmtOutput( 'M4 S' .. EgtNumToString( abs( Speed), 0))
end
-- primo posizionamento
EmtResetPrev()
local sOut = 'M101' .. GetAxisParam( 'L2', 'P1=') .. GetAxisParam( 'L1', 'P2=') .. GetAxisParam( 'L3', 'P3=') ..
GetAxisParam( 'R2', 'P4=') .. GetAxisParam( 'R1', 'P5=')
EmtOutput( sOut)
end
EMT.REFLOC = 0
EMT.MCHFIRST = false
EMT.ZMAX = false
-- se standard
elseif EMT.FLAG == 0 or EMT.FLAG == 1 or EMT.FLAG == 2 then
-- se necessario, impostazione riferimento locale
if EMT.REFLOC == 0 then
-- calcolo per piano generico
CalcInterpPlane()
EMT.REFLOC = 1
if not IsNailingHead( EMT.HEAD) then
EmtOutput( 'G24'..EMT.IPLGLSTR)
end
-- trasformo i punti nel piano
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
EMT.L1p = nil
EMT.L2p = nil
EMT.L3p = nil
EMT.R1p = nil
EMT.R2p = nil
-- emissione movimento
if not IsNailingHead( EMT.HEAD) then
local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis('R2')..EmtGetAxis('R1')
EmtOutput( sOut)
else
EMT.NAIL_START_L1o = EMT.L1o
EMT.NAIL_START_L2o = EMT.L2o
EMT.NAIL_START_L3o = EMT.L3o
EMT.NAIL_START_L1 = EMT.L1
EMT.NAIL_START_L2 = EMT.L2
EMT.NAIL_START_L3 = EMT.L3
EMT.NAIL_END_L1 = EMT.L1
EMT.NAIL_END_L2 = EMT.L2
EMT.NAIL_END = EMT.IPLGLSTR
end
else
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- emissione movimento
if not IsNailingHead( EMT.HEAD) then
local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis('R2')..EmtGetAxis('R1')
EmtOutput( sOut)
else
if EMT.L1 then EMT.NAIL_END_L1 = EMT.L1 end
if EMT.L2 then EMT.NAIL_END_L2 = EMT.L2 end
if EMT.L3 and EMT.L3 < EMT.NAIL_START_L3 then
EMT.NAIL_START_L3 = EMT.L3
end
end
end
-- se altrimenti risalita a Z max a fine lavorazione
elseif EMT.FLAG == 3 then
if not IsNailingHead( EMT.HEAD) then
if EMT.REFLOC then
EMT.REFLOC = nil
EMT.IPLGL = false
EmtResetPrev()
-- dichiarazione fine lavorazione
EmtOutput( 'G27')
EmtOutput( 'M6 T000000')
EmtOutput( 'M99')
EmtOutput( 'M117 P1='..tostring( EMT.CNT+1))
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
local sOut = 'M101' .. GetAxisParam( 'L3', 'P3=') .. GetAxisParam( 'R2', 'P4=') .. GetAxisParam( 'R1', 'P5=')
EmtOutput( sOut)
EMT.ZMAX = true
end
else
EMT.TO_ZMAX = true
end
-- se altrimenti movimento in Home
elseif EMT.FLAG == 4 then
-- non previsto
-- altrimenti errore
else
error( "Unknown Rapid flag")
end
-- aggiorno valori come precedenti
EmtUpdatePrev()
end
---------------------------------------------------------------------
function OnLinear()
-- se necessario, impostazione riferimento locale
if EMT.REFLOC == 0 then
-- calcolo per piano generico
CalcInterpPlane()
EMT.REFLOC = 1
-- salvo posizione attuale
local OldL1 = EMT.L1
local OldL2 = EMT.L2
local OldL3 = EMT.L3
local OldR1p = EMT.R1p
local OldR2p = EMT.R2p
-- imposto posizione precedente
EMT.L1 = EMT.L1o
EMT.L2 = EMT.L2o
EMT.L3 = EMT.L3o
EMT.R1p = nil
EMT.R2p = nil
-- trasformo i punti nel piano
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
if not IsNailingHead( EMT.HEAD) then
EmtOutput( 'G24'..EMT.IPLGLSTR)
end
-- emissione movimento
if not IsNailingHead( EMT.HEAD) then
local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis('R2')..EmtGetAxis('R1')
EmtOutput( sOut)
EmtUpdatePrev()
EMT.Fp = nil
else
EMT.NAIL_START_L1o = EMT.L1o
EMT.NAIL_START_L2o = EMT.L2o
EMT.NAIL_START_L3o = EMT.L3o
EMT.NAIL_START_L1 = EMT.L1
EMT.NAIL_START_L2 = EMT.L2
EMT.NAIL_START_L3 = EMT.L3
EMT.NAIL_END_L1 = EMT.L1
EMT.NAIL_END_L2 = EMT.L2
EMT.NAIL_END = EMT.IPLGLSTR
end
-- ripristino posizione attuale
EMT.L1 = OldL1
EMT.L2 = OldL2
EMT.L3 = OldL3
EMT.R1p = OldR1p
EMT.R2p = OldR2p
end
-- aggiustamento valori
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
if not IsNailingHead( EMT.HEAD) then
-- se inizio lavorazione
if EMT.FEED_FIRST then
EmtOutput( 'M98')
EMT.FEED_FIRST = nil
end
-- valori degli assi
local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis('R2')..EmtGetAxis('R1')
-- se nulla da emettere, esco
if #sAxes == 0 then
return
end
-- aggiungo feed
local sFeed = EmtGetFeed()
-- emetto linea
EmtOutput( "G1"..sAxes..sFeed)
-- eventuale gestione fondo foro
if EMT.FLAG == 101 and EMT.HEAD == 'H5' then
EmtOutput( 'M155')
end
else
if EMT.L1 then EMT.NAIL_END_L1 = EMT.L1 end
if EMT.L2 then EMT.NAIL_END_L2 = EMT.L2 end
if EMT.L3 and EMT.L3 < EMT.NAIL_START_L3 then
EMT.NAIL_START_L3 = EMT.L3
end
end
-- aggiorno valori come precedenti
EmtUpdatePrev()
end
---------------------------------------------------------------------
function OnArc()
-- non modale su archi
local dPrevZ = EMT.L3p
EmtResetPrevLinear()
-- aggiustamento valori
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
if not IsNailingHead( EMT.HEAD) then
-- valori degli assi
local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis('R2')..EmtGetAxis('R1')
-- se nulla da emettere, esco
if #sAxes == 0 then
return
end
-- valori delle coordinate del centro
EmtAdjustCenterAxes()
-- coordinate centro (per ora solo archi nel piano XY)
--local sCen = ' ' .. EMT.C1t .. EmtLenToString(EMT.C1,3) ..
-- ' ' .. EMT.C2t .. EmtLenToString(EMT.C2,3)
-- raggio
local sRad = ' ' .. EMT.RRt .. EmtLenToString(EMT.RR,3)
-- aggiungo feed
local sFeed = EmtGetFeed()
-- tipo arco
local sArc = 'G' .. EgtNumToString(EMT.MOVE,0)
-- emetto arco
EmtOutput( sArc..sAxes..sRad..sFeed)
else
-- Archi non previsti con chiodature
EmtSetLastError( 1212, 'Arcs non allowed with nailing')
end
-- aggiorno valori come precedenti
EmtUpdatePrev()
end
---------------------------------------------------------------------
function MyAdjustLinearAxes()
local MyL1o = EMT.L1
local MyL2o = EMT.L2
local MyL3o = EMT.L3
if EMT.REFLOC then
local vtDelta = V_NULL()
local vtE = V_NULL()
if EMT.HEAD == 'H1' then
local Len = EMT.TLEN + MillOffs
local LenRef = MillOffs
local vtTool = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3)
vtE = vtTool * Len - Z_AX() * LenRef
elseif EMT.HEAD == 'H2' then
local Len = EMT.TLEN + MillOffs - SawOffsZ
local LenRef = MillOffs
local vtTool = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3)
vtE = vtTool * Len - Z_AX() * LenRef
elseif EMT.HEAD == 'H3' then
local Len = ( EMT.TDIST or ChSawLen) + MillOffs
local LenRef = MillOffs
local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3)
vtE = vtAux * Len - Z_AX() * LenRef
elseif EMT.HEAD == 'H11' then
vtDelta = -Vector3d( Nail11DeltaX, Nail11DeltaY, Nail11DeltaZ)
vtE = Z_AX() * EMT.TLEN
elseif EMT.HEAD == 'H12' then
vtDelta = -Vector3d( Nail12DeltaX, Nail12DeltaY, Nail12DeltaZ)
vtE = Z_AX() * EMT.TLEN
end
EMT.L1 = EMT.L1 - vtDelta:getX() - vtE:getX()
EMT.L2 = EMT.L2 - vtDelta:getY() - vtE:getY()
EMT.L3 = EMT.L3 - vtDelta:getZ() - DeltaTabZ - vtE:getZ()
end
EmtAdjustLinearAxes()
EMT.L1o = MyL1o
EMT.L2o = MyL2o
EMT.L3o = MyL3o
if not EMT.REFLOC then
EMT.L1 = - EMT.L1
EMT.L1t = 'Y'
EMT.L2t = 'X'
else
EMT.L1t = 'X'
EMT.L2t = 'Y'
end
end
---------------------------------------------------------------------
function CalcInterpPlane()
-- origine del piano
local xS = EMT.START[1]
local yS = EMT.START[2]
local zS = 0
local ptS = Point3d( xS, yS, zS)
-- calcolo per piano generico
local vtE
if EMT.HEAD ~= 'H3' then
vtE = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3)
else
vtE = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3)
end
EMT.IPLGLFR = Frame3d( ptS, vtE)
--EmtOutput( 'IPLGLFR='..tostring(EMT.IPLGLFR))
local vtX = EMT.IPLGLFR:getVersX()
local vtY = EMT.IPLGLFR:getVersY()
local vtZ = EMT.IPLGLFR:getVersZ()
-- A seconda del corner di riferimento scelto
local xOut = yS - DeltaTabY - DimTabY
local yOut = - ( xS - DeltaTabX)
local zOut = zS
if EMT.ORIG == 2 then
xOut = yS - DeltaTabY
yOut = - ( xS - DeltaTabX)
elseif EMT.ORIG == 3 then
xOut = yS - DeltaTabY - DimTabY
yOut = - ( xS - DeltaTabX - Orig3DeltaX)
elseif EMT.ORIG == 4 then
xOut = yS - DeltaTabY
yOut = - ( xS - DeltaTabX - Orig3DeltaX)
elseif EMT.ORIG == 11 then
xOut = yS - DeltaTabY - DimTabY
yOut = - ( xS - DeltaTabX - Orig5DeltaX)
elseif EMT.ORIG == 12 then
xOut = yS - DeltaTabY
yOut = - ( xS - DeltaTabX - Orig5DeltaX)
elseif EMT.ORIG == 13 then
xOut = yS - DeltaTabY - DimTabY
yOut = - ( xS - DeltaTabX - DimTabX)
elseif EMT.ORIG == 14 then
xOut = yS - DeltaTabY
yOut = - ( xS - DeltaTabX - DimTabX)
end
EMT.IPLGLSTR = ' X' .. EmtLenToString( xOut) ..' Y' .. EmtLenToString( yOut) .. ' Z' .. EmtLenToString( zOut)..
' A' .. EgtNumToString( vtX:getY(), 6) .. ' B' .. EgtNumToString( -vtX:getX(), 6) .. ' C' .. EgtNumToString( vtX:getZ(), 6) ..
' I' .. EgtNumToString( vtY:getY(), 6) .. ' J' .. EgtNumToString( -vtY:getX(), 6) .. ' K' .. EgtNumToString( vtY:getZ(), 6) ..
' P' .. EgtNumToString( vtZ:getY(), 6) .. ' Q' .. EgtNumToString( -vtZ:getX(), 6) .. ' R' .. EgtNumToString( vtZ:getZ(), 6)
EMT.IPLGL = true
end
---------------------------------------------------------------------
function AdjustTcPos( bLen3, sTcPos, dAxR3)
if not sTcPos then sTcPos = EMT.TCPOS end
local sPos = sTcPos:gsub( 'T', '')
if bLen3 then
if #sPos == 1 then
sPos = '00' .. sPos
elseif #sPos == 2 then
sPos = '0' .. sPos
end
end
if sPos == '101' then
if not dAxR3 then dAxR3 = EMT.R3 end
if abs( dAxR3 - 0) < 0.1 then
sPos = '101'
elseif abs( dAxR3 - 270) < 0.1 then
sPos = '102'
elseif abs( dAxR3 - 180) < 0.1 then
sPos = '103'
elseif abs( dAxR3 - 90) < 0.1 then
sPos = '104'
else
EmtSetLastError( 1210, 'Chain saw orientation not allowed')
end
end
return sPos
end
---------------------------------------------------------------------
function GetET()
if EMT.HEAD == 'H1' or EMT.HEAD == 'H3' then
return ' ET2'
elseif EMT.HEAD == 'H2' then
return ' ET1'
elseif EMT.HEAD == 'H5' then
return ' ET3'
end
end
---------------------------------------------------------------------
function GetEU()
local sEU
if EMT.HEAD == 'H1' then
sEU = ' EU'..string.sub( EMT.TCPOS, 2)
elseif EMT.HEAD == 'H2' then
sEU = ' EU0'
elseif EMT.HEAD == 'H3' then
if abs( EMT.R3 - 0) < 0.1 then
sEU = ' EU104'
elseif abs( EMT.R3 - 270) < 0.1 then
sEU = ' EU101'
elseif abs( EMT.R3 - 180) < 0.1 then
sEU = ' EU102'
elseif abs( EMT.R3 - 90) < 0.1 then
sEU = ' EU103'
else
EmtSetLastError( 1210, 'Chain saw orientation not allowed')
end
else
sEU = ''
end
return sEU
end
---------------------------------------------------------------------
function GetEE()
return ' EE' .. EgtNumToString( EMT.ORIG, 0)
end
---------------------------------------------------------------------
function GetEF()
return ' EF60000'
end
---------------------------------------------------------------------
function GetAxisParam( Ax, sPar)
if EMT[Ax] then
local nDec = EMT.DECNUM or 3
if not EMT.INCHES or (( Ax == 'R1' or Ax == 'R2' or Ax == 'R3' or Ax == 'R4')) then
return ' ' .. sPar .. EgtNumToString( EMT[Ax], nDec), true
else
return ' ' .. sPar .. EgtNumToString( EMT[Ax] / GEO.ONE_INCH, nDec + 1), true
end
end
return '', false
end
---------------------------------------------------------------------
function EmitCount( bJump)
EMT.CNT = EMT.CNT + 1
if bJump then
EmtOutput( 'N'..tostring( EMT.CNT)..' IF VGPL > '..tostring( EMT.CNT)..' GOTO N'..tostring( EMT.CNT+1))
else
EmtOutput( 'N'..tostring( EMT.CNT))
end
end
---------------------------------------------------------------------
function IsNailingHead( sHead)
return ( sHead == 'H11' or sHead == 'H12')
end
---------------------------------------------------------------------
function GetValNotes( sNotes, sKey, sType)
local vsChunk = EgtSplitString( sNotes or '', ';')
local dVal
for i = 1, #vsChunk do
local dTmp = EgtGetVal( vsChunk[i], sKey, sType)
if dTmp then dVal = dTmp end
end
return dVal
end
---------------------------------------------------------------------
-- *** END GENERATION ***
---------------------------------------------------------------------