- modificate BatchProcessNew e BeamExec per contemplare nuova tabella RESULTS
This commit is contained in:
+36
-32
@@ -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
|
||||
|
||||
+42
-14
@@ -1018,6 +1018,42 @@ local function OrderFeatures( vProc)
|
||||
return vProcToSort
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- TODO gestire Proc che non hanno una ChosenStrategy, perchè sono specchiate, multi (si legge il risultato da un'altra feature?) o non è stata trovata una strategia
|
||||
local function AddFeatureResultToGlobalList( Proc, nRotation)
|
||||
RESULT[#RESULT+1] = {
|
||||
sType = 'Feature',
|
||||
id = Proc.id,
|
||||
idFeature = Proc.idFeature,
|
||||
idTask = Proc.idTask,
|
||||
idCut = Proc.idCut,
|
||||
nFlg = Proc.nFlg,
|
||||
nRotation = nRotation,
|
||||
idPart = Proc.idPart,
|
||||
ChosenStrategy = {
|
||||
sStrategyName = Proc.ChosenStrategy.sStrategyId,
|
||||
sStatus = Proc.ChosenStrategy.Result.sStatus,
|
||||
nCompletionIndex = Proc.ChosenStrategy.Result.nCompletionIndex,
|
||||
dCompositeRating = Proc.ChosenStrategy.Result.dCompositeRating,
|
||||
sInfo = Proc.ChosenStrategy.Result.sInfo
|
||||
},
|
||||
AvailableStrategies = BeamLib.TableCopyDeep( Proc.AvailableStrategies)
|
||||
}
|
||||
|
||||
return RESULT
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function AddApplyResultToGlobalList( nErr, idCut, sMsg)
|
||||
RESULT[#RESULT+1] = {
|
||||
sType = 'Part',
|
||||
idCut = idCut,
|
||||
idTask = 0,
|
||||
nErr = nErr,
|
||||
sMsg = sMsg
|
||||
}
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- esegue le strategie migliori che ha precedentemente scelto
|
||||
local function CalculateMachinings( vProc, Part, nInitialRotation)
|
||||
@@ -1055,18 +1091,6 @@ local function CalculateMachinings( vProc, Part, nInitialRotation)
|
||||
local StrategyScript = require( StrategyScriptName)
|
||||
-- eseguo la strategia e si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati
|
||||
_, _ = StrategyScript.Make( true, Proc, Part, Proc.ChosenStrategy)
|
||||
-- scrivo risultato in tabella globale
|
||||
-- TODO funzione
|
||||
RESULT[#RESULT+1] = {
|
||||
id = Proc.id,
|
||||
idFeature = Proc.idFeature,
|
||||
idTask = Proc.idTask,
|
||||
idCut = Proc.idCut,
|
||||
nFlag = Proc.nFlg,
|
||||
nRotation = nCurrRotation,
|
||||
ChosenStrategy = BeamLib.TableCopyDeep( Proc.ChosenStrategy),
|
||||
AvailableStrategies = BeamLib.TableCopyDeep( Proc.AvailableStrategies)
|
||||
}
|
||||
else
|
||||
-- se non esiste una strategia scelta (non dovrebbe mai succedere) cancello da lista generale
|
||||
PROCESSINGS[Proc.nIndexPartInParts].Rotation[Proc.nIndexRotation][Proc.nIndexInVProc].ChosenStrategy = nil
|
||||
@@ -1078,6 +1102,8 @@ local function CalculateMachinings( vProc, Part, nInitialRotation)
|
||||
bAreAllApplyOk = false
|
||||
end
|
||||
end
|
||||
-- scrivo risultato in tabella globale
|
||||
AddFeatureResultToGlobalList( Proc, nCurrRotation)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1621,9 +1647,11 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
bApplOk, sApplErrors, _ = EgtApplyAllMachinings()
|
||||
EgtRemoveInfo( EgtGetCurrMachGroup(), 'RECALC')
|
||||
end
|
||||
-- TODO qui restituire errori in modo migliore, come per feature
|
||||
-- TODO in caso di lavorazioni di coda saltate, l'informazione va restituita anche sulle singole feature
|
||||
if not bApplOk then
|
||||
nTotErr = nTotErr + 1
|
||||
table.insert( Stats, {nErr = 1, sMsg=sApplErrors, nRot=0, idCut=0, idTask=0})
|
||||
AddApplyResultToGlobalList( 1, 0, sApplErrors)
|
||||
elseif sApplWarns and #sApplWarns > 0 then
|
||||
local vLine = EgtSplitString( sApplWarns, '\r\n')
|
||||
for i = 1, #vLine do
|
||||
@@ -1634,7 +1662,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
|
||||
table.insert( Stats, { nErr=-nWarn, sMsg=vLine[i], nRot=0, idCut=nCutId, idTask=0})
|
||||
AddApplyResultToGlobalList( -nWarn, nCutId, vLine[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- DiceCut.lua by Egaltech s.r.l. 2024/01/23
|
||||
-- DiceCut.lua by Egalware s.r.l. 2024/01/23
|
||||
-- Gestione dei piano paralleli nei tagli lunghi: equidistanziamento dei piani paralleli
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
|
||||
Reference in New Issue
Block a user