EgtMachKernel 1.6j2 :
- aggiunta prima versione del Simulator.
This commit is contained in:
+24
-2
@@ -22,7 +22,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int CAM_TOTPARAM = 7 ;
|
||||
static int CAM_TOTPARAM = 9 ;
|
||||
static std::string CAM_CORR = "Corr" ;
|
||||
static std::string CAM_TDIR = "TDir" ;
|
||||
static std::string CAM_CDIR = "CDir" ;
|
||||
@@ -30,6 +30,8 @@ static std::string CAM_ADIR = "ADir" ;
|
||||
static std::string CAM_PBAS = "PBas" ;
|
||||
static std::string CAM_FEED = "Feed" ;
|
||||
static std::string CAM_FLAG = "Flg" ;
|
||||
static std::string CAM_AXSTS = "AxS" ;
|
||||
static std::string CAM_AXVAL = "AxV" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkCamData", CamData) ;
|
||||
@@ -80,6 +82,8 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
sOut += CAM_PBAS + "=" + ToString( m_ptBase) + szNewLine ;
|
||||
sOut += CAM_FEED + "=" + ToString( m_dFeed) + szNewLine ;
|
||||
sOut += CAM_FLAG + "=" + ToString( m_nFlag) + szNewLine ;
|
||||
sOut += CAM_AXSTS + "=" + ToString( m_nAxesStatus) + szNewLine ;
|
||||
sOut += CAM_AXVAL + "=" + ToString( m_dMachAxes) + szNewLine ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -121,6 +125,8 @@ CamData::Save( STRVECTOR& vString) const
|
||||
vString[++k] = CAM_PBAS + "=" + ToString( m_ptBase) ;
|
||||
vString[++k] = CAM_FEED + "=" + ToString( m_dFeed) ;
|
||||
vString[++k] = CAM_FLAG + "=" + ToString( m_nFlag) ;
|
||||
vString[++k] = CAM_AXSTS + "=" + ToString( m_nAxesStatus) ;
|
||||
vString[++k] = CAM_AXVAL + "=" + ToString( m_dMachAxes) ;
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
@@ -141,7 +147,9 @@ CamData::Load( const STRVECTOR& vString)
|
||||
! GetVal( vString[++k], CAM_ADIR, m_vtAux) ||
|
||||
! GetVal( vString[++k], CAM_PBAS, m_ptBase) ||
|
||||
! GetVal( vString[++k], CAM_FEED, m_dFeed) ||
|
||||
! GetVal( vString[++k], CAM_FLAG, m_nFlag))
|
||||
! GetVal( vString[++k], CAM_FLAG, m_nFlag) ||
|
||||
! GetVal( vString[++k], CAM_AXSTS, m_nAxesStatus) ||
|
||||
! GetVal( vString[++k], CAM_AXVAL, m_dMachAxes))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
@@ -379,6 +387,9 @@ CamData::CamData( void)
|
||||
m_nCorre = 0 ;
|
||||
m_dFeed = 0 ;
|
||||
m_nFlag = 0 ;
|
||||
m_nAxesStatus = AS_NONE ;
|
||||
for ( auto& dAxVal : m_dMachAxes)
|
||||
dAxVal = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -433,6 +444,17 @@ CamData::SetFlag( int nFlag)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CamData::SetAxes( int nStatus, const MachAxesVal& adAxVal)
|
||||
{
|
||||
if ( nStatus != AS_OK && nStatus != AS_ERR && nStatus != AS_OUTSTROKE)
|
||||
return false ;
|
||||
m_nAxesStatus = nStatus ;
|
||||
m_dMachAxes = adAxVal ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CamData::ResetObjGraphics( void)
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include "/EgtDev/Include/EGkVector3d.h"
|
||||
#include "/EgtDev/Include/EGkUserObj.h"
|
||||
#include "/EgtDev/Include/EGkSelection.h"
|
||||
#include <array>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
typedef std::array<double,8> MachAxesVal ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CamData : public IUserObj
|
||||
@@ -51,18 +55,45 @@ class CamData : public IUserObj
|
||||
bool SetBasePoint( const Point3d& ptBase) ;
|
||||
bool SetFeed( double dFeed) ;
|
||||
bool SetFlag( int nFlag) ;
|
||||
bool SetAxes( int nStatus, const MachAxesVal& adAxVal) ;
|
||||
bool ResetAxes( void)
|
||||
{ m_nAxesStatus = AS_NONE ; return true ; }
|
||||
const Vector3d& GetToolDir( void)
|
||||
{ return m_vtTool ; }
|
||||
const Vector3d& GetCorrDir( void)
|
||||
{ return m_vtCorr ; }
|
||||
const Vector3d& GetAuxDir( void)
|
||||
{ return m_vtAux ; }
|
||||
const Point3d& GetBasePoint( void)
|
||||
{ return m_ptBase ; }
|
||||
double GetFeed( void)
|
||||
{ return m_dFeed ; }
|
||||
int GetFlag( void)
|
||||
{ return m_nFlag ; }
|
||||
int GetAxesStatus( void)
|
||||
{ return m_nAxesStatus ; }
|
||||
const MachAxesVal& GetAxisVal( void)
|
||||
{ return m_dMachAxes ; }
|
||||
|
||||
public :
|
||||
enum { AS_NONE = 0,
|
||||
AS_OK = 1,
|
||||
AS_ERR = 2,
|
||||
AS_OUTSTROKE = 3} ;
|
||||
|
||||
private :
|
||||
void ResetObjGraphics( void) ;
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
int m_nCorre ; // tipo correzione (0, 41, 42, 141, 142, 40)
|
||||
Vector3d m_vtTool ; // versore fresa
|
||||
Vector3d m_vtCorr ; // versore correzione
|
||||
Vector3d m_vtAux ; // versore ausiliario
|
||||
Point3d m_ptBase ; // punto base per il disegno dei vettori
|
||||
double m_dFeed ; // velocità di avanzamento in lavorazione
|
||||
int m_nFlag ; // flag per usi vari
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
int m_nCorre ; // tipo correzione (0, 41, 42, 141, 142, 40)
|
||||
Vector3d m_vtTool ; // versore fresa
|
||||
Vector3d m_vtCorr ; // versore correzione
|
||||
Vector3d m_vtAux ; // versore ausiliario
|
||||
Point3d m_ptBase ; // punto base per il disegno dei vettori
|
||||
double m_dFeed ; // velocità di avanzamento in lavorazione
|
||||
int m_nFlag ; // flag per usi vari
|
||||
int m_nAxesStatus ; // stato dei valori assi
|
||||
MachAxesVal m_dMachAxes ; // valori degli assi macchina
|
||||
} ;
|
||||
@@ -345,6 +345,20 @@ Drilling::Apply( void)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Drilling::GetParam( int nType, string& sVal)
|
||||
{
|
||||
switch ( nType) {
|
||||
case MPA_TOOL :
|
||||
sVal = m_Params.m_sToolName ;
|
||||
break ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Drilling::GetHoleData( SelData Id, Hole& hole)
|
||||
|
||||
@@ -38,6 +38,7 @@ class Drilling : public Machining
|
||||
virtual bool SetParam( int nType, const std::string& sVal) ;
|
||||
virtual bool SetGeometry( const SELVECTOR& vIds) ;
|
||||
virtual bool Apply( void) ;
|
||||
virtual bool GetParam( int nType, std::string& sVal) ;
|
||||
|
||||
public :
|
||||
Drilling( void) ;
|
||||
|
||||
Binary file not shown.
@@ -235,11 +235,13 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="MachMgrOperations.cpp" />
|
||||
<ClCompile Include="MachMgrParts.cpp" />
|
||||
<ClCompile Include="MachMgrRawParts.cpp" />
|
||||
<ClCompile Include="MachMgrSimulation.cpp" />
|
||||
<ClCompile Include="MachMgrTools.cpp" />
|
||||
<ClCompile Include="Milling.cpp" />
|
||||
<ClCompile Include="MillingData.cpp" />
|
||||
<ClCompile Include="Sawing.cpp" />
|
||||
<ClCompile Include="SawingData.cpp" />
|
||||
<ClCompile Include="Simulator.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
@@ -279,6 +281,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Sawing.h" />
|
||||
<ClInclude Include="SawingData.h" />
|
||||
<ClInclude Include="Simulator.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="Head.h" />
|
||||
<ClInclude Include="Table.h" />
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<Filter Include="Source Files\Machinings">
|
||||
<UniqueIdentifier>{9ebd88f4-45ef-477d-b613-d142baef86fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Simulation">
|
||||
<UniqueIdentifier>{fbbebf38-66cd-4db8-863b-bc1a1cbf95d9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EMkDllMain.cpp">
|
||||
@@ -132,6 +135,12 @@
|
||||
<ClCompile Include="MachMgrTools.cpp">
|
||||
<Filter>Source Files\MachMgr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Simulator.cpp">
|
||||
<Filter>Source Files\Simulation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MachMgrSimulation.cpp">
|
||||
<Filter>Source Files\MachMgr</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DllMain.h">
|
||||
@@ -230,6 +239,9 @@
|
||||
<ClInclude Include="..\Include\EMkDispositionConst.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Simulator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtMachKernel.rc">
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include "Machine.h"
|
||||
#include "ToolsMgr.h"
|
||||
#include "MachiningsMgr.h"
|
||||
#include "Simulator.h"
|
||||
#include "/EgtDev/Include/EMkMachMgr.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct MachGrp {
|
||||
std::string MGeoName ;
|
||||
@@ -101,6 +101,7 @@ class MachMgr : public IMachMgr
|
||||
virtual bool GetAxisPos( const std::string& sAxis, double& dVal) ;
|
||||
virtual bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ;
|
||||
virtual bool ResetAxisPos( const std::string& sAxis) ;
|
||||
virtual bool ResetAllAxesPos( void) ;
|
||||
virtual bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ;
|
||||
virtual bool ResetHeadSet( const std::string& sHead) ;
|
||||
virtual bool SetCalcTable( const std::string& sTable) ;
|
||||
@@ -127,6 +128,7 @@ class MachMgr : public IMachMgr
|
||||
virtual int GetOperationCount( void) const ;
|
||||
virtual int GetFirstOperation( void) const ;
|
||||
virtual int GetNextOperation( int nId) const ;
|
||||
virtual int GetOperationType( int nId) const ;
|
||||
virtual bool GetOperationNewName( std::string& sName) const ;
|
||||
virtual std::string GetOperationName( int nId) const ;
|
||||
virtual int GetOperationId( const std::string& sName) const ;
|
||||
@@ -134,6 +136,11 @@ class MachMgr : public IMachMgr
|
||||
virtual bool ResetCurrMachining( void) ;
|
||||
virtual int GetCurrMachining( void) const ;
|
||||
virtual int AddDisposition( const std::string& sName) ;
|
||||
// Simulation
|
||||
virtual bool SimStart( void) ;
|
||||
virtual bool SimMove( void) ;
|
||||
virtual bool SimSetStep( double dStep) ;
|
||||
virtual bool SimStop( void) ;
|
||||
|
||||
public :
|
||||
MachMgr( void) ;
|
||||
@@ -217,5 +224,6 @@ class MachMgr : public IMachMgr
|
||||
MachGrp m_cCurrMGrp ; // dati principali macchinata corrente
|
||||
int m_nCurrMch ; // indice macchina corrente (0-based)
|
||||
MCHDATAVECTOR m_vMachines ; // elenco macchine caricate
|
||||
int m_nCurrMachiningId ; // identificativo della lavorazione corrente
|
||||
int m_nCurrMachiningId ; // identificativo della lavorazione corrente
|
||||
Simulator* m_pSimul ; // puntatore al simulatore attivo
|
||||
} ;
|
||||
|
||||
@@ -48,6 +48,7 @@ MachMgr::MachMgr( void)
|
||||
m_nCurrMGrpId = GDB_ID_NULL ;
|
||||
m_nCurrMch = 0 ;
|
||||
m_nCurrMachiningId = GDB_ID_NULL ;
|
||||
m_pSimul = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -70,6 +71,11 @@ MachMgr::Clear( void)
|
||||
delete m_vMachines.back().pMsMgr ;
|
||||
m_vMachines.pop_back() ;
|
||||
}
|
||||
// cancello simulatore, se necessario
|
||||
if ( m_pSimul != nullptr) {
|
||||
delete m_pSimul ;
|
||||
m_pSimul = nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -147,6 +147,16 @@ MachMgr::ResetAxisPos( const string& sAxis)
|
||||
return m_vMachines[m_nCurrMch].pMachine->ResetAxisPos( sAxis) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::ResetAllAxesPos( void)
|
||||
{
|
||||
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) ||
|
||||
m_vMachines[m_nCurrMch].pMachine == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
return m_vMachines[m_nCurrMch].pMachine->ResetAllAxesPos() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::LoadTool( const string& sHead, int nExit, const string& sTool)
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "Drilling.h"
|
||||
#include "Sawing.h"
|
||||
#include "Milling.h"
|
||||
#include "/EgtDev/Include/EMkOperationConst.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
@@ -68,6 +70,35 @@ MachMgr::GetNextOperation( int nId) const
|
||||
return nNextId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::GetOperationType( int nId) const
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return OPER_NULL ;
|
||||
// verifico che il gruppo ricevuto sia corretto
|
||||
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
|
||||
return OPER_NULL ;
|
||||
// recupero user object
|
||||
IUserObj* pUserObj = m_pGeomDB->GetUserObj( nId) ;
|
||||
if ( pUserObj == nullptr)
|
||||
return OPER_NULL ;
|
||||
// recupero il tipo di UserObj
|
||||
string sUserObj = pUserObj->GetClassName() ;
|
||||
if ( sUserObj == USEROBJ_GETNAME( Disposition))
|
||||
return OPER_DISP ;
|
||||
else if ( sUserObj == USEROBJ_GETNAME( Drilling))
|
||||
return OPER_DRILLING ;
|
||||
else if ( sUserObj == USEROBJ_GETNAME( Sawing))
|
||||
return OPER_SAWING ;
|
||||
else if ( sUserObj == USEROBJ_GETNAME( Milling))
|
||||
return OPER_MILLING ;
|
||||
else
|
||||
return OPER_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::GetOperationNewName( string& sName) const
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : MachMgrSimulation.cpp Data : 20.10.15 Versione : 1.6j2
|
||||
// Contenuto : Implementazione gestione simulazione della classe MachMgr.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 20.10.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Simulator.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimStart( void)
|
||||
{
|
||||
// alloco simulatore
|
||||
if ( m_pSimul != nullptr)
|
||||
delete m_pSimul ;
|
||||
m_pSimul = new( std::nothrow) Simulator ;
|
||||
if ( m_pSimul == nullptr)
|
||||
return false ;
|
||||
// lo inizializzo
|
||||
if ( ! m_pSimul->Init( this))
|
||||
return false ;
|
||||
// lo avvio
|
||||
return m_pSimul->Start() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimMove( void)
|
||||
{
|
||||
// verifico simulatore
|
||||
if ( m_pSimul == nullptr)
|
||||
return false ;
|
||||
// eseguo movimento
|
||||
return m_pSimul->Move() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimSetStep( double dStep)
|
||||
{
|
||||
// verifico simulatore
|
||||
if ( m_pSimul == nullptr)
|
||||
return false ;
|
||||
// imposto lo step di riferimento
|
||||
return m_pSimul->SetStep( dStep) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimStop( void)
|
||||
{
|
||||
// verifico simulatore
|
||||
if ( m_pSimul == nullptr)
|
||||
return true ;
|
||||
// lo fermo e cancello
|
||||
m_pSimul->Stop() ;
|
||||
delete m_pSimul ;
|
||||
m_pSimul = nullptr ;
|
||||
return true ;
|
||||
}
|
||||
@@ -40,15 +40,18 @@ class Machine
|
||||
bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ;
|
||||
bool ResetHeadSet( const std::string& sHead) ;
|
||||
bool SetAxisPos( const std::string& sAxis, double dVal) ;
|
||||
bool SetAxisPos( int nAxGrp, double dVal) ;
|
||||
bool GetAxisPos( const std::string& sAxis, double& dVal) ;
|
||||
bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ;
|
||||
bool ResetAxisPos( const std::string& sAxis) ;
|
||||
bool ResetAllAxesPos( void) ;
|
||||
bool SetCurrTable( const std::string& sTable) ;
|
||||
int GetCurrTable( void) ;
|
||||
bool GetCurrTable( std::string& sTable) ;
|
||||
bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ;
|
||||
int GetCurrTool( void) ;
|
||||
bool GetCurrTool( std::string& sTool) ;
|
||||
std::string GetKinematicAxis( int nInd) ;
|
||||
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
|
||||
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ;
|
||||
bool GetPositions( const Point3d& ptP, double dA, double dB,
|
||||
@@ -86,7 +89,6 @@ class Machine
|
||||
const STRVECTOR& GetHSet( const std::string& sHead) const ;
|
||||
bool EnableHeadInSet( const std::string& sHead) ;
|
||||
bool CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) ;
|
||||
bool ResetAllAxesPos( void) ;
|
||||
bool CalculateKinematicChain( void) ;
|
||||
bool AddKinematicAxis( bool bOnHead, int nId) ;
|
||||
bool AdjustAngleInStroke( int nId, double& dAng) ;
|
||||
|
||||
+23
-1
@@ -228,6 +228,27 @@ Machine::AddKinematicAxis( bool bOnHead, int nId)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
string
|
||||
Machine::GetKinematicAxis( int nInd)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return "" ;
|
||||
// controllo indice
|
||||
int nLinAxTot = int( m_vCalcLinAx.size()) ;
|
||||
int nRotAxTot = int( m_vCalcRotAx.size()) ;
|
||||
if ( nInd < 0 || nInd >= nLinAxTot + nRotAxTot)
|
||||
return "" ;
|
||||
// recupero nome
|
||||
string sName ;
|
||||
if ( nInd < nLinAxTot)
|
||||
m_pGeomDB->GetName( m_vCalcLinAx[nInd].nGrpId, sName) ;
|
||||
else
|
||||
m_pGeomDB->GetName( m_vCalcRotAx[nInd-nLinAxTot].nGrpId, sName) ;
|
||||
return sName ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
|
||||
@@ -392,7 +413,7 @@ Machine::GetPositions( const Point3d& ptP, double dAngA, double dAngB,
|
||||
vtDirH.Rotate( vtAx1, dAngA) ;
|
||||
}
|
||||
|
||||
// assegno l'offset tesat
|
||||
// assegno l'offset testa
|
||||
Vector3d vtDtHe = ORIG - m_ptCalcPos ;
|
||||
|
||||
// calcolo il recupero degli assi : è l'opposto dello spostamento della posizione
|
||||
@@ -406,6 +427,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 ;
|
||||
|
||||
nStat = 0 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ class Machining : public IUserObj
|
||||
virtual bool SetGeometry( const SELVECTOR& vIds) = 0 ;
|
||||
//virtual bool ResetGeometry( void) = 0 ;
|
||||
virtual bool Apply( void) = 0 ;
|
||||
//virtual bool Simulate( void) = 0 ;
|
||||
//virtual bool Generate( void) = 0 ;
|
||||
virtual bool GetParam( int nType, std::string& sVal) = 0 ;
|
||||
|
||||
protected :
|
||||
Machining( void) ;
|
||||
|
||||
@@ -200,6 +200,13 @@ Milling::Apply( void)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::GetParam( int nType, string& sVal)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::VerifyGeometry( SelData Id, int& nSubs)
|
||||
|
||||
@@ -38,6 +38,7 @@ class Milling : public Machining
|
||||
virtual bool SetParam( int nType, const std::string& sVal) ;
|
||||
virtual bool SetGeometry( const SELVECTOR& vIds) ;
|
||||
virtual bool Apply( void) ;
|
||||
virtual bool GetParam( int nType, std::string& sVal) ;
|
||||
|
||||
public :
|
||||
Milling( void) ;
|
||||
|
||||
+106
-2
@@ -17,6 +17,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "Sawing.h"
|
||||
#include "MachiningConst.h"
|
||||
#include "CamData.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
@@ -360,6 +361,39 @@ Sawing::Apply( void)
|
||||
nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
|
||||
}
|
||||
|
||||
// imposto l'utensile per i calcoli macchina
|
||||
m_pMchMgr->SetCalcTool( m_TParams.m_sName, m_TParams.m_sHead, m_TParams.m_nExit) ;
|
||||
|
||||
// assegno gli angoli iniziali
|
||||
double dAngAprec = 0 ;
|
||||
double dAngBprec = 0 ;
|
||||
|
||||
// calcolo il valore degli assi macchina di ogni movimento
|
||||
bool bOk = true ;
|
||||
int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
|
||||
while ( nClPathId != GDB_ID_NULL) {
|
||||
if ( ! ClPathApply( nClPathId, dAngAprec, dAngBprec))
|
||||
bOk = false ;
|
||||
nClPathId = m_pGeomDB->GetNextGroup( nClPathId) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Sawing::GetParam( int nType, string& sVal)
|
||||
{
|
||||
switch ( nType) {
|
||||
case MPA_TOOL :
|
||||
sVal = m_Params.m_sToolName ;
|
||||
break ;
|
||||
case MPA_DEPTH_STR :
|
||||
sVal = m_Params.m_sDepth ;
|
||||
break ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -375,8 +409,12 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs)
|
||||
// se direttamente la curva
|
||||
if ( Id.nSub == SEL_SUB_ALL) {
|
||||
pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
|
||||
if ( pCurve != nullptr && pCurve->GetType() == CRV_COMPO)
|
||||
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
|
||||
if ( pCurve != nullptr) {
|
||||
if ( pCurve->GetType() == CRV_COMPO)
|
||||
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
|
||||
else
|
||||
nSubs = 0 ;
|
||||
}
|
||||
}
|
||||
// altrimenti sottocurva di composita
|
||||
else {
|
||||
@@ -837,3 +875,69 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIs
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Sawing::ClPathApply( int nClPathId, double& dAngAprec, double& dAngBprec)
|
||||
{
|
||||
// ciclo su tutte le entità del percorso CL
|
||||
MachAxesVal adAxVal = {} ;
|
||||
bool bOk = true ;
|
||||
for ( int nEntId = m_pGeomDB->GetFirstInGroup( nClPathId) ;
|
||||
nEntId != GDB_ID_NULL ;
|
||||
nEntId = m_pGeomDB->GetNext( nEntId)) {
|
||||
// recupero i dati Cam dell'entità
|
||||
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( nEntId)) ;
|
||||
// calcolo degli assi rotanti della macchina
|
||||
int nRStat ;
|
||||
double dAngA1, dAngB1, dAngA2, dAngB2 ;
|
||||
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, adAxVal) ;
|
||||
continue ;
|
||||
}
|
||||
if ( nRStat == 2) {
|
||||
double dDeltaA1 = fabs( dAngA1 - dAngAprec) ;
|
||||
double dDeltaB1 = fabs( dAngB1 - dAngBprec) ;
|
||||
double dDeltaA2 = fabs( dAngA2 - dAngAprec) ;
|
||||
double dDeltaB2 = fabs( dAngB2 - dAngBprec) ;
|
||||
if ( dDeltaA2 + dDeltaB2 < dDeltaA1 + dDeltaB1 - 1.) {
|
||||
dAngA1 = dAngA2 ;
|
||||
dAngB1 = dAngB2 ;
|
||||
}
|
||||
}
|
||||
// compenso il raggio dell'utensile
|
||||
Point3d ptP = pCamData->GetBasePoint() + pCamData->GetCorrDir() * ( m_TParams.m_dDiam / 2) ;
|
||||
// calcolo gli assi lineari della macchina
|
||||
int nLStat ;
|
||||
double dX, dY, dZ ;
|
||||
bool bLOk = m_pMchMgr->GetCalcPositions( ptP, dAngA1, dAngB1, nLStat, dX, dY, dZ) ;
|
||||
if ( ! bLOk || nLStat != 0) {
|
||||
bOk = false ;
|
||||
pCamData->SetAxes( CamData::AS_ERR, adAxVal) ;
|
||||
continue ;
|
||||
}
|
||||
// assegno valori assi
|
||||
adAxVal[0] = dX ;
|
||||
adAxVal[1] = dY ;
|
||||
adAxVal[2] = dZ ;
|
||||
adAxVal[3] = dAngA1 ;
|
||||
adAxVal[4] = dAngB1 ;
|
||||
// verifico i limiti di corsa degli assi
|
||||
int nStat ;
|
||||
bool bOsOk = m_pMchMgr->VerifyOutOfStroke( dX, dY, dZ, dAngA1, dAngB1, nStat) ;
|
||||
if ( ! bOsOk || nStat != 0) {
|
||||
bOk = false ;
|
||||
pCamData->SetAxes( CamData::AS_OUTSTROKE, adAxVal) ;
|
||||
continue ;
|
||||
}
|
||||
// salvo i valori degli assi
|
||||
pCamData->SetAxes( CamData::AS_OK, adAxVal) ;
|
||||
// memorizzo i valori degli angoli
|
||||
dAngAprec = dAngA1 ;
|
||||
dAngBprec = dAngB1 ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class Sawing : public Machining
|
||||
virtual bool SetParam( int nType, const std::string& sVal) ;
|
||||
virtual bool SetGeometry( const SELVECTOR& vIds) ;
|
||||
virtual bool Apply( void) ;
|
||||
virtual bool GetParam( int nType, std::string& sVal) ;
|
||||
|
||||
public :
|
||||
Sawing( void) ;
|
||||
@@ -53,6 +54,7 @@ class Sawing : public Machining
|
||||
bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ;
|
||||
bool AdjustForSide( ICurve* pCurve) ;
|
||||
bool AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN) ;
|
||||
bool ClPathApply( int nClPathId, double& dAngAprec, double& dAngBprec) ;
|
||||
|
||||
private :
|
||||
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
|
||||
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Simulation.cpp Data : 19.10.15 Versione : 1.6j2
|
||||
// Contenuto : Implementazione della classe Simulation.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 19.10.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Simulator.h"
|
||||
#include "MachMgr.h"
|
||||
#include "Machining.h"
|
||||
#include "MachiningConst.h"
|
||||
#include "/EgtDev/Include/EMkOperationConst.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Simulator::Simulator( void)
|
||||
{
|
||||
m_pMchMgr = nullptr ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_dStep = 5.0 ;
|
||||
m_nOpId = GDB_ID_NULL ;
|
||||
m_nCLPathId = GDB_ID_NULL ;
|
||||
m_nEntId = GDB_ID_NULL ;
|
||||
m_dCoeff = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Simulator::~Simulator( void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::Init( MachMgr* pMchMgr)
|
||||
{
|
||||
// verifico ambiente
|
||||
if ( pMchMgr == nullptr || pMchMgr->GetContextId() == 0 || pMchMgr->GetGeomDB() == nullptr)
|
||||
return false ;
|
||||
m_pMchMgr = pMchMgr ;
|
||||
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::Start( void)
|
||||
{
|
||||
// verifico ci sia una macchinata corrente
|
||||
if ( m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
int nMachGrp = m_pMchMgr->GetCurrMachGroup() ;
|
||||
if ( nMachGrp == GDB_ID_NULL)
|
||||
return false ;
|
||||
// verifico la disposizione iniziale della macchinata
|
||||
int nOpId = m_pMchMgr->GetFirstOperation() ;
|
||||
if ( m_pMchMgr->GetOperationType( nOpId) != OPER_DISP)
|
||||
return false ;
|
||||
// cerco la prima lavorazione
|
||||
nOpId = m_pMchMgr->GetNextOperation( nOpId) ;
|
||||
while ( nOpId != GDB_ID_NULL && ( m_pMchMgr->GetOperationType( nOpId) & OPER_MACH) == 0)
|
||||
nOpId = m_pMchMgr->GetNextOperation( nOpId) ;
|
||||
if ( nOpId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_nOpId = nOpId ;
|
||||
// recupero l'utensile della lavorazione
|
||||
string sTool ;
|
||||
Machining* pMch = dynamic_cast<Machining*>( m_pGeomDB->GetUserObj( m_nOpId)) ;
|
||||
if ( pMch == nullptr || ! pMch->GetParam( MPA_TOOL, sTool))
|
||||
return false ;
|
||||
const ToolData* pTdata = m_pMchMgr->GetToolData( sTool) ;
|
||||
if ( pTdata == nullptr)
|
||||
return false ;
|
||||
// attivo l'utensile della lavorazione
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, pTdata->m_sHead, pTdata->m_nExit))
|
||||
return false ;
|
||||
// macchina corrente
|
||||
Machine* pMachine = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMachine == nullptr)
|
||||
return false ;
|
||||
// carico i nomi degli assi macchina attivi
|
||||
m_AxesName.clear() ;
|
||||
int nInd = 0 ;
|
||||
string sAxis = pMachine->GetKinematicAxis( nInd) ;
|
||||
while ( ! sAxis.empty()) {
|
||||
m_AxesName.emplace_back( sAxis) ;
|
||||
sAxis = pMachine->GetKinematicAxis( ++ nInd) ;
|
||||
}
|
||||
if ( m_AxesName.size() > m_AxesVal.size())
|
||||
return false ;
|
||||
// porto la macchina in home
|
||||
m_pMchMgr->ResetAllAxesPos() ;
|
||||
// assegno valori home degli assi come precedenti
|
||||
m_AxesVal.fill( 0) ;
|
||||
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
|
||||
double dHVal ;
|
||||
if ( pMachine->GetAxisHomePos( m_AxesName[i], dHVal))
|
||||
m_AxesVal[i] = dHVal ;
|
||||
}
|
||||
// determino il primo percorso di lavoro
|
||||
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 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::Move( void)
|
||||
{
|
||||
// Se arrivato alla fine dell'interpolazione, recupero una nuova entità
|
||||
if ( m_dCoeff > 0.999) {
|
||||
m_nEntId = m_pGeomDB->GetNext( m_nEntId) ;
|
||||
m_dCoeff = 0 ;
|
||||
}
|
||||
// Se arrivato alla fine di un percorso di lavoro, recupero un nuovo CLpath
|
||||
if ( m_nEntId == GDB_ID_NULL) {
|
||||
m_nCLPathId = m_pGeomDB->GetNextGroup( m_nCLPathId) ;
|
||||
m_nEntId = m_pGeomDB->GetFirstInGroup( m_nCLPathId) ;
|
||||
m_dCoeff = 0 ;
|
||||
}
|
||||
// Se arrivato alla fine di una lavorazione, recupero la successiva
|
||||
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)
|
||||
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 ;
|
||||
}
|
||||
|
||||
// Cerco prossima posizione su interpolazione corrente
|
||||
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( m_nEntId)) ;
|
||||
if ( pCamData == nullptr || pCamData->GetAxesStatus() != CamData::AS_OK)
|
||||
return false ;
|
||||
MachAxesVal AxesEnd = pCamData->GetAxisVal() ;
|
||||
// Verifico se movimento in rapido
|
||||
bool bRapid = ( pCamData->GetFeed() < EPS_SMALL) ;
|
||||
// Calcolo distanza di movimento
|
||||
double dDist = 0 ;
|
||||
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i)
|
||||
dDist += ( AxesEnd[i] - m_AxesVal[i]) * ( AxesEnd[i] - m_AxesVal[i]) ;
|
||||
dDist = sqrt( dDist) ;
|
||||
m_dCoeff += ( bRapid ? 4 : 1) * m_dStep / dDist ;
|
||||
if ( m_dCoeff > 1)
|
||||
m_dCoeff = 1 ;
|
||||
// Eseguo movimento
|
||||
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
|
||||
double dVal = m_AxesVal[i] * ( 1 - m_dCoeff) + AxesEnd[i] * m_dCoeff ;
|
||||
m_pMchMgr->SetAxisPos( m_AxesName[i], dVal) ;
|
||||
}
|
||||
|
||||
// Se arrivato a fine interpolazione movimento, salvo posizioni
|
||||
if ( m_dCoeff > 0.999)
|
||||
m_AxesVal = AxesEnd ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::SetStep( double dStep)
|
||||
{
|
||||
const double MIN_STEP = 0.1 ;
|
||||
const double MAX_STEP = 100.0 ;
|
||||
if ( dStep < MIN_STEP)
|
||||
m_dStep = MIN_STEP ;
|
||||
else if ( dStep > MAX_STEP)
|
||||
m_dStep = MAX_STEP ;
|
||||
else
|
||||
m_dStep = dStep ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::Stop( void)
|
||||
{
|
||||
m_nOpId = GDB_ID_NULL ;
|
||||
m_nCLPathId = GDB_ID_NULL ;
|
||||
m_nEntId = GDB_ID_NULL ;
|
||||
m_dCoeff = 0 ;
|
||||
return true ;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Simulator.h Data : 19.10.15 Versione : 1.6j2
|
||||
// Contenuto : Dichiarazione della classe Simulator.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 19.10.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CamData.h"
|
||||
|
||||
class MachMgr ;
|
||||
class IGeomDB ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Simulator
|
||||
{
|
||||
public :
|
||||
Simulator( void) ;
|
||||
~Simulator( void) ;
|
||||
bool Init( MachMgr* pMchMgr) ;
|
||||
bool Start( void) ;
|
||||
bool Move( void) ;
|
||||
bool SetStep( double dStep) ;
|
||||
bool Stop( void) ;
|
||||
|
||||
private :
|
||||
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
double m_dStep ; // lunghezza di riferimento per la velocità di simulazione
|
||||
int m_nOpId ; // identificativo della operazione (lavoraz.) corrente
|
||||
int m_nCLPathId ; // identificativo del percorso di lavoro corrente
|
||||
int m_nEntId ; // identificativo dell'entità corrente
|
||||
double m_dCoeff ; // coefficiente di movimento corrente
|
||||
STRVECTOR m_AxesName ; // nomi degli assi macchina attivi
|
||||
MachAxesVal m_AxesVal ; // valori degli assi macchina all'inizio del movimento corrente
|
||||
} ;
|
||||
Reference in New Issue
Block a user