EgtMachKernel 1.6j3 :

- aggiunta gestione DB utensili
- migliorata simulazione
- aggiunta impostazione macchina corrente anche senza macchinata.
This commit is contained in:
Dario Sassi
2015-10-27 10:12:13 +00:00
parent 2de785c6ce
commit 2c89d112fa
32 changed files with 904 additions and 237 deletions
+56 -33
View File
@@ -31,6 +31,8 @@ Simulator::Simulator( void)
m_nCLPathId = GDB_ID_NULL ;
m_nEntId = GDB_ID_NULL ;
m_dCoeff = 0 ;
m_AxesName.reserve( 8) ;
m_AxesVal.reserve( 8) ;
}
//----------------------------------------------------------------------------
@@ -72,40 +74,15 @@ Simulator::Start( void)
if ( nOpId == GDB_ID_NULL)
return false ;
m_nOpId = nOpId ;
// recupero l'utensile della lavorazione
string sTool ;
Machining* pMch = dynamic_cast<Machining*>( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch == nullptr || ! pMch->GetParam( MPA_TOOL, sTool))
return false ;
const ToolData* pTdata = m_pMchMgr->GetToolData( sTool) ;
if ( pTdata == nullptr)
return false ;
// attivo l'utensile della lavorazione
if ( ! m_pMchMgr->SetCalcTool( sTool, pTdata->m_sHead, pTdata->m_nExit))
return false ;
// macchina corrente
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
if ( pMachine == nullptr)
return false ;
// carico i nomi degli assi macchina attivi
m_AxesName.clear() ;
int nInd = 0 ;
string sAxis = pMachine->GetKinematicAxis( nInd) ;
while ( ! sAxis.empty()) {
m_AxesName.emplace_back( sAxis) ;
sAxis = pMachine->GetKinematicAxis( ++ nInd) ;
}
if ( m_AxesName.size() > m_AxesVal.size())
// aggiornamenti legati al cambio di lavorazione (utensile e assi conseguenti)
if ( ! UpdateTool() || ! UpdateAxes())
return false ;
// porto la macchina in home
m_pMchMgr->ResetAllAxesPos() ;
// assegno valori home degli assi come precedenti
m_AxesVal.fill( 0) ;
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
double dHVal ;
if ( pMachine->GetAxisHomePos( m_AxesName[i], dHVal))
m_AxesVal[i] = dHVal ;
}
if ( ! GoHome())
return false ;
// determino il primo percorso di lavoro
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOpId, MCH_CL) ;
m_nCLPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
@@ -141,13 +118,16 @@ Simulator::Move( void)
m_nCLPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
m_nEntId = m_pGeomDB->GetFirstInGroup( m_nCLPathId) ;
m_dCoeff = 0 ;
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool() || ! UpdateAxes())
return false ;
}
// Cerco prossima posizione su interpolazione corrente
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( m_nEntId)) ;
if ( pCamData == nullptr || pCamData->GetAxesStatus() != CamData::AS_OK)
return false ;
MachAxesVal AxesEnd = pCamData->GetAxisVal() ;
const DBLVECTOR& AxesEnd = pCamData->GetAxisVal() ;
// Verifico se movimento in rapido
bool bRapid = ( pCamData->GetFeed() < EPS_SMALL) ;
// Calcolo distanza di movimento
@@ -196,3 +176,46 @@ Simulator::Stop( void)
m_dCoeff = 0 ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::UpdateTool( void)
{
// Recupero l'utensile della lavorazione corrente
string sTool ;
Machining* pMch = dynamic_cast<Machining*>( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch == nullptr || ! pMch->GetParam( MPA_TOOL, sTool))
return false ;
const ToolData* pTdata = m_pMchMgr->TdbGetToolData( sTool) ;
if ( pTdata == nullptr)
return false ;
// se cambiato, attivo l'utensile della lavorazione
if ( sTool != m_sTool) {
if ( ! m_pMchMgr->SetCalcTool( sTool, pTdata->m_sHead, pTdata->m_nExit))
return false ;
m_sTool = sTool ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::UpdateAxes( void)
{
// Macchina corrente
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
if ( pMachine == nullptr)
return false ;
// Carico i nomi degli assi macchina attivi
return pMachine->GetAllCurrAxesName( m_AxesName) ;
}
//----------------------------------------------------------------------------
bool
Simulator::GoHome( void)
{
// porto la macchina in home
m_pMchMgr->ResetAllAxesPos() ;
// assegno valori home degli assi macchina attivi
return m_pMchMgr->GetAllCalcAxesHomePos( m_AxesVal) ;
}