EgtMachKernel :

- aggiunta gestione aree protette.
This commit is contained in:
Dario Sassi
2019-04-03 06:27:49 +00:00
parent fd31ea425e
commit 033b1ea5fa
3 changed files with 71 additions and 4 deletions
+67 -1
View File
@@ -35,8 +35,20 @@ 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 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" ;
//----------------------------------------------------------------------------
@@ -1356,9 +1368,61 @@ Machine::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng
m_OutstrokeInfo.sAuxInfo = " (R" + ToString( int(i) + 1) + "+) " ;
}
}
// verifica delle aree protette
if ( nStat == 0)
return const_cast<Machine*>( this)->VerifyProtectedAreas( dX, dY, dZ, vAng, nStat) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat)
{
// se non esiste funzione gestione aree protette, non devo fare alcunchè
if ( ! LuaExistsFunction( ON_VERIFY_PROTECTEDAREAS))
return true ;
// default
bool bOk = true ;
int nErr = 99 ;
// definisco variabili
bOk = bOk && LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L1, dX) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L2, dY) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L3, dZ) ;
if ( vAng.size() >= 1)
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_R1, vAng[0]) ;
if ( vAng.size() >= 2)
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_R2, vAng[1]) ;
if ( vAng.size() >= 3)
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_R3, vAng[2]) ;
if ( vAng.size() >= 4)
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_R4, vAng[3]) ;
// chiamo funzione
bOk = bOk && LuaCallFunction( ON_VERIFY_PROTECTEDAREAS) ;
// recupero il risultato
bOk = bOk && LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ;
if ( nErr != 0) {
bOk = false ;
string sOut = " Error in " + ON_VERIFY_PROTECTEDAREAS + " (" + ToString( nErr) + ")" ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
}
int nMyStat = 0 ;
bOk = bOk && LuaGetGlobVar( EMC_VAR + EVAR_STAT, nMyStat) ;
if ( nMyStat != 0) {
nStat += ( nMyStat << 14) ;
m_OutstrokeInfo.sAxName = AXIS_NAME_PROTECTEDAREAS ;
m_OutstrokeInfo.sAxToken = "" ;
m_OutstrokeInfo.bLinear = false ;
m_OutstrokeInfo.dExtra = 0 ;
bOk = bOk && LuaGetGlobVar( EMC_VAR + EVAR_AUXINFO, m_OutstrokeInfo.sAuxInfo) ;
}
// reset variabili
bOk = LuaResetGlobVar( EMC_VAR) && bOk ;
// esco
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machine::VerifyOutstroke( const string& sAxName, double dVal) const
@@ -1403,7 +1467,9 @@ Machine::GetOutstrokeInfo( bool bMM) const
if ( m_OutstrokeInfo.sAxName.empty())
return "" ;
// creo stringa con info opportune
if ( bMM || ! m_OutstrokeInfo.bLinear)
if ( m_OutstrokeInfo.sAxName == AXIS_NAME_PROTECTEDAREAS)
return m_OutstrokeInfo.sAuxInfo ;
else if ( bMM || ! m_OutstrokeInfo.bLinear)
return m_OutstrokeInfo.sAxToken + "=" + ToString( m_OutstrokeInfo.dExtra, 1) + m_OutstrokeInfo.sAuxInfo ;
else
return m_OutstrokeInfo.sAxToken + "=" + ToString( m_OutstrokeInfo.dExtra / ONEINCH, 2) + m_OutstrokeInfo.sAuxInfo ;