- in BatchProcessNew varie modifiche per renderla compatibile con nuovo automatismo; manca restituzione risultati
- in BeamExec prima versione della tabella globale RESULT per la restituzione risultati
This commit is contained in:
+102
-44
@@ -3,24 +3,109 @@
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( false)
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-- Imposto direttorio libreria specializzata per Travi
|
||||
EgtAddToPackagePath( BEAM.BASEDIR .. '\\LuaLibs\\?.lua')
|
||||
-- Imposto direttorio strategie. N.B. Le strategie dovranno essere caricate con il nome del direttorio padre
|
||||
EgtAddToPackagePath( BEAM.BASEDIR .. '\\Strategies\\Standard\\?.lua')
|
||||
EgtAddToPackagePath( BEAM.BASEDIR .. '\\StrategyLibs\\?.lua')
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi
|
||||
local sMachine = BEAM.MACHINE
|
||||
if BEAM.FLAG ~= 6 then
|
||||
EgtResetCurrMachGroup()
|
||||
if not EgtSetCurrMachine( sMachine) then
|
||||
BEAM.ERR = 11
|
||||
BEAM.MSG = 'Error selecting machine : ' .. sMachine
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
end
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
if not sMachDir then
|
||||
EgtOutBox( 'Errore nel caricamento della macchina corrente', 'Lavora Travi', 'ERROR')
|
||||
return
|
||||
end
|
||||
if not EgtExistsFile( sMachDir .. '\\Beam\\BeamData.lua') then
|
||||
EgtOutBox( 'La macchina corrente non è configurata per lavorare travi', 'Lavora Travi', 'ERROR')
|
||||
BEAM.ERR = 12
|
||||
BEAM.MSG = 'Error not configured for beams machine : ' .. sMachine
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
|
||||
-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie
|
||||
EgtRemoveBaseMachineDirFromPackagePath()
|
||||
EgtAddToPackagePath( sMachDir .. '\\Beam\\?.lua')
|
||||
-- Imposto direttorio libreria specializzata per Travi
|
||||
EgtAddToPackagePath( BEAM.BASEDIR .. '\\LuaLibs\\?.lua')
|
||||
|
||||
-- Segnalazione avvio
|
||||
EgtOutLog( '*** Beam Process Start ***', 1)
|
||||
|
||||
-- Carico le librerie
|
||||
_G.package.loaded.BeamExec = nil
|
||||
local BeamExec = require( 'BeamExec')
|
||||
local BeamLib = require( 'BeamLib')
|
||||
_G.package.loaded.BeamLib = nil
|
||||
_G.package.loaded.BeamData = nil
|
||||
_G.package.loaded.Identity = nil
|
||||
_G.package.loaded.BasicCustomerStrategies = nil
|
||||
_G.package.loaded.FeatureLib = nil
|
||||
_G.package.loaded.FaceData = nil
|
||||
_G.package.loaded.MachiningLib = nil
|
||||
_G.package.loaded.DiceCut = nil
|
||||
_G.package.loaded.Logs = nil
|
||||
-- strategie di base sempre presenti
|
||||
_G.package.loaded['HEADCUT\\HEADCUT'] = nil
|
||||
_G.package.loaded['TAILCUT\\TAILCUT'] = nil
|
||||
|
||||
-- TODO controllare se c'è un modo migliore per resettare librerie delle strategie caricate precedentemente
|
||||
-- Per ottimizzare potremmo anche ciclare solo fino al numero di strategie raggiunto per il momento.
|
||||
-- Infatti difficile ci siano 9999 strategie.
|
||||
-- reset strategie caricate come librerie
|
||||
for i = 1, 9999 do
|
||||
local IdSTRTemp = EgtReplaceString( tostring( i/10000, 4), '0.', '')
|
||||
local sLibraryToReload = "STR" .. IdSTRTemp .. "\\STR" .. IdSTRTemp
|
||||
if _G.package.loaded[sLibraryToReload] then
|
||||
_G.package.loaded[sLibraryToReload] = nil
|
||||
end
|
||||
end
|
||||
local vtCoreStrategiesNames = EgtFindAllFiles( BEAM.BASEDIR .. '\\StrategyLibs\\*.lua')
|
||||
for i = 1, #vtCoreStrategiesNames do
|
||||
local sCurrentName = EgtSplitString( vtCoreStrategiesNames[i], '.')[1]
|
||||
if _G.package.loaded[sCurrentName] then
|
||||
_G.package.loaded[sCurrentName] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Variabili globali
|
||||
PARTS = {} -- tabella contenente tutte le informazioni di ogni pezzo
|
||||
|
||||
-- Carico i dati globali
|
||||
local BeamData = require( 'BeamData')
|
||||
-- carico librerie
|
||||
local BeamExec = require( 'BeamExec')
|
||||
|
||||
-- Variabili di modulo
|
||||
local dRawW
|
||||
local dRawH
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- Funzioni per scrittura su file di log specifico
|
||||
-- Funzioni di supporto
|
||||
|
||||
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
|
||||
if bIsBeamWall then
|
||||
BeamExec.GetStrategiesFromJSONinBD()
|
||||
end
|
||||
-- TODO da gestire eventuali errori bloccanti
|
||||
return true
|
||||
end
|
||||
|
||||
local function WriteErrToLogFile( nErr, sMsg, nRot, nCutId, nTaskId)
|
||||
local hFile = io.open( sTxtLogFile, 'a')
|
||||
hFile:write( 'ERR=' .. tostring( nErr) .. '\n')
|
||||
@@ -66,7 +151,7 @@ end
|
||||
-- Funzione di reset gruppo di lavoro in caso di impossibilità di inserire i pezzi
|
||||
local function ResetMachGroup( PARTS)
|
||||
for i = 1, #PARTS do
|
||||
EgtErase( PARTS[i].Id)
|
||||
EgtErase( PARTS[i].id)
|
||||
end
|
||||
EgtRemoveMachGroup( EgtGetCurrMachGroup() or GDB_ID.NULL)
|
||||
end
|
||||
@@ -115,31 +200,6 @@ end
|
||||
-- Cancello file di log specifico
|
||||
EgtEraseFile( sTxtLogFile)
|
||||
|
||||
-- impostazione della macchina corrente
|
||||
local sMachine = BEAM.MACHINE
|
||||
|
||||
if BEAM.FLAG ~= 6 then
|
||||
EgtResetCurrMachGroup()
|
||||
if not EgtSetCurrMachine( sMachine) then
|
||||
BEAM.ERR = 11
|
||||
BEAM.MSG = 'Error selecting machine : ' .. sMachine
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
|
||||
if not EgtExistsFile( sMachDir .. '\\Beam\\BeamData.lua') then
|
||||
BEAM.ERR = 12
|
||||
BEAM.MSG = 'Error not configured for beams machine : ' .. sMachine
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
end
|
||||
|
||||
-- In generale va completamente riprocessato
|
||||
local bToProcess = true
|
||||
local bToRecalc = false
|
||||
@@ -167,7 +227,6 @@ if bToProcess then
|
||||
local bCreateBar
|
||||
-- Lunghezza della barra ed elenco travi
|
||||
local dBarLen
|
||||
local PARTS = {}
|
||||
|
||||
-- Se necessario, apro il file Bwe
|
||||
if BEAM.FLAG ~= 6 then
|
||||
@@ -212,7 +271,7 @@ if bToProcess then
|
||||
-- Recupero l'elenco ordinato delle travi
|
||||
local nPartId = EgtGetFirstPart()
|
||||
while nPartId do
|
||||
table.insert( PARTS, { Id = nPartId, Name = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
|
||||
table.insert( PARTS, { id = nPartId, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
|
||||
nPartId = EgtGetNextPart( nPartId)
|
||||
end
|
||||
if #PARTS == 0 then
|
||||
@@ -224,18 +283,18 @@ if bToProcess then
|
||||
else
|
||||
local sOut = ''
|
||||
for i = 1, #PARTS do
|
||||
sOut = sOut .. PARTS[i].Name .. ', '
|
||||
sOut = sOut .. PARTS[i].sName .. ', '
|
||||
end
|
||||
sOut = sOut:sub( 1, -3)
|
||||
EgtOutLog( 'Travi trovate : ' .. sOut, 1)
|
||||
end
|
||||
-- Ne recupero le dimensioni
|
||||
for i = 1, #PARTS do
|
||||
local Ls = EgtGetFirstNameInGroup( PARTS[i].Id, 'Box')
|
||||
local Ls = EgtGetFirstNameInGroup( PARTS[i].id, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
BEAM.ERR = 15
|
||||
BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].Name
|
||||
BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].sName
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
PostErrView( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
@@ -268,7 +327,7 @@ if bToProcess then
|
||||
if not vVal or #vVal < 2 then break end
|
||||
local nPartId = tonumber( vVal[1])
|
||||
local dPosX = tonumber( vVal[2])
|
||||
table.insert( PARTS, { Id = nPartId, PosX = dPosX, Name = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
|
||||
table.insert( PARTS, { id = nPartId, dPosX = dPosX, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
|
||||
end
|
||||
if #PARTS == 0 then
|
||||
BEAM.ERR = 14
|
||||
@@ -278,18 +337,18 @@ if bToProcess then
|
||||
else
|
||||
local sOut = ''
|
||||
for i = 1, #PARTS do
|
||||
sOut = sOut .. PARTS[i].Name .. ', '
|
||||
sOut = sOut .. PARTS[i].sName .. ', '
|
||||
end
|
||||
sOut = sOut:sub( 1, -3)
|
||||
EgtOutLog( 'Travi trovate : ' .. sOut, 1)
|
||||
end
|
||||
-- Ne recupero le dimensioni
|
||||
for i = 1, #PARTS do
|
||||
local Ls = EgtGetFirstNameInGroup( PARTS[i].Id, 'Box')
|
||||
local Ls = EgtGetFirstNameInGroup( PARTS[i].id, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
BEAM.ERR = 15
|
||||
BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].Name
|
||||
BEAM.MSG = 'Box undefined for beam ' .. PARTS[i].sName
|
||||
WriteErrToLogFile( BEAM.ERR, BEAM.MSG)
|
||||
return
|
||||
else
|
||||
@@ -300,8 +359,6 @@ if bToProcess then
|
||||
|
||||
-- Se devo creare la barra
|
||||
if bCreateBar then
|
||||
local dRawW
|
||||
local dRawH
|
||||
if #PARTS == 0 then
|
||||
-- Recupero l'identificativo del gruppo di lavoro corrente
|
||||
local nMGrpId = EgtGetCurrMachGroup()
|
||||
@@ -325,7 +382,7 @@ if bToProcess then
|
||||
if #vBeamErr > 0 then
|
||||
local sOut = 'Rimosse travi con sezioni diverse dalla prima :\n'
|
||||
for i = #vBeamErr, 1, -1 do
|
||||
sOut = sOut .. PARTS[vBeamErr[i]].Name .. '\n'
|
||||
sOut = sOut .. PARTS[vBeamErr[i]].sName .. '\n'
|
||||
table.remove( PARTS, vBeamErr[i])
|
||||
end
|
||||
ResetMachGroup( PARTS)
|
||||
@@ -447,6 +504,7 @@ if bToProcess then
|
||||
|
||||
-- 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 = ''
|
||||
|
||||
Reference in New Issue
Block a user