- modificate BatchProcessNew e BeamExec per contemplare nuova tabella RESULTS

This commit is contained in:
luca.mazzoleni
2025-04-26 02:05:33 +02:00
parent 3bc9ef4688
commit 837969e0a7
3 changed files with 79 additions and 47 deletions
+36 -32
View File
@@ -1,4 +1,4 @@
-- BatchProcessNew.lua by Egaltech s.r.l. 2025/04/24
-- BatchProcessNew.lua by Egalware s.r.l. 2025/04/24
-- Intestazioni
require( 'EgtBase')
@@ -90,6 +90,7 @@ local BeamExec = require( 'BeamExec')
-- Variabili di modulo
local dRawW
local dRawH
local sTxtLogFile = EgtChangePathExtension( BEAM.FILE, '.txt')
-------------------------------------------------------------------------------------------------------------
-- Funzioni di supporto
@@ -98,7 +99,7 @@ local function GetDataConfig()
-- recupero utensili dal magazzino
BeamExec.GetToolsFromDB()
-- se si utilizza interfaccia B&W, si carica il file JSON
local bIsBeamWall = true -- TODO serve parametro per capire se stiamo utilizzando B&W
local bIsBeamWall = BEAM.BW -- TODO verificare se questo parametro funziona
if bIsBeamWall then
BeamExec.GetStrategiesFromJSONinBD()
end
@@ -106,21 +107,21 @@ local function GetDataConfig()
return true
end
local function WriteErrToLogFile( nErr, sMsg, nRot, nCutId, nTaskId)
local function WriteErrToLogFile( nErr, sMsg, nRot, idCut, idTask)
local hFile = io.open( sTxtLogFile, '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:write( 'CUTID=' .. tostring( idCut or 0) .. '\n')
hFile:write( 'TASKID=' .. tostring( idTask or 0) .. '\n')
hFile:close()
end
local function WriteFallToLogFile( nErr, sMsg, nCutId, nFall)
local function WriteFallToLogFile( nErr, sMsg, idCut, nFall)
local hFile = io.open( sTxtLogFile, 'a')
hFile:write( 'ERR=' .. tostring( nErr) .. '\n')
hFile:write( sMsg .. '\n')
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
hFile:write( 'CUTID=' .. tostring( idCut or 0) .. '\n')
hFile:write( 'FALL=' .. tostring( nFall or 0) .. '\n')
hFile:close()
end
@@ -180,7 +181,6 @@ EgtOutLog( sLog)
local sDir, sTitle = EgtSplitPath( BEAM.FILE)
local sOriFile = sDir..sTitle..'.ori.bwe'
local sNgeFile = sDir..sTitle..'.bwe'
local sTxtLogFile = EgtChangePathExtension( BEAM.FILE, '.txt')
-- cancellazione file log txt precedente
-- in caso sia richiesta generazione senza check, verifico prima che il file log specifico non contenga errori: se sì, forzo il check
@@ -503,48 +503,52 @@ if bToProcess then
EgtImportSetup()
-- Lavoro le features
--local bPfOk, Stats = BeamExec.ProcessFeatures()
if not GetDataConfig() then return end
BeamExec.GetProcessings( PARTS)
local bOk, Stats = BeamExec.ProcessMachinings( PARTS)
local sOutput = ''
for i = 1, #Stats do
local sMsg = Stats[i].Msg
for i = 1, #RESULT do
local sMsg = ''
if RESULT[i].sType == 'Feature' then
sMsg = RESULT[i].ChosenStrategy.sInfo
elseif RESULT[i].sType == 'Part' then
sMsg = RESULT[i].sMsg
end
sMsg = string.gsub( sMsg or '', '\n', ' ', 10)
sMsg = string.gsub( sMsg or '', '\r', ' ', 10)
if Stats[i].Err == 0 then
if RESULT[i].sType == 'Feature' and RESULT[i].ChosenStrategy.sStatus == 'Completed' then
BEAM.ERR = 0
BEAM.MSG = '---'
BEAM.ROT = Stats[i].Rot or 0
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
BEAM.ROT = RESULT[i].nRotation or 0
BEAM.CUTID = RESULT[i].idCut
BEAM.TASKID = RESULT[i].idTask
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
elseif Stats[i].Err > 0 then
elseif RESULT[i].sType == 'Feature' and RESULT[i].ChosenStrategy.sStatus == 'Not-Applicable' then
nErrCnt = nErrCnt + 1
sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, sMsg)
sOutput = sOutput .. string.format( '[%d,%d] %s\n', RESULT[i].CutId, RESULT[i].TaskId, sMsg)
BEAM.ERR = 19
BEAM.MSG = sMsg
BEAM.ROT = Stats[i].Rot or 0
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
BEAM.ROT = RESULT[i].nRotation or 0
BEAM.CUTID = RESULT[i].idCut
BEAM.TASKID = RESULT[i].idTask
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
elseif Stats[i].Err < 0 then
-- se segnalazione scarico pezzo standard, incompleto o a caduta
if Stats[i].Err == -100 or Stats[i].Err == -101 or Stats[i].Err == -102 then
else
-- segnalazione scarico pezzo standard, incompleto o a caduta
if RESULT[i].sType == 'Part' and ( RESULT[i].nErr == -100 or RESULT[i].nErr == -101 or RESULT[i].nErr == -102) then
BEAM.ERR = 0
BEAM.MSG = sMsg
BEAM.CUTID = Stats[i].CutId
BEAM.FALL = abs( Stats[i].Err + 100)
BEAM.CUTID = RESULT[i].idCut
BEAM.FALL = abs( RESULT[i].nErr + 100)
WriteFallToLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.FALL)
-- altri avvertimenti
else
-- feature incompleta e altro
elseif RESULT[i].sType == 'Feature' and RESULT[i].ChosenStrategy.sStatus == 'Not-Completed' then
nWarnCnt = nWarnCnt + 1
sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, sMsg)
sOutput = sOutput .. string.format( '[%d,%d] %s\n', RESULT[i].CutId, RESULT[i].TaskId, sMsg)
BEAM.ERR = -19
BEAM.MSG = sMsg
BEAM.ROT = Stats[i].Rot or 0
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
BEAM.MSG = 'Completion : ' .. Proc.nCompletionIndex .. '/5\n' .. sMsg
BEAM.ROT = RESULT[i].nRotation or 0
BEAM.CUTID = RESULT[i].idCut
BEAM.TASKID = RESULT[i].idTask
WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID)
end
end