From e1b4089bfc4a687a206f41c2dc818842a784a4ec Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 20 May 2025 11:57:07 +0200 Subject: [PATCH] - in BatchProcessNew si scrive Json risultati --- BatchProcessNew.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 09a263d..78d9bd1 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -3,7 +3,7 @@ -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() -EgtEnableDebug( true) +EgtEnableDebug( false) -- Imposto direttorio libreria specializzata per Travi EgtAddToPackagePath( BEAM.BASEDIR .. '\\LuaLibs\\?.lua') @@ -91,6 +91,7 @@ local BeamData = require( 'BeamData') local BeamExec = require( 'BeamExec') local BeamLib = require( 'BeamLib') local FeatureLib = require( 'FeatureLib') +local JSON = require( 'JSON') -- Variabili di modulo local dRawW @@ -161,6 +162,24 @@ local function ResetMachGroup( PARTS) EgtRemoveMachGroup( EgtGetCurrMachGroup() or GDB_ID.NULL) end +-- scrittura JSON risultati +-- TODO da migliorare/completare +local function WriteResultToJson( RESULT) + local sData = JSON:encode_pretty( RESULT) + + -- Salvataggio e visualizzazione tabella + local sOutFile = EgtChangePathExtension( BEAM.FILE, '.json') + local DestFh = io.open( sOutFile, 'w+') + if not DestFh then + EgtOutBox( 'Error opening ' .. sOutFile, 'TestJson', 'ERROR') + return false + end + DestFh:write( sData) + DestFh:close() + + return true +end + ------------------------------------------------------------------------------------------------------------- local sFlag = '' if BEAM.FLAG == 0 then @@ -599,6 +618,10 @@ if bToProcess then BeamExec.GetProcessings( PARTS) BeamExec.ProcessMachinings( PARTS) local sOutput = '' + + -- Scrittura json risultati + WriteResultToJson( RESULT) + -- scrittura txt risultati for i = 1, #RESULT do local sMsg = '' if RESULT[i].sType == 'Feature' then