-- Processore macchina Masterwood-TF600KST 2025/08/22 -- by EgalWare s.r.l. -- -- Intestazioni require( 'EmtGenerator') EgtEnableDebug( false) --------------------------------------------------------------------- -- *** GENERATION *** --------------------------------------------------------------------- local sBaseDir = EgtGetCurrMachineDir() if NumericalControl == 'woodWOP' then dofile( sBaseDir .. '\\Masterwood-woodWOP.mlpe') else EmtSetLastError( 1201, 'Numerical Control error : unkwnown type') end --------------------------------------------------------------------- -- *** SIMULATION *** --------------------------------------------------------------------- --------------------------------------------------------------------- function OnSimulStart() -- controllo versione programma if not EMT.VER or EMT.VER < MIN_MACH_VER then EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel '..MIN_MACH_VER..')') end -- Se reset o home, esco if EMT.SIM1ST then return end -- Creo o svuoto gruppo per copia finale degli oggetti virtual milling local nVmGrpId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') if nVmGrpId then EgtSetStatus( nVmGrpId, GDB_ST.ON) EgtEmptyGroup( nVmGrpId) else nVmGrpId = EgtGroup( GDB_ID.ROOT) EgtSetName( nVmGrpId, 'VMill') EgtSetLevel( nVmGrpId, GDB_LV.TEMP) end -- Preparo lista oggetti da verificare per collisioni EMT.COLLOBJ = {} --AddToCollisionCheck( 'C', 'COLLISION', EMT.COLLOBJ) DumpCollisionCheck( EMT.COLLOBJ, 'Collision Objects :', 4) -- Preparo lista solidi macchina con cui possono collidere gli oggetti sopra riportati (in aggiunta a VMill) EMT.MCODET = {} --local McdData = { { Grp = 'PL1', Sub = 'COLLISION', Name = 'STM'}, -- { Grp = 'PL2', Sub = 'COLLISION', Name = 'STM'}, -- { Grp = 'PL3', Sub = 'COLLISION', Name = 'STM'}, -- { Grp = 'PL4', Sub = 'COLLISION', Name = 'STM'}, -- { Grp = 'PL5', Sub = 'COLLISION', Name = 'STM'}, -- { Grp = 'PL6', Sub = 'COLLISION', Name = 'STM'}} EgtOutLog( 'MCODET Objects :', 4) local nMcdNullCnt = 0 for i = 1, #(McdData or {}) do local nGrpId if McdData[i].Grp == 'Base' then nGrpId = EgtGetBaseId( 'Base') else nGrpId = EgtGetAxisId( McdData[i].Grp) end local nId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nGrpId or GDB_ID.NULL, McdData[i].Sub) or GDB_ID.NULL, McdData[i].Name) if nId then table.insert( EMT.MCODET, nId) EgtOutLog( 'Element ' .. McdData[i].Grp .. '/' .. McdData[i].Sub .. '/' .. McdData[i].Name .. ' (' .. tostring( nId) .. ') is ok', 4) else nMcdNullCnt = nMcdNullCnt + 1 EgtOutLog( 'Element ' .. McdData[i].Grp .. '/' .. McdData[i].Sub .. '/' .. McdData[i].Name .. ' is null', 4) end end if nMcdNullCnt > 0 then EgtOutLog( 'Warning : MCODET with one or more null Element(s) ') end -- Preparo lista collisioni vuota EMT.COLLIDE = {} end --------------------------------------------------------------------- function OnSimulEnd() -- posizioni home degli assi testa local HomeX = EgtGetAxisHomePos( 'X') local HomeY = EgtGetAxisHomePos( 'Y') local HomeZ1 = EgtGetAxisHomePos( 'Z1') local HomeC = EgtGetAxisHomePos( 'C') local HomeA = EgtGetAxisHomePos( 'A') SimulMoveAxes( 'X', HomeX, MCH_SIM_STEP.RAPID, 'Y', HomeY, MCH_SIM_STEP.RAPID,'Z1', HomeZ1, MCH_SIM_STEP.RAPID, 'A', HomeA, MCH_SIM_STEP.COLLROT, 'C', HomeC, MCH_SIM_STEP.COLLROT) end --------------------------------------------------------------------- function OnSimulDispositionStart() EMT.OPEISDISP = true -- se non esiste la lista con le info dei pezzi, la creo if not EMT.PIECES or EMT.PHASE > 1 then EMT.PIECES = {} end -- recupero tutte le info dei pezzi, dimensioni e posizione local nPartRawId = EgtGetFirstRawPart() while nPartRawId do local vPiece = {} -- recupero il solido local nSolId = EgtGetFirstNameInGroup( nPartRawId, 'RawSolid') local b3Raw = EgtGetBBoxGlob( nSolId, GDB_BB.STANDARD) vPiece.Id = nPartRawId vPiece.IdPiece = EgtGetFirstPartInRawPart( nPartRawId) vPiece.SolId = nSolId vPiece.Len = b3Raw:getDimX() vPiece.Wid = b3Raw:getDimY() vPiece.Thk = b3Raw:getDimZ() vPiece.Offs = b3Raw:getMin() -- offset rispetto a zero vPiece.Area = vPiece.Len * vPiece.Wid + vPiece.Len * vPiece.Thk + vPiece.Wid * vPiece.Thk table.insert( EMT.PIECES, vPiece) nPartRawId = EgtGetNextRawPart( nPartRawId) end -- Se prima disposizione if EMT.PHASE == 1 then -- Determino dimensioni del grezzo local nSolId = EgtGetFirstNameInGroup( EgtGetFirstRawPart() or GDB_ID.NULL, 'RawSolid') or GDB_ID.NULL local b3Sol = EgtGetBBoxGlob( nSolId, GDB_BB.STANDARD) EMT.LB = 0 EMT.SB = 0 EMT.HB = 0 if b3Sol then EMT.LB = b3Sol:getDimX() EMT.SB = b3Sol:getDimY() EMT.HB = b3Sol:getDimZ() end -- Carico primo utensile sulla testa 1 local sTool, nTlen = FindFirstToolOnHead( 'H11') if sTool then EMT.TOOL_1 = sTool else EMT.TOOL_1 = GetDefaultToolName() end EgtLoadTool( 'H11', 1, EMT.TOOL_1) EMT.TCPOS_1 = GetToolTcPos( EMT.TOOL_1) EMT.LOAD = true -- Se vero inizio e abilitato creo gli Zmap EMT.VMILL = {} if not EMT.SIM1ST and EgtGetInfo( EgtGetCurrMachGroup(), 'Vm', 'b') then for i = 1, #EMT.PIECES do -- elimino eventuale vecchio Zmap EgtErase( EgtGetFirstNameInGroup( EMT.PIECES[i].Id, 'VMill') or GDB_ID.NULL) -- recupero il solido local nPartSolId = EgtGetFirstNameInGroup( EMT.PIECES[i].Id, 'RawSolid') local b3PartSol = EgtGetBBoxGlob( nPartSolId, GDB_BB.STANDARD) -- determino la risoluzione dello Zmap local dTol = 4.71 if EmtGetVMillStep then dTol = EmtGetVMillStep( b3PartSol:getDimX(), b3PartSol:getDimY(), b3PartSol:getDimZ(), 4.71) else local dArea = b3PartSol:getDimX() * b3PartSol:getDimY() + b3PartSol:getDimX() * b3PartSol:getDimZ() + b3PartSol:getDimY() * b3PartSol:getDimZ() if dArea < 0.075e6 then dTol = 0.71 elseif dArea < 0.15e6 then dTol = 1.01 elseif dArea < 0.3e6 then dTol = 1.51 elseif dArea < 0.6e6 then dTol = 1.97 elseif dArea < 1.2e6 then dTol = 2.81 elseif dArea < 2.4e6 then dTol = 3.77 end end -- creo lo Zmap local VMillId = EgtVolZmapBox( EMT.PIECES[i].Id, EMT.PIECES[i].Offs, EMT.PIECES[i].Len, EMT.PIECES[i].Wid, EMT.PIECES[i].Thk, dTol, true, GDB_RT.GLOB) if VMillId then EgtSetName( VMillId, 'VMill') EgtSetLevel( VMillId, GDB_LV.TEMP) EgtSetColor( VMillId, EgtGetColor( nSolId), false) -- nascondo le altre geometrie local nId = EgtGetFirstInGroup( EMT.PIECES[i].Id) while nId do if nId ~= VMillId then EgtSetStatus( nId, GDB_ST.OFF) end nId = EgtGetNext( nId) end table.insert( EMT.VMILL, VMillId) end end -- se vero inizio, assegno solidi per verifica collisione if not EMT.SIM1ST then EMT.CODET = {} for i = 1, #( EMT.MCODET or {}) do EMT.CODET[i] = EMT.MCODET[i] end for i = 1, #( EMT.VMILL or {}) do table.insert( EMT.CODET, EMT.VMILL[i]) end end end -- fasi successive else EMT.LOAD = false end -- nascondo lavorazioni che risulterebbero in posizione diversa dai pezzi local nMchId = EgtGetNextOperation( EgtGetPhaseDisposition( EMT.PHASE)) while nMchId do if EgtGetOperationPhase( nMchId) ~= EMT.PHASE then break end EgtSetOperationStatus( nMchId, false) nMchId = EgtGetNextOperation( nMchId) end end --------------------------------------------------------------------- function OnSimulDispositionEnd() -- Se prima disposizione if EMT.PHASE == 1 then -- Se vero inizio e abilitato creo gli Zmap EMT.VMILL = {} if not EMT.SIM1ST and EgtGetInfo( EgtGetCurrMachGroup(), 'Vm', 'b') then local nRawId = EgtGetFirstRawPart() while nRawId do if EgtVerifyRawPartPhase( nRawId, 1) then -- elimino eventuale vecchio Zmap EgtErase( EgtGetFirstNameInGroup( nRawId, 'VMill') or GDB_ID.NULL) -- recupero il solido local nSolId = EgtGetFirstNameInGroup( nRawId, 'RawSolid') -- determino la risoluzione dello Zmap local b3Sol = EgtGetBBoxGlob( nSolId, GDB_BB.STANDARD) local dTol = EmtGetVMillStep( b3Sol:getDimX(), b3Sol:getDimY(), b3Sol:getDimZ(), 2.01) -- creo lo Zmap local VMillId = EgtVolZmapFromSurfTm( nRawId, nSolId, dTol, true) if VMillId then EgtSetName( VMillId, 'VMill') EgtSetLevel( VMillId, GDB_LV.TEMP) EgtSetColor( VMillId, EgtGetColor( nSolId), false) -- nascondo le altre geometrie local nId = EgtGetFirstInGroup( nRawId) while nId do if nId ~= VMillId then EgtSetStatus( nId, GDB_ST.OFF) end nId = EgtGetNext( nId) end table.insert( EMT.VMILL, VMillId) end end nRawId = EgtGetNextRawPart( nRawId) end end end EMT.OPEISDISP = false end --------------------------------------------------------------------- function OnSimulToolSelect() -- carico utensile, con breve pausa EgtPause( 100) EgtOutText( '') -- se attivo Vmill if EMT.VMILL then EmtSetToolForVmill( EMT.TOOL, EMT.HEAD, EMT.EXIT, EMT.VMILL) end -- se attivo Collision Check EMT.SAFEDIST = COLL_SAFE_DIST if EMT.COLLOBJ then for i, Coll in ipairs( EMT.COLLOBJ) do EmtAddCollisionObjEx( i, Coll.Fr, Coll.Ty, Coll.Mv, Coll.P1, Coll.P2, Coll.P3) end if EMT.HEAD ~= 'H2' then AddToolToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, 1001) AddToolHolderToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, 1002) else AddToolToCollisionObj( nil, 'H1', 1, 1001) AddToolHolderToCollisionObj( nil, 'H1', 1, 1002) end end end --------------------------------------------------------------------- function OnSimulToolDeselect() -- se utensile non cambia, esco if EMT.NEXTTOOL == EMT.PREVTOOL then return end -- deposito utensile EgtOutText( 'Tool change in progress...') if EMT.HEAD == 'H11' and EMT.NEXTHEAD ~= EMT.HEAD then SimulMoveAxis( 'Z11', 650, MCH_SIM_STEP.RAPID) elseif EMT.HEAD == 'H12' and EMT.NEXTHEAD ~= EMT.HEAD then SimulMoveAxis( 'Z12', 400, MCH_SIM_STEP.RAPID) elseif EMT.HEAD == 'H21' and EMT.NEXTHEAD ~= EMT.HEAD then SimulMoveAxis( 'Z21', -650, MCH_SIM_STEP.RAPID) elseif EMT.HEAD == 'H22' and EMT.NEXTHEAD ~= EMT.HEAD then SimulMoveAxis( 'Z22', -400, MCH_SIM_STEP.RAPID) end end --------------------------------------------------------------------- function OnSimulMachiningStart() EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE) EMT.MCHNAME = EgtGetMachiningParam(MCH_MP.NAME) EMT.NOTES = EgtGetMachiningParam( MCH_MP.USERNOTES) EMT.VMRS = ( EMT.MCHTYPE ~= MCH_MY.DRILLING and EgtGetValInNotes( EMT.NOTES or '', 'VMRS', 'i') ~= 0) end --------------------------------------------------------------------- function OnSimulMachiningEnd() EMT.PREVTOOL = EMT.TOOL EMT.PREVHEAD = EMT.HEAD EMT.PREVTCPOS = EMT.TCPOS end --------------------------------------------------------------------- function OnSimulPathStart() -- speciale per gruppi a forare if EMT.HEAD == 'H12' or EMT.HEAD == 'H22' then -- attivazione uscite EMC = { HEADID = EgtGetHeadId( EMT.HEAD), DRACEX = EMT.DRACEX} OnActivateDrillingUnit() EMC = nil -- impostazione utensili aggiuntivi per Vmill if EMT.VMILL then for i = 1, #( EMT.DRACEX or {}) do local nExit = EMT.DRACEX[i] local sTool = EgtGetLoadedTool( EMT.HEAD, nExit) if i == 1 then EmtSetToolForVmill( sTool, EMT.HEAD, nExit, EMT.VMILL) else EmtAddToolForVmill( sTool, EMT.HEAD, nExit, EMT.VMILL) end end end end end --------------------------------------------------------------------- function OnSimulPathEnd() if EMT.VMILL and #EMT.VMILL > 0 and not EMT.OPEISDISP and EMT.VMRS then -- elimino eventuali sfridi for j = 1, #EMT.VMILL do local vMillId = EMT.VMILL[j] local nPart = EgtVolZmapPartCount( vMillId) if nPart > 1 then -- ricerca del pezzo con massimo volume local nPartMax = 0 local dVolMax = 0 for i = 1, nPart do local dVol = EgtVolZmapPartVolume( vMillId, i - 1) if dVol > dVolMax then dVolMax = dVol nPartMax = i end end -- eliminazione di tutti i pezzi piccoli for i = nPart, 1, -1 do if i ~= nPartMax then EgtRemoveVolZmapPart( vMillId, i - 1) end end end end EgtDraw() end end --------------------------------------------------------------------- function OnSimulMoveStart() end --------------------------------------------------------------------- function OnSimulMoveEnd() end --------------------------------------------------------------------- function OnSimulCollision() -- se prima collisione della lavorazione, la segnalo if EMT.MCHNAME ~= EMT.LAST_MCHNAME_COLLIDE then -- speciale per utensile flottante (suo holder contro il grezzo) if EMT.TFLOAT and EMT.TFLOAT_CMP and EMT.SIMCOBIND == 1002 and EMT.SIMVMID == EMT.VMILL[1] then if EMT.MOVEID == EMT.TFLOAT_CMP then EMT.TFLOAT_TH_COMPR_COLL = true end return end -- standard local Class = '' if EMT.SIMCOBIND == 1001 then Class = 'T_H1' elseif EMT.SIMCOBIND == 1002 then Class = 'TH_H1' else Class = EMT.COLLOBJ[EMT.SIMCOBIND].Cl end table.insert( EMT.COLLIDE, { Mc = EMT.MCHNAME, Cl = Class, Vm = EMT.SIMVMID}) EMT.LAST_MCHNAME_COLLIDE = EMT.MCHNAME EMT.ERR = 1 local sErr = 'CUTID='..tostring( EMT.CUTID)..'; TASKID='..tostring( EMT.TASKID)..'; Mach='..EMT.MCHNAME..'; Class='..Class..'; VMill='..EMT.SIMVMID EmtSetLastError( 1221, sErr, true) EgtOutLog( 'Collision : ' .. sErr, 1) end end --------------------------------------------------------------------- -- *** GENERAL *** --------------------------------------------------------------------- function FindFirstToolOnHead( sH1) -- salvo stato iniziale local CurrMachId = EgtGetCurrMachining() local CurrTool = EgtTdbGetCurrToolParam( MCH_TP.NAME) -- cerco lavorazione con utensile su testa indicata local sTool, nTlen local OpId = EgtGetFirstActiveOperation() while OpId do local nType = EgtGetOperationType( OpId) if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then if EgtSetCurrMachining( OpId) then local sTest = EgtGetMachiningParam( MCH_MP.TOOL) if EgtTdbSetCurrTool( sTest) then local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if sHead and ( sHead == sH1) then sTool = sTest nTlen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) break end end end end OpId = EgtGetNextActiveOperation( OpId) end -- ripristino stato iniziale if CurrMachId then EgtSetCurrMachining( CurrMachId) else EgtResetCurrMachining() end if CurrTool then EgtTdbSetCurrTool( CurrTool) else EgtTdbSetCurrTool( '') end -- restituisco risultato return sTool, nTlen end --------------------------------------------------------------------- function GetDefaultToolName() local DefTcPos = 'T1' local vTools = EgtGetToolsInCurrSetupPos( DefTcPos) if vTools and vTools[1] and #vTools[1] > 0 then return vTools[1] else -- local sErr = 'Missing tool in Default Position ' .. DefTcPos -- EgtOutLog( 'Error : ' .. sErr) -- EgtOutBox( sErr, 'ERROR', 'ERROR') return '' end end --------------------------------------------------------------------- function GetToolTcPos( sTool) -- salvo stato iniziale local CurrTool = EgtTdbGetCurrToolParam( MCH_TP.NAME) -- recupero la posizione di cambio utensile dell'utensile indicato local sTcPos if EgtTdbSetCurrTool( sTool) then sTcPos = EgtTdbGetCurrToolParam( MCH_TP.TCPOS) end -- ripristino stato iniziale if CurrTool then EgtTdbSetCurrTool( CurrTool) else EgtTdbSetCurrTool( '') end -- restituisco risultato return sTcPos end --------------------------------------------------------------------- function MoveHead( nGrpId, vtVers, dPos, bLoc) local dVal = EgtGetInfo( nGrpId or GDB_ID.NULL, 'Val') if not dVal then return end if abs( dPos - dVal) > GEO.EPS_SMALL then local nRT = EgtIf( bLoc, GDB_RT.LOC, GDB_RT.GLOB) EgtMove( nGrpId, ( dPos - dVal) * vtVers, nRT) EgtSetInfo( nGrpId, 'Val', dPos) end end --------------------------------------------------------------------- function ExecUnloading() if EMT.VMILL then local vMillId = EMT.VMILL -- gruppo dei Vmill local nVmGrpId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') -- creo un nuovo layer e vi inserisco il nuovo pezzo local nLayId = EgtGroup( nVmGrpId, EgtGetGlobFrame( vMillId)) EgtRelocate( vMillId, nLayId) EgtSetLevel( vMillId, GDB_LV.USER) -- aggiungo gli spigoli if EgtVolZmapSetShowEdges then EgtVolZmapSetShowEdges( vMillId, true) else local nFirstId, nCount = EgtVolZmapGetEdges( vMillId, nLayId) if nFirstId then for nId = nFirstId, nFirstId + nCount - 1 do EgtSetColor( nId, Color3d( 96, 96, 96)) end end end -- rilascio Vmill EMT.VMILL = nil -- aggiorno la visualizzazione EgtDraw() -- se impostato di salvare i Vmill, lo faccio local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini' if EgtGetStringFromIni( 'VMill', 'Save', '', sMachIni) == '1' then local sFile = EgtGetCurrFilePath() if sFile then local sDir, sName, sExt = EgtSplitPath( sFile) if sExt and sExt:lower() == ".nge" then sName = sName .. '_VM_' .. EgtGetMachGroupName( EgtGetCurrMachGroup()) EgtSetLevel( nVmGrpId, GDB_LV.USER) EgtSaveObjToFile( nVmGrpId, sDir .. sName .. '.Nge') EgtSetLevel( nVmGrpId, GDB_LV.TEMP) end end end end end --------------------------------------------------------------------- -- *** STIMA T&L *** --------------------------------------------------------------------- local RAPID_X_FEED = 20000 -- mm/min local RAPID_Y_FEED = 20000 -- mm/min local RAPID_Z_FEED = 10000 -- mm/min local RAPID_MIN_T = 1.0 -- s --------------------------------------------------------------------- function OnEstimStart() EMT.INCHES = not EgtUiUnitsAreMM() -- unità di misura mm/inches end --------------------------------------------------------------------- function OnEstimEnd() end --------------------------------------------------------------------- function OnEstimProgramStart() -- imposto inizio movimenti da Home EMT.L1 = EgtGetAxisHomePos( 'X') EMT.L2 = EgtGetAxisHomePos( 'Y') EMT.L3 = EgtGetAxisHomePos( 'Z11') -- aggiorno valori come precedenti EmtUpdatePrev() -- totalizzatori tempi e lunghezze EMT.TOTCUTLEN = 0 EMT.TOTCUTTIME = 0 EMT.TOTEXTLEN = 0 EMT.TOTEXTTIME = 0 -- variabile per lunghezza taglio utensili EMT.TOOLCUTLEN = {} -- intestazioni EmtTleStart( EMT.INFO) end --------------------------------------------------------------------- function OnEstimProgramEnd() -- stampa dei totali delle lavorazioni EmtTleAddTotal( EmtSecToHMS( EMT.TOTCUTTIME + EMT.TOTEXTTIME), EmtLenToMF( EMT.TOTCUTLEN)) -- stampa dei totali degli utensili for i = 1, #EMT.TOOLCUTLEN do local TCL = EMT.TOOLCUTLEN[i] EmtTleAddTool( TCL.Name, EmtLenToMF( TCL.Len)) end -- completo il file local _, _, sExt = EgtSplitPath( EMT.FILE) EmtTleEnd( sExt:sub( 2)) -- salvo i dati principali nel progetto EgtSetInfo( EgtGetCurrMachGroup(), 'Ttot', EgtNumToString( EMT.TOTCUTTIME + EMT.TOTEXTTIME, 0)) EgtSetInfo( EgtGetCurrMachGroup(), 'Ltot', EgtNumToString( EMT.TOTCUTLEN, 0)) end --------------------------------------------------------------------- function OnEstimDispositionStart() -- inizioe disposizione EMT.OPEISDISP = true -- non va fatto alcunché end --------------------------------------------------------------------- function OnEstimDispositionEnd() -- termine disposizione EMT.OPEISDISP = false -- non va fatto alcunché end --------------------------------------------------------------------- function OnEstimToolSelect() -- reset indice utensile in tabella lunghezze EMT.TCLIND = 0 -- verifico che l'utensile sia definito if #EMT.TOOL == 0 then return end -- cerco l'utensile nella tabella for i = 1, #EMT.TOOLCUTLEN do if EMT.TOOLCUTLEN[i].Name == EMT.TOOL then EMT.TCLIND = i break end end -- se non trovato, lo aggiungo if EMT.TCLIND == 0 then table.insert( EMT.TOOLCUTLEN, { Name = EMT.TOOL, Len = 0}) EMT.TCLIND = #EMT.TOOLCUTLEN end end --------------------------------------------------------------------- function OnEstimToolDeselect() end --------------------------------------------------------------------- function OnEstimMachiningStart() EMT.MCHNAME = EgtGetMachiningParam(MCH_MP.NAME) EMT.MCHTYPE = EgtGetMachiningParam(MCH_MP.TYPE) -- reset contatori di lavorazione EMT.MCHCUTLEN = 0 EMT.MCHCUTTIME = 0 EMT.MCHEXTLEN = 0 EMT.MCHEXTTIME = 0 end --------------------------------------------------------------------- function OnEstimMachiningEnd() local sName = EgtGetName( EMT.MCHID) .. ' (' .. EMT.MCHNAME .. ')' EmtTleAddMachining( sName, EmtSecToHMS( EMT.MCHCUTTIME + EMT.MCHEXTTIME), EmtLenToMF( EMT.MCHCUTLEN), EMT.TOOL) -- aggiorno totali e utensili EMT.TOTCUTLEN = EMT.TOTCUTLEN + EMT.MCHCUTLEN EMT.TOTCUTTIME = EMT.TOTCUTTIME + EMT.MCHCUTTIME EMT.TOTEXTLEN = EMT.TOTEXTLEN + EMT.MCHEXTLEN EMT.TOTEXTTIME = EMT.TOTEXTTIME + EMT.MCHEXTTIME EMT.TOOLCUTLEN[EMT.TCLIND].Len = EMT.TOOLCUTLEN[EMT.TCLIND].Len + EMT.MCHCUTLEN end --------------------------------------------------------------------- function OnEstimPathStart() end --------------------------------------------------------------------- function OnEstimPathEnd() end --------------------------------------------------------------------- function OnEstimRapid() -- dati movimento local dL1 = EMT.L1 - EMT.L1p local dL2 = EMT.L2 - EMT.L2p local dL3 = EMT.L3 - EMT.L3p -- calcolo lunghezza local dLen = sqrt( dL1 * dL1 + dL2 * dL2 + dL3 * dL3) if not EMT.OPEISDISP then EMT.MCHEXTLEN = EMT.MCHEXTLEN + dLen else EMT.DSPEXTLEN = EMT.DSPEXTLEN + dLen end -- calcolo tempo local dTime = RAPID_MIN_T local dT1 = abs( dL1) / RAPID_X_FEED * 60 if dT1 > dTime then dTime = dT1 end local dT2 = abs( dL2) / RAPID_Y_FEED * 60 if dT2 > dTime then dTime = dT2 end local dT3 = abs( dL3) / RAPID_Z_FEED * 60 if dT3 > dTime then dTime = dT3 end EMT.MCHEXTTIME = EMT.MCHEXTTIME + dTime -- aggiorno valori come precedenti EmtUpdatePrev() end --------------------------------------------------------------------- function OnEstimLinear() -- dati movimento local dL1 = EMT.L1 - EMT.L1p local dL2 = EMT.L2 - EMT.L2p local dL3 = EMT.L3 - EMT.L3p -- calcolo lunghezza local dLen = sqrt( dL1 * dL1 + dL2 * dL2 + dL3 * dL3) EMT.MCHCUTLEN = EMT.MCHCUTLEN + dLen -- calcolo tempo local dTime = dLen / ( EMT.F * 1000) * 60 EMT.MCHCUTTIME = EMT.MCHCUTTIME + dTime EgtOutLog( string.format( ' G1 Len=%.0f Time=%.2f', dLen, dTime), 5) -- aggiorno valori come precedenti EmtUpdatePrev() end --------------------------------------------------------------------- function OnEstimArc() -- dati movimento local dLxy = EMT.RR * abs( EMT.AC) * pi / 180 local dLz = abs( ( Point3d( EMT.L1, EMT.L2, EMT.L3) - Point3d( EMT.L1p, EMT.L2p, EMT.L3p)) * Vector3d( EMT.EXTR)) -- calcolo lunghezza local dLen = sqrt( dLxy * dLxy + dLz * dLz) EMT.MCHCUTLEN = EMT.MCHCUTLEN + dLen -- calcolo tempo local dTime = dLen / ( EMT.F * 1000) * 60 EMT.MCHCUTTIME = EMT.MCHCUTTIME + dTime EgtOutLog( string.format( ' G2 Len=%.0f Time=%.2f', dLen, dTime), 5) -- aggiorno valori come precedenti EmtUpdatePrev() end