EgtMachKernel :

- modifiche alla simulazione.
This commit is contained in:
Dario Sassi
2017-01-05 16:37:36 +00:00
parent ab392fb4e2
commit c1b66b4477
3 changed files with 103 additions and 3 deletions
+95 -3
View File
@@ -342,6 +342,7 @@ Simulator::UpdateTool( bool bForced)
bool
Simulator::UpdateAxes( void)
{
ResetAxes() ;
// Macchina corrente
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
if ( pMachine == nullptr)
@@ -351,9 +352,6 @@ Simulator::UpdateAxes( void)
! pMachine->GetAllCurrAxesToken( m_AxesToken))
return false ;
// Aggiorno flag invertito, il tipo e la posizione corrente degli assi macchina attivi
m_AxesInvert.clear() ;
m_AxesLinear.clear() ;
m_AxesVal.clear() ;
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
bool bInvert ;
m_pMachine->GetAxisInvert( m_AxesName[i], bInvert) ;
@@ -393,7 +391,9 @@ Simulator::ResetAxes( void)
// pulisco dati assi
m_AxesName.clear() ;
m_AxesToken.clear() ;
m_AxesInvert.clear() ;
m_AxesLinear.clear() ;
m_AxesVal.clear() ;
return true ;
}
@@ -560,6 +560,9 @@ Simulator::FindAndManagePathStart( int& nStatus)
nStatus = MCH_SIM_ERR ;
return false ;
}
// gestione eventuali eventi ausiliari prima di percorso
if ( ! ManagePathStartAuxes( nStatus))
return false ;
}
return true ;
@@ -569,6 +572,9 @@ Simulator::FindAndManagePathStart( int& nStatus)
bool
Simulator::ManagePathEnd( int& nStatus)
{
// gestione eventuali eventi ausiliari dopo percorso
if ( ! ManagePathEndAuxes( nStatus))
return false ;
// richiamo gestione evento fine percorso di lavoro
if ( ! OnPathEnd()) {
nStatus = MCH_SIM_ERR ;
@@ -577,6 +583,58 @@ Simulator::ManagePathEnd( int& nStatus)
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::ManagePathStartAuxes( int& nStatus)
{
// recupero il numero di eventi ausiliari
int nAS ;
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, "AS#", nAS) || nAS == 0)
return true ;
// processo gli eventi
for ( int i = 1 ; i <= nAS ; ++ i) {
// recupero i dati per l'evento
string sAS ;
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, "AS" + ToString( i), sAS)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
// richiamo gestione evento ausiliario prima di inizio percorso di lavoro
if ( ! OnPathStartAux( i, sAS)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::ManagePathEndAuxes( int& nStatus)
{
// recupero il numero di eventi ausiliari
int nAE ;
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, "AE#", nAE) || nAE == 0)
return true ;
// processo gli eventi
for ( int i = 1 ; i <= nAE ; ++ i) {
// recupero i dati per l'evento
string sAE ;
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, "AE" + ToString( i), sAE)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
// richiamo gestione evento ausiliario dopo fine percorso di lavoro
if ( ! OnPathEndAux( i, sAE)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::ManageMove( int& nStatus)
@@ -868,6 +926,40 @@ Simulator::OnPathEnd( void)
return bOk ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnPathStartAux( int nInd, const string& sAS)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_START_AUX))
return true ;
// assegno identificativo e indice percorso di lavorazione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAS) ;
// chiamo la funzione di evento ausiliario all'inizio del percorso
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_START_AUX) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnPathEndAux( int nInd, const string& sAE)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_END_AUX))
return true ;
// assegno identificativo e indice percorso di lavorazione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAE) ;
// chiamo la funzione di evento ausiliario alla fine del percorso
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_END_AUX) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnMoveStart( const CamData* pCamData)