Files
EgtMachKernel/MachMgrMachines.cpp
Dario Sassi b6ef052c50 EgtMachKernel 3.1c7 :
- esportata VerifyOutstroke con angoli da vettore di double
- resa più robusta GetCalcAngles che restituisce due soli assi rotanti (ora i primi due)
- nelle GetCalcAngles ora si applicano gli assi bloccati impostati tramite SetBlockedRotAxis
- consentiti fino a 4 assi rotanti nelle catene cinematiche dei centri di lavoro.
2026-03-25 16:42:53 +01:00

945 lines
33 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : MachMgrMachines.cpp Data : 02.05.15 Versione : 1.6e1
// Contenuto : Implementazione gestione macchine della classe MachMgr.
//
//
//
// Modifiche : 02.05.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "MachMgr.h"
#include "MachConst.h"
#include "ToolsMgr.h"
#include "MachiningsMgr.h"
#include "SawingData.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
MachMgr::GetMachines( STRVECTOR& vsMachineNames, STRVECTOR& vsMachineDirs) const
{
// pulisco elenco delle macchine
vsMachineNames.clear() ;
// eseguo ricerca delle macchine nei direttori base
for ( int i = 0 ; i < int( m_vMachinesBaseDir.size()) ; ++ i) {
STRVECTOR vsDirNames ;
if ( FindAllDirectories( m_vMachinesBaseDir[i] + "\\*", vsDirNames)) {
for ( int j = 0 ; j < int( vsDirNames.size()) ; ++ j) {
// nome e direttorio della macchina
string sMachName = vsDirNames[j] ;
string sMachDir = m_vMachinesBaseDir[i] + "\\" + vsDirNames[j] ;
// verifico esista il file mlde ( o mde) della macchina
string sMachineMlde = sMachDir + "\\" + sMachName + ".Mlde" ;
string sMachineMde = sMachDir + "\\" + sMachName + ".Mde" ;
if ( ( ExistsFile( sMachineMlde) || ExistsFile( sMachineMde)) &&
find_if( vsMachineNames.begin(), vsMachineNames.end(),
[ &sMachName]( const string& sName)
{ return EqualNoCase( sName, sMachName) ; }) == vsMachineNames.end()) {
vsMachineNames.emplace_back( sMachName) ;
vsMachineDirs.emplace_back( sMachDir) ;
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::LoadMachine( const string& sMachineName)
{
// verifico validità del nome
if ( ! IsValidFileName( sMachineName))
return false ;
// se macchina già caricata, non devo fare alcunchè
if ( GetMachine( sMachineName) != - 1)
return true ;
// cerco il direttorio della macchina
string sMachDir ;
for ( int i = 0 ; i < int( m_vMachinesBaseDir.size()) ; ++ i) {
string sTemp = m_vMachinesBaseDir[i] + "\\" + sMachineName ;
if ( ExistsDirectory( sTemp)) {
sMachDir = sTemp ;
break ;
}
}
if ( IsEmptyOrSpaces( sMachDir))
return false ;
// verifico esista il file mlde ( o mde) della macchina
string sMachineMlde = sMachDir + "\\" + sMachineName + ".Mlde" ;
if ( ! ExistsFile( sMachineMlde))
sMachineMlde = ChangeFileExtension( sMachineMlde, ".Mde") ;
if ( ! ExistsFile( sMachineMlde))
return false ;
// salvo nel vettore
m_vMachines.emplace_back( sMachineName, sMachDir, nullptr, nullptr, nullptr) ;
return true ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetMachine( const string& sMachineName) const
{
// ciclo sulle macchine
for ( size_t i = 0 ; i < m_vMachines.size() ; ++ i) {
if ( EqualNoCase( m_vMachines[i].sName, sMachineName))
return int( i) ;
}
return - 1 ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetCurrMachine( const string& sMachineName)
{
// se è già la macchina corrente, tutto bene
if ( m_nCurrMch >= 0 && m_nCurrMch < int( m_vMachines.size()) &&
EqualNoCase( m_vMachines[m_nCurrMch].sName, sMachineName))
return true ;
// se c'è macchinata corrente, non posso cambiare la macchina
if ( m_nCurrMGrpId != GDB_ID_NULL)
return false ;
// verifica ed eventuale caricamento della macchina
if ( ! LoadMachine( sMachineName))
return false ;
// imposto i dati della macchina corrente
m_nCurrMch = GetMachine( sMachineName) ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrMachineName( string& sMachineName) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return false ;
// assegno il nome
sMachineName = m_vMachines[m_nCurrMch].sName ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrMachineDir( string& sMachineDir) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return false ;
// assegno il direttorio
sMachineDir = m_vMachines[m_nCurrMch].sDir ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::IsCurrMachineLoaded( void) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return false ;
// verifico esistenza gestore macchina
return ( m_vMachines[m_nCurrMch].pMachine != nullptr) ;
}
//----------------------------------------------------------------------------
Machine*
MachMgr::GetCurrMachine( void) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return nullptr ;
// se gestore macchina non esiste, provo a crearlo e caricarlo
if ( m_vMachines[m_nCurrMch].pMachine == nullptr) {
// creo gruppo ausiliario di base per le macchine
if ( ! const_cast<MachMgr*>(this)->CreateMachAux())
return nullptr ;
// creo e carico la macchina
PtrOwner<Machine> pMch( new( nothrow) Machine) ;
if ( IsNull( pMch) || ! pMch->Init( m_vMachines[m_nCurrMch].sName, m_vMachines[m_nCurrMch].sDir, const_cast<MachMgr*>(this)))
return nullptr ;
// nascondo la macchina
if ( m_pGeomDB != nullptr)
m_pGeomDB->SetStatus( pMch->GetMachineId(), GDB_ST_OFF) ;
// salvo nel vettore
const_cast<MachineData&>( m_vMachines[m_nCurrMch]).pMachine = Release( pMch) ;
}
// restituisco il gestore macchina
return m_vMachines[m_nCurrMch].pMachine ;
}
//----------------------------------------------------------------------------
ToolsMgr*
MachMgr::GetCurrToolsMgr( void) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return nullptr ;
// se DB utensili non esiste, provo a crearlo e caricarlo
if ( m_vMachines[m_nCurrMch].pTsMgr == nullptr) {
PtrOwner<ToolsMgr> pTsMgr( new( nothrow) ToolsMgr) ;
string sToolsDir = m_vMachines[m_nCurrMch].sDir + "\\" + TOOLS_DIR ;
if ( IsNull( pTsMgr) || ! pTsMgr->Load( sToolsDir, TOOLS_FILE))
return nullptr ;
// salvo nel vettore
const_cast<MachineData&>( m_vMachines[m_nCurrMch]).pTsMgr = Release( pTsMgr) ;
}
// restituisco il gestore DB utensili
return m_vMachines[m_nCurrMch].pTsMgr ;
}
//----------------------------------------------------------------------------
MachiningsMgr*
MachMgr::GetCurrMachiningsMgr( void) const
{
// verifico validità indice macchina corrente
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return nullptr ;
// se DB lavorazioni non esiste, provo a crearlo e caricarlo
if ( m_vMachines[m_nCurrMch].pMsMgr == nullptr) {
PtrOwner<MachiningsMgr> pMsMgr( new( nothrow) MachiningsMgr) ;
string sMachsDir = m_vMachines[m_nCurrMch].sDir + "\\" + MACHININGS_DIR ;
if ( IsNull( pMsMgr) || ! pMsMgr->Load( sMachsDir, MACHININGS_FILE, GetCurrToolsMgr()))
return nullptr ;
// salvo nel vettore
const_cast<MachineData&>( m_vMachines[m_nCurrMch]).pMsMgr = Release( pMsMgr) ;
}
// restituisco il gestore DB lavorazioni
return m_vMachines[m_nCurrMch].pMsMgr ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCurrMachineId( void) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo della radice della geometria della macchina corrente
return ( ( pMch != nullptr) ? pMch->GetMachineId() : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetBaseId( const string& sBase) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo della base indicata nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetBaseId( sBase) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetTableId( const string& sTable) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo della tavola indicata nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetTableId( sTable) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetAxisId( const string& sAxis) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo dell'asse indicato nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetAxisId( sAxis) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetHeadId( const string& sHead) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo della testa indicata nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetHeadId( sHead) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetHeadExitCount( const string& sHead) const
{
Machine* pMch = GetCurrMachine() ;
// recupero il numero di uscite della testa
return ( ( pMch != nullptr) ? pMch->GetHeadExitCount( sHead) : 0) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetExitId( const string& sHead, int nExit) const
{
Machine* pMch = GetCurrMachine() ;
// recupero identificativo dell'uscita della testa indicata nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetExitId( sHead, nExit) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetTcPosId( const string& sTcPos) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco identificativo della posizione cambio utensile indicata nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetTcPosId( sTcPos) : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetHeadAbove( const string& sHead) const
{
if ( m_pGeomDB == nullptr)
return false ;
// Leggo da testa Info ABOVE
bool bAbove = true ;
return ( ! m_pGeomDB->GetInfo( GetHeadId( sHead), MCH_ABOVE, bAbove) || bAbove) ;
}
//----------------------------------------------------------------------------
double
MachMgr::GetAngDeltaMinForHome( void) const
{
Machine* pMch = GetCurrMachine() ;
// recupero la minima differenza angolare da posizione precedente per stare vivino a posizione home
return ( ( pMch != nullptr) ? pMch->GetAngDeltaMinForHome() : INFINITO) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisToken( const string& sAxis, string& sToken) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco token dell'asse indicato nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetAxisToken( sAxis, sToken) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisType( const string& sAxis, bool& bLinear) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco il tipo dell'asse indicato nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetAxisType( sAxis, bLinear) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisDir( const string& sAxis, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco la direzione dell'asse indicato nella macchina corrente
return ( ( pMch != nullptr) ? pMch->GetAxisDir( sAxis, vtDir) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisInvert( const string& sAxis, bool& bInvert) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco il flag di inversione asse in visualizzazione
return ( ( pMch != nullptr) ? pMch->GetAxisInvert( sAxis, bInvert) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisOffset( const string& sAxis, double& dOffset) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco il valore di offset asse in visualizzazione
return ( ( pMch != nullptr) ? pMch->GetAxisOffset( sAxis, dOffset) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->SetAxisPos( sAxis, dVal, true, pdNewVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisPos( const string& sAxis, double& dVal) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAxisPos( sAxis, dVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisMin( const string& sAxis, double& dMin) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAxisMin( sAxis, dMin) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisMax( const string& sAxis, double& dMax) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAxisMax( sAxis, dMax) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisHomePos( const string& sAxis, double& dHomeVal) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAxisHomePos( sAxis, dHomeVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetAxisPos( const string& sAxis)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->ResetAxisPos( sAxis) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::IsDispositionAxis( const string& sAxis, const string& sTable) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->IsDispositionAxis( sAxis, sTable) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetAllAxesPos( void)
{
return ResetAllAxesPos( true, false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetAllAxesPos( bool bStdAxes, bool bDispAxes)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->ResetAllAxesPos( bStdAxes, bDispAxes) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::LoadTool( const string& sHead, int nExit, const string& sTool)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->LoadTool( sHead, nExit, sTool) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetLoadedTool( const string& sHead, int nExit, string& sTool) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetLoadedTool( sHead, nExit, sTool) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::UnloadTool( const string& sHead, int nExit)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->UnloadTool( sHead, nExit) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetHeadSet( const string& sHead)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->ResetHeadSet( sHead) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetCalcTable( const string& sTable)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->SetCurrTable( sTable) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetCalcTool( const string& sTool, const string& sHead, int nExit)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->SetCurrTool( sTool, sHead, nExit) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetRotAxisBlock( const string& sAxis, double dVal)
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
int nAxId = pMch->GetAxisId( sAxis) ;
if ( nAxId == GDB_ID_NULL)
return false ;
m_vAxisBlock.emplace_back( sAxis, dVal) ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetRotAxisBlocked( int nInd, string& sAxis, double& dVal) const
{
// se bloccaggi non ancora impostati
if ( ! m_vAxisBlock.empty()) {
if ( nInd < 0 || nInd >= int( m_vAxisBlock.size()))
return false ;
sAxis = m_vAxisBlock[nInd].sAxis ;
dVal = m_vAxisBlock[nInd].dVal ;
return true ;
}
// altrimenti cerco negli assi rotanti correnti
const Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
int nMyInd = 0 ;
for ( int i = 0 ; i < pMch->GetCurrRotAxes() ; ++ i) {
if ( pMch->GetKinematicRotAxisBlocked( i, sAxis, dVal)) {
if ( nMyInd == nInd)
return true ;
else
++ nMyInd ;
}
}
return false ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ApplyRotAxisBlock( void)
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// applico blocchi
bool bOk = true ;
for ( auto& abVal : m_vAxisBlock) {
if ( ! pMch->BlockKinematicRotAxis( abVal.sAxis, abVal.dVal))
bOk = false ;
}
// pulisco
m_vAxisBlock.clear() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachMgr::IsKinematicRotAxisBlocked( int nInd) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->IsKinematicRotAxisBlocked( nInd) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetCalcSolCh( int nScc, bool bExact)
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// imposto il criterio di scelta della soluzione
return pMch->SetSolCh( nScc, bExact) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcSolCh( int& nScc, bool& bExact) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// recupero il criterio di scelta della soluzione
return pMch->GetSolCh( nScc, bExact) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTable( string& sTable) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrTable( sTable) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTool( string& sTool) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrTool( sTool) : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCalcTool( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrTool() : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcHead( string& sHead) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrHead( sHead) : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCalcHead( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrHead() : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcExit( int& nExit) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrExit( nExit) : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCalcExit( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrExit() : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
double
MachMgr::GetCalcRot1W( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrRot1W() : 1) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcMaxDeltaR2OnFirst( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrCalcMaxDeltaR2OnFirst() : true) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllTablesNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco tavole alla macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllTablesNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllAxesNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco assi alla macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllAxesNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllHeadsNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco teste alla macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllHeadsNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllTcPosNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco posizioni cambio utensile alla macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllTcPosNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCurrLinAxes( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrLinAxes() : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetCurrRotAxes( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrRotAxes() : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllCurrAxesNames( STRVECTOR& vAxName) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesNames( vAxName) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesHomePos( vAxHomeVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrAxisHomePos( int nInd, double& dHome) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrAxisHomePos( nInd, dHome) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrAxisMax( int nInd, double& dMax) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrAxisMax( nInd, dMax) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrAxisMin( int nInd, double& dMin) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrAxisMin( nInd, dMin) : false) ;
}
//----------------------------------------------------------------------------
const Frame3d&
MachMgr::GetCurrLinAxesFrame( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr) {
static Frame3d frDummy ;
return frDummy ;
}
return pMch->GetCurrLinAxesFrame() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrIsMcent( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return ( pMch->GetCurrKinematicChainType() == KIN_CHAIN_MCENT) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrIsRobot( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return ( pMch->GetCurrKinematicChainType() == KIN_CHAIN_ROBOT) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const
{
nStat = 0 ; dAngA1 = 0 ; dAngB1 = 0 ; dAngA2 = 0 ; dAngB2 = 0 ;
DBLVECTOR vAng1, vAng2 ;
if ( ! GetCalcAngles( vtDirT, vtDirA, nStat, vAng1, vAng2))
return false ;
if ( vAng1.size() >= 1) {
dAngA1 = vAng1[0] ;
dAngA2 = vAng2[0] ;
if ( vAng1.size() >= 2) {
dAngB1 = vAng1[1] ;
dAngB2 = vAng2[1] ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const
{
const_cast<MachMgr*>(this)->ApplyRotAxisBlock() ;
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAngles( vtDirT, vtDirA, nStat, vAng1, vAng2) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
double& dX, double& dY, double& dZ) const
{
DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ;
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetPositions( ptP, vAng, dX, dY, dZ) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcPositions( const Point3d& ptP, const DBLVECTOR& vAng,
double& dX, double& dY, double& dZ) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetPositions( ptP, vAng, dX, dY, dZ) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetRobotAngles( const Point3d& ptP, const Vector3d& vtDirT, const Vector3d& vtDirA,
DBLVECTOR& vAng1, DBLVECTOR& vAng2) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetRobotAngles( ptP, vtDirT, vtDirA, vAng1, vAng2) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB,
bool bOverall, bool bBottom, Point3d& ptTip) const
{
DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ;
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetTipFromPositions( dX, dY, dZ, vAng, bOverall, bBottom, false, ptTip) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
bool bOverall, bool bBottom, Point3d& ptTip) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetTipFromPositions( dX, dY, dZ, vAng, bOverall, bBottom, false, ptTip) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetToolDirFromAngles( vAng, vtDir) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAuxDirFromAngles( vAng, vtDir) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetPartDirFromAngles( vtPart, vAng, vtDir) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetNearestAngleInStroke( nInd, dAngRef, dAng) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::LimitAngleToStroke( int nInd, double& dAng) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->LimitAngleToStroke( nInd, dAng) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyAngleOutstroke( int nInd, double dAng) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->VerifyAngleOutstroke( nInd, dAng) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) const
{
DBLVECTOR vAng(2) ; vAng[0] = dAngA ; vAng[1] = dAngB ;
return VerifyOutstroke( dX, dY, dZ, vAng, true, nStat) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, bool bClear, int& nStat) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->VerifyOutstroke( dX, dY, dZ, vAng, bClear, nStat) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ExistProtectedAreas( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->ExistProtectedAreas() : false) ;
}
//----------------------------------------------------------------------------
string
MachMgr::GetOutstrokeInfo( bool bMM) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetOutstrokeInfo( bMM) : "") ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetMachineLook( int nFlag)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->SetLook( nFlag) : false) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetMachineLook( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetLook() : MCH_LOOK_NONE) ;
}