EgtMachKernel :

- in calcolo angoli macchina aggiunta segnalazione di direzione utensile irraggiungibile
- in disposizione aggiunti controlli di sottopezzo e grezzo in tavola
- in simulazione la Move ora restituisce uno stato
- migliorato calcolo elevazione per lavorazioni con lama
- la tavola macchina conserva l'area utile.
This commit is contained in:
Dario Sassi
2015-11-23 09:06:44 +00:00
parent 8dd67afcb7
commit 2f016585bb
15 changed files with 134 additions and 49 deletions
+1 -1
View File
@@ -447,7 +447,7 @@ CamData::SetFlag( int nFlag)
bool
CamData::SetAxes( int nStatus, const DBLVECTOR& vAxVal)
{
if ( nStatus != AS_OK && nStatus != AS_ERR && nStatus != AS_OUTSTROKE)
if ( nStatus != AS_OK && nStatus != AS_OUTSTROKE && nStatus != AS_DIR_ERR && nStatus != AS_ERR)
return false ;
m_nAxesStatus = nStatus ;
m_vMachAxes = vAxVal ;
+3 -2
View File
@@ -74,8 +74,9 @@ class CamData : public IUserObj
public :
enum { AS_NONE = 0,
AS_OK = 1,
AS_ERR = 2,
AS_OUTSTROKE = 3} ;
AS_OUTSTROKE = 2,
AS_DIR_ERR = 3,
AS_ERR = 4} ;
private :
void ResetObjGraphics( void) ;
+43 -1
View File
@@ -245,11 +245,12 @@ Disposition::SetTable( const string& sTable)
// imposta questa tavola come corrente
if ( ! pMch->SetCurrTable( sTable))
return false ;
// recupero il primo riferimento della tavola
// recupero il primo riferimento e l'area utile della tavola
Table* pTab = pMch->GetTable( sTable) ;
if ( pTab == nullptr)
return false ;
m_ptRef1 = pTab->GetRef1() ;
m_b3Area1 = pTab->GetArea1() ;
// salvo il nome e dichiaro tavola verificata
m_sTabName = sTable ;
m_bTabOk = true ;
@@ -286,6 +287,21 @@ Disposition::GetTableRef1( Point3d& ptRef1) const
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::GetTableArea1( BBox3d& b3Area1) const
{
// verifico MachMgr e GeomDB
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// verifico tavola
if ( ! m_bTabOk && ! const_cast<Disposition*>(this)->SetTable( m_sTabName))
return false ;
// recupero la prima area utile della tavola
b3Area1 = m_b3Area1 ;
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::Apply(void)
@@ -343,6 +359,9 @@ Disposition::AddFixture( const string& sName, const Point3d& ptPos, double dAngD
// verifico tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
return GDB_ID_NULL ;
// verifico che la posizione sia nell'area della tavola
if ( ! m_b3Area1.EnclosesXY( m_ptRef1 + ptPos))
return GDB_ID_NULL ;
// recupero il gruppo delle fixtures nella macchinata corrente
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
if ( nFixtGrpId == GDB_ID_NULL)
@@ -381,6 +400,11 @@ Disposition::MoveFixture( int nId, const Vector3d& vtMove)
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
return false ;
// verifico che la posizione finale sia nell'area della tavola
Frame3d frFixt ;
if ( ! m_pGeomDB->GetGlobFrame( nId, frFixt) ||
! m_b3Area1.EnclosesXY( frFixt.Orig() + vtMove))
return false ;
// muovo l'oggetto
m_pGeomDB->TranslateGlob( nId, vtMove) ;
// aggiorno la posizione dell'oggetto nel vettore dei comandi
@@ -469,6 +493,10 @@ Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMax().x, b3Raw.GetMin().y, b3Raw.GetMin().z) ;
break ;
}
// verifico se il grezzo nella posizione finale sarà nella tavola
b3Raw.Translate( vtMove) ;
if ( ! m_b3Area1.EnclosesXY( b3Raw))
return false ;
// eseguo traslazione in globale
if ( ! vtMove.IsSmall())
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
@@ -521,6 +549,10 @@ Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
vtMove = ( m_ptRef1 + ptP) - Point3d( ptCen.x, ptCen.y, b3Raw.GetMin().z) ;
break ;
}
// verifico se il grezzo nella posizione finale sarà nella tavola
b3Raw.Translate( vtMove) ;
if ( ! m_b3Area1.EnclosesXY( b3Raw))
return false ;
// eseguo traslazione in globale
if ( ! vtMove.IsSmall())
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
@@ -555,6 +587,16 @@ Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
if ( iIter == m_vMvrData.end())
return false ;
// recupero il solido
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
// determino il box del grezzo (solo il solido ovviamente)
BBox3d b3Raw ;
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
return false ;
// verifico se il grezzo nella posizione finale sarà nella tavola
b3Raw.Translate( vtMove) ;
if ( ! m_b3Area1.EnclosesXY( b3Raw))
return false ;
// eseguo traslazione in globale
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
// aggiorno comando di movimento
+2
View File
@@ -68,6 +68,7 @@ class Disposition : public IUserObj
bool Apply( void) ;
bool GetTable( std::string& sTable) const ;
bool GetTableRef1( Point3d& ptRef1) const ;
bool GetTableArea1( BBox3d& b3Area1) const ;
int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngDeg = 0, bool bAddToList = true) ;
bool MoveFixture( int nId, const Vector3d& vtMove) ;
bool RotateFixture( int nId, double dAngDeg) ;
@@ -91,6 +92,7 @@ class Disposition : public IUserObj
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
std::string m_sTabName ; // nome della tavola di appartenenza
Point3d m_ptRef1 ; // origine 1 della tavola
BBox3d m_b3Area1 ; // area utile 1 della tavola
bool m_bTabOk ; // flag di tavola verificata
FIXDATAVECTOR m_vFixData ; // elenco posizionamento bloccaggi
MVRDATAVECTOR m_vMvrData ; // elenco movimenti grezzi
+3 -3
View File
@@ -94,8 +94,8 @@ class MachMgr : public IMachMgr
virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ;
// Tables and Fixtures
virtual bool SetTable( const std::string& sTable) ;
virtual bool GetTableRef1( Point3d& ptPos) ;
virtual bool GetTableArea1( int& nAreaId) ;
virtual bool GetTableRef( int nInd, Point3d& ptPos) ;
virtual bool GetTableArea( int nInd, BBox3d& b3Area) ;
virtual int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ;
virtual bool ShowOnlyTable( bool bVal) ;
// Tools DataBase
@@ -169,7 +169,7 @@ class MachMgr : public IMachMgr
virtual bool GetMachiningParam( int nType, std::string& sVal) const ;
// Simulation
virtual bool SimStart( void) ;
virtual bool SimMove( void) ;
virtual bool SimMove( int& nStatus) ;
virtual bool SimGetAxisInfoPos( int nI, std::string& sName, double& dVal) ;
virtual bool SimSetStep( double dStep) ;
virtual bool SimStop( void) ;
+15 -15
View File
@@ -35,11 +35,14 @@ MachMgr::SetTable( const string& sTable)
//----------------------------------------------------------------------------
bool
MachMgr::GetTableRef1( Point3d& ptPos)
MachMgr::GetTableRef( int nInd, Point3d& ptPos)
{
// attualmente previsto solo il riferimento 1
if ( nInd != 1)
return false ;
// recupero la prima operazione, deve essere la disposizione
int nDispId = GetFirstOperation() ;
// recupero l'oggetto disposizione
// recupero il primo oggetto disposizione
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
if ( pDisp == nullptr)
return false ;
@@ -49,22 +52,19 @@ MachMgr::GetTableRef1( Point3d& ptPos)
//----------------------------------------------------------------------------
bool
MachMgr::GetTableArea1( int& nAreaId)
MachMgr::GetTableArea( int nInd, BBox3d& b3Area1)
{
// verifico DB geometrico
if ( m_pGeomDB == nullptr)
// attualmente prevista solo l'area 1
if ( nInd != 1)
return false ;
// recupero la macchina corrente
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
// recupero la prima operazione, deve essere la disposizione
int nDispId = GetFirstOperation() ;
// recupero il primo oggetto disposizione
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
if ( pDisp == nullptr)
return false ;
// recupero la tavola corrente
int nTabId = pMch->GetCurrTable() ;
if ( nTabId == GDB_ID_NULL)
return false ;
// recupero l'oggetto che ne definisce l'area utile
nAreaId = m_pGeomDB->GetFirstNameInGroup( nTabId, MCH_TAREA + "1") ;
return ( nAreaId != GDB_ID_NULL) ;
// recupero il bounding box
return pDisp->GetTableArea1( b3Area1) ;
}
//----------------------------------------------------------------------------
+5 -3
View File
@@ -39,13 +39,15 @@ MachMgr::SimStart( void)
//----------------------------------------------------------------------------
bool
MachMgr::SimMove( void)
MachMgr::SimMove( int& nStatus)
{
// verifico simulatore
if ( m_pSimul == nullptr)
if ( m_pSimul == nullptr) {
nStatus = MCH_SIM_ERR ;
return false ;
}
// eseguo movimento
return m_pSimul->Move() ;
return m_pSimul->Move( nStatus) ;
}
//----------------------------------------------------------------------------
+9 -4
View File
@@ -172,15 +172,20 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
return false ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// aggiusto la posizione della tavola
if ( ! AdjustTablePos( nLay, ptRef1))
return false ;
// recupero l'area valida
int nAreaId = m_pGeomDB->GetFirstNameInGroup( nLay, MCH_TAREA + "1") ;
BBox3d b3Area1 ;
if ( ! m_pGeomDB->GetGlobalBBox( nAreaId, b3Area1))
return false ;
// installo e inizializzo il gestore della tavola
Table* pTab = new(nothrow) Table ;
if ( pTab == nullptr)
return false ;
pTab->Set( sName, nType, ptRef1) ;
pTab->Set( sName, nType, ptRef1, b3Area1) ;
m_pGeomDB->SetUserObj( nLay, pTab) ;
// aggiusto la posizione della tavola
if ( ! AdjustTablePos( nLay, ptRef1))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
}
+1
View File
@@ -436,6 +436,7 @@ Machine::GetPositions( const Point3d& ptP, double dAngA, double dAngB,
dY = ptP.y + vtDtHe.y + vtDtAx.y + vtDtTL.y ;
dZ = ptP.z + vtDtHe.z + vtDtAx.z + vtDtTL.z ;
// tutto ok
nStat = 0 ;
return true ;
}
+5 -6
View File
@@ -349,7 +349,7 @@ Machining::GetFinalAxesValues( DBLVECTOR& vAxVal)
return false ;
// assegno i valori degli assi
vAxVal = pCamData->GetAxisVal() ;
return true ;
return ( vAxVal.size() > 0) ;
}
//----------------------------------------------------------------------------
@@ -375,10 +375,10 @@ Machining::CalculateAxesValues( void)
// assegno gli angoli iniziali
double dAngAprec = 0 ;
double dAngBprec = 0 ;
DBLVECTOR vAxVal ;
// se utensile non cambiato, uso gli angoli finali della lavorazione precedente
if ( ! sPrevTool.empty() && GetToolData().m_sName == sPrevTool) {
DBLVECTOR vAxVal ;
pPrevMch->GetFinalAxesValues( vAxVal) ;
if ( ! sPrevTool.empty() && GetToolData().m_sName == sPrevTool &&
pPrevMch->GetFinalAxesValues( vAxVal)) {
if ( nRotAxes >= 1)
dAngAprec = vAxVal[nLinAxes - 1 + 1] ;
if ( nRotAxes >= 2)
@@ -386,7 +386,6 @@ Machining::CalculateAxesValues( void)
}
// altrimenti uso gli angoli home
else {
DBLVECTOR vAxVal ;
m_pMchMgr->GetAllCalcAxesHomePos( vAxVal) ;
if ( nRotAxes >= 1)
dAngAprec = vAxVal[nLinAxes - 1 + 1] ;
@@ -438,7 +437,7 @@ Machining::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
bool bROk = m_pMchMgr->GetCalcAngles( pCamData->GetToolDir(), pCamData->GetCorrDir(), nRStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
if ( ! bROk || nRStat == 0) {
bOk = false ;
pCamData->SetAxes( CamData::AS_ERR, vAxVal) ;
pCamData->SetAxes( CamData::AS_DIR_ERR, vAxVal) ;
continue ;
}
if ( nRStat == 1) {
+6 -3
View File
@@ -845,13 +845,16 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr
}
// aggiungo affondamento
pLine->Translate( - vtCorr * dDepth) ;
// calcolo elevazione
double dElev ;
if ( ! GetElevation( pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev)) {
// calcolo elevazione (sui due bordi della striscia
double dElev, dElev2 ;
Vector3d vtThick = vtTool * m_TParams.m_dThick ;
if ( ! GetElevation( pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev) ||
! GetElevation( pLine->GetStart() + vtThick, pLine->GetEnd() + vtThick, vtCorr, dElev2) ) {
string sOut = "Entity not elevation-enabled by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
dElev = max( dElev, dElev2) ;
// direzione linea corrente
Vector3d vtDirC ;
pLine->GetStartDir( vtDirC) ;
+27 -5
View File
@@ -95,11 +95,13 @@ Simulator::Start( void)
//----------------------------------------------------------------------------
bool
Simulator::Move( void)
Simulator::Move( int& nStatus)
{
// Verifiche
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) {
nStatus = MCH_SIM_ERR ;
return false ;
}
// Se arrivato alla fine dell'interpolazione, recupero una nuova entità
if ( m_dCoeff > 0.999) {
m_nEntId = m_pGeomDB->GetNext( m_nEntId) ;
@@ -115,22 +117,41 @@ Simulator::Move( void)
if ( m_nCLPathId == GDB_ID_NULL) {
m_nOpId = m_pMchMgr->GetNextOperation( m_nOpId) ;
// se non ce ne sono altre, sono alla fine
if ( m_nOpId == GDB_ID_NULL)
if ( m_nOpId == GDB_ID_NULL) {
nStatus = MCH_SIM_END ;
return false ;
}
// aggiorno gli altri dati
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOpId, MCH_CL) ;
m_nCLPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
m_nEntId = m_pGeomDB->GetFirstInGroup( m_nCLPathId) ;
m_dCoeff = 0 ;
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool() || ! UpdateAxes())
if ( ! UpdateTool() || ! UpdateAxes()) {
nStatus = MCH_SIM_ERR ;
return false ;
}
}
// Cerco prossima posizione su interpolazione corrente
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( m_nEntId)) ;
if ( pCamData == nullptr || pCamData->GetAxesStatus() != CamData::AS_OK)
if ( pCamData == nullptr) {
nStatus = MCH_SIM_ERR ;
return false ;
}
switch ( pCamData->GetAxesStatus()) {
case CamData::AS_OK :
break ;
case CamData::AS_OUTSTROKE :
nStatus = MCH_SIM_OUTSTROKE ;
return false ;
case CamData::AS_DIR_ERR :
nStatus = MCH_SIM_DIR_ERR ;
return false ;
default :
nStatus = MCH_SIM_ERR ;
return false ;
}
const DBLVECTOR& AxesEnd = pCamData->GetAxisVal() ;
// Verifico se movimento in rapido
bool bRapid = ( pCamData->GetFeed() < EPS_SMALL) ;
@@ -152,6 +173,7 @@ Simulator::Move( void)
if ( m_dCoeff > 0.999)
m_AxesVal = AxesEnd ;
nStatus = MCH_SIM_OK ;
return true ;
}
+2 -1
View File
@@ -14,6 +14,7 @@
#pragma once
#include "CamData.h"
#include "/EgtDev/Include/EMkSimuGenConst.h"
class MachMgr ;
class IGeomDB ;
@@ -26,7 +27,7 @@ class Simulator
~Simulator( void) ;
bool Init( MachMgr* pMchMgr) ;
bool Start( void) ;
bool Move( void) ;
bool Move( int& nStatus) ;
bool GetAxisInfoPos( int nI, std::string& sName, double& dVal) ;
bool SetStep( double dStep) ;
bool Stop( void) ;
+2 -1
View File
@@ -99,11 +99,12 @@ Table::Table( void)
//----------------------------------------------------------------------------
bool
Table::Set( const string& sName, int nType, const Point3d& ptRef1)
Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1)
{
m_sName = sName ;
m_nType = nType ;
m_ptRef1 = ptRef1 ;
m_b3Area1 = b3Area1 ;
return true ;
}
+10 -4
View File
@@ -30,10 +30,15 @@ class Table : public IUserObj
public :
Table( void) ;
bool Set( const std::string& sName, int nType, const Point3d& ptRef1) ;
const std::string& GetName( void) { return m_sName ; }
int GetType( void) { return m_nType ; }
const Point3d& GetRef1( void) { return m_ptRef1 ; }
bool Set( const std::string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1) ;
const std::string& GetName( void)
{ return m_sName ; }
int GetType( void)
{ return m_nType ; }
const Point3d& GetRef1( void)
{ return m_ptRef1 ; }
const BBox3d& GetArea1( void)
{ return m_b3Area1 ; }
private :
int m_nOwnerId ;
@@ -41,4 +46,5 @@ class Table : public IUserObj
std::string m_sName ;
int m_nType ;
Point3d m_ptRef1 ;
BBox3d m_b3Area1 ;
} ;