Merge remote-tracking branch 'origin/master'

This commit is contained in:
Riccardo Elitropi
2023-01-23 08:14:14 +01:00
8 changed files with 258 additions and 42 deletions
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -452,10 +452,11 @@ class MachMgr : public IMachMgr
bool GetOperationNewName( std::string& sName) const ;
const ToolData* GetMachiningToolData( void) const ;
// Simulation
bool SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ;
bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ;
bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
int SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ;
// Machine
bool GetHeadAbove( const std::string& sHead) const ;
double GetDeltaSafeZ( const std::string& sHead) const ;
+15 -4
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : MachMgrSimulation.cpp Data : 20.10.15 Versione : 1.6j2
// File : MachMgrSimulation.cpp Data : 16.01.23 Versione : 2.5a2
// Contenuto : Implementazione gestione simulazione della classe MachMgr.
//
//
@@ -150,13 +150,13 @@ MachMgr::SimExit( void)
//----------------------------------------------------------------------------
bool
MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
MachMgr::SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// aggiungo un oggetto da verificare per la collisione con il grezzo
return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
return m_pSimul->AddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
}
//----------------------------------------------------------------------------
@@ -191,3 +191,14 @@ MachMgr::SimSetToolForVmill( const string& sTool, const string& sHead, int nExit
// imposto utensile per Vmill
return m_pSimul->SetToolForVmill( sTool, sHead, nExit, vVmill, bFirst) ;
}
//----------------------------------------------------------------------------
int
MachMgr::SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// lancio movimento assi
return m_pSimul->MoveAxes( nMoveType, vAxNaEpSt) ;
}
+4 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2021
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : Machine.h Data : 14.10.21 Versione : 2.3j5
// File : Machine.h Data : 16.01.23 Versione : 2.5a2
// Contenuto : Dichiarazione della classe Machine.
//
//
@@ -356,6 +356,8 @@ class Machine
static int LuaEmtOnCollision( lua_State* L) ;
static int LuaEmtSetToolForVmill( lua_State* L) ;
static int LuaEmtAddToolForVmill( lua_State* L) ;
static int LuaEmtMoveAxes( lua_State* L) ;
} ;
//----------------------------------------------------------------------------
+48 -3
View File
@@ -136,6 +136,8 @@ Machine::LuaInit( const string& sMachineName)
m_LuaMgr.RegisterFunction( "EmtSetToolForVmill", Machine::LuaEmtSetToolForVmill) ;
// registro la funzione di impostazione di utensile aggiuntivo per virtual milling in simulazione
m_LuaMgr.RegisterFunction( "EmtAddToolForVmill", Machine::LuaEmtAddToolForVmill) ;
// registro la funzione di movimento assi in simulazione
m_LuaMgr.RegisterFunction( "EmtMoveAxes", Machine::LuaEmtMoveAxes) ;
return true ;
}
@@ -1260,7 +1262,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L)
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, false, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1270,7 +1272,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L)
int
Machine::LuaEmtAddCollisionObjEx( lua_State* L)
{
// 7 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3
// 7 o 8 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 [,bToolOn]
int nInd ;
LuaCheckParam( L, 1, nInd)
int nFrameId ;
@@ -1285,12 +1287,14 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L)
LuaCheckParam( L, 6, dPar2)
double dPar3 ;
LuaCheckParam( L, 7, dPar3)
bool bToolOn = false ;
LuaGetParam( L, 8, bToolOn) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1386,3 +1390,44 @@ Machine::LuaEmtAddToolForVmill( lua_State* L)
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtMoveAxes( lua_State* L)
{
// 4, ..., 16 parametri : nMoveType, sAx1, dPos1, dStep1 [, sAx2, dPos2, dStep2] [, sAx3, dPos3, dStep3] [, sAx4, dPos4, dStep4] [, sAx5, dPos5, dStep5]
int nMoveType ;
LuaCheckParam( L, 1, nMoveType)
string sAx1 ;
LuaCheckParam( L, 2, sAx1) ;
double dEnd1 ;
LuaCheckParam( L, 3, dEnd1) ;
double dStep1 ;
LuaCheckParam( L, 4, dStep1) ;
SAMVECTOR vAxNaEpSt ;
vAxNaEpSt.emplace_back( sAx1, dEnd1, dStep1) ;
for ( int i = 0 ; i < 4 ; ++ i) {
int nInd = 5 + 3 * i ;
string sAxN ;
double dEndN ;
double dStepN ;
if ( LuaGetParam( L, nInd, sAxN) && LuaGetParam( L, nInd + 1, dEndN) && LuaGetParam( L, nInd + 2, dStepN))
vAxNaEpSt.emplace_back( sAxN, dEndN, dStepN) ;
else
break ;
}
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// eseguo movimento in simulazione
int nRes = 0 ;
if ( m_pMchLua->m_pMchMgr != nullptr)
nRes = m_pMchLua->m_pMchMgr->SimMoveAxes( nMoveType, vAxNaEpSt) ;
// assegno risultato
if ( nRes == SIM_AXMV_RES_STOP)
return luaL_error( L, "STOP") ;
else
LuaSetParam( L, ( nRes == SIM_AXMV_RES_OK)) ;
return 1 ;
}
+1 -1
View File
@@ -1555,8 +1555,8 @@ Operation::CalculateAxesValues( const string& sHint, bool bSolChExact)
}
// se extracorsa dell'asse C, provo a precaricarlo al contrario
if ( nOutStrC != 0) {
vAxRotPrec = vAxRotPrecOri ;
vAxRotPrec[0] = vAxRotPrecOri[0] + ( nOutStrC > 0 ? - ANG_FULL : ANG_FULL) ;
vAxRotPrec[1] = vAxRotPrecOri[1] ;
m_pMchMgr->GetCurrMachine()->ResetOutstrokeInfo() ;
if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, bMaxDeltaR2OnFirst,
INFINITO, vAxRotHome, vAxRotPrec, nOutStrC))
+163 -21
View File
@@ -44,8 +44,11 @@ using namespace std ;
static const double MIN_STEP = 1.0 ;
static const double MAX_STEP = 100.0 ;
static const double MID_STEP = 50.0 ;
static const double COLL_STEP = 10. ;
static const double COEFF_LIM = 0.999 ;
static const double SAFEDIST_STD = 5.0 ;
static const int ERR_OUTSTROKE = 1 ;
static const int ERR_COLLISION = 11 ;
//----------------------------------------------------------------------------
Simulator::Simulator( void)
@@ -450,7 +453,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
if ( nCurrErr != ERR_COLLISION)
return false ;
}
}
@@ -477,7 +480,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
if ( nCurrErr != ERR_COLLISION)
return false ;
}
}
@@ -495,7 +498,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
if ( nCurrErr != ERR_COLLISION)
return false ;
}
}
@@ -513,7 +516,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
if ( nCurrErr != ERR_COLLISION)
return false ;
}
return ( nErr == 0) ;
@@ -622,13 +625,14 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
// 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 ( ! UpdateTool( bFirst, nErr)) {
string sOut = "Err=" + ToString( nErr) ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
nStatus = CalcStatusOnError( nErr) ;
return false ;
bOk = false ;
}
++ m_nOpInd ;
// imposto la lavorazione come corrente
@@ -644,8 +648,10 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
// richiamo gestione evento inizio lavorazione
if ( ! OnMachiningStart( m_nOpId, m_nOpInd, ptMin, ptMax, vAxMin, vAxMax)) {
nStatus = CalcStatusOnError( 0) ;
return false ;
bOk = false ;
}
if ( ! bOk)
return false ;
break ;
}
// se disposizione con cambio di fase
@@ -1004,10 +1010,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
if ( nMoveType != 2 && nMoveType != 3) {
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck()) {
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
if ( NeedCollisionCheck())
nStep = max( int( dMove / COLL_STEP), 1) ;
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
DBLVECTOR vDeltaVal( m_AxesName.size()) ;
@@ -1160,10 +1164,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
dMove = ( m_dCoeff - dPrevCoeff) * dDist ;
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck()) {
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
if ( NeedCollisionCheck())
nStep = max( int( dMove / COLL_STEP), 1) ;
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
// muovo eventuali assi ausiliari
@@ -1223,9 +1225,9 @@ Simulator::CalcStatusOnError( int nErr)
{
if ( Stopped())
return MCH_SIM_STOP ;
else if ( nErr == 1)
else if ( nErr == ERR_OUTSTROKE)
return MCH_SIM_OUTSTROKE ;
else if ( nErr == 11)
else if ( nErr == ERR_COLLISION)
return MCH_SIM_COLLISION ;
else
return MCH_SIM_ERR ;
@@ -1317,8 +1319,8 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
// verifico se è l'utensile attivo
string sHead ; m_pGeomDB->GetName( m_pGeomDB->GetParentId( m_CollObj[j].nFrameId), sHead) ;
string sExit ; m_pGeomDB->GetName( m_CollObj[j].nFrameId, sExit) ;
bool bIsTool = ( sHead == m_sHead &&
( sExit == string( "_T") + ToString( m_nExit) || sExit == string( "_TT") + ToString( m_nExit))) ;
bool bIsTool = m_CollObj[j].bToolOn ||
( sHead == m_sHead && ( sExit == "_T" + ToString( m_nExit) || sExit == "_TT" + ToString( m_nExit))) ;
// se utensile attivo su grezzo in lavoro e non è rapido, salto
if ( bIsTool && bIsRaw && nMoveType != 0)
continue ;
@@ -1901,7 +1903,7 @@ Simulator::OnCollision( int nCdInd, int nObjInd, int& nErr)
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// l'errore standard di collisione è stato portato da 1 a 11 per non collidere con altri tipi di errori
if ( nErr == 1) {
nErr = 11 ;
nErr = ERR_COLLISION ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
}
return ( nErr == 0) ;
@@ -1920,7 +1922,7 @@ Simulator::OnResetMachine( void)
//----------------------------------------------------------------------------
bool
Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
Simulator::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
{
// verifiche sui parametri
if ( nInd <= 0 || nFrameId <= GDB_ID_NULL)
@@ -1946,7 +1948,7 @@ Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& v
return false ;
}
// aggiungo al vettore
m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
m_CollObj.emplace_back( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
return true ;
}
@@ -2040,3 +2042,143 @@ Simulator::SetToolForVmill( const string& sTool, const string& sHead, int nExit,
return true ;
}
//----------------------------------------------------------------------------
int
Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// Salvo lo step di simulazione corrente
double dOrigStep = m_dStep ;
// Verifico ci siano assi da muovere
if ( vAxNaEpSt.empty())
return SIM_AXMV_RES_ERR ;
// Numero assi da muovere
int nAxCount = int( vAxNaEpSt.size()) ;
// Posizioni iniziali
DBLVECTOR vPrev( nAxCount) ;
for ( int i = 0 ; i < nAxCount ; ++ i) {
if ( ! m_pMchMgr->GetAxisPos( vAxNaEpSt[i].sName, vPrev[i]))
return SIM_AXMV_RES_ERR ;
}
// Posizione e direzione attuali degli utensili e riferimenti dei pezzi (per Vmill)
bool bExecVmill = (( nMoveType != 0 || ! NeedCollisionCheck()) && ! m_VmTool.empty() && ! m_VmId.empty()) ;
PNTVECTOR vPtNoseI ;
VCT3DVECTOR vVtDirI ;
VCT3DVECTOR vVtAuxI ;
vector<Frame3d> vFrVzmI ;
if ( bExecVmill) {
vPtNoseI.resize( m_VmTool.size()) ;
vVtDirI.resize( m_VmTool.size()) ;
vVtAuxI.resize( m_VmTool.size()) ;
vFrVzmI.resize( m_VmId.size()) ;
bool bOkI = true ;
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i)
bOkI = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, vPtNoseI[i], vVtDirI[i], vVtAuxI[i]) && bOkI ;
for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i)
bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ;
}
// Determino gli step di movimento
static const int STEP_FEED = -1 ;
static const int STEP_RAPID = -2 ;
static const int STEP_RAPROT = -3 ;
static const int STEP_COLLROT = -4 ;
int nStep = 1 ;
for ( int i = 0 ; i < nAxCount ; ++ i) {
double dMove = abs( vAxNaEpSt[i].dEndPos - vPrev[i]) ;
double dStep = vAxNaEpSt[i].dStep ;
if ( dStep < 0) {
if ( abs( dStep - STEP_FEED) < EPS_SMALL)
dStep = m_dStep ;
else if ( abs( dStep - STEP_RAPID) < EPS_SMALL)
dStep = 4 * m_dStep ;
else if ( abs( dStep - STEP_RAPROT) < EPS_SMALL)
dStep = 0.4 * m_dStep ;
else // STEP_COLLROT
dStep = min( 0.4 * m_dStep, 10.) ;
}
dStep = max( dStep, 1.) ;
int nAxStep = int( dMove / dStep) + 1 ;
nStep = max( nStep, nAxStep) ;
}
// Eseguo il movimento
for ( int i = 1 ; i <= nStep ; ++ i) {
// Muovo
bool bMoveOk = true ;
double dCoeff = double( i) / nStep ;
for ( int j = 0 ; j < nAxCount ; ++ j) {
bMoveOk = m_pMchMgr->SetAxisPos( vAxNaEpSt[j].sName, ( 1 - dCoeff) * vPrev[j] + dCoeff * vAxNaEpSt[j].dEndPos) && bMoveOk ;
}
// Eseguo eventuale Vmill
if ( bExecVmill) {
for ( int j = 0 ; j < int( m_VmTool.size()) ; ++ j) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[j].sHead, m_VmTool[j].nExit, ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], j, m_VmTool[j].dTdOffs, m_VmTool[j].dAdOffs,
vPtNoseI[j], vVtDirI[j], vVtAuxI[j], vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// se ultimo utensile, salvo riferimento per prossimo inizio
if ( j == int( m_VmTool.size()) - 1)
vFrVzmI[k] = frVzmF ;
}
// aggiorno prossimo inizio
vPtNoseI[j] = ptNoseF ;
vVtDirI[j] = vtDirF ;
vVtAuxI[j] = vtAuxF ;
}
}
// Aggiorno visualizzazione
ExeDraw() ;
// Verifico collisioni
int nCdInd, nObjInd ;
bool bCollCheck = ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
if ( ! bCollCheck) {
// Richiamo funzione di convalida collisione
int nPrevErr ;
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nPrevErr) ;
int nErr ;
if ( ! OnCollision( nCdInd, nObjInd, nErr) && nErr == ERR_COLLISION) {
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
if ( ExeGetEnableUI()) {
// Box di messaggio : Collisione! AVVERTIMENTO
ExeMessageBox( ExeGetMsg( 5319), ExeGetMsg( 5315), MB_OK | MB_ICONWARNING) ;
// Gestione Pausa
m_nUiStatus = MCH_UISIM_PAUSE ;
while ( m_nUiStatus == MCH_UISIM_PAUSE) {
// -11 notifica al simulatore pausa dopo collisione
ExeProcessEvents( -11, 4) ;
}
}
}
else {
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nPrevErr) ;
}
}
// In caso di errore esco
if ( ! bMoveOk)
return SIM_AXMV_RES_ERR ;
// Gestione aggiornamenti...
if ( ExeGetEnableUI()) {
// Aggiornamento interfaccia
ExeProcessEvents( 0, 4) ;
while ( m_nUiStatus == MCH_UISIM_PAUSE) {
ExeProcessEvents( 0, 4) ;
}
// Gestione Stop
if ( m_nUiStatus == MCH_UISIM_STOP)
return SIM_AXMV_RES_STOP ;
// Se cambia lo step di simulazione in modo significativo ...
if ( abs( m_dStep - dOrigStep) > 10 || abs( ( m_dStep - dOrigStep) / ( m_dStep + dOrigStep)) > 0.2) {
double dRat = m_dStep / dOrigStep ;
for ( int j = 0 ; j < nAxCount ; ++ j) {
if ( vAxNaEpSt[j].dStep > 0)
const_cast<double&>( vAxNaEpSt[j].dStep) *= dRat ;
}
return MoveAxes( nMoveType, vAxNaEpSt) ;
}
}
}
return SIM_AXMV_RES_OK ;
}
+25 -10
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : Simulator.h Data : 19.10.15 Versione : 1.6j2
// File : Simulator.h Data : 16.01.23 Versione : 2.5a2
// Contenuto : Dichiarazione della classe Simulator.
//
//
@@ -21,6 +21,21 @@ class IGeomDB ;
class Machine ;
class PerformanceCounter ;
//------------------------ Struttura per movimento esterno assi --------------
struct SimAxMv
{
std::string sName ;
double dEndPos ;
double dStep ;
SimAxMv( void) : dEndPos( 0), dStep( 0) { }
SimAxMv( std::string sN, double dE, double dS) : sName( sN), dEndPos( dE), dStep( dS) {}
} ;
typedef std::vector<SimAxMv> SAMVECTOR ;
//------------------------ Risultato movimento esterno assi -------------------
enum SimAxMvRes { SIM_AXMV_RES_STOP = -1,
SIM_AXMV_RES_ERR = 0,
SIM_AXMV_RES_OK = 1} ;
//----------------------------------------------------------------------------
class Simulator
@@ -38,10 +53,11 @@ class Simulator
bool GetToolInfo( std::string& sName, double& dSpeed) const ;
bool GetOperationInfo( std::string& sName, int& nType) const ;
bool GetMoveInfo( int& nGmove, double& dFeed) const ;
bool AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ;
bool OnCollision( int nCdInd, int nObjInd, int& nErr) ;
bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
int MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ;
private :
bool UpdateTool( bool bFirst, int& nErr) ;
@@ -95,17 +111,18 @@ class Simulator
private :
struct CollObj {
int nInd ;
bool bToolOn ;
int nFrameId ;
int nType ;
Vector3d vtMove ;
double dPar1 ;
double dPar2 ;
double dPar3 ;
CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {}
CollObj( int nI, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3)
: nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {}
CollObj( void) : nInd( 0), bToolOn( false), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {}
CollObj( int nI, bool bTOn, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3)
: nInd( nI), bToolOn( bTOn), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {}
} ;
typedef std::vector< CollObj> COBVECTOR ;
typedef std::vector<CollObj> COBVECTOR ;
struct VmTool
{
std::string sName ;
@@ -117,7 +134,7 @@ class Simulator
VmTool( std::string sN, std::string sH, int nE, double dT, double dA)
: sName( sN), sHead( sH), nExit( nE), dTdOffs( dT), dAdOffs( dA) {}
} ;
typedef std::vector< VmTool> VMTVECTOR ;
typedef std::vector<VmTool> VMTVECTOR ;
private :
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
@@ -143,8 +160,6 @@ class Simulator
double m_dTDiam ; // diametro dell'utensile corrente
INTVECTOR m_VmId ; // vettore identificativi Zmap per Virtual Milling
INTVECTOR m_CdId ; // vettore identificativi Zmap per Collision Detection
//double m_dVmTdOffs ; // offset utensile in direzione principale per VM
//double m_dVmAdOffs ; // offset utensile in direzione ausiliaria per VM
VMTVECTOR m_VmTool ; // vettore utensili attivi per virtual milling
COBVECTOR m_CollObj ; // vettore oggetti da testare per collisione con grezzo
double m_dSafeDist ; // distanza di sicurezza per verifica collisioni