Files
masterwood-project265/Masterwood-Project265.TECNOS.mlpe
T

660 lines
25 KiB
Plaintext

-- Processore macchina Masterwood Project265 2025/01/09
-- by EgalWare s.r.l.
--
-- Intestazioni
require( 'EmtGenerator')
EgtEnableDebug( false)
-- Variabili di modulo
local MLE_INFO = 'Project265.TECNOS.mlpe ver.2.7a1 by EgalWare s.r.l.'
-- ******************************************************************
-- ************************ GENERATION *************************
-- ******************************************************************
function OnStart()
EMT.USETO1 = true -- abilitazione uso origine tavola
EMT.MODAL = true -- abilitazione emissione modale
EMT.INCHES = not EgtUiUnitsAreMM() -- unità di misura mm/inches
EMT.DECNUM = EgtIf( EMT.INCHES, 4, 3) -- numero di decimali dopo la virgola
EMT.NUM = false -- abilitazione numerazione linee
end
---------------------------------------------------------------------
function OnEnd()
-- Chiusura file altri processi (qui si passa sempre, anche in caso di errore)
local sNewPath = EgtChangePathExtension( EMT.FILE, '.prg')
EgtEraseFile( sNewPath)
EgtRenameFile( EMT.FILE, sNewPath)
end
---------------------------------------------------------------------
function OnProgramStart()
-- Intestazione processo 1
-- EmtOutput( EgtIf( EMT.INFO, '( '..EMT.INFO, ';Program Start'))
-- EmtOutput( '( '.. MLE_INFO)
end
---------------------------------------------------------------------
function OnProgramEnd()
EmtOutput( '( --- PARK HEAD')
EmtOutput( 'G170 W0.00')
EmtOutput( '( --- END PROGRAM')
EmtOutput( '%')
end
---------------------------------------------------------------------
function OnToolData()
end
---------------------------------------------------------------------
function OnDispositionStart()
-- inizialiozzo lista disposizione
EMT.DISP = {}
end
---------------------------------------------------------------------
function OnDispositionEnd()
-- in prima fase, scrivo header
if EMT.PHASE == 1 then
EmtOutput( '% ')
local sDateFile = string.sub( EMT.INFO, -20)
EmtOutput( '|1' .. sDateFile)
EmtOutput( '|2 0')
-- acquisizione nome attrezzaggio
local sSetupName = EgtGetInfo( EgtGetCurrSetup() or GDB_ID.NULL, 'Name') or '01'
EmtOutput( '|3 ' .. sSetupName)
EmtOutput( '|4 ' .. tostring( EMT.LP)) -- dim x pezzo
EmtOutput( '|5 ' .. tostring( EMT.TP)) -- dim z pezzo
EmtOutput( '|6 ' .. tostring( EMT.HP)) -- dim y pezzo
EmtOutput( '|7 0 0 0 0')
EmtOutput( '|8 0')
EmtOutput( '|9 ')
EmtOutput( '|10 ')
EmtOutput( '|11 ')
EmtOutput( '|12 ')
EmtOutput( '|13 ')
EmtOutput( '|14 ')
-- scrittura info piani di lavoro e sottopezzi
WriteDispositionInfo()
end
end
---------------------------------------------------------------------
function OnTableData()
end
---------------------------------------------------------------------
function OnTableAxisData()
-- EmtOutput( '( TabAxis '..EgtNumToString( EMT.TAIND)..' : Name='..EMT.TANAME..
-- ' Pos='..EgtNumToString( EMT.TAPOS)..' Moved='..EgtIf( EMT.TAMOVED, 'true', 'false'))
local PLx = {}
PLx.sName = EMT.TANAME
PLx.dPosX = EMT.TAPOS
PLx.Fixture = {}
table.insert( EMT.DISP, PLx)
end
---------------------------------------------------------------------
function OnFixtureData()
-- EmtOutput( '( Fixture '..EgtNumToString( EMT.FIXIND)..' : Name='..EMT.FIXNAME..
-- ' Pos=('..EmtNum3ToString( EMT.FIXPOS)..') Ang='..EgtNumToString( EMT.FIXANG)..' Mob='..EgtNumToString( EMT.FIXMOB))
local SubPiece = {}
SubPiece.sPLName = EMT.FIXTAL
SubPiece.sName = EMT.FIXNAME
SubPiece.ptPos = EMT.FIXPOS
SubPiece.dAngle = EMT.FIXANG
-- metto il sottopezzo sulla barra opportuna
for i = 1, #EMT.DISP do
-- cerco il piano sul quale è montato il sottopezzo
if EMT.DISP[i].sName == SubPiece.sPLName and EgtStartsWith( SubPiece.sName, 'Vac') then
table.insert( EMT.DISP[i].Fixture, SubPiece)
end
end
end
---------------------------------------------------------------------
function OnRawMoveData()
-- EmtOutput( '( RawMove '..EMT.RAWIND..' : Id='..EMT.RAWID..' Type='..EMT.RAWTYPE..
-- ' Pos=('..EmtNum3ToString( EMT.RAWPOS)..') Flag='..EMT.RAWFLAG)
-- Determino dimensioni del grezzo
local b3Sol = EgtGetBBoxGlob( EMT.RAWID, GDB_BB.STANDARD)
EMT.LP = 0 -- lunghezza
EMT.HP = 0 -- altezza
EMT.TP = 0 -- spessore
if b3Sol then
EMT.LP = b3Sol:getDimX()
EMT.HP = b3Sol:getDimY()
EMT.TP = b3Sol:getDimZ()
end
-- riqualifico il punto zero sempre in basso a sinistra. Se arriva da B&W potrebbe essere in un altro punto, in base a come è girato il pezzo
EMT.RAWPOS[1] = b3Sol:getMin():getX() - EMT.TABORI1[1]
EMT.RAWPOS[2] = b3Sol:getMin():getY() - EMT.TABORI1[2]
end
---------------------------------------------------------------------
function OnToolSelect()
EMT.TOOLTYPE = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
EMT.TDIAM = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
EMT.TTOTDIAM = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM)
EMT.TLEN = EgtTdbGetCurrToolParam( MCH_TP.LEN)
EMT.TTOTLEN = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
EMT.TUSERNOTES = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
end
---------------------------------------------------------------------
function OnToolDeselect()
end
---------------------------------------------------------------------
function OnMachiningStart()
EMT.MCHNAME = EgtGetOperationName( EMT.MCHID)
EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE)
EMT.MCHUSERNOTES = EgtGetMachiningParam( MCH_MP.USERNOTES)
EMT.MCHFIRST = true
-- inizio lavorazione
EmtOutput( '( === '.. EMT.MCHNAME .. ' - ' .. EMT.TOOL .. ' ===')
-- impostazione cuffia ( 0-alta, 1-bassa, 2-medio-bassa, 3-medio-alta)
local nHoodPos = EgtGetValInNotes( EMT.MCHUSERNOTES, 'HOODPOS', d) or 0
EmtOutput( '( --- Hood position' )
EmtOutput( 'M61 K' .. tostring( nHoodPos) .. ' D0')
end
---------------------------------------------------------------------
function OnMachiningEnd()
-- reset eventuali macro
EMT.MACROLAMA = nil
EMT.MACROFORO = nil
EMT.PTMACRO = nil
end
---------------------------------------------------------------------
function OnPathStart()
-- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento)
EmtResetPrev()
-- EmtOutput( '( DRACEX='..table.concat( EMT.DRACEX, ','))
EMT.IPLGL = false
end
---------------------------------------------------------------------
function OnPathEnd()
end
---------------------------------------------------------------------
function OnRapid()
-- se standard
if EMT.FLAG == 0 or EMT.FLAG == 1 or EMT.FLAG == 2 then
-- se foratura, si scrive macro alla fine del foro
if EMT.HEAD == 'H21' then
-- movimenti rapidi gestiti da macro macchina
EMT.MACROFORO = true
-- inizializzo lista contenente punti di lavorazione
EMT.PTMACRO = {}
-- se punto successivo lineare, salvo questo punto
if EMT.MOVESUCC == 1 then
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- emissione piano di interpolazione
EmitInterpPlane( true)
local p3FirstPoint = Point3d( EMT.L1, EMT.L2, EMT.L3)
table.insert( EMT.PTMACRO, p3FirstPoint)
EMT.MCHFIRSTLIN = true
end
-- se utensile lama, si scrive macro con punto finale
elseif EMT.TOOLTYPE == MCH_TY.SAW_STD or EMT.TOOLTYPE == MCH_TY.SAW_FLAT then
EMT.MACROLAMA = true
-- inizializzo lista contenente primo punto di lavorazione
EMT.PTMACRO = {}
-- se punto successivo lineare, salvo questo punto
if EMT.MOVESUCC == 1 then
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- emissione piano di interpolazione
EmitInterpPlane( true)
local p3FirstPoint = { EmtLenToString(EMT.L1), EmtLenToString(EMT.L2), EmtLenToString(EMT.L3)}
AdjustBladeZeroPoint( p3FirstPoint, EMT.CDIR)
table.insert( EMT.PTMACRO, p3FirstPoint)
EMT.MCHFIRSTLIN = true
end
-- altrimenti testa 5 assi
else
-- se primo movimento della lavorazione, gestione speciale
if EMT.MCHFIRST then
--if EMT.MOVESUCC == 1 then
-- emissione piano di interpolazione
EmitInterpPlane( false)
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- emissione primo punto della lavorazione
local sLinearAxes = EmtGetRapidAxis('L1') .. EmtGetRapidAxis('L2')
if not EMT.IPLGL then
sLinearAxes = sLinearAxes .. ' ' .. EMT.L3t .. EmtLenToString( - EgtMdbGetGeneralParam( MCH_GP.SAFEZ), EMT.DECNUM)
else
sLinearAxes = sLinearAxes .. EmtGetAxis('L3')
end
local sSpeed = ' S' .. EmtLenToString( EMT.S / 1000)
local sFeed = ' E5' -- feed entrata
local sToolSelection = GetToolSelectionString( EMT.HEAD, EMT.TCPOS)
local sVertAngle = ' J' .. EmtLenToString( EMT.R2)
EmtOutput( 'G172' .. sLinearAxes .. sSpeed .. sFeed .. sToolSelection .. sVertAngle)
EMT.MCHFIRST = false
--end
else
-- su primo rapido dopo G172, scrivo asse C
if EMT.FLAG == 1 then
EMT.R1p = nil
end
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
local sAxes = EmtGetRapidAxis('L1')..EmtGetRapidAxis('L2')..EmtGetRapidAxis('L3')..
EmtGetRapidAxis( 'R1')..EmtGetRapidAxis('R2')
if #sAxes > 0 then
EmtOutput( 'G101'..sAxes..' F50')
end
end
end
-- se altrimenti risalita a Z max a fine lavorazione
elseif EMT.FLAG == 3 then
EMT.IPLGL = false
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- se altrimenti movimento in Home
elseif EMT.FLAG == 4 then
-- da gestire ???
-- altrimenti errore
else
error( "Unknown Rapid flag")
end
-- aggiorno valori come precedenti
EmtUpdatePrev()
end
---------------------------------------------------------------------
function OnLinear()
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
-- controllo feed che sia espressa in metri
local dFeed
if EMT.F < 10 then
sFeed = ' F' .. EMT.F
elseif EMT.F > 1000 then
sFeed = ' F' .. (EMT.F/1000)
else
EmtSetLastError( 1210, 'Feed TOO HIGH!! Machining: ' .. EMT.MCHNAME)
end
-- macro foratura
if EMT.MACROFORO then
-- se inversione movimento al fondo di un foro, scrivo macro
if EMT.FLAG == 101 then
-- se testa 5 assi
if EMT.HEAD == 'H21' then
local p3SecondPoint = Point3d( EMT.L1, EMT.L2, EMT.L3)
table.insert( EMT.PTMACRO, p3SecondPoint)
local sLinearAxes = EMT.L1t .. EmtLenToString(EMT.PTMACRO[2][1]) .. ' ' ..
EMT.L2t .. EmtLenToString(EMT.PTMACRO[2][2]) .. ' ' ..
EMT.L3t .. EmtLenToString(EMT.PTMACRO[2][3])
local sToolSelection = GetToolSelectionString( EMT.HEAD, EMT.DRACEX)
EmtOutput( '( --- Tool selection for MultiDrill')
EmtOutput( sToolSelection)
-- FACCIA SOPRA
local v3TDir = Vector3d( EMT.TDIR)
if AreSameVectorApprox( v3TDir, Z_AX()) then
EmtOutput( 'G100 ' .. sLinearAxes .. sFeed .. ' T81')
-- FACCIA DESTRA
elseif AreSameVectorApprox( v3TDir, X_AX()) then
EmtOutput( 'G183 ' .. sLinearAxes .. sFeed .. ' T81')
-- FACCIA SINISTRA
elseif AreSameVectorApprox( v3TDir, -X_AX()) then
EmtOutput( 'G182 ' .. sLinearAxes .. sFeed .. ' T81')
-- FACCIA RETRO
elseif AreSameVectorApprox( v3TDir, Y_AX()) then
EmtOutput( 'G184 ' .. sLinearAxes .. sFeed .. ' T81')
-- FACCIA FRONTE
elseif AreSameVectorApprox( v3TDir, -Y_AX()) then
EmtOutput( 'G185 ' .. sLinearAxes .. sFeed .. ' T81')
end
end
end
elseif EMT.MACROLAMA then
-- se primo movimento lineare, aggiusto la Z del primo punto
if EMT.MCHFIRSTLIN then
local p3FirstLinear = { EmtLenToString(EMT.L1), EmtLenToString(EMT.L2), EmtLenToString(EMT.L3)}
AdjustBladeZeroPoint( p3FirstLinear, EMT.CDIR)
-- se taglio inclinato, prendo tutto il punto e correggo in direzione
if abs( EMT.TDIR[3]) > GEO.EPS_SMALL * 10 then
EMT.PTMACRO[1][1] = p3FirstLinear[1] - p3FirstLinear[3] * tan( asin( EMT.CDIR[1]))
EMT.PTMACRO[1][2] = p3FirstLinear[2] - p3FirstLinear[3] * tan( asin( EMT.CDIR[2]))
EMT.PTMACRO[1][3] = p3FirstLinear[3]
-- altrimenti prendo solo la Z
else
EMT.PTMACRO[1][3] = p3FirstLinear[3]
end
-- se primo punto già emesso, recupero il secondo punto
else
-- se movimento successivo è un rapido, si scrive il secondo punto
if EMT.MOVESUCC == 0 then
local p3SecondPoint
-- se taglio inclinato, prendo il punto precedente e correggo in direzione
if abs( EMT.TDIR[3]) > GEO.EPS_SMALL * 10 then
p3SecondPoint = { EmtLenToString(EMT.L1p), EmtLenToString(EMT.L2p), EmtLenToString(EMT.L3p)}
else
p3SecondPoint = { EmtLenToString(EMT.L1), EmtLenToString(EMT.L2), EmtLenToString(EMT.L3)}
end
AdjustBladeZeroPoint( p3SecondPoint, EMT.CDIR)
-- forzo la stessa Z in entrambi i punti. !! Non è possibile fare lavorazioni di lama con variazioni in Z
p3SecondPoint[3] = EMT.PTMACRO[1][3]
-- se inclinato, prendo punto prcedente
if abs( EMT.TDIR[3]) > GEO.EPS_SMALL * 10 then
p3SecondPoint[1] = p3SecondPoint[1] - p3SecondPoint[3] * tan( asin( EMT.CDIR[1]))
p3SecondPoint[2] = p3SecondPoint[2] - p3SecondPoint[3] * tan( asin( EMT.CDIR[2]))
p3SecondPoint[3] = p3SecondPoint[3]
end
table.insert( EMT.PTMACRO, p3SecondPoint)
local bClimbCut = true
local bInvertPoints = false
if EgtGetMachiningParam( MCH_MP.TYPE) == MCH_MY.SAWING then
local nHeadSide = EgtGetMachiningParam( MCH_MP.HEADSIDE)
-- se rotazione oraria e lato testa destro, lavorazione concorde
if EMT.S > 0 and nHeadSide == MCH_SAW_HS.RIGHT then
bClimbCut = true
else
bClimbCut = false
end
elseif EgtGetMachiningParam( MCH_MP.TYPE) == MCH_MY.MILLING then
local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE)
-- se rotazione oraria e lato di lavoro sinistro, lavorazione concorde
if EMT.S > 0 and nWorkSide == MCH_MILL_WS.LEFT then
bClimbCut = true
else
bClimbCut = false
end
end
local sDiscordanza = EgtIf( bClimbCut, ' D0', ' D1')
local sSpeed = ' S' .. EmtLenToString( EMT.S / 1000)
local sToolSelection = GetToolSelectionString( EMT.HEAD, EMT.TCPOS)
local sVertAngle = ' J' .. EmtLenToString( EMT.R2)
-- se taglio in discordanza, si invertono i punti start/end per mantenere direzione testa
if bClimbCut then
bInvertPoints = true
end
local sLinearAxes
if bInvertPoints then
sLinearAxes = EMT.L1t .. EmtLenToString(EMT.PTMACRO[2][1]) .. ' ' ..
EMT.L2t .. EmtLenToString(EMT.PTMACRO[2][2]) .. ' ' ..
EMT.L3t .. EmtLenToString(EMT.PTMACRO[2][3])
else
sLinearAxes = EMT.L1t .. EmtLenToString(EMT.PTMACRO[1][1]) .. ' ' ..
EMT.L2t .. EmtLenToString(EMT.PTMACRO[1][2]) .. ' ' ..
EMT.L3t .. EmtLenToString(EMT.PTMACRO[1][3])
end
local sFeedOnMacro = sFeed:gsub( 'F', 'E')
EmtOutput( 'G172 ' .. sLinearAxes .. sSpeed .. sFeedOnMacro .. sToolSelection .. sVertAngle)
if bInvertPoints then
sLinearAxes = EMT.L1t .. EmtLenToString(EMT.PTMACRO[1][1]) .. ' ' ..
EMT.L2t .. EmtLenToString(EMT.PTMACRO[1][2]) .. ' ' ..
EMT.L3t .. EmtLenToString(EMT.PTMACRO[1][3])
else
sLinearAxes = EMT.L1t .. EmtLenToString(EMT.PTMACRO[2][1]) .. ' ' ..
EMT.L2t .. EmtLenToString(EMT.PTMACRO[2][2]) .. ' ' ..
EMT.L3t .. EmtLenToString(EMT.PTMACRO[2][3])
end
local sBladeAngle = ' K' .. EmtLenToString( EMT.R2)
EmtOutput( 'G189 ' .. sLinearAxes .. sFeed .. sBladeAngle .. sDiscordanza)
end
end
-- lavorazione standard
else
-- valori degli assi
local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..
EmtGetAxis( 'R1')..EmtGetAxis('R2')
-- se nulla da emettere, esco
if #sAxes == 0 then
return
end
-- emetto linea
EmtOutput( 'G101' .. sAxes .. sFeed)
end
-- aggiorno valori come precedenti
EmtUpdatePrev()
-- reset info primo lineare
EMT.MCHFIRSTLIN = nil
end
---------------------------------------------------------------------
function OnArc()
-- non modale su archi
EmtResetPrevLinear()
-- valori degli assi
MyAdjustLinearAxes()
EmtAdjustRotaryAxes()
local sAxes = EmtGetAxis( 'L1')..EmtGetAxis( 'L2')..EmtGetAxis( 'L3')..
EmtGetAxis( 'R1')..EmtGetAxis( 'R2')
-- 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,4)
-- controllo feed che sia espressa in metri
local dFeed
if EMT.F < 10 then
sFeed = ' F' .. EMT.F
elseif EMT.F > 1000 then
sFeed = ' F' .. (EMT.F/1000)
else
EmtSetLastError( 1210, 'Feed TOO HIGH!! Machining: ' .. EMT.MCHNAME)
end
-- tipo arco
local nMove = EmtGetArcType( EMT.MOVE, EMT.IPLSX)
local sArc = 'G10' .. EgtNumToString( nMove,0)
-- emetto arco
EmtOutput( sArc .. sAxes .. sRad .. sFeed)
-- aggiorno valori come precedenti
EmtUpdatePrev()
end
---------------------------------------------------------------------
---------------------------------------------------------------------
function EmitInterpPlane( bForceTopPlane)
-- Reset piano globale di interpolazione
EMT.IPLGL = false
EMT.IPLGLFR = nil
-- Imposto piano di interpolazione
EMT.IPLSX = false
local vtE = Vector3d( EMT.TDIR) -- si costruisce il piano in base alla direzione utensile
local nPlaneNumber = 1
-- piano TOP
if bForceTopPlane or vtE:isSmall() or AreSameVectorApprox( vtE, Z_AX()) or EMT.HEAD == 'H21' then
EmtOutput( '( --- Plane TOP')
EMT.IPLGLSTR = 'G120 K' .. tostring( nPlaneNumber)
EmtOutput( EMT.IPLGLSTR)
nPlaneNumber = 1
-- piano generico
else
-- indice piano generico
if EMT.INDEXGENPLANE then
EMT.INDEXGENPLANE = EMT.INDEXGENPLANE + 1
else
EMT.INDEXGENPLANE = 11
end
local ptS = Point3d( EMT.START)
if EMT.USETO1 then
ptS[1] = ptS[1] - EMT.TABORI1[1] - EMT.RAWPOS[1]
ptS[2] = ptS[2] - EMT.TABORI1[2] - EMT.RAWPOS[2] - EMT.HP
ptS[3] = ptS[3] - EMT.TABORI1[3] - EMT.RAWPOS[3]
end
-- calcolo per piano generico da emettere a vero inizio lavorazione
EMT.IPLGLFR = Frame3d( ptS, vtE)
local _, dAngV, dAngO = SphericalFromVector( vtE)
dAngV = - dAngV
dAngO = -( dAngO + 90)
while dAngO < -359.9 do
dAngO = dAngO + 360
end
while dAngO > 359.9 do
dAngO = dAngO - 360
end
EmtOutput( '( --- Plane GEN') -- EmtLenToString EgtNumToString
local sOriPlane = ' U' .. EmtLenToString( ptS:getX()) .. ' V' .. EmtLenToString( -ptS:getY()) .. ' W' .. EmtLenToString( ptS:getZ())
local sDirPlane = ' A' .. EmtLenToString( dAngV) .. ' B' .. EmtLenToString( dAngO)
EmtOutput( 'G121 K'..EmtLenToString( EMT.INDEXGENPLANE)..sOriPlane..sDirPlane)
EmtOutput( 'G120 K' .. EmtLenToString( EMT.INDEXGENPLANE))
EMT.IPLGL = true
end
-- emissione piano
end
---------------------------------------------------------------------
function GetToolSelectionString( sHead, sToolPos)
local sToolSelString
-- se testa 1, la selezione si scrive in questo modo
if sHead == 'H11' then
sToolSelString = ' T41/' .. sToolPos:sub(2)
-- selezione sul gruppo a forare
else
-- gestire nomi uscite non corrette
local sToolPosList = ''
for i = 1, #sToolPos do
sToolPosList = sToolPosList .. EmtLenToString( MDRILL[sToolPos[i]].Token or MDRILL[sToolPos[i]].Ex)
if i < #sToolPos then
sToolPosList = sToolPosList .. ','
end
end
sToolSelString = '#T81=' .. sToolPosList
end
return sToolSelString
end
---------------------------------------------------------------------
function WriteDispositionInfo()
-- se lavoro con tavola intera 0, altrimenti a 1
local bUseCompleteTable = false
local nUseCompleteTableIndex = EgtIf( bUseCompleteTable, 0, 1)
-- se lavoro con la meta' tavola di sinistra o con tavola intera 98, altrimenti 99
local bUseTableDX = false
local nUseTableDXIndex = EgtIf( bUseTableDX, 99, 98)
EmtOutput( '|30 ' .. tostring( nUseCompleteTableIndex) .. ' ' .. tostring( nUseTableDXIndex) .. ' 1')
-- scrittura piani e sottopezzi
for i = 1, #EMT.DISP do
local nIndexPL = 30 + i
local sInfoPL = ''
for j = 1, #EMT.DISP[i].Fixture do
EMT.DISP[i].Fixture[j].ptPos[2] = EMT.RAWPOS[2] + EMT.HP - EMT.DISP[i].Fixture[j].ptPos[2]
sInfoPL = sInfoPL .. ' ' .. EMT.DISP[i].Fixture[j].ptPos[2] .. ' ' .. EMT.DISP[i].Fixture[j].dAngle
end
EmtOutput( '|' .. tostring( nIndexPL) .. ' ' .. tostring( EMT.DISP[i].dPosX) .. tostring( sInfoPL))
end
EmtOutput( ':')
end
---------------------------------------------------------------------
function MyAdjustLinearAxes()
local MyL1o = EMT.L1
local MyL2o = EMT.L2
local MyL3o = EMT.L3
-- se testa a 5 assi
if EMT.HEAD == 'H11' then
local Len = EMT.TLEN + PIVOT
local LenRef = PIVOT
local vtE = Vector3d( EMT.TDIR) * Len + X_AX() * LenRef
-- si compensa utensile
EMT.L1 = EMT.L1 - vtE:getX()
EMT.L2 = EMT.L2 - vtE:getY()
EMT.L3 = EMT.L3 - vtE:getZ()
if not EMT.IPLGL then
-- compensazione punto zero pezzo
EMT.L1 = EMT.L1 - EMT.RAWPOS[1]
EMT.L2 = EMT.L2 - EMT.RAWPOS[2] - EMT.HP
EMT.L3 = EMT.L3 - EMT.RAWPOS[3] - EMT.TP
else
EMT.L1 = EMT.L1 - EMT.RAWPOS[1]
EMT.L2 = EMT.L2 - EMT.RAWPOS[2] - EMT.HP
EMT.L3 = EMT.L3 - EMT.RAWPOS[3]
end
EmtAdjustLinearAxes()
EMT.L1o = MyL1o
EMT.L2o = MyL2o
EMT.L3o = MyL3o
-- Y e Z sono invertiti
EMT.L2 = -EMT.L2
EMT.L3 = -EMT.L3
-- altrimenti foratore
else
local Len = EMT.TLEN
local vtE = Vector3d( EMT.TDIR) * Len
-- si compensa utensile
EMT.L1 = EMT.L1 - vtE:getX()
EMT.L2 = EMT.L2 - vtE:getY()
EMT.L3 = EMT.L3 - vtE:getZ()
local nExit = EMT.DRACEX[1]
EMT.L1 = EMT.L1 + MDRILL[nExit].Pos[1]
EMT.L2 = EMT.L2 + MDRILL[nExit].Pos[2] - EMT.RAWPOS[2] - EMT.HP
EMT.L3 = EMT.L3 + MDRILL[nExit].Pos[3] - EMT.RAWPOS[3] - EMT.TP
EmtAdjustLinearAxes()
-- Y e Z sono invertiti
EMT.L2 = -EMT.L2
EMT.L3 = -EMT.L3
-- per foratore, il riferimento è la faccia di lavoro, quindi si corregge la dimensione del pezzo
local v3TDir = Vector3d( EMT.TDIR)
if AreSameVectorApprox( v3TDir, X_AX()) then
EMT.L1 = - ( EMT.L1 - EMT.LP)
elseif AreSameVectorApprox( v3TDir, -Y_AX()) then
EMT.L2 = - ( EMT.L2 - EMT.HP)
end
end
end
---------------------------------------------------------------------
function AdjustBladeZeroPoint( p3FirstPoint, vCorrDirr)
p3FirstPoint[1] = p3FirstPoint[1] + ( vCorrDirr[1] * EMT.TDIAM/2)
p3FirstPoint[2] = p3FirstPoint[2] + ( vCorrDirr[2] * EMT.TDIAM/2)
p3FirstPoint[3] = p3FirstPoint[3] + ( vCorrDirr[3] * EMT.TDIAM/2)
end
---------------------------------------------------------------------