From 1c8049d9a9641db302aaf92a311f2acdc48c298d Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Wed, 26 Nov 2025 16:47:09 +0100 Subject: [PATCH] - in BatchProcessNew gestito ritorno risultati in caso di errore e ritorno tempi - in BeamExec resa non locale la funzione AddApplyResultToGlobalList --- BatchProcessNew.lua | 59 +++++++++++++++++++++++++++++++++++++++++--- LuaLibs/BeamExec.lua | 6 ++--- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 916d580..5bcbf0b 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -300,6 +300,9 @@ if bToProcess then BEAM.MSG = 'Error opening BWE file : ' .. BEAM.FILE WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end -- Faccio copia del file originale @@ -320,6 +323,9 @@ if bToProcess then BEAM.MSG = 'Error no Raw Parts in the file : ' .. BEAM.FILE WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end local b3Raw = EgtGetRawPartBBox( nRawId) @@ -344,6 +350,9 @@ if bToProcess then BEAM.MSG = 'Error no beams in the file : ' .. BEAM.FILE WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return else local sOut = '' @@ -362,6 +371,9 @@ if bToProcess then BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].sName WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return else PARTS[i].b3PartOriginal = b3Solid @@ -398,6 +410,9 @@ if bToProcess then BEAM.ERR = 14 BEAM.MSG = 'Error : no beams in the project' WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return else local sOut = '' @@ -415,6 +430,9 @@ if bToProcess then BEAM.ERR = 15 BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].sName WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return else PARTS[i].b3PartOriginal = b3Solid @@ -471,6 +489,9 @@ if bToProcess then BEAM.MSG = sOut WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end else @@ -484,6 +505,9 @@ if bToProcess then BEAM.MSG = sOut WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end end @@ -497,6 +521,9 @@ if bToProcess then BEAM.MSG = sOut WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end @@ -515,6 +542,9 @@ if bToProcess then BEAM.MSG = sPbErr WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return else -- Scrivo altezza e larghezza barra nel gruppo di lavoro corrente @@ -623,6 +653,9 @@ if bToProcess then BEAM.ERR = 0 BEAM.MSG = '---' WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) end EgtOutLog( ' +++ BatchProcess completed') return @@ -639,6 +672,7 @@ if bToProcess then EgtImportSetup() -- Lavoro le features + -- TODO gestire errori e messaggi di ritorno in questo caso if not GetDataConfig() then return end -- creo un gruppo temporaneo dove finiranno tutte le entità che non bisogna salvare, alla fine lo si cancella @@ -654,8 +688,6 @@ if bToProcess then local sOutput = '' - -- Scrittura json risultati - WriteResultToJson( RESULT) -- scrittura txt risultati for i = 1, #RESULT do local sMsg = '' @@ -766,7 +798,12 @@ if ( BEAM.FLAG == 0 and ( bToProcess or bToRecalc)) or BEAM.FLAG == 3 or BEAM.F sToolsList = sToolsList .. ", " end end - WriteErrToLogFile( 19, 'Error in setup: tool/s ' .. sToolsList .. ' not found', 0, 0, 0) + BEAM.ERR = 19 + BEAM.MSG = 'Error in setup: tool/s ' .. sToolsList .. ' not found' + WriteErrToLogFile( BEAM.ERR, BEAM.MSG, 0, 0, 0) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end -- lancio simulazione @@ -801,6 +838,10 @@ if ( BEAM.FLAG == 0 and ( bToProcess or bToRecalc)) or BEAM.FLAG == 3 or BEAM.F end end WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) + -- TODO gestire collisione su feature specifica!!!!!!!!!!!!!!!!!!!!!!!!!!!! + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, BEAM.CUTID, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end end @@ -820,6 +861,9 @@ if bIsGenerationEnabled and ( BEAM.FLAG == 0 or BEAM.FLAG == 4) then BEAM.MSG = 'Error generating NC part program : ' .. sName WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end end @@ -832,6 +876,9 @@ if not EgtEstimate( '', 'EgtCAM5 - ' .. sNgeFile) then BEAM.MSG = 'Error estimating production time : ' .. sName WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) + BeamExec.AddApplyResultToGlobalList( BEAM.ERR, 0, BEAM.MSG) + BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) + WriteResultToJson( RESULT) return end local Ttot = EgtGetInfo( EgtGetCurrMachGroup(), 'Ttot', 'd') @@ -854,5 +901,11 @@ end -- Scrittura tempo totale stimato di lavorazione WriteTimeToLogFile( Ttot) +RESULT[#RESULT+1] = { dTime = Ttot, sType = 'Time'} + +-- Riporto risultati in tabella globale BEAM +BEAM.RESULT = BeamLib.TableCopyDeep( RESULT) +-- Scrittura json risultati +WriteResultToJson( RESULT) EgtOutLog( ' +++ BatchProcess completed') diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index bd24d0a..31d2d72 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1109,7 +1109,7 @@ local function AddFeatureResultToGlobalList( Proc, OptionalParameters) end ------------------------------------------------------------------------------------------------------------- -local function AddApplyResultToGlobalList( nErr, idCut, sMsg) +function BeamExec.AddApplyResultToGlobalList( nErr, idCut, sMsg) RESULT[#RESULT+1] = { sType = 'Part', idCut = idCut, @@ -1828,7 +1828,7 @@ function BeamExec.ProcessMachinings( PARTS) -- TODO in caso di lavorazioni di coda saltate, l'informazione va restituita anche sulle singole feature if not bApplOk then nTotErr = nTotErr + 1 - AddApplyResultToGlobalList( 1, 0, sApplErrors) + BeamExec.AddApplyResultToGlobalList( 1, 0, sApplErrors) elseif sApplWarns and #sApplWarns > 0 then local vLine = EgtSplitString( sApplWarns, '\r\n') for i = 1, #vLine do @@ -1839,7 +1839,7 @@ function BeamExec.ProcessMachinings( PARTS) local nWarn = EgtGetVal( vVal[1] or '', 'WRN', 'i') local nCutId = EgtGetVal( vVal[2] or '', 'CUTID', 'i') if nWarn and nCutId then - AddApplyResultToGlobalList( -nWarn, nCutId, vLine[i]) + BeamExec.AddApplyResultToGlobalList( -nWarn, nCutId, vLine[i]) end end end