Gestione Macro Lama
This commit is contained in:
@@ -24,9 +24,9 @@ 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)
|
||||
--local sNewPath = EgtChangePathExtension( EMT.FILE, '.prg')
|
||||
--EgtEraseFile( sNewPath)
|
||||
--EgtRenameFile( EMT.FILE, sNewPath)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -162,6 +162,9 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function OnMachiningEnd()
|
||||
-- reset eventuali macro
|
||||
EMT.MACROLAMA = nil
|
||||
EMT.MACROFORO = nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -181,15 +184,34 @@ end
|
||||
function OnRapid()
|
||||
-- se standard
|
||||
if EMT.FLAG == 0 or EMT.FLAG == 1 or EMT.FLAG == 2 then
|
||||
-- se gruppo a forare
|
||||
if EMT.HEAD == 'H21' then
|
||||
|
||||
-- se foratura, si scrive macro alla fine del foro
|
||||
if false and EMT.MCHTYPE == MCH_OY.DRILLING then
|
||||
-- se gruppo a forare
|
||||
if EMT.HEAD == 'H21' then
|
||||
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, emetto 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
|
||||
-- emissione piano di interpolazione
|
||||
EmitInterpPlane()
|
||||
EmitInterpPlane( false)
|
||||
MyAdjustLinearAxes()
|
||||
EmtAdjustRotaryAxes()
|
||||
-- emissione primo punto della lavorazione
|
||||
@@ -200,7 +222,7 @@ function OnRapid()
|
||||
sLinearAxes = sLinearAxes .. EmtGetAxis('L3')
|
||||
end
|
||||
local sSpeed = ' S' .. EmtLenToString( EMT.S / 1000)
|
||||
local sFeed = ' E50' -- feed rapido
|
||||
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)
|
||||
@@ -239,36 +261,138 @@ end
|
||||
function OnLinear()
|
||||
MyAdjustLinearAxes()
|
||||
EmtAdjustRotaryAxes()
|
||||
-- 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
|
||||
-- aggiungo feed
|
||||
local sFeed = EmtGetFeed()
|
||||
if sFeed and sFeed ~= '' then
|
||||
EMT.FEED = sFeed
|
||||
else
|
||||
sFeed = EMT.FEED
|
||||
end
|
||||
-- controllo che la feed non sia troppo alta
|
||||
local cleaned_Feed = sFeed:gsub( 'F', '') -- Rimuove tutte le occorrenze di "F"
|
||||
local dFeed = tonumber( cleaned_Feed) -- Converte la stringa rimanente in numero
|
||||
if dFeed > 10 then
|
||||
EmtSetLastError( 1210, 'Feed TOO HIGH!! Machining: ' .. EMT.MCHNAME)
|
||||
end
|
||||
|
||||
|
||||
-- emetto linea
|
||||
EmtOutput( 'G101' .. sAxes .. sFeed)
|
||||
-- leggo feed
|
||||
if not EMT.FEED then
|
||||
local sFeed = EmtGetFeed()
|
||||
if sFeed and sFeed ~= '' then
|
||||
EMT.FEED = sFeed
|
||||
end
|
||||
-- controllo che la feed non sia troppo alta
|
||||
local cleaned_Feed = sFeed:gsub( 'F', '') -- Rimuove tutte le occorrenze di "F"
|
||||
local dFeed = tonumber( cleaned_Feed) -- Converte la stringa rimanente in numero
|
||||
if dFeed > 10 then
|
||||
EmtSetLastError( 1210, 'Feed TOO HIGH!! Machining: ' .. EMT.MCHNAME)
|
||||
end
|
||||
end
|
||||
|
||||
if 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)
|
||||
|
||||
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
|
||||
EmtOutput( 'G172 ' .. sLinearAxes .. sSpeed .. EMT.FEED .. 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 .. sBladeAngle .. sDiscordanza)
|
||||
|
||||
end
|
||||
end
|
||||
-- macro foratura
|
||||
elseif EMT.MACROFORO then
|
||||
-- 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 è possibile fare archi con la lama, errore
|
||||
if EMT.TOOLTYPE == MCH_TY.SAW_STD or EMT.TOOLTYPE == MCH_TY.SAW_FLAT then
|
||||
EmtSetLastError( 1210, 'ARCS with blade not allowed!! Machining: ' .. EMT.MCHNAME)
|
||||
end
|
||||
|
||||
-- non modale su archi
|
||||
EmtResetPrevLinear()
|
||||
-- valori degli assi
|
||||
@@ -314,7 +438,7 @@ end
|
||||
---------------------------------------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
function EmitInterpPlane()
|
||||
function EmitInterpPlane( bForceTopPlane)
|
||||
-- Reset piano globale di interpolazione
|
||||
EMT.IPLGL = false
|
||||
EMT.IPLGLFR = nil
|
||||
@@ -324,7 +448,7 @@ function EmitInterpPlane()
|
||||
local nPlaneNumber = 1
|
||||
|
||||
-- piano TOP
|
||||
if vtE:isSmall() or AreSameVectorApprox( vtE, Z_AX()) or EMT.HEAD == 'H21' then
|
||||
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)
|
||||
@@ -446,3 +570,9 @@ function MyAdjustLinearAxes()
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
@@ -136,8 +136,7 @@ EmtHead {
|
||||
Type = MCH_HT.STD,
|
||||
Pos = H11Pos,
|
||||
TDir = -X_AX(),
|
||||
ADir = -X_AX(),
|
||||
SolCh = MCH_SCC.ADIR_ZP,
|
||||
ADir = Y_AX(),
|
||||
OthColl = {'C/SOLID','A/SOLID'},
|
||||
Geo = 'H11_HEAD/GEO'}
|
||||
EmtAxis {
|
||||
|
||||
Reference in New Issue
Block a user