DataBeam :
- migliorie e correzioni.
This commit is contained in:
+49
-19
@@ -1,6 +1,6 @@
|
||||
-- BatchProcess.lua by Egaltech s.r.l. 2019/07/01
|
||||
-- BatchProcess.lua by Egaltech s.r.l. 2019/07/12
|
||||
-- Gestione calcolo batch disposizione e lavorazioni per Travi
|
||||
|
||||
-- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3.
|
||||
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
@@ -21,15 +21,21 @@ EgtOutLog( sLog)
|
||||
local sLogFile = EgtChangePathExtension( BEAM.FILE, '.txt')
|
||||
EgtEraseFile( sLogFile)
|
||||
|
||||
-- Funzione per scrittura su file di log specifico
|
||||
local function WriteLogFile( nErr, sMsg, nCutId, nTaskId)
|
||||
-- Funzioni per scrittura su file di log specifico
|
||||
local function WriteErrToLogFile( nErr, sMsg, nRot, nCutId, nTaskId)
|
||||
local hFile = io.open( sLogFile, 'a')
|
||||
hFile:write( 'ERR=' .. tostring( nErr) .. '\n')
|
||||
hFile:write( sMsg .. '\n')
|
||||
hFile:write( 'ROT=' .. tostring( nRot or 0) .. '\n')
|
||||
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
|
||||
hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n')
|
||||
hFile:close()
|
||||
end
|
||||
local function WriteTimeToLogFile( dTime)
|
||||
local hFile = io.open( sLogFile, 'a')
|
||||
hFile:write( 'TIME=' .. EgtNumToString( dTime) .. '\n')
|
||||
hFile:close()
|
||||
end
|
||||
|
||||
-- Funzione per gestire visualizzazione dopo errore
|
||||
local function PostErrView( nErr, sMsg)
|
||||
@@ -59,7 +65,7 @@ local sMachine = 'Essetre-' .. BEAM.MACHINE
|
||||
if not EgtSetCurrMachine( sMachine) then
|
||||
BEAM.ERR = 11
|
||||
BEAM.MSG = 'Error selecting machine : ' .. sMachine
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -69,7 +75,7 @@ local sMachDir = EgtGetCurrMachineDir()
|
||||
if not EgtExistsFile( sMachDir .. '\\Beam\\BeamData.lua') then
|
||||
BEAM.ERR = 12
|
||||
BEAM.MSG = 'Error not configured for beams machine : ' .. sMachine
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -94,7 +100,7 @@ EgtNewFile()
|
||||
if not EgtImportBtl( BEAM.FILE, EIB_FL.TS3_POS) then
|
||||
BEAM.ERR = 13
|
||||
BEAM.MSG = 'Error importing BTL file : ' .. BEAM.FILE
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -109,7 +115,7 @@ end
|
||||
if #vBeam == 0 then
|
||||
BEAM.ERR = 14
|
||||
BEAM.MSG = 'Error no beams in the file : ' .. BEAM.FILE
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
else
|
||||
@@ -128,7 +134,7 @@ for i = 1, #vBeam do
|
||||
if not b3Solid then
|
||||
BEAM.ERR = 15
|
||||
BEAM.MSG = 'Box undefined for beam ' .. vBeam[i].Name
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
else
|
||||
@@ -136,6 +142,12 @@ for i = 1, #vBeam do
|
||||
end
|
||||
end
|
||||
|
||||
-- Ne recupero la posizione
|
||||
for i = 1, #vBeam do
|
||||
local PosX = EgtGetInfo( vBeam[i].Id, 'POSX', 'd')
|
||||
vBeam[i].PosX = PosX
|
||||
end
|
||||
|
||||
-- Eseguo eventuali rotazioni e inversioni testa-coda
|
||||
for i = 1, #vBeam do
|
||||
local b3Solid = vBeam[i].Box
|
||||
@@ -174,7 +186,7 @@ if #vBeamErr > 0 then
|
||||
end
|
||||
BEAM.ERR = 16
|
||||
BEAM.MSG = sOut
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -185,7 +197,7 @@ if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO
|
||||
'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ')'
|
||||
BEAM.ERR = 17
|
||||
BEAM.MSG = sOut
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -200,7 +212,7 @@ local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam)
|
||||
if not bPbOk then
|
||||
BEAM.ERR = 18
|
||||
BEAM.MSG = sPbErr
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
@@ -221,26 +233,29 @@ for i = 1, #Stats do
|
||||
if Stats[i].Err == 0 then
|
||||
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d Ok\n', Stats[i].CutId, Stats[i].TaskId)
|
||||
BEAM.ERR = 0
|
||||
BEAM.MSG = ''
|
||||
BEAM.MSG = '---'
|
||||
BEAM.ROT = Stats[i].Rot or 0
|
||||
BEAM.CUTID = Stats[i].CutId
|
||||
BEAM.TASKID = Stats[i].TaskId
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
|
||||
elseif Stats[i].Err > 0 then
|
||||
nErrCnt = nErrCnt + 1
|
||||
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
|
||||
BEAM.ERR = 19
|
||||
BEAM.MSG = Stats[i].Msg
|
||||
BEAM.ROT = Stats[i].Rot or 0
|
||||
BEAM.CUTID = Stats[i].CutId
|
||||
BEAM.TASKID = Stats[i].TaskId
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
|
||||
elseif Stats[i].Err < 0 then
|
||||
nWarnCnt = nWarnCnt + 1
|
||||
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
|
||||
BEAM.ERR = -19
|
||||
BEAM.MSG = Stats[i].Msg
|
||||
BEAM.ROT = Stats[i].Rot or 0
|
||||
BEAM.CUTID = Stats[i].CutId
|
||||
BEAM.TASKID = Stats[i].TaskId
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
|
||||
end
|
||||
end
|
||||
if #sOutput > 0 then EgtOutLog( sOutput) end
|
||||
@@ -260,12 +275,24 @@ if BEAM.FLAG == 0 then
|
||||
if not EgtGenerate( '', 'EgtCAM5 - ' .. sNgeFile) then
|
||||
BEAM.ERR = 20
|
||||
BEAM.MSG = 'Error generating NC part program : ' .. sName
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Eseguo stima tempi
|
||||
if not EgtEstimate( '', 'EgtCAM5 - ' .. sNgeFile) then
|
||||
BEAM.ERR = 21
|
||||
BEAM.MSG = 'Error estimating production time : ' .. sName
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
local Ttot = EgtGetInfo( EgtGetCurrMachGroup(), 'Ttot')
|
||||
local sTime = 'Total Time = ' .. EgtNumToString( Ttot, 1)
|
||||
EgtOutLog( sTime)
|
||||
|
||||
-- Imposto la vista ISO 3d, se richiesto
|
||||
if BEAM.FLAG == 1 or BEAM.FLAG == 2 then
|
||||
EgtSetView( SCE_VD.ISO_SW, false)
|
||||
@@ -274,6 +301,9 @@ end
|
||||
-- Completamento senza errori e avvisi
|
||||
if nWarnCnt == 0 then
|
||||
BEAM.ERR = 0
|
||||
BEAM.MSG = ''
|
||||
WriteLogFile( BEAM.ERR, BEAM.MSG)
|
||||
BEAM.MSG = '---'
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
end
|
||||
|
||||
-- Scrittura tempo totale stimato di lavorazione
|
||||
WriteTimeToLogFile( Ttot)
|
||||
|
||||
Reference in New Issue
Block a user