Merge commit 'c8fe978a9669e2a506e74b5c316f6113c61dda85' into Sgrossature

This commit is contained in:
Riccardo Elitropi
2024-07-25 12:15:41 +02:00
7 changed files with 146 additions and 21 deletions
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -2349,13 +2349,13 @@ Operation::VerifyLineMidPoint( const Point3d& ptPrec, const Vector3d& vtDirPrec,
Point3d ptMid = Media( ptPrec, ptP) ;
Vector3d vtDirMid = Media( vtDirPrec, vtDir) ;
if ( ! vtDirMid.Normalize())
return false ;
return true ;
Vector3d vtAuxMid = Media( vtAuxPrec, vtAux) ;
if ( ! vtAuxPrec.IsSmall() && ! vtAux.IsSmall() && ! vtAuxMid.Normalize())
return false ;
return true ;
Vector3d vtCorrMid = Media( vtCorrPrec, vtCorr) ;
if ( ! vtCorrPrec.IsSmall() && ! vtCorr.IsSmall() && ! vtCorrMid.Normalize())
return false ;
return true ;
// inserisco nuova entità e modifico vecchia
int nMidEntId = m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_BEFORE) ;
if ( nMidEntId == GDB_ID_NULL)
+41
View File
@@ -124,6 +124,17 @@ static const std::string GVAR_R4P = ".R4p" ; // (num) valore pr
static const std::string GVAR_R5P = ".R5p" ; // (num) valore precedente del quinto asse rotante
static const std::string GVAR_R6P = ".R6p" ; // (num) valore precedente del sesto asse rotante
static const std::string GVAR_R7P = ".R7p" ; // (num) valore precedente del settimo asse rotante
static const std::string GVAR_MOVESUCC = ".MOVESUCC" ; // (int) tipo del movimento successivo (0,1,2,3)
static const std::string GVAR_L1S = ".L1s" ; // (num) valore successivo del primo asse lineare
static const std::string GVAR_L2S = ".L2s" ; // (num) valore successivo del secondo asse lineare
static const std::string GVAR_L3S = ".L3s" ; // (num) valore successivo del terzo asse lineare
static const std::string GVAR_R1S = ".R1s" ; // (num) valore successivo del primo asse rotante
static const std::string GVAR_R2S = ".R2s" ; // (num) valore successivo del secondo asse rotante
static const std::string GVAR_R3S = ".R3s" ; // (num) valore successivo del terzo asse rotante
static const std::string GVAR_R4S = ".R4s" ; // (num) valore successivo del quarto asse rotante
static const std::string GVAR_R5S = ".R5s" ; // (num) valore successivo del quinto asse rotante
static const std::string GVAR_R6S = ".R6s" ; // (num) valore successivo del sesto asse rotante
static const std::string GVAR_R7S = ".R7s" ; // (num) valore successivo del settimo asse rotante
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
@@ -299,6 +310,36 @@ GetGlobVarAxisPrev( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot =
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisNext( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot = false)
{
if ( ! bIsRobot) {
switch ( nAx) {
case 1 : return ( sVar + GVAR_L1S) ;
case 2 : return ( sVar + GVAR_L2S) ;
case 3 : return ( sVar + GVAR_L3S) ;
case 4 : return ( sVar + GVAR_R1S) ;
case 5 : return ( sVar + GVAR_R2S) ;
case 6 : return ( sVar + GVAR_R3S) ;
case 7 : return ( sVar + GVAR_R4S) ;
default : return "" ;
}
}
else {
switch ( nAx) {
case 1 : return ( sVar + GVAR_R1S) ;
case 2 : return ( sVar + GVAR_R2S) ;
case 3 : return ( sVar + GVAR_R3S) ;
case 4 : return ( sVar + GVAR_R4S) ;
case 5 : return ( sVar + GVAR_R5S) ;
case 6 : return ( sVar + GVAR_R6S) ;
case 7 : return ( sVar + GVAR_R7S) ;
default : return "" ;
}
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisToken( int nAx, bool bIsRobot = false)
+58 -8
View File
@@ -414,7 +414,7 @@ Processor::ProcessClPath( int nClPathId, int nClPathInd, int nOpId, int nOpInd)
// processo l'entità
if ( ! ProcessClEnt( nEntId, nEntInd, nClPathId, nClPathInd, nOpId, nOpInd))
bOk = false ;
// passo all'entità successivo
// passo all'entità successiva
nEntId = m_pGeomDB->GetNext( nEntId) ;
}
@@ -449,19 +449,24 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd,
if ( pCamData == nullptr || pCamData->GetAxesStatus() != CamData::AS_OK)
return false ;
const DBLVECTOR& AxesEnd = pCamData->GetAxesVal() ;
// Emetto movimento
int nMove = pCamData->GetMoveType() ;
// Recupero i dati Cam del movimento successivo del percorso (se esiste)
CamData* pNextCamData = GetCamData( m_pGeomDB->GetUserObj( m_pGeomDB->GetNext( nEntId))) ;
int nMoveNext = ( pNextCamData != nullptr ? pNextCamData->GetMoveType() : -1) ;
DBLVECTOR AxesNull ;
const DBLVECTOR& AxesNext = ( pNextCamData != nullptr ? pNextCamData->GetAxesVal() : AxesNull) ;
// Emetto movimento
switch ( nMove) {
case 0 : // rapido
if ( ! OnRapid( nEntId, nEntInd, nMove, AxesEnd, pCamData->GetAxesMask(),
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext))
return false ;
break ;
case 1 : // linea
if ( ! OnLinear( nEntId, nEntInd, nMove, AxesEnd,
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext))
return false ;
break ;
case 2 : // arco CW
@@ -471,7 +476,7 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd,
if ( ! OnArc( nEntId, nEntInd, nMove, AxesEnd,
pCamData->GetAxesCen(), ptMid, pCamData->GetAxesRad(), pCamData->GetAxesAngCen(),
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext))
return false ;
break ;
}
@@ -974,7 +979,7 @@ Processor::OnPathEndAux( int nInd, const string& sAE)
bool
Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
int nFlag, int nFlag2, int nIndex)
int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext)
{
// cancello variabili estranee
ResetArcData() ;
@@ -1006,6 +1011,21 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ;
// assegno il valore dell'indice
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ;
// anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso
if ( nMoveNext != -1) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i)
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
// chiamo la funzione di movimento in rapido
bOk = bOk && CallOnRapid() ;
return bOk ;
@@ -1015,7 +1035,7 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd
bool
Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex)
double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext)
{
// cancello variabili estranee
ResetArcData() ;
@@ -1047,6 +1067,21 @@ Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEn
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ;
// assegno il valore dell'indice
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ;
// anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso
if ( nMoveNext != -1) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i)
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
// chiamo la funzione di movimento in rapido
bOk = bOk && CallOnLinear() ;
return bOk ;
@@ -1057,7 +1092,7 @@ bool
Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex)
double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext)
{
// assegno Id e indice entità di movimento
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, nEntId) ;
@@ -1099,6 +1134,21 @@ Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ;
// assegno il valore dell'indice
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ;
// anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso
if ( nMoveNext != -1) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i)
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
// chiamo la funzione di movimento in rapido
bOk = bOk && CallOnArc() ;
return bOk ;
+3 -3
View File
@@ -61,14 +61,14 @@ class Processor
bool OnPathEndAux( int nInd, const std::string& sAE) ;
bool OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
int nFlag, int nFlag2, int nIndex) ;
int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ;
bool OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex) ;
double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ;
bool OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex) ;
double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ;
bool ResetArcData( void) ;
protected :
+40 -6
View File
@@ -1009,8 +1009,9 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
// Se inizio di nuova entità
if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) {
++ m_nEntInd ;
const CamData* pNextCamData = GetCamData( m_pGeomDB->GetUserObj( m_pGeomDB->GetNext( m_nEntId))) ;
int nErr ;
if ( ! OnMoveStart( pCamData, nErr)) {
if ( ! OnMoveStart( pCamData, pNextCamData, nErr)) {
nStatus = CalcStatusOnError( nErr) ;
return false ;
}
@@ -1514,6 +1515,25 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
return true ;
}
//----------------------------------------------------------------------------
static int
FindCollisionMarkId( const IGeomDB* pGeomDB, int nCollId)
{
int nCollParId = pGeomDB->GetParentId( nCollId) ;
string sCollParName = "COLLISION" ;
pGeomDB->GetName( nCollParId, sCollParName) ;
if ( sCollParName != "COLLISION")
return nCollParId ;
else {
int nCollGprId = pGeomDB->GetParentId( nCollParId) ;
int nCollSolId = pGeomDB->GetFirstNameInGroup( nCollGprId, "SOLID") ;
if ( nCollSolId != GDB_ID_NULL)
return nCollSolId ;
else
return nCollGprId ;
}
}
//----------------------------------------------------------------------------
bool
Simulator::SetCollisionMark( int nCdInd, int nObjInd)
@@ -1521,10 +1541,8 @@ Simulator::SetCollisionMark( int nCdInd, int nObjInd)
if ( m_pGeomDB == nullptr)
return false ;
m_nCollMarkId.clear() ;
int nCdGeoId = m_pGeomDB->GetParentId( m_pGeomDB->GetParentId( m_CdId[nCdInd])) ;
int nCoGeoId = m_pGeomDB->GetParentId( m_pGeomDB->GetParentId( m_CollObj[nObjInd].nFrameId)) ;
m_nCollMarkId.push_back( nCdGeoId) ;
m_nCollMarkId.push_back( nCoGeoId) ;
m_nCollMarkId.push_back( FindCollisionMarkId( m_pGeomDB, m_CdId[nCdInd])) ;
m_nCollMarkId.push_back( FindCollisionMarkId( m_pGeomDB, m_CollObj[nObjInd].nFrameId)) ;
for ( auto nId : m_nCollMarkId)
m_pGeomDB->SetMark( nId) ;
return true ;
@@ -1916,7 +1934,7 @@ Simulator::OnPathEndAux( int nInd, const string& sAE, int& nErr)
//----------------------------------------------------------------------------
bool
Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
Simulator::OnMoveStart( const CamData* pCamData, const CamData* pNextCamData, int& nErr)
{
// reset stato di errore da script
nErr = 0 ;
@@ -1948,6 +1966,22 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIR, pCamData->GetToolDir()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_CDIR, pCamData->GetCorrDir()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ADIR, pCamData->GetBackAuxDir()) ;
// anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso
if ( pNextCamData != nullptr && pNextCamData->GetAxesStatus() == CamData::AS_OK) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, pNextCamData->GetMoveType()) ;
const DBLVECTOR& AxesNext = pNextCamData->GetAxesVal() ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i)
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ;
}
// reset abilitazione assi attivi
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_ENABAXES) ;
// reset numero assi ausiliari
+1 -1
View File
@@ -110,7 +110,7 @@ class Simulator
const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax,
const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev) ;
bool OnPathEnd( int nAE) ;
bool OnMoveStart( const CamData* pCamData, int& nErr) ;
bool OnMoveStart( const CamData* pCamData, const CamData* pNextCamData, int& nErr) ;
bool OnMoveEnd( int& nErr) ;
bool OnResetMachine( void) ;