EgtMachKernel 1.6r7 :
- possibilità di collegare e scollegare fixtures da gruppi macchina (come i grezzi) - aggiunto richiamo funzione script OnSetHead.
This commit is contained in:
+74
-15
@@ -431,6 +431,9 @@ Simulator::SetStep( double dStep)
|
||||
bool
|
||||
Simulator::GoHome( void)
|
||||
{
|
||||
// controllo validità stato
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr)
|
||||
return false ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// porto la macchina in home
|
||||
@@ -443,6 +446,9 @@ Simulator::GoHome( void)
|
||||
bool
|
||||
Simulator::Stop( void)
|
||||
{
|
||||
// controllo validità stato
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr)
|
||||
return false ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// porto la macchina in home
|
||||
@@ -464,9 +470,16 @@ 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
|
||||
string sTool ;
|
||||
if ( ! pMch->GetParam( MPA_TOOL, sTool))
|
||||
return false ;
|
||||
// se cambierà e non forzato (inizio), scarico l'utensile corrente
|
||||
if ( sTool != m_sTool && ! bForced) {
|
||||
// eventuale lancio script per scarico utensile
|
||||
if ( ! OnToolDeselect())
|
||||
return false ;
|
||||
}
|
||||
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
|
||||
return false ;
|
||||
// se cambiato oppure forzato, attivo l'utensile della lavorazione
|
||||
@@ -480,10 +493,8 @@ Simulator::UpdateTool( bool bForced)
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
return false ;
|
||||
m_sTool = sTool ;
|
||||
// imposto variabili per script
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit))
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
@@ -491,6 +502,9 @@ 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) ;
|
||||
@@ -498,10 +512,8 @@ Simulator::UpdateTool( bool bForced)
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
return false ;
|
||||
m_sTool = sTool ;
|
||||
// imposto variabili per script
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit))
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
@@ -529,6 +541,24 @@ Simulator::UpdateAxes( void)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::UpdateAxesPos( void)
|
||||
{
|
||||
// Macchina corrente
|
||||
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMachine == nullptr)
|
||||
return false ;
|
||||
// Aggiorno la posizione corrente degli assi macchina attivi
|
||||
m_AxesVal.clear() ;
|
||||
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
|
||||
double dVal ;
|
||||
m_pMachine->GetAxisPos( m_AxesName[i], dVal) ;
|
||||
m_AxesVal.emplace_back( dVal) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnOperationEnd( void)
|
||||
@@ -580,6 +610,33 @@ Simulator::OnDispositionEnd( void)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
|
||||
{
|
||||
// assegno dati
|
||||
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 ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT))
|
||||
return true ;
|
||||
// chiamo la funzione di selezione utensile
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_SELECT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnToolDeselect( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
|
||||
return true ;
|
||||
// chiamo la funzione di deselezione utensile
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_DESELECT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::OnMachiningStart( int nOpId, int nOpInd)
|
||||
@@ -588,11 +645,11 @@ Simulator::OnMachiningStart( int nOpId, int nOpInd)
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
|
||||
return true ;
|
||||
// assegno identificativo e indice lavorazione
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd) ;
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd))
|
||||
return false ;
|
||||
// chiamo la funzione di inizio disposizione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
|
||||
return bOk ;
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -667,12 +724,15 @@ Simulator::OnMoveStart( const CamData* pCamData)
|
||||
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START))
|
||||
return true ;
|
||||
return bOk ;
|
||||
// chiamo la funzione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_START) ;
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
|
||||
// forzo aggiornamento posizione assi (possono essere stati mssi nello script)
|
||||
UpdateAxesPos() ;
|
||||
|
||||
// recupero i dati di ritorno
|
||||
int nNumAuxAxes = 0 ;
|
||||
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_AUXAXES, nNumAuxAxes) || nNumAuxAxes == 0)
|
||||
@@ -718,6 +778,5 @@ Simulator::OnResetMachine( void)
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_RESET_MACHINE))
|
||||
return true ;
|
||||
// eseguo reset macchina
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_RESET_MACHINE) ;
|
||||
return bOk ;
|
||||
return m_pMachine->LuaCallFunction( ON_RESET_MACHINE) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user