EgtMachKernel 2.2d3 :

- modifiche per consentire richiami incrociati tra funzioni lua di macchina senza distruggere riferimento a macchina e variabili globali.
This commit is contained in:
Dario Sassi
2020-04-19 16:30:05 +00:00
parent c80825110d
commit c841813162
6 changed files with 110 additions and 39 deletions
+34 -18
View File
@@ -28,27 +28,28 @@
using namespace std ;
//----------------------------------------------------------------------------
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_TABNAME = ".TABNAME" ; // (string) nome della tavola macchina
static const string EVAR_HEAD = ".HEAD" ; // (string) nome della testa
static const string EVAR_EXIT = ".EXIT" ; // (int) numero dell'uscita
static const string EVAR_TOOL = ".TOOL" ; // (string) nome dell'utensile
static const string EVAR_TOTDIAM = ".TOTDIAM" ; // (num) diametro di ingombro dell'utensile
static const string EVAR_TOTLEN = ".TOTLEN" ; // (num) lunghezza di ingombro dell'utensile
static const string EVAR_L1 = ".L1" ; // (num) valore del primo asse lineare
static const string EVAR_L2 = ".L2" ; // (num) valore del secondo asse lineare
static const string EVAR_L3 = ".L3" ; // (num) valore del terzo asse lineare
static const string EVAR_R1 = ".R1" ; // (num) valore del primo asse rotante
static const string EVAR_R2 = ".R2" ; // (num) valore del secondo asse rotante
static const string EVAR_R3 = ".R3" ; // (num) valore del terzo asse rotante
static const string EVAR_R4 = ".R4" ; // (num) valore del quarto asse rotante
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
static const string EVAR_STAT = ".STAT" ; // OUT (int) codice di stato ( 0 = ok)
static const string EVAR_AUXINFO = ".AUXINFO" ; // OUT (string) stringa con info ausiliarie
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_TABNAME = ".TABNAME" ; // (string) nome della tavola macchina
static const string EVAR_HEAD = ".HEAD" ; // (string) nome della testa
static const string EVAR_EXIT = ".EXIT" ; // (int) numero dell'uscita
static const string EVAR_TOOL = ".TOOL" ; // (string) nome dell'utensile
static const string EVAR_TOTDIAM = ".TOTDIAM" ; // (num) diametro di ingombro dell'utensile
static const string EVAR_TOTLEN = ".TOTLEN" ; // (num) lunghezza di ingombro dell'utensile
static const string EVAR_L1 = ".L1" ; // (num) valore del primo asse lineare
static const string EVAR_L2 = ".L2" ; // (num) valore del secondo asse lineare
static const string EVAR_L3 = ".L3" ; // (num) valore del terzo asse lineare
static const string EVAR_R1 = ".R1" ; // (num) valore del primo asse rotante
static const string EVAR_R2 = ".R2" ; // (num) valore del secondo asse rotante
static const string EVAR_R3 = ".R3" ; // (num) valore del terzo asse rotante
static const string EVAR_R4 = ".R4" ; // (num) valore del quarto asse rotante
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
static const string EVAR_STAT = ".STAT" ; // OUT (int) codice di stato ( 0 = ok)
static const string EVAR_AUXINFO = ".AUXINFO" ; // OUT (string) stringa con info ausiliarie
static const string EMC_VAR_BACKUP = "QQQ_EMC" ; // nome del backup della tabella sopra indicata
static const string AXIS_NAME_PROTECTEDAREAS = "PRA" ;
static const string ON_SET_TABLE = "OnSetTable" ;
static const string ON_SET_HEAD = "OnSetHead" ;
static const string ON_VERIFY_PROTECTEDAREAS = "OnVerifyProtectedAreas" ;
static const string AXIS_NAME_PROTECTEDAREAS = "PRA" ;
//----------------------------------------------------------------------------
@@ -66,6 +67,8 @@ Machine::SetCurrTable( const string& sTable)
}
// lancio eventuale funzione lua di personalizzazione
if ( LuaExistsFunction( ON_SET_TABLE)) {
// salvo eventuale variabile EMC_VAR già presente
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bool bOk = LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, sTable) ;
@@ -73,6 +76,9 @@ Machine::SetCurrTable( const string& sTable)
bOk = bOk && LuaCallFunction( ON_SET_TABLE) ;
// reset variabili
bOk = bOk && LuaResetGlobVar( EMC_VAR) ;
// ripristino eventuale variabile EMC_VAR già presente
if ( bOldEMC)
LuaChangeNameGlobVar( EMC_VAR_BACKUP, EMC_VAR) ;
// restituisco risultato
return bOk ;
}
@@ -267,6 +273,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
m_dCalcTOvRad = dTOvDiam / 2 ;
// lancio eventuale funzione lua di personalizzazione
if ( LuaExistsFunction( ON_SET_HEAD)) {
// salvo eventuale variabile EMC_VAR già presente
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bool bOk = LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_HEAD, sHead) ;
@@ -278,6 +286,9 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
bOk = bOk && LuaCallFunction( ON_SET_HEAD) ;
// reset variabili
bOk = bOk && LuaResetGlobVar( EMC_VAR) ;
// ripristino eventuale variabile EMC_VAR già presente
if ( bOldEMC)
LuaChangeNameGlobVar( EMC_VAR_BACKUP, EMC_VAR) ;
// in caso di errore esco
if ( ! bOk)
return false ;
@@ -1392,6 +1403,8 @@ Machine::VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR&
// default
bool bOk = true ;
int nErr = 99 ;
// salvo eventuale variabile EMC_VAR già presente
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bOk = bOk && LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L1, dX) ;
@@ -1426,6 +1439,9 @@ Machine::VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR&
}
// reset variabili
bOk = LuaResetGlobVar( EMC_VAR) && bOk ;
// ripristino eventuale variabile EMC_VAR già presente
if ( bOldEMC)
LuaChangeNameGlobVar( EMC_VAR_BACKUP, EMC_VAR) ;
// esco
return bOk ;
}