EgtMachKernel :
- modifiche per simulazione MP.
This commit is contained in:
+136
-129
@@ -79,7 +79,7 @@ SimulatorMP::SimulatorMP( void)
|
||||
m_nEntId = GDB_ID_NULL ;
|
||||
m_nEntInd = 0 ;
|
||||
m_dCoeff = 0 ;
|
||||
m_bChangedTool = false ;
|
||||
m_nChangeTool = 0 ;
|
||||
m_nAuxSTot = 0 ;
|
||||
m_nAuxSInd = 0 ;
|
||||
m_nAuxETot = 0 ;
|
||||
@@ -131,7 +131,6 @@ SimulatorMP::Init( MachMgr* pMchMgr)
|
||||
m_nStatus = SIS_INITIALIZED ;
|
||||
if ( ExeGetDebugLevel() >= 1)
|
||||
LOG_INFO( GetEMkLogger(), " * SimulatorMP *")
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -164,7 +163,7 @@ SimulatorMP::Start( bool bFirst)
|
||||
m_nExit = 0 ;
|
||||
m_dTDiam = 0 ;
|
||||
m_bCutOnTip = false ;
|
||||
m_bChangedTool = false ;
|
||||
m_nChangeTool = 0 ;
|
||||
ResetInterpolation() ;
|
||||
ResetAxes() ;
|
||||
ResetAuxAxes() ;
|
||||
@@ -201,7 +200,7 @@ SimulatorMP::Start( bool bFirst)
|
||||
|
||||
// Arrivo alla preparazione per la prima lavorazione
|
||||
int nStatus ;
|
||||
if ( ! FindAndManageOperationStart( true, bFirst, m_bChangedTool, nStatus) && nStatus != MCH_SIM_STOP)
|
||||
if ( ! FindAndManageOperationStart( true, bFirst, m_nChangeTool, nStatus) && nStatus != MCH_SIM_STOP)
|
||||
bOk = false ;
|
||||
// se sono ancora su disposizione
|
||||
if ( m_pMchMgr->GetOperationType( m_nOpId) == OPER_DISP) {
|
||||
@@ -212,6 +211,8 @@ SimulatorMP::Start( bool bFirst)
|
||||
while ( m_nAuxSInd < m_nAuxSTot) {
|
||||
if ( ! ManagePathStartAux( nStatus))
|
||||
return false ;
|
||||
if ( ! ExecAllCmdData( nStatus))
|
||||
return false ;
|
||||
}
|
||||
// aggiornamento assi per eventuali teste caricate
|
||||
UpdateAxes() ;
|
||||
@@ -288,7 +289,7 @@ SimulatorMP::Move( int& nStatus)
|
||||
}
|
||||
|
||||
// Recupero tempo impiegato (calcolo + visualizzazione precedenti)
|
||||
if ( m_pPerfCnt != nullptr && ExeGetDebugLevel() >= 5) {
|
||||
if ( m_pPerfCnt != nullptr && ExeGetDebugLevel() >= 8) {
|
||||
double dElapsed = m_pPerfCnt->Stop() ;
|
||||
string sOut = "Elapsed=" + ToString( dElapsed, 1) ;
|
||||
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
@@ -305,29 +306,38 @@ SimulatorMP::Move( int& nStatus)
|
||||
m_dCoeff = 0 ;
|
||||
}
|
||||
|
||||
// Se comandi in lista ancora da eseguire, procedo con uno step
|
||||
if ( m_nCmdInd < int( m_CmdData.size())) {
|
||||
return ExecCmdData( nStatus) ;
|
||||
}
|
||||
else {
|
||||
m_CmdData.clear() ;
|
||||
m_nCmdInd = 0 ;
|
||||
}
|
||||
|
||||
// Se appena arrivato alla fine di un percorso di lavoro (verifico anche completamento dei comandi aux di start per path vuote)
|
||||
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0 && m_nAuxSInd >= m_nAuxSTot) {
|
||||
if ( m_nChangeTool == 0 && m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0 && m_nAuxSInd >= m_nAuxSTot) {
|
||||
// gestione fine percorso di lavoro
|
||||
if ( ! ManagePathEnd( nStatus))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Se alla fine del percorso dopo esecuzione azioni ausiliarie (verifico anche completamento dei comandi aux di start per path vuote)
|
||||
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot && m_nAuxSInd >= m_nAuxSTot) {
|
||||
if ( m_nChangeTool == 0 && m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot && m_nAuxSInd >= m_nAuxSTot) {
|
||||
// ricerca e gestione inizio percorso di lavoro
|
||||
if ( ! FindAndManagePathStart( nStatus))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Se arrivato alla fine di una operazione o appena scaricato utensile
|
||||
if ( m_nCLPathId == GDB_ID_NULL || m_bChangedTool) {
|
||||
if ( m_nCLPathId == GDB_ID_NULL || m_nChangeTool != 0) {
|
||||
// gestione fine operazione
|
||||
if ( m_nCLPathId == GDB_ID_NULL && ! ManageOperationEnd( nStatus))
|
||||
if ( m_nChangeTool == 0 && m_nCLPathId == GDB_ID_NULL && ! ManageOperationEnd( nStatus))
|
||||
return false ;
|
||||
// ricerca e gestione nuova operazione
|
||||
if ( ! FindAndManageOperationStart( false, false, m_bChangedTool, nStatus))
|
||||
if ( ! FindAndManageOperationStart( false, false, m_nChangeTool, nStatus))
|
||||
return false ;
|
||||
if ( m_bChangedTool)
|
||||
if ( m_nChangeTool != 0)
|
||||
return true ;
|
||||
// se non ce ne sono altre, sono alla fine
|
||||
if ( m_nOpId == GDB_ID_NULL) {
|
||||
@@ -340,15 +350,6 @@ SimulatorMP::Move( int& nStatus)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Se comandi in lista ancora da eseguire, procedo con uno step
|
||||
if ( m_nCmdInd < int( m_CmdData.size())) {
|
||||
return ExecCmdData( nStatus) ;
|
||||
}
|
||||
else {
|
||||
m_CmdData.clear() ;
|
||||
m_nCmdInd = 0 ;
|
||||
}
|
||||
|
||||
// Se sto eseguendo i movimenti ausiliari di inizio percorso
|
||||
if ( m_nAuxSInd < m_nAuxSTot)
|
||||
return ManagePathStartAux( nStatus) ;
|
||||
@@ -357,6 +358,10 @@ SimulatorMP::Move( int& nStatus)
|
||||
if ( m_nAuxEInd < m_nAuxETot)
|
||||
return ManagePathEndAux( nStatus) ;
|
||||
|
||||
// Se ci sono comandi da eseguire
|
||||
if ( ! m_CmdData.empty())
|
||||
return true ;
|
||||
|
||||
// Gestione movimento assi
|
||||
return ManageMove( nStatus) ;
|
||||
}
|
||||
@@ -498,7 +503,7 @@ SimulatorMP::GoHome( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::UpdateMachiningTool( bool bFirst, bool& bDeselected, int& nErr)
|
||||
SimulatorMP::UpdateMachiningTool( bool bFirst, int& nChangeTool, int& nErr)
|
||||
{
|
||||
// Reset stato
|
||||
nErr = ERR_NONE ;
|
||||
@@ -526,11 +531,11 @@ SimulatorMP::UpdateMachiningTool( bool bFirst, bool& bDeselected, int& nErr)
|
||||
// verifico se cambierà
|
||||
bool bDiffTool = ( sTool != m_sTool) ;
|
||||
// se cambierà ed esiste il corrente, lo scarico
|
||||
if ( bDiffTool && ! m_sTool.empty() && ! bDeselected) {
|
||||
if ( bDiffTool && ! m_sTool.empty() && nChangeTool == 0) {
|
||||
// eventuale lancio script per scarico utensile
|
||||
int nCurrErr ;
|
||||
if ( OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
|
||||
bDeselected = true ;
|
||||
nChangeTool = 1 ;
|
||||
return true ;
|
||||
}
|
||||
else {
|
||||
@@ -539,7 +544,6 @@ SimulatorMP::UpdateMachiningTool( bool bFirst, bool& bDeselected, int& nErr)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
bDeselected = false ;
|
||||
// se prima volta, pulisco la testa
|
||||
if ( bFirst)
|
||||
m_pMchMgr->ResetHeadSet( sHead) ;
|
||||
@@ -562,14 +566,17 @@ SimulatorMP::UpdateMachiningTool( bool bFirst, bool& bDeselected, int& nErr)
|
||||
if ( ! UpdateAxes())
|
||||
return false ;
|
||||
// se cambiato oppure prima volta, lancio lo script di selezione
|
||||
if ( bDiffTool || bFirst) {
|
||||
if ( ( bDiffTool || bFirst) && nChangeTool != 2) {
|
||||
int nCurrErr ;
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
|
||||
nErr = ( nErr != ERR_NONE ? nErr : nCurrErr) ;
|
||||
if ( nCurrErr != ERR_COLLISION)
|
||||
return false ;
|
||||
}
|
||||
nChangeTool = 2 ;
|
||||
return ( nErr == ERR_NONE) ;
|
||||
}
|
||||
nChangeTool = 0 ;
|
||||
return ( nErr == ERR_NONE) ;
|
||||
}
|
||||
|
||||
@@ -704,13 +711,13 @@ SimulatorMP::ResetAuxAxes( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::FindAndManageOperationStart( bool bStart, bool bFirst, bool& bChangedTool, int& nStatus)
|
||||
SimulatorMP::FindAndManageOperationStart( bool bStart, bool bFirst, int& nChangeTool, int& nStatus)
|
||||
{
|
||||
// verifico parametri
|
||||
if ( ! bStart)
|
||||
bFirst = false ;
|
||||
// recupero la nuova operazione
|
||||
if ( ! bChangedTool) {
|
||||
if ( nChangeTool == 0) {
|
||||
if ( bStart) {
|
||||
m_nOpId = m_pMchMgr->GetFirstActiveOperation() ;
|
||||
m_nOpInd = 0 ;
|
||||
@@ -723,16 +730,15 @@ SimulatorMP::FindAndManageOperationStart( bool bStart, bool bFirst, bool& bChang
|
||||
// se lavorazione valida
|
||||
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
if ( pMch != nullptr && ! pMch->IsEmpty()) {
|
||||
bool bOk = true ;
|
||||
// aggiorno utensile e assi conseguenti
|
||||
int nErr ;
|
||||
if ( ! UpdateMachiningTool( bFirst, bChangedTool, nErr)) {
|
||||
if ( ! UpdateMachiningTool( bFirst, nChangeTool, nErr)) {
|
||||
string sOut = "Err=" + ToString( nErr) ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
nStatus = CalcStatusOnError( nErr) ;
|
||||
return false ;
|
||||
}
|
||||
if ( bChangedTool)
|
||||
if ( nChangeTool != 0)
|
||||
return true ;
|
||||
++ m_nOpInd ;
|
||||
// imposto la lavorazione come corrente
|
||||
@@ -1612,24 +1618,42 @@ SimulatorMP::ResetCollisionMark( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::OnInit( void)
|
||||
SimulatorMP::CallFunction( const string& sFun, bool bSetRecord, bool bSetModifiedOff)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_INIT))
|
||||
if ( ! m_pMachine->LuaExistsFunction( sFun))
|
||||
return true ;
|
||||
// se richiesto, imposto modalità registrazione
|
||||
if ( bSetRecord && ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RECORD, true))
|
||||
return false ;
|
||||
// eventuale log di inizio esecuzione
|
||||
if ( ExeGetDebugLevel() >= 6) {
|
||||
string sOut = "** " + sFun ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
}
|
||||
// chiamo la funzione di inizio disposizione
|
||||
bool bOk = m_pMachine->LuaCallFunction( sFun, bSetModifiedOff) ;
|
||||
// se necessario, annullo stato registrazione
|
||||
if ( bSetRecord && ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RECORD, false))
|
||||
return false ;
|
||||
// restituisco stato esecuzione
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::OnInit( void)
|
||||
{
|
||||
// chiamo la funzione di ingresso nella simulazione
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_INIT) ;
|
||||
return CallFunction( ON_SIMUL_INIT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::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) ;
|
||||
return CallFunction( ON_SIMUL_EXIT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1638,11 +1662,8 @@ SimulatorMP::OnProgramStart( bool bFirst)
|
||||
{
|
||||
// assegno flag inizio simulazione
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIM1ST, bFirst) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_START))
|
||||
return true ;
|
||||
// chiamo la funzione di inizio simulazione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_START) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_START) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -1650,11 +1671,8 @@ SimulatorMP::OnProgramStart( bool bFirst)
|
||||
bool
|
||||
SimulatorMP::OnProgramEnd( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_END))
|
||||
return true ;
|
||||
// chiamo la funzione di fine simulazione
|
||||
return m_pMachine->LuaCallFunction( ON_SIMUL_END) ;
|
||||
return CallFunction( ON_SIMUL_END) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1673,11 +1691,8 @@ SimulatorMP::OnDispositionStarting( int nOpId, int nOpInd, int nPhase,
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ;
|
||||
// assegno flag disposizione con operazioni manuali
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SBH, bSomeByHand) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_STARTING))
|
||||
return true ;
|
||||
// chiamo la funzione di inizio disposizione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_STARTING) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_DISPOSITION_STARTING) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
return bOk ;
|
||||
@@ -1700,11 +1715,8 @@ SimulatorMP::OnDispositionStart( int nOpId, int nOpInd, int nPhase,
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ;
|
||||
// assegno flag disposizione con operazioni manuali
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SBH, bSomeByHand) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_START))
|
||||
return true ;
|
||||
// chiamo la funzione di inizio disposizione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_START) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_DISPOSITION_START) ;
|
||||
// recupero i dati di ritorno
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_VMILL, m_VmId) ;
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_CODET, m_CdId) ;
|
||||
@@ -1717,11 +1729,8 @@ SimulatorMP::OnDispositionStart( int nOpId, int nOpInd, int nPhase,
|
||||
bool
|
||||
SimulatorMP::OnDispositionEnd( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_END))
|
||||
return true ;
|
||||
// chiamo la funzione di fine disposizione
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_END) ;
|
||||
bool bOk = CallFunction( ON_SIMUL_DISPOSITION_END) ;
|
||||
// recupero i dati di ritorno
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_VMILL, m_VmId) ;
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_CODET, m_CdId) ;
|
||||
@@ -1766,11 +1775,8 @@ SimulatorMP::OnToolSelect( const string& sTool, const string& sHead, int nExit,
|
||||
// reset errore
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr))
|
||||
return false ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT))
|
||||
return true ;
|
||||
// chiamo la funzione di selezione utensile
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_SELECT) ;
|
||||
bool bOk = CallFunction( ON_SIMUL_TOOL_SELECT, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
// recupero dati per verifica collisione
|
||||
@@ -1840,7 +1846,7 @@ SimulatorMP::OnToolDeselect( const string& sNextTool, const string& sNextHead, i
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
|
||||
return bOk ;
|
||||
// chiamo la funzione di deselezione utensile
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_DESELECT) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_TOOL_DESELECT, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
// verifico codice di errore
|
||||
@@ -1865,11 +1871,8 @@ SimulatorMP::OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, cons
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MAXMIN, vAxMin) ||
|
||||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MAXMAX, vAxMax))
|
||||
return false ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
|
||||
return true ;
|
||||
// chiamo la funzione di inizio disposizione
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
|
||||
// chiamo la funzione di inizio lavorazione
|
||||
bool bOk = CallFunction( ON_SIMUL_MACHINING_START, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
return bOk ;
|
||||
@@ -1879,11 +1882,8 @@ SimulatorMP::OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, cons
|
||||
bool
|
||||
SimulatorMP::OnMachiningEnd( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_END))
|
||||
return true ;
|
||||
// chiamo la funzione di fine lavorazione
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_END) ;
|
||||
bool bOk = CallFunction( ON_SIMUL_MACHINING_END, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
return bOk ;
|
||||
@@ -1912,11 +1912,8 @@ SimulatorMP::OnPathStart( int nClPathId, int nClPathInd, int nAS, const Point3d&
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PAXMAX, vAxMax) ;
|
||||
// assegno la massima elevazione
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ELEV, dElev) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_START))
|
||||
return bOk ;
|
||||
// chiamo la funzione di inizio percorso di lavorazione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_START) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_PATH_START, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
return bOk ;
|
||||
@@ -1928,11 +1925,8 @@ SimulatorMP::OnPathEnd( int nAE)
|
||||
{
|
||||
// assegno numero di dati ausiliari finali
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXTOT, nAE) ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_END))
|
||||
return bOk ;
|
||||
// chiamo la funzione di fine percorso di lavorazione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_END) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_PATH_END, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
return bOk ;
|
||||
@@ -1944,15 +1938,12 @@ SimulatorMP::OnPathStartAux( int nInd, const string& sAS, int& nErr)
|
||||
{
|
||||
// reset stato di errore da script
|
||||
nErr = ERR_NONE ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_START_AUX))
|
||||
return true ;
|
||||
// assegno indice, valore dato ausiliario e resetto errore
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAS) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
|
||||
// chiamo la funzione di evento ausiliario all'inizio del percorso
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_START_AUX) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_PATH_START_AUX, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
// verifico codice di errore
|
||||
@@ -1966,15 +1957,12 @@ SimulatorMP::OnPathEndAux( int nInd, const string& sAE, int& nErr)
|
||||
{
|
||||
// reset stato di errore da script
|
||||
nErr = ERR_NONE ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_END_AUX))
|
||||
return true ;
|
||||
// assegno indice, valore dato ausiliario e resetto errore
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAE) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
|
||||
// chiamo la funzione di evento ausiliario alla fine del percorso
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_END_AUX) ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_PATH_END_AUX, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
// verifico codice di errore
|
||||
@@ -2037,30 +2025,20 @@ SimulatorMP::OnMoveStart( const CamData* pCamData, const CamData* pNextCamData,
|
||||
// reset numero assi ausiliari
|
||||
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_AUXAXES) ;
|
||||
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START)) {
|
||||
ResetAuxAxes() ;
|
||||
return bOk ;
|
||||
}
|
||||
// chiamo la funzione
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_START) ;
|
||||
// con errore, esco
|
||||
if ( ! bOk) {
|
||||
ResetAuxAxes() ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico codice di errore
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
|
||||
if ( nErr != ERR_NONE)
|
||||
return false ;
|
||||
bOk = bOk && CallFunction( ON_SIMUL_MOVE_START, true) ;
|
||||
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
|
||||
// reset assi ausiliari
|
||||
ResetAuxAxes() ;
|
||||
|
||||
// verifico codice di errore
|
||||
bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
|
||||
// con errore, esco
|
||||
if ( ! bOk || nErr != ERR_NONE)
|
||||
return false ;
|
||||
|
||||
// recupero i dati di ritorno
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_MASK, m_nAxesMask) ;
|
||||
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ENABAXES, m_bEnabAxes))
|
||||
@@ -2144,14 +2122,11 @@ SimulatorMP::OnMoveEnd( int& nErr)
|
||||
{
|
||||
// reset stato di errore da script
|
||||
nErr = ERR_NONE ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_END))
|
||||
return true ;
|
||||
// reset errore
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr))
|
||||
return false ;
|
||||
// chiamo la funzione
|
||||
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_END) ;
|
||||
bool bOk = CallFunction( ON_SIMUL_MOVE_END, true) ;
|
||||
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
|
||||
UpdateAxesPos() ;
|
||||
// verifico codice di errore
|
||||
@@ -2165,9 +2140,6 @@ SimulatorMP::OnCollision( int nCdInd, int nObjInd, int& nErr)
|
||||
{
|
||||
// reset stato di errore da script
|
||||
nErr = ERR_NONE ;
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_COLLISION))
|
||||
return true ;
|
||||
// reset stato di errore
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr))
|
||||
return false ;
|
||||
@@ -2177,7 +2149,7 @@ SimulatorMP::OnCollision( int nCdInd, int nObjInd, int& nErr)
|
||||
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMCOBIND, m_CollObj[nObjInd].nInd))
|
||||
return false ;
|
||||
// chiamo la funzione
|
||||
if ( ! m_pMachine->LuaCallFunction( ON_SIMUL_COLLISION))
|
||||
if ( ! CallFunction( ON_SIMUL_COLLISION))
|
||||
return false ;
|
||||
// verifico codice di errore
|
||||
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
|
||||
@@ -2199,11 +2171,8 @@ SimulatorMP::OnCollision( int nCdInd, int nObjInd, int& nErr)
|
||||
bool
|
||||
SimulatorMP::OnResetMachine( void)
|
||||
{
|
||||
// verifico esistenza funzione
|
||||
if ( ! m_pMachine->LuaExistsFunction( ON_RESET_MACHINE))
|
||||
return true ;
|
||||
// eseguo reset macchina
|
||||
return m_pMachine->LuaCallFunction( ON_RESET_MACHINE) ;
|
||||
return CallFunction( ON_RESET_MACHINE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -2361,7 +2330,7 @@ SimulatorMP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
|
||||
// Salvo i dati di movimento
|
||||
m_CmdData.emplace_back( nMoveType, vAxNaEpSt) ;
|
||||
// Log dati
|
||||
if ( ExeGetDebugLevel() >= 4) {
|
||||
if ( ExeGetDebugLevel() >= 6) {
|
||||
string sOut = "Save=SimulMoveAxes," + ToString( nMoveType) ;
|
||||
for ( int i = 0 ; i < int( vAxNaEpSt.size()) ; ++ i)
|
||||
sOut += "," + vAxNaEpSt[i].sName +
|
||||
@@ -2375,13 +2344,15 @@ SimulatorMP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SimulatorMP::SaveCmd( int nType, int nPar, const string& sPar)
|
||||
SimulatorMP::SaveCmd( int nType, int nPar, const string& sPar, const string& sPar2)
|
||||
{
|
||||
// Salvo il comando
|
||||
m_CmdData.emplace_back( nType, nPar, sPar) ;
|
||||
m_CmdData.emplace_back( nType, nPar, sPar, sPar2) ;
|
||||
// Log dati
|
||||
if ( ExeGetDebugLevel() >= 4) {
|
||||
string sOut = "Save=SimulSaveCmd," + ToString( nType) + "," + ToString( nPar) + "," + sPar ;
|
||||
if ( ExeGetDebugLevel() >= 6) {
|
||||
string sOut = "Save=SimulCmd," + ToString( nType) + "," + ToString( nPar) + "," + sPar ;
|
||||
if ( ! IsEmptyOrSpaces( sPar2))
|
||||
sOut += "," + sPar2 ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
}
|
||||
return false ;
|
||||
@@ -2395,17 +2366,21 @@ SimulatorMP::ExecCmdData( int& nStatus)
|
||||
auto& CmdCurr = m_CmdData[m_nCmdInd] ;
|
||||
|
||||
// Stampe di debug
|
||||
if ( ExeGetDebugLevel() >= 4) {
|
||||
if ( ExeGetDebugLevel() >= 6) {
|
||||
if ( CmdCurr.nType == 1) {
|
||||
string sOut = "Cmd=SimulMoveAxes," + ToString( CmdCurr.nMoveType) ;
|
||||
for ( int i = 0 ; i < int( CmdCurr.vAxNaEpSt.size()) ; ++ i)
|
||||
sOut += "," + CmdCurr.vAxNaEpSt[i].sName +
|
||||
"," + ToString( CmdCurr.vAxNaEpSt[i].dEndPos, 3) +
|
||||
"," + ToString( CmdCurr.vAxNaEpSt[i].dStep, 3) ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
if ( m_dCmdCoeff < EPS_ZERO) {
|
||||
string sOut = "Exec=SimulMoveAxes," + ToString( CmdCurr.nMoveType) ;
|
||||
for ( int i = 0 ; i < int( CmdCurr.vAxNaEpSt.size()) ; ++ i)
|
||||
sOut += "," + CmdCurr.vAxNaEpSt[i].sName +
|
||||
"," + ToString( CmdCurr.vAxNaEpSt[i].dEndPos, 3) +
|
||||
"," + ToString( CmdCurr.vAxNaEpSt[i].dStep, 3) ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
}
|
||||
}
|
||||
else {
|
||||
string sOut = "Cmd=SimulSaveCmd," + ToString( CmdCurr.nType) + "," + ToString( CmdCurr.nPar) + "," + CmdCurr.sPar ;
|
||||
string sOut = "Exec=SimulCmd," + ToString( CmdCurr.nType) + "," + ToString( CmdCurr.nPar) + "," + CmdCurr.sPar ;
|
||||
if ( ! IsEmptyOrSpaces( CmdCurr.sPar2))
|
||||
sOut += "," + CmdCurr.sPar2 ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
}
|
||||
}
|
||||
@@ -2535,6 +2510,37 @@ SimulatorMP::ExecCmdData( int& nStatus)
|
||||
m_nCmdInd += 1 ;
|
||||
m_dCmdCoeff = 0 ;
|
||||
}
|
||||
// eseguo assegnazione di variabile globale
|
||||
else if ( CmdCurr.nType == 4) {
|
||||
bool bOk = false ;
|
||||
switch ( CmdCurr.nPar) {
|
||||
case 0 :
|
||||
bOk = m_pMachine->LuaResetGlobVar( CmdCurr.sPar) ;
|
||||
break ;
|
||||
case 1 :
|
||||
{ bool bVal = ( CmdCurr.sPar2 == "1") ;
|
||||
bOk = m_pMachine->LuaSetGlobVar( CmdCurr.sPar, bVal) ;
|
||||
} break ;
|
||||
case 2 :
|
||||
{ int nVal ; FromString( CmdCurr.sPar2, nVal) ;
|
||||
bOk = m_pMachine->LuaSetGlobVar( CmdCurr.sPar, nVal) ;
|
||||
} break ;
|
||||
case 3 :
|
||||
{ double dVal ; FromString( CmdCurr.sPar2, dVal) ;
|
||||
bOk = m_pMachine->LuaSetGlobVar( CmdCurr.sPar, dVal) ;
|
||||
} break ;
|
||||
case 4 :
|
||||
bOk = m_pMachine->LuaSetGlobVar( CmdCurr.sPar, CmdCurr.sPar2) ;
|
||||
break ;
|
||||
}
|
||||
if ( ! bOk) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
// Aggiorno indice comandi eseguiti
|
||||
m_nCmdInd += 1 ;
|
||||
m_dCmdCoeff = 0 ;
|
||||
}
|
||||
// eseguo chiamata funzione
|
||||
else if ( CmdCurr.nType == 5) {
|
||||
// chiamo la funzione
|
||||
@@ -2549,6 +2555,7 @@ SimulatorMP::ExecCmdData( int& nStatus)
|
||||
// altrimenti errore
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
LOG_DBG_INFO( GetEMkLogger(), " --> ExecCmdData nType Error <--")
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user