diff --git a/BatchProcess.lua b/BatchProcess.lua index 386c191..66271c8 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2021/02/22 +-- BatchProcess.lua by Egaltech s.r.l. 2021/02/25 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. @@ -19,6 +19,7 @@ -- 2021/02/04 Se necessario ricalcolo allora si aggiorna anche l'attrezzaggio. -- 2021/02/14 Modifica per macchine senza BD.MAX_WIDTH2 e BD.MAX_HEIGHT2. -- 2021/02/22 Aggiunto anche controllo su file macchina mlde per aggiornare calcoli. +-- 2021/02/25 Aggiunta gestione tipo scarico (standard, lav. incomplete, a caduta). -- Intestazioni require( 'EgtBase') @@ -67,6 +68,14 @@ local function WriteErrToLogFile( nErr, sMsg, nRot, nCutId, nTaskId) hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n') hFile:close() end +local function WriteFallToLogFile( nErr, sMsg, nCutId, nFall) + local hFile = io.open( sLogFile, 'a') + hFile:write( 'ERR=' .. tostring( nErr) .. '\n') + hFile:write( sMsg .. '\n') + hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n') + hFile:write( 'FALL=' .. tostring( nFall or 0) .. '\n') + hFile:close() +end local function WriteTimeToLogFile( dTime) local hFile = io.open( sLogFile, 'a') hFile:write( 'TIME=' .. EgtNumToString( dTime) .. '\n') @@ -380,14 +389,24 @@ if bToProcess then BEAM.TASKID = Stats[i].TaskId WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) elseif Stats[i].Err < 0 then - nWarnCnt = nWarnCnt + 1 - sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[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 - WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) + -- 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 + BEAM.ERR = 0 + BEAM.MSG = sMsg + BEAM.CUTID = Stats[i].CutId + BEAM.FALL = abs( Stats[i].Err + 100) + WriteFallToLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.FALL) + -- altri avvertimenti + else + nWarnCnt = nWarnCnt + 1 + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[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 + WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) + end end end diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 4a5ef2c..e5a8baa 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2021/01/21 +-- BeamExec.lua by Egaltech s.r.l. 2021/02/25 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -20,6 +20,7 @@ -- 2020/10/15 Per foro sdoppiato ricalcolo anche flag Head oltre a Tail . -- 2020/10/23 Corretto spostamento foro per tenone quando tenone nullo. -- 2020/12/29 Aggiunta gestione fori in doppio. +-- 2021/02/25 Aggiunta gestione eventuale ricalcolo per macchine tipo PF. -- Tabella per definizione modulo local BeamExec = {} @@ -1232,10 +1233,30 @@ function BeamExec.ProcessFeatures() -- Aggiornamento finale di tutto EgtSetCurrPhase( 1) - local bApplOk, sApplErrors = EgtApplyAllMachinings() + local bApplOk, sApplErrors, sApplWarns = EgtApplyAllMachinings() + -- eventuale ricalcolo per macchine tipo PF (ma tengo warning del primo calcolo) + if EgtExistsInfo( EgtGetCurrMachGroup(), 'RECALC') then + EgtOutLog( ' **** RECALC ****') + bApplOk, sApplErrors, _ = EgtApplyAllMachinings() + EgtRemoveInfo( EgtGetCurrMachGroup(), 'RECALC') + end if not bApplOk then nTotErr = nTotErr + 1 table.insert( Stats, {Err = 1, Msg=sApplErrors, Rot=0, CutId=0, TaskId=0}) + elseif sApplWarns and #sApplWarns > 0 then + local vLine = EgtSplitString( sApplWarns, '\r\n') + for i = 1, #vLine do + local nPos = vLine[i]:find( '(WRN', 1, true) + if nPos then + local sData = vLine[i]:sub( nPos + 1, -2) + local vVal = EgtSplitString( sData, ',') + local nWarn = EgtGetVal( vVal[1] or '', 'WRN', 'i') + local nCutId = EgtGetVal( vVal[2] or '', 'CUTID', 'i') + if nWarn and nCutId then + table.insert( Stats, { Err=-nWarn, Msg=vLine[i], Rot=0, CutId=nCutId, TaskId=0}) + end + end + end end return ( nTotErr == 0), Stats diff --git a/Process.lua b/Process.lua index 809027a..b588058 100644 --- a/Process.lua +++ b/Process.lua @@ -1,4 +1,4 @@ --- Process.lua by Egaltech s.r.l. 2020/10/25 +-- Process.lua by Egaltech s.r.l. 2021/02/25 -- Gestione calcolo disposizione e lavorazioni per Travi -- Si opera sulla macchina corrente -- 2020/01/08 Aggiunta seconda sezione limite (BD.MAX_WIDTH2 x BD.MAX_HEIGHT2). @@ -240,8 +240,13 @@ local function MyProcessFeatures() nErrCnt = nErrCnt + 1 sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) elseif Stats[i].Err < 0 then - nWarnCnt = nWarnCnt + 1 - sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) + -- se segnalazione scarico pezzo standard, incompleto o a caduta + if Stats[i].Err == -101 or Stats[i].Err == -102 or Stats[i].Err == -103 then + -- non faccio niente + else + nWarnCnt = nWarnCnt + 1 + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) + end end end if #sOutput > 0 then EgtOutLog( sOutput) end