EgtMachkernel :

- aggiunta gestione OnSpecialApplyMachining appena prima del calcolo dei collegamenti tra lavorazioni.
This commit is contained in:
Dario Sassi
2026-01-21 09:46:38 +01:00
parent 2bd9b292fd
commit 4ab7788d6d
17 changed files with 327 additions and 109 deletions
+53
View File
@@ -552,6 +552,59 @@ Machining::ActivateDrillingUnit( int nHeadId, const INTVECTOR& vActExit) const
return ( bOk && nErr == 0) ;
}
//----------------------------------------------------------------------------
bool
Machining::SpecialApply( string& sErr)
{
// recupero la macchina corrente
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
if ( pMch == nullptr)
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, > 0 errore, < 0 warning)
static const string EVAR_MSG = ".MSG" ; // OUT (string) stringa di errore ( opzionale)
static const string ON_SPECIAL_APPLY = "OnSpecialApplyMachining" ;
// se non esiste la funzione, esco
if ( ! pMch->LuaExistsFunction( ON_SPECIAL_APPLY))
return true ;
// eseguo l'azione
bool bOk = true ;
int nErr = 99 ;
// imposto valori parametri
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_PHASE, m_nPhase) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_MCHID, m_nOwnerId) ;
// eseguo
bOk = bOk && pMch->LuaCallFunction( ON_SPECIAL_APPLY, false) ;
// 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 ( ! bOk || nErr > 0) {
bOk = false ;
sErr = sMsg ;
if ( IsEmptyOrSpaces( sErr))
sErr = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ;
}
// recupero eventuale warning
else if ( nErr < 0) {
string sOut = sMsg ;
if ( IsEmptyOrSpaces( sOut))
sOut = " Warning in " + ON_SPECIAL_APPLY + " (" + ToString( abs( nErr)) + ")" ;
m_pMchMgr->SetWarning( abs( nErr), sOut) ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machining::PostApply( string& sErr)