EgtMachKernel :

- aggiunta gestione Invert su asse (per ora solo in simulazione)
- possibilità di invertire lavorazione fori passanti
- in simulazione e generazione aggiunti punti estremi di box lavorazione.
This commit is contained in:
Dario Sassi
2016-12-12 09:18:50 +00:00
parent a706c667aa
commit 329136f5ca
11 changed files with 149 additions and 25 deletions
+75 -16
View File
@@ -136,9 +136,13 @@ Simulator::Start( void)
// recupero versore estrusione associato al percorso (normale al piano di interpolazione)
Vector3d vtExtr ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_EXTR, vtExtr) ;
// recupero punti di minimo e massimo ingombro
Point3d ptMin, ptMax ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMIN, ptMin) ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMAX, ptMax) ;
// richiamo gestione evento inizio percorso di lavoro
++ m_nCLPathInd ;
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr))
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr, ptMin, ptMax))
return false ;
return true ;
@@ -183,9 +187,13 @@ Simulator::Move( int& nStatus)
// recupero versore estrusione associato al percorso (normale al piano di interpolazione)
Vector3d vtExtr ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_EXTR, vtExtr) ;
// recupero punti di minimo e massimo ingombro
Point3d ptMin, ptMax ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMIN, ptMin) ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMAX, ptMax) ;
// richiamo gestione evento inizio percorso di lavoro
++ m_nCLPathInd ;
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr)) {
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr, ptMin, ptMax)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
@@ -249,8 +257,6 @@ Simulator::Move( int& nStatus)
nStatus = MCH_SIM_ERR ;
return false ;
}
// recupero eventuali forzature assi da gestione inizio disposizione
UpdateAxesPos() ;
break ;
}
// altrimenti disposizione passiva
@@ -292,9 +298,13 @@ Simulator::Move( int& nStatus)
// recupero versore estrusione associato al percorso (normale al piano di interpolazione)
Vector3d vtExtr ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_EXTR, vtExtr) ;
// recupero punti di minimo e massimo ingombro
Point3d ptMin, ptMax ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMIN, ptMin) ;
m_pGeomDB->GetInfo( m_nCLPathId, KEY_PMAX, ptMax) ;
// richiamo gestione evento inizio percorso di lavoro
++ m_nCLPathInd ;
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr)) {
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, ptStart, vtExtr, ptMin, ptMax)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
@@ -429,7 +439,19 @@ Simulator::GetAxisInfoPos( int nI, string& sToken, bool& bLinear, double& dVal)
sToken = m_AuxAxesToken[ nI - nAxisCount] ;
bLinear = m_AuxAxesLinear[ nI - nAxisCount] ;
}
return m_pMchMgr->GetAxisPos( sName, dVal) ;
// recupero la posizione
if ( ! m_pMchMgr->GetAxisPos( sName, dVal))
return false ;
// verifico se da invertire
if ( nI < nAxisCount) {
if ( m_AxesInvert[nI])
dVal = - dVal ;
}
else {
if ( m_AuxAxesInvert[nI - nAxisCount])
dVal = - dVal ;
}
return true ;
}
//----------------------------------------------------------------------------
@@ -599,11 +621,16 @@ Simulator::UpdateAxes( void)
if ( ! pMachine->GetAllCurrAxesName( m_AxesName) ||
! pMachine->GetAllCurrAxesToken( m_AxesToken))
return false ;
// Aggiorno il tipo e la posizione corrente degli assi macchina attivi
// 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) ;
m_AxesInvert.push_back( bInvert) ;
bool bLinear ;
m_pMachine->GetAxisType(m_AxesName[i], bLinear) ;
m_pMachine->GetAxisType( m_AxesName[i], bLinear) ;
m_AxesLinear.push_back( bLinear) ;
double dVal ;
m_pMachine->GetAxisPos( m_AxesName[i], dVal) ;
@@ -670,6 +697,8 @@ Simulator::OnDispositionStarting( int nOpId, int nOpInd, int nPhase,
return true ;
// chiamo la funzione di inizio disposizione
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_STARTING) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
@@ -693,6 +722,8 @@ Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase,
return true ;
// chiamo la funzione di inizio disposizione
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_START) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
@@ -705,6 +736,8 @@ Simulator::OnDispositionEnd( void)
return true ;
// chiamo la funzione di fine disposizione
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_END) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
@@ -735,7 +768,10 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
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 bOk = m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_SELECT) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -750,9 +786,12 @@ Simulator::OnToolDeselect( const string& sNextHead, int nNextExit, const string&
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTTCPOS, sNextTcPos) ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
return true ;
return bOk ;
// chiamo la funzione di deselezione utensile
return m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_DESELECT) ;
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_DESELECT) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -767,7 +806,10 @@ Simulator::OnMachiningStart( int nOpId, int nOpInd)
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
return true ;
// chiamo la funzione di inizio disposizione
return m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -777,14 +819,17 @@ Simulator::OnMachiningEnd( void)
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_END))
return true ;
// chiamo la funzione di fine disposizione
// chiamo la funzione di fine lavorazione
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_END) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnPathStart( int nClPathId, int nClPathInd, const Point3d& ptStart, const Vector3d& vtExtr)
Simulator::OnPathStart( int nClPathId, int nClPathInd, const Point3d& ptStart, const Vector3d& vtExtr,
const Point3d& ptMin, const Point3d& ptMax)
{
// assegno identificativo e indice percorso di lavorazione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ;
@@ -792,11 +837,16 @@ Simulator::OnPathStart( int nClPathId, int nClPathInd, const Point3d& ptStart, c
// assegno punto iniziale e versore estrusione
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_START, ptStart) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXTR, vtExtr) ;
// assegno punti estremi dell'ingombro del percorso di lavorazione
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PMIN, ptMin) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PMAX, ptMax) ;
// 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) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
@@ -809,6 +859,8 @@ Simulator::OnPathEnd( void)
return true ;
// chiamo la funzione di fine percorso di lavorazione
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_PATH_END) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}
@@ -819,6 +871,7 @@ Simulator::OnMoveStart( const CamData* pCamData)
// pulisco dati assi ausiliari
m_AuxAxesName.clear() ;
m_AuxAxesToken.clear() ;
m_AuxAxesInvert.clear() ;
m_AuxAxesLinear.clear() ;
m_AuxAxesVal.clear() ;
m_AuxAxesEnd.clear() ;
@@ -853,7 +906,7 @@ Simulator::OnMoveStart( const CamData* pCamData)
if ( ! bOk)
return false ;
// forzo aggiornamento posizione assi (possono essere stati messi nello script)
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
// recupero i dati di ritorno
@@ -862,19 +915,23 @@ Simulator::OnMoveStart( const CamData* pCamData)
return true ;
m_AuxAxesName.reserve( nNumAuxAxes) ;
m_AuxAxesToken.reserve( nNumAuxAxes) ;
m_AuxAxesInvert.reserve( nNumAuxAxes) ;
m_AuxAxesLinear.reserve( nNumAuxAxes) ;
m_AuxAxesVal.reserve( nNumAuxAxes) ;
m_AuxAxesEnd.reserve( nNumAuxAxes) ;
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
string sName ; string sToken ; bool bLinear ; double dVal ; double dEnd ;
string sName ; string sToken ; bool bInvert ; bool bLinear ; double dVal ; double dEnd ;
string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ;
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
m_pMachine->GetAxisToken( sName, sToken) &&
m_pMachine->GetAxisInvert( sName, bInvert) &&
m_pMachine->GetAxisType( sName, bLinear) &&
m_pMachine->GetAxisPos( sName, dVal) &&
m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dEnd) ;
@@ -895,6 +952,8 @@ Simulator::OnMoveEnd( void)
return true ;
// chiamo la funzione
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_END) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
}