EgtMachKernel 1.6r9 :

- separato nome da token per gli assi macchina e gestito il tutto
- in milling aggiunta gestione punto start e estrusione di path per piano locale di interpolazione in part-program
- migliorata gestione deselezione utensile in simulazione.
This commit is contained in:
Dario Sassi
2016-06-14 06:34:46 +00:00
parent fe0cbd0191
commit bce7e1353c
13 changed files with 222 additions and 82 deletions
+7 -4
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2016
//----------------------------------------------------------------------------
// File : Axis.cpp Data : 24.05.15 Versione : 1.6e7
// File : Axis.cpp Data : 09.06.16 Versione : 1.6r9
// Contenuto : Oggetto asse per gruppo asse di macchina.
//
//
//
// Modifiche : 24.05.15 DS Creazione modulo.
//
// 09.06.16 DS Aggiunto token.
//
//----------------------------------------------------------------------------
@@ -43,6 +43,7 @@ Axis::Clone( void) const
try { pAx->m_nOwnerId = GDB_ID_NULL ;
pAx->m_pGeomDB = nullptr ;
pAx->m_sName = m_sName ;
pAx->m_sToken = m_sToken ;
pAx->m_nType = m_nType ;
pAx->m_ptPos = m_ptPos ;
pAx->m_vtDir = m_vtDir ;
@@ -66,6 +67,7 @@ Axis::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += GetClassName() + szNewLine ;
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
sOut += "Name=" + m_sName + szNewLine ;
sOut += "Token=" + m_sToken + szNewLine ;
sOut += "Type=" + ToString( m_nType) + szNewLine ;
sOut += "Pos=" + ToString( GetInUiUnits( m_ptPos, bMM), 4) + szNewLine ;
sOut += "Dir=" + ToString( m_vtDir) + szNewLine ;
@@ -112,10 +114,11 @@ Axis::Axis( void)
//----------------------------------------------------------------------------
bool
Axis::Set( const string& sName, int nType,
Axis::Set( const string& sName, const string& sToken, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome)
{
m_sName = sName ;
m_sToken = sToken ;
m_nType = nType ;
m_ptPos = ptPos ;
m_vtDir = vtDir ;
+11 -8
View File
@@ -30,31 +30,34 @@ class Axis : public IUserObj
public :
Axis( void) ;
bool Set( const std::string& sName, int nType,
bool Set( const std::string& sName, const std::string& sToken, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome) ;
bool Modify( const STROKE& Stroke) ;
bool Modify( double dHome) ;
bool SetCurrVal( double dVal)
{ m_dCurrVal = dVal ; return true ; }
const std::string& GetName( void)
const std::string& GetName( void) const
{ return m_sName ; }
int GetType( void)
const std::string& GetToken( void) const
{ return m_sToken ; }
int GetType( void) const
{ return m_nType ; }
const Point3d& GetPos( void)
const Point3d& GetPos( void) const
{ return m_ptPos ; }
const Vector3d& GetDir( void)
const Vector3d& GetDir( void) const
{ return m_vtDir ; }
const STROKE& GetStroke( void)
const STROKE& GetStroke( void) const
{ return m_Stroke ; }
double GetHomeVal( void)
double GetHomeVal( void) const
{ return m_dHomeVal ; }
double GetCurrVal( void)
double GetCurrVal( void) const
{ return m_dCurrVal ; }
private :
int m_nOwnerId ;
IGeomDB* m_pGeomDB ;
std::string m_sName ;
std::string m_sToken ;
int m_nType ;
Point3d m_ptPos ;
Vector3d m_vtDir ;
BIN
View File
Binary file not shown.
+49 -17
View File
@@ -22,6 +22,7 @@
#include "OutputConst.h"
#include "/EgtDev/Include/EMkToolConst.h"
#include "/EgtDev/Include/EMkOperationConst.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnFileUtils.h"
@@ -37,6 +38,7 @@ Generator::Generator( void)
m_pGeomDB = nullptr ;
m_pMachine = nullptr ;
m_AxesName.reserve( 8) ;
m_AxesToken.reserve( 8) ;
m_AxesVal.reserve( 8) ;
}
@@ -206,7 +208,7 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
// Se utensile cambierà
if ( ! m_sTool.empty() && m_sTool != sTool) {
// emetto deselezione vecchio utensile
if ( ! OnToolDeselect())
if ( ! OnToolDeselect( sHead, nExit))
return false ;
}
// Aggiorno utensile e assi macchina
@@ -214,7 +216,7 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
return false ;
// Se utensile cambiato, emetto selezione nuovo utensile
if ( m_sTool != m_sPrevTool) {
if ( ! OnToolSelect())
if ( ! OnToolSelect( sTool, sHead, nExit))
return false ;
}
// Ciclo su tutti i percorsi CL della disposizione
@@ -256,8 +258,16 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
// Se utensile cambierà
if ( ! m_sTool.empty() && m_sTool != sTool) {
// recupero la testa del prossimo utensile
string sNextHead ; int nNextExit ;
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sNextHead) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nNextExit) ;
}
// ripristino l'utensile corrente
m_pMchMgr->TdbSetCurrTool( m_sTool) ;
// emetto deselezione vecchio utensile
if ( ! OnToolDeselect())
if ( ! OnToolDeselect( sNextHead, nNextExit))
return false ;
}
// Aggiorno utensile e assi macchina
@@ -265,7 +275,9 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
return false ;
// Se utensile cambiato, emetto selezione nuovo utensile
if ( m_sTool != m_sPrevTool) {
if ( ! OnToolSelect())
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
if ( ! OnToolSelect( sTool, sHead, nExit))
return false ;
}
@@ -302,11 +314,17 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
bool
Generator::ProcessClPath( int nClPathId, int nClPathInd, int nOpId, int nOpInd)
{
// Recupero punto di inizio del percorso
Point3d ptStart ;
m_pGeomDB->GetInfo( nClPathId, KEY_START, ptStart) ;
// Recupero versore estrusione associato al percorso (normale al piano di interpolazione)
Vector3d vtExtr ;
m_pGeomDB->GetInfo( nClPathId, KEY_EXTR, vtExtr) ;
// Emetto inizio percorso di lavoro
if ( ! OnPathStart( nClPathId, nClPathInd))
if ( ! OnPathStart( nClPathId, nClPathInd, ptStart, vtExtr))
return false ;
// Ciclo su tutte le entità del percorsi CL
// Ciclo su tutte le entità del percorso CL
bool bOk = true ;
int nEntInd = 0 ;
int nEntId = m_pGeomDB->GetFirstInGroup( nClPathId) ;
@@ -398,7 +416,8 @@ bool
Generator::UpdateAxes( void)
{
// Carico i nomi degli assi macchina attivi
return m_pMachine->GetAllCurrAxesName( m_AxesName) ;
return m_pMachine->GetAllCurrAxesName( m_AxesName) &&
m_pMachine->GetAllCurrAxesToken( m_AxesToken) ;
}
//----------------------------------------------------------------------------
@@ -532,17 +551,23 @@ Generator::OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d&
//----------------------------------------------------------------------------
bool
Generator::OnToolSelect( void)
Generator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
{
// assegno il nome dell'utensile
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) ;
// assegno il nome degli assi
// assegno il nome dell'utensile, la testa e l'uscita
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ;
// assegno il token e il nome degli assi
int nNumAxes = int( m_AxesName.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesName[i-1]) ;
else
if ( i <= nNumAxes) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesToken[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisName(i), m_AxesName[i-1]) ;
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisName(i)) ;
}
}
// chiamo la funzione di selezione utensile
bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_SELECT) ;
@@ -551,10 +576,14 @@ Generator::OnToolSelect( void)
//----------------------------------------------------------------------------
bool
Generator::OnToolDeselect( void)
Generator::OnToolDeselect( const string& sNextHead, int nNextExit)
{
// assegno la prossima testa
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTHEAD, sNextHead) ;
// assegno la prossima uscita
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTEXIT, nNextExit) ;
// chiamo la funzione di deselezione utensile
bool bOk = m_pMachine->LuaCallFunction( ON_TOOL_DESELECT) ;
bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DESELECT) ;
return bOk ;
}
@@ -583,11 +612,14 @@ Generator::OnMachiningEnd( void)
//----------------------------------------------------------------------------
bool
Generator::OnPathStart( int nClPathId, int nClPathInd)
Generator::OnPathStart( int nClPathId, int nClPathInd, const Point3d& ptStart, const Vector3d& vtExtr)
{
// assegno identificativo e indice percorso di lavorazione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHIND, nClPathInd) ;
// 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) ;
// chiamo la funzione di inizio percorso di lavorazione
bOk = bOk && m_pMachine->LuaCallFunction( ON_PATH_START) ;
return bOk ;
+4 -3
View File
@@ -40,8 +40,8 @@ class Generator
bool OnEnd( void) ;
bool OnProgramStart( const std::string& sCncFile, const std::string& sInfo) ;
bool OnProgramEnd( void) ;
bool OnToolSelect( void) ;
bool OnToolDeselect( void) ;
bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit) ;
bool OnToolDeselect( const std::string& sNextHead, int nNextExit) ;
bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, bool bEmpty) ;
bool OnDispositionEnd( void) ;
bool OnTableData( const std::string& sName, const Point3d& ptOri1) ;
@@ -50,7 +50,7 @@ class Generator
bool OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d& ptPos, int nFlag) ;
bool OnMachiningStart( int nOpId, int nOpInd, double dSpeed) ;
bool OnMachiningEnd( void) ;
bool OnPathStart( int nClPathId, int nClPathInd) ;
bool OnPathStart( int nClPathId, int nClPathInd, const Point3d& ptStart, const Vector3d& vtExtr) ;
bool OnPathEnd( void) ;
bool OnRapid( int nMove, const DBLVECTOR& AxesEnd, int nAxesMask, int nFlag) ;
bool OnLinear( int nMove, const DBLVECTOR& AxesEnd, double dFeed, int nFlag) ;
@@ -65,5 +65,6 @@ class Generator
std::string m_sPrevTool ; // nome dell'utensile precedente
std::string m_sTool ; // nome dell'utensile corrente
STRVECTOR m_AxesName ; // nomi degli assi macchina attivi
STRVECTOR m_AxesToken ; // token degli assi macchina attivi
DBLVECTOR m_AxesVal ; // valori degli assi macchina all'inizio del movimento corrente
} ;
+4 -4
View File
@@ -262,9 +262,9 @@ Machine::AdjustTable( int nLay, const Point3d& ptRef1)
//----------------------------------------------------------------------------
bool
Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome,
bool bAdjustAux, const string& sGeo, const STRVECTOR& vsAux)
Machine::LoadMachineAxis( const string& sName, const string& sParent, const string& sToken,
int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
double dHome, bool bAdjustAux, const string& sGeo, const STRVECTOR& vsAux)
{
// verifico sia di tipo ammesso
if ( nType != MCH_AT_LINEAR && nType != MCH_AT_ROTARY) {
@@ -304,7 +304,7 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
Axis* pAxis = new(nothrow) Axis ;
if ( pAxis == nullptr)
return false ;
pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dHome) ;
pAxis->Set( sName, sToken, nType, ptPos, vtDir, Stroke, dHome) ;
m_pGeomDB->SetUserObj( nLay, pAxis) ;
// verifico il vettore rappresentativo dell'asse
if ( ! AdjustAxis( nLay, sPart, sName, nType, ptPos, vtDir, bAdjustAux))
+4 -3
View File
@@ -81,6 +81,7 @@ class Machine
int GetCurrLinAxes( void) const ;
int GetCurrRotAxes( void) const ;
bool GetAllCurrAxesName( STRVECTOR& vAxName) const ;
bool GetAllCurrAxesToken( STRVECTOR& vAxToken) const ;
bool GetCurrAxisHomePos( int nInd, double& dHome) const ;
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
@@ -126,9 +127,9 @@ class Machine
bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType,
const Point3d& ptRef1, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustTable( int nLay, const Point3d& ptRef1) ;
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome,
bool bAdjustAux, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken,
int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
double dHome, bool bAdjustAux, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustAxis( int nLay, const std::string& sPart, const std::string& sName,
int nType, const Point3d& ptPos, const Vector3d& vtDir, bool bAdjustAux) ;
bool ModifyMachineAxisStroke( const std::string& sName, const STROKE& Stroke) ;
+25
View File
@@ -1109,6 +1109,31 @@ Machine::GetAllCurrAxesName( STRVECTOR& vAxName) const
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machine::GetAllCurrAxesToken( STRVECTOR& vAxToken) const
{
vAxToken.clear() ;
bool bOk = true ;
// ciclo sugli assi lineari correnti
for ( auto& CalcLinAx : m_vCalcLinAx) {
Axis* pAx = GetAxis( CalcLinAx.nGrpId) ;
if ( pAx != nullptr)
vAxToken.emplace_back( pAx->GetToken()) ;
else
bOk = false ;
}
// ciclo sugli assi rotanti correnti
for ( auto& CalcRotAx : m_vCalcRotAx) {
Axis* pAx = GetAxis( CalcRotAx.nGrpId) ;
if ( pAx != nullptr)
vAxToken.emplace_back( pAx->GetToken()) ;
else
bOk = false ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machine::GetCurrAxisHomePos( int nInd, double& dHome) const
+5 -1
View File
@@ -34,6 +34,7 @@ static const string FLD_NAME = "Name" ;
static const string FLD_PARENT = "Parent" ;
static const string FLD_GEO = "Geo" ;
static const string FLD_AUX = "Aux" ;
static const string FLD_TOKEN = "Token" ;
static const string FLD_TYPE = "Type" ;
static const string FLD_REF1 = "Ref1" ;
static const string FLD_POS = "Pos" ;
@@ -373,6 +374,9 @@ Machine::LuaEmtAxis( lua_State* L)
// lettura campo 'Parent' dalla tabella
string sParent ;
LuaCheckTabFieldParam( L, 1, FLD_PARENT, sParent)
// lettura eventuale campo 'Token' dalla tabella (default Name)
string sToken = sName ;
LuaGetTabFieldParam( L, 1, FLD_TOKEN, sToken) ;
// lettura campo 'Type' dalla tabella
int nType ;
LuaCheckTabFieldParam( L, 1, FLD_TYPE, nType)
@@ -408,7 +412,7 @@ Machine::LuaEmtAxis( lua_State* L)
return luaL_error( L, " Unknown Machine") ;
// carico i dati dell'asse
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, nType, ptPos, vtDir,
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, sToken, nType, ptPos, vtDir,
Stroke, dHome, bAdjustAux, sGeo, vsAux))
return luaL_error( L, " Load Machine Axis failed") ;
+9
View File
@@ -864,6 +864,10 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
if ( m_Params.m_bInvert)
pCompo->Invert() ;
// recupero il punto di inizio (per poi salvarlo nelle info di CL path)
Point3d ptStart ;
pCompo->GetStartPoint( ptStart) ;
// eventuale allungamento/accorciamento dell'inizio
if ( abs( m_Params.m_dStartAddLen) > EPS_SMALL) {
if ( m_Params.m_dStartAddLen > 0) {
@@ -962,6 +966,11 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
if ( ! vtExtr.IsSmall())
vtTool = vtExtr ;
// assegno il vettore estrazione al gruppo del percorso
m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
// assegno il punto di inizio al gruppo del percorso
m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ;
// Imposto dati comuni
SetPathId( nPxId) ;
SetToolDir( vtTool) ;
+39 -12
View File
@@ -51,10 +51,14 @@ static const std::string GVAR_RAWFLAG = ".RAWFLAG" ; // (int) flag per m
static const std::string GVAR_TOOL = ".TOOL" ; // (string) nome utensile
static const std::string GVAR_HEAD = ".HEAD" ; // (string) nome testa
static const std::string GVAR_EXIT = ".EXIT" ; // (int) indice uscita
static const std::string GVAR_NEXTHEAD = ".NEXTHEAD" ; // (string) nome testa del prossimo utensile
static const std::string GVAR_NEXTEXIT = ".NEXTEXIT" ; // (int) indice uscita su testa del prox utensile
static const std::string GVAR_MCHID = ".MCHID" ; // (int) identificativo lavorazione
static const std::string GVAR_MCHIND = ".MCHIND" ; // (int) indice lavorazione
static const std::string GVAR_PATHID = ".PATHID" ; // (int) identificativo percorso di lavorazione
static const std::string GVAR_PATHIND = ".PATHIND" ; // (int) indice percorso di lavorazione
static const std::string GVAR_START = ".START" ; // (Point3d) punto iniziale del percorso originale
static const std::string GVAR_EXTR = ".EXTR" ; // (Vector3d)versore estrusione
static const std::string GVAR_MOVEID = ".MOVEID" ; // (int) identificativo movimento
static const std::string GVAR_MOVEIND = ".MOVEIND" ; // (int) indice movimento
static const std::string GVAR_MOVE = ".MOVE" ; // (int) tipo di movimento (0,1,2,3)
@@ -77,22 +81,29 @@ static const std::string GVAR_R1P = ".R1p" ; // (num) valore pre
static const std::string GVAR_R2P = ".R2p" ; // (num) valore precedente del secondo asse rotante
static const std::string GVAR_R3P = ".R3p" ; // (num) valore precedente del terzo asse rotante
static const std::string GVAR_R4P = ".R4p" ; // (num) valore precedente del quarto asse rotante
static const std::string GVAR_L1T = ".L1t" ; // (num) token del primo asse lineare
static const std::string GVAR_L2T = ".L2t" ; // (num) token del secondo asse lineare
static const std::string GVAR_L3T = ".L3t" ; // (num) token del terzo asse lineare
static const std::string GVAR_R1T = ".R1t" ; // (num) token del primo asse rotante
static const std::string GVAR_R2T = ".R2t" ; // (num) token del secondo asse rotante
static const std::string GVAR_R3T = ".R3t" ; // (num) token del terzo asse rotante
static const std::string GVAR_R4T = ".R4t" ; // (num) token del quarto asse rotante
static const std::string GVAR_C1T = ".C1t" ; // (num) token del primo asse lineare per centro arco
static const std::string GVAR_C2T = ".C2t" ; // (num) token del secondo asse lineare per centro arco
static const std::string GVAR_C3T = ".C3t" ; // (num) token del terzo asse lineare per centro arco
static const std::string GVAR_RRT = ".RRt" ; // (num) token del raggio per arco
static const std::string GVAR_L1T = ".L1t" ; // (string) token del primo asse lineare
static const std::string GVAR_L2T = ".L2t" ; // (string) token del secondo asse lineare
static const std::string GVAR_L3T = ".L3t" ; // (string) token del terzo asse lineare
static const std::string GVAR_R1T = ".R1t" ; // (string) token del primo asse rotante
static const std::string GVAR_R2T = ".R2t" ; // (string) token del secondo asse rotante
static const std::string GVAR_R3T = ".R3t" ; // (string) token del terzo asse rotante
static const std::string GVAR_R4T = ".R4t" ; // (string) token del quarto asse rotante
static const std::string GVAR_C1T = ".C1t" ; // (string) token del primo asse lineare per centro arco
static const std::string GVAR_C2T = ".C2t" ; // (string) token del secondo asse lineare per centro arco
static const std::string GVAR_C3T = ".C3t" ; // (string) token del terzo asse lineare per centro arco
static const std::string GVAR_RRT = ".RRt" ; // (string) token del raggio per arco
static const std::string GVAR_L1N = ".L1n" ; // (string) nome del primo asse lineare
static const std::string GVAR_L2N = ".L2n" ; // (string) nome del secondo asse lineare
static const std::string GVAR_L3N = ".L3n" ; // (string) nome del terzo asse lineare
static const std::string GVAR_R1N = ".R1n" ; // (string) nome del primo asse rotante
static const std::string GVAR_R2N = ".R2n" ; // (string) nome del secondo asse rotante
static const std::string GVAR_R3N = ".R3n" ; // (string) nome del terzo asse rotante
static const std::string GVAR_R4N = ".R4n" ; // (string) nome del quarto asse rotante
static const std::string GVAR_MASK = ".MASK" ; // (int) mask associato ai movimenti in rapido
static const std::string GVAR_FLAG = ".FLAG" ; // (int) flag associato ad ogni movimento
static const std::string GVAR_AUXAXES = ".AuxAxes" ; // (int) numero assi ausiliari per simulazione
static const std::string GVAR_AN = ".AN" ; // (num) valore del N-esimo asse ausiliario per simulazione
static const std::string GVAR_ANT = ".ANt" ; // (string) token del N-esimo asse ausiliario per simulazione
static const std::string GVAR_ANN = ".ANn" ; // (string) nome del N-esimo asse ausiliario per simulazione
// Funzioni generazione
static const std::string ON_START = "OnStart" ;
@@ -177,3 +188,19 @@ GetGlobVarAxisToken( int nAx)
default : return "" ;
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisName( int nAx)
{
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_L1N) ;
case 2 : return ( GLOB_VAR + GVAR_L2N) ;
case 3 : return ( GLOB_VAR + GVAR_L3N) ;
case 4 : return ( GLOB_VAR + GVAR_R1N) ;
case 5 : return ( GLOB_VAR + GVAR_R2N) ;
case 6 : return ( GLOB_VAR + GVAR_R3N) ;
case 7 : return ( GLOB_VAR + GVAR_R4N) ;
default : return "" ;
}
}
+61 -28
View File
@@ -39,6 +39,7 @@ Simulator::Simulator( void)
m_nEntInd = 0 ;
m_dCoeff = 0 ;
m_AxesName.reserve( 8) ;
m_AxesToken.reserve( 8) ;
m_AxesVal.reserve( 8) ;
}
@@ -75,6 +76,7 @@ Simulator::Start( void)
// reset utensile e assi correnti
m_sTool.clear() ;
m_AxesName.clear() ;
m_AxesToken.clear() ;
// porto la macchina in home
if ( ! GoHome())
return false ;
@@ -91,8 +93,10 @@ Simulator::Start( void)
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ;
string sTable ;
pDisp->GetTable( sTable) ;
Point3d ptOri1 ;
pDisp->GetTableRef1( ptOri1) ;
// richiamo gestione evento inizio e fine disposizione
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, sTable, true) ||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, sTable, ptOri1, true) ||
! OnDispositionEnd())
return false ;
// cerco la prima lavorazione valida
@@ -109,7 +113,7 @@ Simulator::Start( void)
return false ;
// aggiornamenti legati al cambio di lavorazione (utensile e assi conseguenti)
if ( ! UpdateTool( true) || ! UpdateAxes())
if ( ! UpdateTool( true))
return false ;
// richiamo gestione evento inizio lavorazione
@@ -189,7 +193,7 @@ Simulator::Move( int& nStatus)
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch != nullptr && ! pMch->IsEmpty()) {
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool() || ! UpdateAxes()) {
if ( ! UpdateTool()) {
nStatus = MCH_SIM_ERR ;
return false ;
}
@@ -209,28 +213,30 @@ Simulator::Move( int& nStatus)
// recupero dati tavola
string sTable ;
pDisp->GetTable( sTable) ;
Point3d ptOri1 ;
pDisp->GetTableRef1( ptOri1) ;
// se con movimenti autonomi
if ( ! pDisp->IsEmpty()) {
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool() || ! UpdateAxes()) {
if ( ! UpdateTool()) {
nStatus = MCH_SIM_ERR ;
return false ;
}
++ m_nOpInd ;
// richiamo gestione evento inizio disposizione
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, false)) {
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, false)) {
nStatus = MCH_SIM_ERR ;
return false ;
}
// recupero eventuali forzature assi da gestione inizio disposizione
UpdateAxes() ;
UpdateAxesPos() ;
break ;
}
// altrimenti disposizione passiva
else {
++ m_nOpInd ;
// richiamo gestione evento inizio e fine disposizione
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, true) ||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, true) ||
! OnDispositionEnd()) {
nStatus = MCH_SIM_ERR ;
return false ;
@@ -480,22 +486,22 @@ 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
// recupero nome e dati nuovo utensile
string sTool ;
if ( ! pMch->GetParam( MPA_TOOL, sTool))
return false ;
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
return false ;
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
// se cambierà e non forzato (inizio), scarico l'utensile corrente
if ( sTool != m_sTool && ! bForced) {
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect())
if ( ! OnToolDeselect( sHead, nExit))
return false ;
}
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
return false ;
// se cambiato oppure forzato, attivo l'utensile della lavorazione
if ( sTool != m_sTool || bForced) {
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
// se forzato, pulisco la testa
if ( bForced)
m_pMchMgr->ResetHeadSet( sHead) ;
@@ -503,6 +509,9 @@ Simulator::UpdateTool( bool bForced)
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
return false ;
m_sTool = sTool ;
// aggiorno gli assi macchina
if ( ! UpdateAxes())
return false ;
// eventuale lancio script
if ( ! OnToolSelect( m_sTool, sHead, nExit))
return false ;
@@ -512,16 +521,19 @@ 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) ;
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect( sHead, nExit))
return false ;
// carico l'utensile
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
return false ;
m_sTool = sTool ;
// aggiorno gli assi macchina
if ( ! UpdateAxes())
return false ;
// eventuale lancio script
if ( ! OnToolSelect( m_sTool, sHead, nExit))
return false ;
@@ -538,8 +550,9 @@ Simulator::UpdateAxes( void)
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
if ( pMachine == nullptr)
return false ;
// Carico i nomi degli assi macchina attivi
if ( ! pMachine->GetAllCurrAxesName( m_AxesName))
// Carico i nomi e i token degli assi macchina attivi
if ( ! pMachine->GetAllCurrAxesName( m_AxesName) ||
! pMachine->GetAllCurrAxesToken( m_AxesToken))
return false ;
// Aggiorno la posizione corrente degli assi macchina attivi
m_AxesVal.clear() ;
@@ -591,15 +604,17 @@ Simulator::OnOperationEnd( void)
//----------------------------------------------------------------------------
bool
Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, const string& sTable, bool bEmpty)
Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase,
const string& sTable, const Point3d& ptOri1, bool bEmpty)
{
// assegno identificativo e indice disposizione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ;
// assegno nuovo indice di fase
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PHASE, nPhase) ;
// assegno nome della tavola corrente
// assegno nome e valore riferimento della tavola corrente
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sTable) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABORI1, ptOri1) ;
// assegno flag disposizione passiva
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ;
// verifico esistenza funzione
@@ -626,11 +641,25 @@ Simulator::OnDispositionEnd( void)
bool
Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
{
// assegno dati
// assegno il nome dell'utensile, la testa e l'uscita
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 ;
// assegno il token e il nome degli assi
int nNumAxes = int( m_AxesName.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes) {
if ( ! m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesToken[i-1]) ||
! m_pMachine->LuaSetGlobVar( GetGlobVarAxisName(i), m_AxesName[i-1]))
return false ;
}
else {
if ( ! m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken(i)) ||
! m_pMachine->LuaResetGlobVar( GetGlobVarAxisName(i)))
return false ;
}
}
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT))
return true ;
@@ -640,8 +669,12 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit)
//----------------------------------------------------------------------------
bool
Simulator::OnToolDeselect( void)
Simulator::OnToolDeselect( const string& sNextHead, int nNextExit)
{
// assegno la prossima testa
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTHEAD, sNextHead) ;
// assegno la prossima uscita
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTEXIT, nNextExit) ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
return true ;
@@ -653,13 +686,13 @@ Simulator::OnToolDeselect( void)
bool
Simulator::OnMachiningStart( int nOpId, int nOpInd)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
return true ;
// assegno identificativo e indice lavorazione
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ||
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd))
return false ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START))
return true ;
// chiamo la funzione di inizio disposizione
return m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_START) ;
}
@@ -742,7 +775,7 @@ Simulator::OnMoveStart( const CamData* pCamData)
if ( ! bOk)
return false ;
// forzo aggiornamento posizione assi (possono essere stati mssi nello script)
// forzo aggiornamento posizione assi (possono essere stati messi nello script)
UpdateAxesPos() ;
// recupero i dati di ritorno
@@ -755,8 +788,8 @@ Simulator::OnMoveStart( const CamData* pCamData)
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
string sName ; double dVal ; double dEnd ;
string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ;
string sAuxAxTok = GLOB_VAR + GVAR_ANT ; ReplaceString( sAuxAxTok, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxTok, sName) &&
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
m_pMachine->GetAxisPos( sName, dVal) &&
m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
m_AuxAxesName.emplace_back( sName) ;
+4 -2
View File
@@ -43,10 +43,11 @@ class Simulator
private :
bool OnOperationEnd( void) ;
bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, bool bEmpty) ;
bool OnDispositionStart( int nOpId, int nOpInd, int nPhase,
const std::string& sTable, const Point3d& ptOri1, bool bEmpty) ;
bool OnDispositionEnd( void) ;
bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit) ;
bool OnToolDeselect( void) ;
bool OnToolDeselect( const std::string& sNextHead, int nNextExit) ;
bool OnMachiningStart( int nOpId, int nOpInd) ;
bool OnMachiningEnd( void) ;
bool OnPathStart( int nClPathId, int nClPathInd) ;
@@ -69,6 +70,7 @@ class Simulator
double m_dCoeff ; // coefficiente di movimento corrente
std::string m_sTool ; // nome dell'utensile corrente
STRVECTOR m_AxesName ; // nomi degli assi macchina attivi
STRVECTOR m_AxesToken ; // token degli assi macchina attivi
DBLVECTOR m_AxesVal ; // valori degli assi macchina all'inizio del movimento corrente
STRVECTOR m_AuxAxesName ; // nomi degli assi macchina ausiliari abilitati
DBLVECTOR m_AuxAxesVal ; // valori degli assi macchina ausiliari all'inizio del movimento corrente