EgtMachKernel 1.6r9 :
- separato nome da token per gli assi macchina e gestito il tutto - in milling aggiunta gestione punto start e estrusione di path per piano locale di interpolazione in part-program - migliorata gestione deselezione utensile in simulazione.
This commit is contained in:
+61
-28
@@ -39,6 +39,7 @@ Simulator::Simulator( void)
|
||||
m_nEntInd = 0 ;
|
||||
m_dCoeff = 0 ;
|
||||
m_AxesName.reserve( 8) ;
|
||||
m_AxesToken.reserve( 8) ;
|
||||
m_AxesVal.reserve( 8) ;
|
||||
}
|
||||
|
||||
@@ -75,6 +76,7 @@ Simulator::Start( void)
|
||||
// reset utensile e assi correnti
|
||||
m_sTool.clear() ;
|
||||
m_AxesName.clear() ;
|
||||
m_AxesToken.clear() ;
|
||||
// porto la macchina in home
|
||||
if ( ! GoHome())
|
||||
return false ;
|
||||
@@ -91,8 +93,10 @@ Simulator::Start( void)
|
||||
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
string sTable ;
|
||||
pDisp->GetTable( sTable) ;
|
||||
Point3d ptOri1 ;
|
||||
pDisp->GetTableRef1( ptOri1) ;
|
||||
// richiamo gestione evento inizio e fine disposizione
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, sTable, true) ||
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, sTable, ptOri1, true) ||
|
||||
! OnDispositionEnd())
|
||||
return false ;
|
||||
// cerco la prima lavorazione valida
|
||||
@@ -109,7 +113,7 @@ Simulator::Start( void)
|
||||
return false ;
|
||||
|
||||
// aggiornamenti legati al cambio di lavorazione (utensile e assi conseguenti)
|
||||
if ( ! UpdateTool( true) || ! UpdateAxes())
|
||||
if ( ! UpdateTool( true))
|
||||
return false ;
|
||||
|
||||
// richiamo gestione evento inizio lavorazione
|
||||
@@ -189,7 +193,7 @@ Simulator::Move( int& nStatus)
|
||||
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
if ( pMch != nullptr && ! pMch->IsEmpty()) {
|
||||
// aggiorno utensile e assi conseguenti
|
||||
if ( ! UpdateTool() || ! UpdateAxes()) {
|
||||
if ( ! UpdateTool()) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
@@ -209,28 +213,30 @@ Simulator::Move( int& nStatus)
|
||||
// recupero dati tavola
|
||||
string sTable ;
|
||||
pDisp->GetTable( sTable) ;
|
||||
Point3d ptOri1 ;
|
||||
pDisp->GetTableRef1( ptOri1) ;
|
||||
// se con movimenti autonomi
|
||||
if ( ! pDisp->IsEmpty()) {
|
||||
// aggiorno utensile e assi conseguenti
|
||||
if ( ! UpdateTool() || ! UpdateAxes()) {
|
||||
if ( ! UpdateTool()) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
++ m_nOpInd ;
|
||||
// richiamo gestione evento inizio disposizione
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, false)) {
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, false)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
// recupero eventuali forzature assi da gestione inizio disposizione
|
||||
UpdateAxes() ;
|
||||
UpdateAxesPos() ;
|
||||
break ;
|
||||
}
|
||||
// altrimenti disposizione passiva
|
||||
else {
|
||||
++ m_nOpInd ;
|
||||
// richiamo gestione evento inizio e fine disposizione
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, true) ||
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, true) ||
|
||||
! OnDispositionEnd()) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
@@ -480,22 +486,22 @@ Simulator::UpdateTool( bool bForced)
|
||||
// Recupero l'utensile della lavorazione corrente
|
||||
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
if ( pMch != nullptr) {
|
||||
// recupero nome nuovo utensile
|
||||
// recupero nome e dati nuovo utensile
|
||||
string sTool ;
|
||||
if ( ! pMch->GetParam( MPA_TOOL, sTool))
|
||||
return false ;
|
||||
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
|
||||
return false ;
|
||||
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
// se cambierà e non forzato (inizio), scarico l'utensile corrente
|
||||
if ( sTool != m_sTool && ! bForced) {
|
||||
// eventuale lancio script per scarico utensile
|
||||
if ( ! OnToolDeselect())
|
||||
if ( ! OnToolDeselect( sHead, nExit))
|
||||
return false ;
|
||||
}
|
||||
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
|
||||
return false ;
|
||||
// se cambiato oppure forzato, attivo l'utensile della lavorazione
|
||||
if ( sTool != m_sTool || bForced) {
|
||||
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
// se forzato, pulisco la testa
|
||||
if ( bForced)
|
||||
m_pMchMgr->ResetHeadSet( sHead) ;
|
||||
@@ -503,6 +509,9 @@ Simulator::UpdateTool( bool bForced)
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
return false ;
|
||||
m_sTool = sTool ;
|
||||
// aggiorno gli assi macchina
|
||||
if ( ! UpdateAxes())
|
||||
return false ;
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit))
|
||||
return false ;
|
||||
@@ -512,16 +521,19 @@ Simulator::UpdateTool( bool bForced)
|
||||
// Provo con una disposizione
|
||||
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
if ( pDisp != nullptr) {
|
||||
// eventuale lancio script per scarico utensile
|
||||
if ( ! OnToolDeselect())
|
||||
return false ;
|
||||
// recupero i dati
|
||||
string sTool ; string sHead ; int nExit ;
|
||||
pDisp->GetToolData( sTool, sHead, nExit) ;
|
||||
// eventuale lancio script per scarico utensile
|
||||
if ( ! OnToolDeselect( sHead, nExit))
|
||||
return false ;
|
||||
// carico l'utensile
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
return false ;
|
||||
m_sTool = sTool ;
|
||||
// aggiorno gli assi macchina
|
||||
if ( ! UpdateAxes())
|
||||
return false ;
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit))
|
||||
return false ;
|
||||
@@ -538,8 +550,9 @@ Simulator::UpdateAxes( void)
|
||||
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMachine == nullptr)
|
||||
return false ;
|
||||
// Carico i nomi degli assi macchina attivi
|
||||
if ( ! pMachine->GetAllCurrAxesName( m_AxesName))
|
||||
// Carico i nomi e i token degli assi macchina attivi
|
||||
if ( ! pMachine->GetAllCurrAxesName( m_AxesName) ||
|
||||
! pMachine->GetAllCurrAxesToken( m_AxesToken))
|
||||
return false ;
|
||||
// Aggiorno la posizione corrente degli assi macchina attivi
|
||||
m_AxesVal.clear() ;
|
||||
@@ -591,15 +604,17 @@ Simulator::OnOperationEnd( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, const string& sTable, bool bEmpty)
|
||||
Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase,
|
||||
const string& sTable, const Point3d& ptOri1, bool bEmpty)
|
||||
{
|
||||
// assegno identificativo e indice disposizione
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ;
|
||||
// assegno nuovo indice di fase
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PHASE, nPhase) ;
|
||||
// assegno nome della tavola corrente
|
||||
// assegno nome e valore riferimento della tavola corrente
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sTable) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABORI1, ptOri1) ;
|
||||
// assegno flag disposizione passiva
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ;
|
||||
// verifico esistenza funzione
|
||||
@@ -626,11 +641,25 @@ Simulator::OnDispositionEnd( void)
|
||||
bool
|
||||
Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
|
||||
{
|
||||
// assegno dati
|
||||
// assegno il nome dell'utensile, la testa e l'uscita
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit))
|
||||
return false ;
|
||||
// assegno il token e il nome degli assi
|
||||
int nNumAxes = int( m_AxesName.size()) ;
|
||||
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
|
||||
if ( i <= nNumAxes) {
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesToken[i-1]) ||
|
||||
! m_pMachine->LuaSetGlobVar( GetGlobVarAxisName(i), m_AxesName[i-1]))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken(i)) ||
|
||||
! m_pMachine->LuaResetGlobVar( GetGlobVarAxisName(i)))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT))
|
||||
return true ;
|
||||
@@ -640,8 +669,12 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnToolDeselect( void)
|
||||
Simulator::OnToolDeselect( const string& sNextHead, int nNextExit)
|
||||
{
|
||||
// assegno la prossima testa
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTHEAD, sNextHead) ;
|
||||
// assegno la prossima uscita
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTEXIT, nNextExit) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
|
||||
return true ;
|
||||
@@ -653,13 +686,13 @@ Simulator::OnToolDeselect( void)
|
||||
bool
|
||||
Simulator::OnMachiningStart( int nOpId, int nOpInd)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
|
||||
return true ;
|
||||
// assegno identificativo e indice lavorazione
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd))
|
||||
return false ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
|
||||
return true ;
|
||||
// chiamo la funzione di inizio disposizione
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
|
||||
}
|
||||
@@ -742,7 +775,7 @@ Simulator::OnMoveStart( const CamData* pCamData)
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
|
||||
// forzo aggiornamento posizione assi (possono essere stati mssi nello script)
|
||||
// forzo aggiornamento posizione assi (possono essere stati messi nello script)
|
||||
UpdateAxesPos() ;
|
||||
|
||||
// recupero i dati di ritorno
|
||||
@@ -755,8 +788,8 @@ Simulator::OnMoveStart( const CamData* pCamData)
|
||||
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
|
||||
string sName ; double dVal ; double dEnd ;
|
||||
string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ;
|
||||
string sAuxAxTok = GLOB_VAR + GVAR_ANT ; ReplaceString( sAuxAxTok, "N", ToString( i)) ;
|
||||
if ( m_pMachine->LuaGetGlobVar( sAuxAxTok, sName) &&
|
||||
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
|
||||
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
|
||||
m_pMachine->GetAxisPos( sName, dVal) &&
|
||||
m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
|
||||
m_AuxAxesName.emplace_back( sName) ;
|
||||
|
||||
Reference in New Issue
Block a user