DataBeam :

- migliorie e correzioni varie
- unificati BirdsMouth con LapJoint.
This commit is contained in:
Dario Sassi
2019-07-03 10:27:55 +00:00
parent 9ac596d5d7
commit 7c1a4ba546
20 changed files with 473 additions and 511 deletions
+76 -23
View File
@@ -1,4 +1,4 @@
-- BatchProcess.lua by Egaltech s.r.l. 2019/04/01
-- BatchProcess.lua by Egaltech s.r.l. 2019/07/01
-- Gestione calcolo batch disposizione e lavorazioni per Travi
@@ -7,6 +7,12 @@ require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Per test
--BEAM = {}
--BEAM.FILE = 'c:\\TechnoEssetre7\\EgtBtl\\Part_15_116.btl'
--BEAM.MACHINE = 'FAST'
--BEAM.FLAG = 3
-- Log dati di generazione
local sLog = 'BatchProcess : ' .. BEAM.FILE .. ', ' .. BEAM.MACHINE .. ', ' .. tostring( BEAM.FLAG)
EgtOutLog( sLog)
@@ -16,22 +22,30 @@ local sLogFile = EgtChangePathExtension( BEAM.FILE, '.txt')
EgtEraseFile( sLogFile)
-- Funzione per scrittura su file di log specifico
local function WriteLogFile( nErr, sErr, nCutId, nTaskId)
if nErr ~= 0 then
EgtOutLog( sErr .. ' (' .. tostring( nErr) ..')')
end
local hFile = io.open( sLogFile, 'w')
local function WriteLogFile( nErr, sMsg, nCutId, nTaskId)
local hFile = io.open( sLogFile, 'a')
hFile:write( 'ERR=' .. tostring( nErr) .. '\n')
if nErr ~= 0 then
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n')
hFile:write( sErr .. '\n')
end
hFile:write( sMsg .. '\n')
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n')
hFile:close()
end
-- Funzione per gestire visualizzazione dopo errore
local function PostErrView( nErr, sMsg)
if nErr ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then
EgtSetView( SCE_VD.ISO_SW, false)
EgtZoom( SCE_ZM.ALL)
EgtOutBox( sErr .. ' (error ' .. tostring( nErr) .. ')', 'BatchProcess', 'ERROR')
EgtOutBox( sMsg .. ' (error ' .. tostring( nErr) .. ')', 'BatchProcess', 'ERRORS')
end
end
-- Funzione per gestire visualizzazione dopo errore
local function PostWarnView( nWarn, sMsg)
if nWarn ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then
EgtSetView( SCE_VD.ISO_SW, false)
EgtZoom( SCE_ZM.ALL)
EgtOutBox( sMsg .. ' (warning ' .. tostring( nWarn) .. ')', 'BatchProcess', 'WARNINGS')
end
end
@@ -46,6 +60,7 @@ if not EgtSetCurrMachine( sMachine) then
BEAM.ERR = 11
BEAM.MSG = 'Error selecting machine : ' .. sMachine
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -55,6 +70,7 @@ 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)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -79,6 +95,7 @@ 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)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -93,6 +110,7 @@ if #vBeam == 0 then
BEAM.ERR = 14
BEAM.MSG = 'Error no beams in the file : ' .. BEAM.FILE
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
else
local sOut = ''
@@ -111,6 +129,7 @@ for i = 1, #vBeam do
BEAM.ERR = 15
BEAM.MSG = 'Box undefined for beam ' .. vBeam[i].Name
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
else
vBeam[i].Box = b3Solid
@@ -156,6 +175,7 @@ if #vBeamErr > 0 then
BEAM.ERR = 16
BEAM.MSG = sOut
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -166,6 +186,7 @@ if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO
BEAM.ERR = 17
BEAM.MSG = sOut
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -180,6 +201,7 @@ if not bPbOk then
BEAM.ERR = 18
BEAM.MSG = sPbErr
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -191,14 +213,42 @@ EgtSetInfo( EgtGetCurrMachGroup(), 'NcName', sName .. '.cnc')
EgtSetInfo( EgtGetCurrMachGroup(), 'Vm', '1')
-- Lavoro le features
local bPfOk, sPfErr, nPfCutId, nPfTaskId = BE.ProcessFeatures()
if not bPfOk then
BEAM.ERR = 19
BEAM.MSG = sPfErr
BEAM.CUTID = nPfCutId
BEAM.TASKID = nPfTaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
local bPfOk, Stats = BE.ProcessFeatures()
local nErrCnt = 0
local nWarnCnt = 0
local sOutput = ''
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.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, 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.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, 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.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
end
end
if #sOutput > 0 then EgtOutLog( sOutput) end
if nErrCnt > 0 then
PostErrView( 19, sOutput)
return
elseif nWarnCnt > 0 then
PostWarnView( 19, sOutput)
end
-- Salvo il progetto
@@ -211,6 +261,7 @@ if BEAM.FLAG == 0 then
BEAM.ERR = 20
BEAM.MSG = 'Error generating NC part program : ' .. sName
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
end
@@ -220,7 +271,9 @@ if BEAM.FLAG == 1 or BEAM.FLAG == 2 then
EgtSetView( SCE_VD.ISO_SW, false)
end
-- Completamento senza errori
BEAM.ERR = 0
BEAM.MSG = ''
WriteLogFile( BEAM.ERR, BEAM.MSG)
-- Completamento senza errori e avvisi
if nWarnCnt == 0 then
BEAM.ERR = 0
BEAM.MSG = ''
WriteLogFile( BEAM.ERR, BEAM.MSG)
end