EgtMachKernel :
- aggiunta gestione aree protette.
This commit is contained in:
@@ -130,6 +130,7 @@ class Machine
|
||||
bool LimitAngleToStroke( int nInd, double& dAng) const ;
|
||||
bool VerifyAngleOutstroke( int nInd, double dAng) const ;
|
||||
bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, bool bClear, int& nStat) const ;
|
||||
bool VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) ;
|
||||
bool VerifyOutstroke( const std::string& sAxName, double dVal) const ;
|
||||
std::string GetOutstrokeInfo( bool bMM = true) const ;
|
||||
void ResetOutstrokeInfo( void) const
|
||||
@@ -149,7 +150,7 @@ class Machine
|
||||
bool IsLinkedPart( int nPartId) const ;
|
||||
bool UnlinkPartFromGroup( int nPartId) ;
|
||||
bool UnlinkAllPartsFromGroups( void) ;
|
||||
bool LuaExistsFunction( const std::string& sFun) ;
|
||||
bool LuaExistsFunction( const std::string& sFun) const ;
|
||||
bool LuaCallFunction( const std::string& sFun, bool bSetModifiedOff = true) ;
|
||||
bool LuaCreateGlobTable( const std::string& sName) ;
|
||||
bool LuaResetGlobVar( const std::string& sName) ;
|
||||
|
||||
+67
-1
@@ -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 ;
|
||||
|
||||
+2
-2
@@ -128,14 +128,14 @@ Machine::LuaExit( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::LuaExistsFunction( const string& sFun)
|
||||
Machine::LuaExistsFunction( const string& sFun) const
|
||||
{
|
||||
// imposto contesto corretto
|
||||
int nOldCtx = ExeGetCurrentContext() ;
|
||||
if ( nOldCtx != m_pMchMgr->GetContextId())
|
||||
ExeSetCurrentContext( m_pMchMgr->GetContextId()) ;
|
||||
// imposto l'oggetto corrente per Lua
|
||||
m_pMchLua = this ;
|
||||
m_pMchLua = const_cast<Machine*>( this) ;
|
||||
// verifico esistenza della funzione
|
||||
bool bOk = m_LuaMgr.ExistsFunction( sFun) ;
|
||||
// ripristino contesto originale
|
||||
|
||||
Reference in New Issue
Block a user