EgtMachKernel 2.6b4 :
- in simulazione aggiunti eventi Init e Exit a cui possono rispondere le funzioni lua OnSimulInit e OnSimulExit.
This commit is contained in:
+44
-8
@@ -61,6 +61,7 @@ Simulator::Simulator( void)
|
||||
m_pGeomDB = nullptr ;
|
||||
m_pMachine = nullptr ;
|
||||
m_pPerfCnt = nullptr ;
|
||||
m_nStatus = SIS_CREATED ;
|
||||
m_dStep = MID_STEP ;
|
||||
m_nUiStatus = MCH_UISIM_NULL ;
|
||||
m_nOpId = GDB_ID_NULL ;
|
||||
@@ -92,6 +93,8 @@ Simulator::~Simulator( void)
|
||||
{
|
||||
// porto la macchina in posizione home
|
||||
GoHome() ;
|
||||
// gestione evento uscita dal simulatore
|
||||
OnExit() ;
|
||||
// rimuovo tavola variabili globali
|
||||
m_pMachine->LuaResetGlobVar( GLOB_VAR) ;
|
||||
// rimuovo performance counter
|
||||
@@ -113,6 +116,7 @@ Simulator::Init( MachMgr* pMchMgr)
|
||||
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
|
||||
m_pMachine = m_pMchMgr->GetCurrMachine() ;
|
||||
m_pPerfCnt = new PerformanceCounter ;
|
||||
m_nStatus = SIS_INITIALIZED ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -129,8 +133,8 @@ Simulator::Start( bool bFirst)
|
||||
|
||||
bool bOk = true ;
|
||||
|
||||
// Se avvio vero
|
||||
if ( bFirst) {
|
||||
// Se appena entrati in simulazione
|
||||
if ( m_nStatus == SIS_INITIALIZED) {
|
||||
// Forzo aggiornamento attrezzaggio della macchinata
|
||||
if ( ! m_pMchMgr->UpdateCurrSetup())
|
||||
bOk = false ;
|
||||
@@ -167,8 +171,15 @@ Simulator::Start( bool bFirst)
|
||||
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_VER, GetEMkVer()) ;
|
||||
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MACHNAME, m_pMachine->GetMachineName()) ;
|
||||
|
||||
// Richiamo funzione su avvio simulazione
|
||||
if ( ! OnStart( bFirst))
|
||||
// Se appena entrati in simulazione
|
||||
if ( m_nStatus == SIS_INITIALIZED) {
|
||||
if ( ! OnInit())
|
||||
bOk = false ;
|
||||
m_nStatus = SIS_READYTOSTART ;
|
||||
}
|
||||
|
||||
// Richiamo funzione per evento avvio simulazione
|
||||
if ( ! OnProgramStart( bFirst))
|
||||
bOk = false ;
|
||||
|
||||
// Arrivo alla preparazione per la prima lavorazione
|
||||
@@ -193,6 +204,9 @@ Simulator::Start( bool bFirst)
|
||||
if ( m_pPerfCnt != nullptr)
|
||||
m_pPerfCnt->Start() ;
|
||||
|
||||
// Imposto lo stato interno
|
||||
m_nStatus = ( bOk ? SIS_READYTORUN : SIS_READYTOSTART) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -248,7 +262,7 @@ bool
|
||||
Simulator::Move( int& nStatus)
|
||||
{
|
||||
// Verifiche
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr) {
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr || m_nStatus != SIS_READYTORUN) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
@@ -292,7 +306,7 @@ Simulator::Move( int& nStatus)
|
||||
return false ;
|
||||
// se non ce ne sono altre, sono alla fine
|
||||
if ( m_nOpId == GDB_ID_NULL) {
|
||||
OnEnd() ;
|
||||
OnProgramEnd() ;
|
||||
nStatus = MCH_SIM_END ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1474,7 +1488,29 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnStart( bool bFirst)
|
||||
Simulator::OnInit( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_INIT))
|
||||
return true ;
|
||||
// chiamo la funzione di ingresso nella simulazione
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_INIT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnExit( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_EXIT))
|
||||
return true ;
|
||||
// chiamo la funzione di uscita dalla simulazione
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_EXIT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnProgramStart( bool bFirst)
|
||||
{
|
||||
// assegno flag inizio simulazione
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIM1ST, bFirst) ;
|
||||
@@ -1488,7 +1524,7 @@ Simulator::OnStart( bool bFirst)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnEnd( void)
|
||||
Simulator::OnProgramEnd( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_END))
|
||||
|
||||
Reference in New Issue
Block a user