EgtMachKernel 1.6e7 :
- introdotto uso ObjUser per gruppi di macchina - prima versione prototipo delle forature - migliorie al calolo angoli e posizioni macchina.
This commit is contained in:
+74
-73
@@ -15,6 +15,10 @@
|
||||
#include "stdafx.h"
|
||||
#include "MachMgr.h"
|
||||
#include "DllMain.h"
|
||||
#include "Table.h"
|
||||
#include "Axis.h"
|
||||
#include "Head.h"
|
||||
#include "Exit.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
@@ -161,9 +165,12 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
|
||||
return false ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
// gli assegno il tipo
|
||||
string sInfo = MCH_TAB + ToString( nType) ;
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ;
|
||||
// installo e inizializzo il gestore della tavola
|
||||
Table* pTab = new(nothrow) Table ;
|
||||
if ( pTab == nullptr)
|
||||
return false ;
|
||||
pTab->Set( sName, nType) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pTab) ;
|
||||
// lo inserisco nel dizionario dei gruppi della macchina
|
||||
return m_mapGroups.emplace( sName, nLay).second ;
|
||||
}
|
||||
@@ -192,21 +199,12 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
|
||||
return false ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
// gli assegno il tipo
|
||||
string sInfo = MCH_AXIS + ToString( nType) ;
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ;
|
||||
// gli assegno la posizione
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Pos", ptPos) ;
|
||||
// gli assegno la direzione
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Dir", vtDir) ;
|
||||
// gli assegno i limiti di corsa
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Stroke", ToString( Stroke.v)) ;
|
||||
// gli assegno il valore iniziale di home
|
||||
if ( ! m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HVal", dVal))
|
||||
return false ;
|
||||
// gli assegno il valore corrente
|
||||
if ( ! m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Val", dVal))
|
||||
// installo e inizializzo il gestore dell'asse
|
||||
Axis* pAxis = new(nothrow) Axis ;
|
||||
if ( pAxis == nullptr)
|
||||
return false ;
|
||||
pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dVal) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pAxis) ;
|
||||
// inserisco il vettore rappresentativo dell'asse
|
||||
if ( ! AddAxisVector( nLay, ptPos, vtDir, sName))
|
||||
return false ;
|
||||
@@ -273,15 +271,15 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
// gli assegno l'insieme di teste e aggiorno il capostipite
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HSet", sHSet) ;
|
||||
// installo e inizializzo il gestore della testa
|
||||
Head* pHead = new(nothrow) Head ;
|
||||
if ( pHead == nullptr)
|
||||
return false ;
|
||||
pHead->Set( sName, MCH_HT_STD, sHSet, vtADir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
// aggiorno la testa capostipite
|
||||
if ( ! AddHeadToSet( sHSet, sName))
|
||||
return false ;
|
||||
// gli assegno il tipo
|
||||
string sInfo = MCH_HEAD + ToString( MCH_HT_STD) ;
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ;
|
||||
// gli assegno la direzione ausiliaria
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "ADir", vtADir) ;
|
||||
// trasformazione del riferimento di uscita in gruppo di uscita
|
||||
MUEXITVECTOR vMuExit ;
|
||||
vMuExit.emplace_back( ptPos, vtTDir) ;
|
||||
@@ -315,15 +313,15 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
// gli assegno l'insieme teste e aggiorno il capostipite
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HSet", sHSet) ;
|
||||
// installo e inizializzo il gestore della testa
|
||||
Head* pHead = new(nothrow) Head ;
|
||||
if ( pHead == nullptr)
|
||||
return false ;
|
||||
pHead->Set( sName, MCH_HT_MULTI, sHSet, vtADir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
// aggiorno la testa capostipite
|
||||
if ( ! AddHeadToSet( sHSet, sName))
|
||||
return false ;
|
||||
// gli assegno il tipo
|
||||
string sInfo = MCH_HEAD + ToString( MCH_HT_MULTI) ;
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ;
|
||||
// gli assegno la direzione ausiliaria
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nLay, "ADir", vtADir) ;
|
||||
// trasformazione dei riferimenti di uscita in gruppi di uscita
|
||||
if ( ! CreateExitGroups( nLay, vMuExit))
|
||||
return false ;
|
||||
@@ -340,27 +338,31 @@ Machine::GetGroup( const string& sGroup)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::IsAxisGroup( int nGroup)
|
||||
Axis*
|
||||
Machine::GetAxis( int nGroup)
|
||||
{
|
||||
string sType ;
|
||||
return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_AXIS) ;
|
||||
return ( dynamic_cast<Axis*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::IsTableGroup( int nGroup)
|
||||
Table*
|
||||
Machine::GetTable( int nGroup)
|
||||
{
|
||||
string sType ;
|
||||
return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_TAB) ;
|
||||
return ( dynamic_cast<Table*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::IsHeadGroup( int nGroup)
|
||||
Head*
|
||||
Machine::GetHead( int nGroup)
|
||||
{
|
||||
string sType ;
|
||||
return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_HEAD) ;
|
||||
return ( dynamic_cast<Head*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Exit*
|
||||
Machine::GetExit( int nGroup)
|
||||
{
|
||||
return ( dynamic_cast<Exit*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -370,36 +372,33 @@ Machine::AddHeadToSet( const string& sHSet, const string& sName)
|
||||
// se il capo-insieme coincide con la testa, non devo fare alcunchè
|
||||
if ( sHSet == sName)
|
||||
return true ;
|
||||
// recupero le info della testa capo-insieme
|
||||
int nHGroupId = GetGroup( sHSet) ;
|
||||
if ( nHGroupId == GDB_ID_NULL)
|
||||
// recupero la testa capo-insieme
|
||||
Head* pHead = GetHead( GetGroup( sHSet)) ;
|
||||
if ( pHead == nullptr)
|
||||
return false ;
|
||||
STRVECTOR vsHSet ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nHGroupId, "HSet", vsHSet))
|
||||
return false ;
|
||||
// se già presente non devo fare alcunchè, altrimenti lo aggiungo
|
||||
if ( find( vsHSet.begin(), vsHSet.end(), sName) != vsHSet.end())
|
||||
return true ;
|
||||
vsHSet.emplace_back( sName) ;
|
||||
return m_pMchMgr->m_pGeomDB->SetInfo( nHGroupId, "HSet", vsHSet) ;
|
||||
// aggiungo questa testa all'insieme
|
||||
return pHead->AddHeadToHSet( sName) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::GetHSet( const string& sHead, STRVECTOR& vsHSet)
|
||||
const STRVECTOR&
|
||||
Machine::GetHSet( const string& sHead)
|
||||
{
|
||||
// recupero l'indice della testa
|
||||
int nHead = GetGroup( sHead) ;
|
||||
if ( ! IsHeadGroup( nHead))
|
||||
return false ;
|
||||
// recupero la stringa dell'insieme di teste
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nHead, "HSet", vsHSet))
|
||||
return false ;
|
||||
// vettore di stringhe vuoto, da restituire in caso di errore
|
||||
static const STRVECTOR vsNull ;
|
||||
// recupero la testa
|
||||
Head* pHead = GetHead( GetGroup( sHead)) ;
|
||||
if ( pHead == nullptr)
|
||||
return vsNull ;
|
||||
// recupero l'insieme di teste a cui appartiene
|
||||
const STRVECTOR& vsTmp = pHead->GetHSet() ;
|
||||
if ( vsTmp.empty())
|
||||
return vsNull ;
|
||||
// se il primo membro coincide con la testa, allora è già l'insieme di teste
|
||||
if ( vsHSet[0] == sHead)
|
||||
return true ;
|
||||
if ( vsTmp[0] == sHead)
|
||||
return vsTmp ;
|
||||
// altrimenti cerco l'insieme della prima testa
|
||||
return GetHSet( vsHSet[0], vsHSet) ;
|
||||
return GetHSet( vsTmp[0]) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -407,8 +406,8 @@ bool
|
||||
Machine::EnableHeadInSet( const string& sHead)
|
||||
{
|
||||
// recupero l'insieme di teste
|
||||
STRVECTOR vsHSet ;
|
||||
if ( ! GetHSet( sHead, vsHSet))
|
||||
const STRVECTOR& vsHSet = GetHSet( sHead) ;
|
||||
if ( vsHSet.empty())
|
||||
return false ;
|
||||
// spengo tutte le teste tranne questa
|
||||
for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) {
|
||||
@@ -425,7 +424,7 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
|
||||
{
|
||||
// ciclo sulle uscite
|
||||
for ( int i = 0 ; i < int( vMuExit.size()) ; ++ i) {
|
||||
string sName = "T" + ToString( i+1) ;
|
||||
string sName = MCH_EXIT + ToString( i+1) ;
|
||||
// se trovo riferimento per uscita, lo sostituisco con gruppo equivalente
|
||||
int nT = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nLay, sName) ;
|
||||
if ( nT != GDB_ID_NULL && m_pMchMgr->m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) {
|
||||
@@ -439,10 +438,12 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
|
||||
m_pMchMgr->m_pGeomDB->Erase( nT) ;
|
||||
// assegno nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nGT, sName) ;
|
||||
// gli assegno la posizione
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nGT, "Pos", vMuExit[i].ptPos) ;
|
||||
// gli assegno la direzione utensile
|
||||
m_pMchMgr->m_pGeomDB->SetInfo( nGT, "TDir", vMuExit[i].vtTDir) ;
|
||||
// installo e inizializzo il gestore dell'uscita
|
||||
Exit* pExit = new(nothrow) Exit ;
|
||||
if ( pExit == nullptr)
|
||||
return false ;
|
||||
pExit->Set( sName, vMuExit[i].ptPos, vMuExit[i].vtTDir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nGT, pExit) ;
|
||||
}
|
||||
else {
|
||||
string sOut = "Error finding frame " + sName ;
|
||||
|
||||
Reference in New Issue
Block a user