From e2164dfc5784f4141b98e098c52e6efba22d5bc1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 16 Nov 2020 12:10:07 +0000 Subject: [PATCH] EgtMachKernel 2.2k4 : - aggiunta gestione stringa di errore o avvertimento da PostApply delle lavorazioni e da SpecialApply delle disposizioni. --- Chiseling.cpp | 8 ++++++-- Disposition.cpp | 28 +++++++++++++++++----------- Drilling.cpp | 8 ++++++-- EgtMachKernel.rc | Bin 11782 -> 11782 bytes GenMachining.cpp | 8 ++++++-- Machining.cpp | 26 ++++++++++++++++++-------- Machining.h | 2 +- Milling.cpp | 8 ++++++-- Mortising.cpp | 8 ++++++-- Pocketing.cpp | 8 ++++++-- SawFinishing.cpp | 8 ++++++-- SawRoughing.cpp | 8 ++++++-- Sawing.cpp | 8 ++++++-- SurfFinishing.cpp | 8 ++++++-- WaterJetting.cpp | 8 ++++++-- 15 files changed, 102 insertions(+), 42 deletions(-) diff --git a/Chiseling.cpp b/Chiseling.cpp index fcdd73e..a004756 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -621,8 +621,12 @@ Chiseling::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2912, "Error in Chiseling : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2912, sErr) ; + else + m_pMchMgr->SetLastError( 2912, "Error in Chiseling : post apply not calculable") ; return false ; } diff --git a/Disposition.cpp b/Disposition.cpp index a86eeaf..4bc010d 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -1315,15 +1315,16 @@ Disposition::SpecialApply( bool bRecalc) // costanti static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo - static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina - static const string EVAR_DISPID = ".DISPID" ; // IN (int) identificativo della disposizione - static const string EVAR_PHASE = ".PHASE" ; // IN (int) indice fase - static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok, > 0 errore, < 0 warning) + static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina + static const string EVAR_DISPID = ".DISPID" ; // IN (int) identificativo della disposizione + static const string EVAR_PHASE = ".PHASE" ; // IN (int) indice fase + static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok, > 0 errore, < 0 warning) + static const string EVAR_MSG = ".MSG" ; // OUT (string) stringa di errore o warning ( opzionale) static const string EVAR_HEAD = ".HEAD" ; // OUT (string) nome della testa - static const string EVAR_EXIT = ".EXIT" ; // OUT (int) indice dell'uscita + static const string EVAR_EXIT = ".EXIT" ; // OUT (int) indice dell'uscita static const string EVAR_TCPOS = ".TCPOS" ; // OUT (string) nome della posizione nel TC - static const string EVAR_SHIFTS = ".SHIFTS" ; // OUT (int) numero di movimenti eseguiti - static const string EVAR_SBH = ".SBH" ; // OUT (bool) flag presenza operazioni manuali + static const string EVAR_SHIFTS = ".SHIFTS" ; // OUT (int) numero di movimenti eseguiti + static const string EVAR_SBH = ".SBH" ; // OUT (bool) flag presenza operazioni manuali // eseguo l'azione bool bOk = true ; @@ -1344,20 +1345,25 @@ Disposition::SpecialApply( bool bRecalc) bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SHIFTS, m_nShifts) ; bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SBH, m_bSomeByHand) ; // recupero valori parametri opzionali - if ( bOk) - pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos) ; + bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos) ; + string sMsg ; + bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_MSG, sMsg) ; // reset bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ; // segnalo errori ed esco if ( ! bOk || nErr > 0) { m_nShifts = - 1 ; - string sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; + string sOut = sMsg ; + if ( IsEmptyOrSpaces( sOut)) + sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; m_pMchMgr->SetLastError( 2006, sOut) ; return false ; } // recupero eventuale warning else if ( nErr < 0) { - string sOut = " Warning in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; + string sOut = sMsg ; + if ( IsEmptyOrSpaces( sOut)) + sOut = " Warning in " + ON_SPECIAL_APPLY + " (" + ToString( abs( nErr)) + ")" ; m_pMchMgr->SetWarning( 2053, sOut) ; } diff --git a/Drilling.cpp b/Drilling.cpp index dceeeea..95065d4 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -640,8 +640,12 @@ Drilling::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2113, "Error in Drilling : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2113, sErr) ; + else + m_pMchMgr->SetLastError( 2113, "Error in Drilling : post apply not calculable") ; return false ; } diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 1ebc4139b14809b93d92a2a8469ddbdacb120828..eea7eeaedf9ff2af1e2745f5eaf8509ccea77480 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFx>^ItYwW=50Aj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQ1Kv2 delta 97 zcmZpRX^YwLhmFyA^ItYwW=7-5j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHPhB8F diff --git a/GenMachining.cpp b/GenMachining.cpp index 14ce169..f9af0c0 100644 --- a/GenMachining.cpp +++ b/GenMachining.cpp @@ -665,8 +665,12 @@ GenMachining::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2808, "Error in GenMachining : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2808, sErr) ; + else + m_pMchMgr->SetLastError( 2808, "Error in GenMachining : post apply not calculable") ; return false ; } diff --git a/Machining.cpp b/Machining.cpp index 0e064fc..1b55645 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -305,7 +305,7 @@ Machining::ToolPreview( int nEntId, int nFlag) const //---------------------------------------------------------------------------- bool -Machining::PostApply( void) +Machining::PostApply( string& sErr) { // recupero la macchina corrente Machine* pMch = m_pMchMgr->GetCurrMachine() ; @@ -313,9 +313,10 @@ Machining::PostApply( void) return false ; // costanti static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo - static const string EVAR_PHASE = ".PHASE" ; // IN (int) indice fase - static const string EVAR_MCHID = ".MCHID" ; // IN (int) identificativo della lavorazione - static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok) + static const string EVAR_PHASE = ".PHASE" ; // IN (int) indice fase + static const string EVAR_MCHID = ".MCHID" ; // IN (int) identificativo della lavorazione + static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok, > 0 errore, < 0 warning) + static const string EVAR_MSG = ".MSG" ; // OUT (string) stringa di errore ( opzionale) static const string ON_POST_APPLY = "OnPostApplyMachining" ; // eseguo l'azione @@ -331,14 +332,23 @@ Machining::PostApply( void) // recupero valori parametri obbligatori bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ; // recupero valori parametri opzionali - // ... + string sMsg ; + bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_MSG, sMsg) ; // reset bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ; // segnalo errori - if ( nErr != 0) { + if ( ! bOk || nErr > 0) { bOk = false ; - string sOut = " Error in " + ON_POST_APPLY + " (" + ToString( nErr) + ")" ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) + sErr = sMsg ; + if ( IsEmptyOrSpaces( sErr)) + sErr = " Error in " + ON_POST_APPLY + " (" + ToString( nErr) + ")" ; + } + // recupero eventuale warning + else if ( nErr < 0) { + string sOut = sMsg ; + if ( IsEmptyOrSpaces( sOut)) + sOut = " Warning in " + ON_POST_APPLY + " (" + ToString( abs( nErr)) + ")" ; + m_pMchMgr->SetWarning( abs( nErr), sOut) ; } return bOk ; } diff --git a/Machining.h b/Machining.h index 76a1641..1401b03 100644 --- a/Machining.h +++ b/Machining.h @@ -53,7 +53,7 @@ class Machining : public Operation protected : Machining( void) ; - bool PostApply( void) ; + bool PostApply( std::string& sErr) ; } ; //---------------------------------------------------------------------------- diff --git a/Milling.cpp b/Milling.cpp index 5718590..7815d28 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -835,8 +835,12 @@ Milling::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2321, "Error in Milling : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2321, sErr) ; + else + m_pMchMgr->SetLastError( 2321, "Error in Milling : post apply not calculable") ; return false ; } diff --git a/Mortising.cpp b/Mortising.cpp index 7f29e24..58dcaa8 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -641,8 +641,12 @@ Mortising::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2511, "Error in Mortising : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2511, sErr) ; + else + m_pMchMgr->SetLastError( 2511, "Error in Mortising : post apply not calculable") ; return false ; } diff --git a/Pocketing.cpp b/Pocketing.cpp index d164279..9494478 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -720,8 +720,12 @@ Pocketing::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2427, "Error in Pocketing : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2427, sErr) ; + else + m_pMchMgr->SetLastError( 2427, "Error in Pocketing : post apply not calculable") ; return false ; } diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 3da6133..729fbc7 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -633,8 +633,12 @@ SawFinishing::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2715, "Error in SawFinishing : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2715, sErr) ; + else + m_pMchMgr->SetLastError( 2715, "Error in SawFinishing : post apply not calculable") ; return false ; } diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 9f431f2..c1d128c 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -597,8 +597,12 @@ SawRoughing::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2615, "Error in SawRoughing : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2615, sErr) ; + else + m_pMchMgr->SetLastError( 2615, "Error in SawRoughing : post apply not calculable") ; return false ; } diff --git a/Sawing.cpp b/Sawing.cpp index 63aab02..1cb0685 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -771,8 +771,12 @@ Sawing::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 2219, "Error in Sawing : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 2219, sErr) ; + else + m_pMchMgr->SetLastError( 2219, "Error in Sawing : post apply not calculable") ; return false ; } diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index 129f921..bc9e6ea 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -626,8 +626,12 @@ SurfFinishing::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 3120, "Error in SurfFinishing : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 3120, sErr) ; + else + m_pMchMgr->SetLastError( 3120, "Error in SurfFinishing : post apply not calculable") ; return false ; } diff --git a/WaterJetting.cpp b/WaterJetting.cpp index d8cadaf..e5b2c81 100644 --- a/WaterJetting.cpp +++ b/WaterJetting.cpp @@ -757,8 +757,12 @@ WaterJetting::Update( bool bPostApply) } // esecuzione eventuali personalizzazioni - if ( bPostApply && ! PostApply()) { - m_pMchMgr->SetLastError( 3218, "Error in WaterJetting : post apply not calculable") ; + string sErr ; + if ( bPostApply && ! PostApply( sErr)) { + if ( ! IsEmptyOrSpaces( sErr)) + m_pMchMgr->SetLastError( 3218, sErr) ; + else + m_pMchMgr->SetLastError( 3218, "Error in WaterJetting : post apply not calculable") ; return false ; }