8dd67afcb7
- modifiche per tagli di lama inclinati.
289 lines
15 KiB
C++
289 lines
15 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachMgr.h Data : 23.03.15 Versione : 1.6c6
|
|
// Contenuto : Dichiarazione della classe MachMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 23.03.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "MachConst.h"
|
|
#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 ;
|
|
int SetupGroupId ;
|
|
int FixtGroupId ;
|
|
int RawGroupId ;
|
|
int OperGroupId ;
|
|
MachGrp( void)
|
|
: MGeoName(), SetupGroupId( GDB_ID_NULL), FixtGroupId( GDB_ID_NULL),
|
|
RawGroupId( GDB_ID_NULL), OperGroupId( GDB_ID_NULL) {}
|
|
MachGrp( std::string MgName, int SgId, int FgId, int RgId, int OgId)
|
|
: MGeoName( MgName), SetupGroupId( SgId), FixtGroupId( FgId),
|
|
RawGroupId( RgId), OperGroupId( OgId) {}
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
struct MachineData {
|
|
Machine* pMachine ;
|
|
ToolsMgr* pTsMgr ;
|
|
MachiningsMgr* pMsMgr ;
|
|
MachineData( void)
|
|
: pMachine( nullptr), pTsMgr( nullptr), pMsMgr( nullptr) {}
|
|
MachineData( Machine* pM, ToolsMgr* pTM, MachiningsMgr* pMM)
|
|
{ pMachine = pM ; pTsMgr = pTM ; pMsMgr = pMM ; }
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class MachMgr : public IMachMgr
|
|
{
|
|
public :
|
|
// Basic
|
|
virtual ~MachMgr( void) ;
|
|
virtual bool Init( const std::string& sMachinesDir, IGeomDB* pGeomDB,
|
|
int nContextId, const std::string& sLuaLibsDir, const std::string& sLuaLastRequire) ;
|
|
virtual bool Update( void) ;
|
|
virtual bool Insert( int nInsGrp) ;
|
|
// Machines
|
|
virtual bool SetCurrMachine( const std::string& sMachineName) ;
|
|
// MachGroups
|
|
virtual int GetMachGroupCount( void) const ;
|
|
virtual int GetFirstMachGroup( void) const ;
|
|
virtual int GetNextMachGroup( int nId) const ;
|
|
virtual bool GetMachGroupNewName( std::string& sName) const ;
|
|
virtual int AddMachGroup( const std::string& sName, const std::string& sMachineName) ;
|
|
virtual bool RemoveMachGroup( int nId) ;
|
|
virtual std::string GetMachGroupName( int nId) const ;
|
|
virtual int GetMachGroupId( const std::string& sName) const ;
|
|
virtual bool SetCurrMachGroup( int nId) ;
|
|
virtual bool ResetCurrMachGroup( void) ;
|
|
virtual int GetCurrMachGroup( void) const ;
|
|
// RawParts
|
|
virtual int GetRawPartCount( void) const ;
|
|
virtual int GetFirstRawPart( void) const ;
|
|
virtual int GetNextRawPart( int nId) const ;
|
|
virtual int AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ;
|
|
virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ;
|
|
virtual bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) ;
|
|
virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ;
|
|
virtual bool RemoveRawPart( int nRawId) ;
|
|
virtual bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ;
|
|
virtual bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ;
|
|
virtual bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ;
|
|
virtual bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
|
|
// Parts
|
|
virtual int GetPartInRawPartCount( int nRawId) const ;
|
|
virtual int GetFirstPartInRawPart( int nRawId) const ;
|
|
virtual int GetNextPartInRawPart( int nId) const ;
|
|
virtual bool AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ;
|
|
virtual bool RemovePartFromRawPart( int nPartId) ;
|
|
virtual bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ;
|
|
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 int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ;
|
|
virtual bool ShowOnlyTable( bool bVal) ;
|
|
// Tools DataBase
|
|
virtual bool TdbGetToolNewName( std::string& sName) const ;
|
|
virtual bool TdbAddTool( const std::string& sName, int nType) ;
|
|
virtual bool TdbCopyTool( const std::string& sSource, const std::string& sName) ;
|
|
virtual bool TdbRemoveTool( const std::string& sName) ;
|
|
virtual bool TdbGetFirstTool( int nFamily, std::string& sName, int& nType) const ;
|
|
virtual bool TdbGetNextTool( int nFamily, std::string& sName, int& nType) const ;
|
|
virtual bool TdbSetCurrTool( const std::string& sName) ;
|
|
virtual bool TdbSaveCurrTool( void) ;
|
|
virtual bool TdbIsCurrToolModified( void) const ;
|
|
virtual bool TdbSetCurrToolParam( int nType, bool bVal) ;
|
|
virtual bool TdbSetCurrToolParam( int nType, int nVal) ;
|
|
virtual bool TdbSetCurrToolParam( int nType, double dVal) ;
|
|
virtual bool TdbSetCurrToolParam( int nType, const std::string& sVal) ;
|
|
virtual bool TdbGetCurrToolParam( int nType, bool& bVal) const ;
|
|
virtual bool TdbGetCurrToolParam( int nType, int& nVal) const ;
|
|
virtual bool TdbGetCurrToolParam( int nType, double& dVal) const ;
|
|
virtual bool TdbGetCurrToolParam( int nType, std::string& sVal) const ;
|
|
virtual bool TdbSave( void) const ;
|
|
virtual bool TdbGetToolDir( std::string& sToolDir) const ;
|
|
virtual bool TdbGetToolHolderDir( std::string& sTHolderDir) const ;
|
|
// Machinings DataBase
|
|
virtual bool MdbGetMachiningNewName( std::string& sName) const ;
|
|
virtual bool MdbAddMachining( const std::string& sName, int nType) ;
|
|
virtual bool MdbCopyMachining( const std::string& sSource, const std::string& sName) ;
|
|
virtual bool MdbRemoveMachining( const std::string& sName) ;
|
|
virtual bool MdbGetFirstMachining( int nType, std::string& sName) const ;
|
|
virtual bool MdbGetNextMachining( int nType, std::string& sName) const ;
|
|
virtual bool MdbSetCurrMachining( const std::string& sName) ;
|
|
virtual bool MdbSaveCurrMachining( void) ;
|
|
virtual bool MdbIsCurrMachiningModified( void) const ;
|
|
virtual bool MdbSetCurrMachiningParam( int nType, bool bVal) ;
|
|
virtual bool MdbSetCurrMachiningParam( int nType, int nVal) ;
|
|
virtual bool MdbSetCurrMachiningParam( int nType, double dVal) ;
|
|
virtual bool MdbSetCurrMachiningParam( int nType, const std::string& sVal) ;
|
|
virtual bool MdbGetCurrMachiningParam( int nType, bool& bVal) const ;
|
|
virtual bool MdbGetCurrMachiningParam( int nType, int& nVal) const ;
|
|
virtual bool MdbGetCurrMachiningParam( int nType, double& dVal) const ;
|
|
virtual bool MdbGetCurrMachiningParam( int nType, std::string& sVal) const ;
|
|
virtual bool MdbSave( void) const ;
|
|
virtual bool MdbGetMachiningDir( std::string& sMchDir) const ;
|
|
// Operations : general
|
|
virtual int GetOperationCount( void) const ;
|
|
virtual int GetFirstOperation( void) const ;
|
|
virtual int GetNextOperation( int nId) const ;
|
|
virtual int GetLastOperation( void) const ;
|
|
virtual int GetPrevOperation( int nId) const ;
|
|
virtual int GetOperationType( int nId) const ;
|
|
virtual std::string GetOperationName( int nId) const ;
|
|
virtual int GetOperationId( const std::string& sName) const ;
|
|
virtual bool RemoveOperation( int nId) ;
|
|
virtual bool RemoveAllOperations( bool bExceptFirstDisp) ;
|
|
// Operations : dispositions
|
|
virtual int AddDisposition( const std::string& sName) ;
|
|
// Operations : machinings
|
|
virtual int AddMachining( const std::string& sName, const std::string& sMachining) ;
|
|
virtual bool SetCurrMachining( int nId) ;
|
|
virtual bool ResetCurrMachining( void) ;
|
|
virtual int GetCurrMachining( void) const ;
|
|
virtual bool SetMachiningParam( int nType, bool bVal) ;
|
|
virtual bool SetMachiningParam( int nType, int nVal) ;
|
|
virtual bool SetMachiningParam( int nType, double dVal) ;
|
|
virtual bool SetMachiningParam( int nType, const std::string& sVal) ;
|
|
virtual bool SetMachiningGeometry( const SELVECTOR& vIds) ;
|
|
virtual bool MachiningApply( void) ;
|
|
virtual bool GetMachiningParam( int nType, bool& bVal) const ;
|
|
virtual bool GetMachiningParam( int nType, int& dVal) const ;
|
|
virtual bool GetMachiningParam( int nType, double& dVal) const ;
|
|
virtual bool GetMachiningParam( int nType, std::string& sVal) const ;
|
|
// Simulation
|
|
virtual bool SimStart( void) ;
|
|
virtual bool SimMove( void) ;
|
|
virtual bool SimGetAxisInfoPos( int nI, std::string& sName, double& dVal) ;
|
|
virtual bool SimSetStep( double dStep) ;
|
|
virtual bool SimStop( void) ;
|
|
// Generation
|
|
virtual bool Generate( const std::string& sCncFile, const std::string& sInfo) ;
|
|
// Machine Calc
|
|
virtual bool SetCalcTable( const std::string& sTable) ;
|
|
virtual bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) ;
|
|
virtual bool GetCalcTool( std::string& sTool) ;
|
|
virtual bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
|
|
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ;
|
|
virtual bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
|
|
int& nStat, double& dX, double& dY, double& dZ) ;
|
|
virtual bool GetNearestAngleInStroke( int nId, double dAngRef, double& dAng) ;
|
|
virtual bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ;
|
|
// Machine Move
|
|
virtual bool SetAxisPos( const std::string& sAxis, double dVal) ;
|
|
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) ;
|
|
|
|
public :
|
|
MachMgr( void) ;
|
|
// Basic
|
|
int GetContextId( void)
|
|
{ return m_nContextId ; }
|
|
IGeomDB* GetGeomDB( void)
|
|
{ return m_pGeomDB ; }
|
|
int GetMachBaseId( void)
|
|
{ return m_nMachBaseId ; }
|
|
int GetMachAuxId( void)
|
|
{ return m_nMachAuxId ; }
|
|
std::string GetLuaLibsDir( void) const
|
|
{ return m_sLuaLibsDir ; }
|
|
std::string GetLuaLastRequire( void) const
|
|
{ return m_sLuaLastRequire ; }
|
|
// MachGroups
|
|
std::string GetCurrMGeoName( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.MGeoName : "") ; }
|
|
std::string GetCurrFixtDir( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_sMachinesDir+"\\"+m_cCurrMGrp.MGeoName+"\\"+FIXTURES_DIR : "") ; }
|
|
int GetCurrSetupGroupId( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.SetupGroupId : GDB_ID_NULL) ; }
|
|
int GetCurrFixtGroupId( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.FixtGroupId : GDB_ID_NULL) ; }
|
|
int GetCurrRawGroupId( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.RawGroupId : GDB_ID_NULL) ; }
|
|
int GetCurrOperId( void) const
|
|
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.OperGroupId : GDB_ID_NULL) ; }
|
|
// RawParts
|
|
bool GetRawPartCenter( int nRawId, Point3d& ptCen) ;
|
|
// Machines
|
|
Machine* GetCurrMachine( void) const ;
|
|
ToolsMgr* GetCurrToolsMgr( void) const ;
|
|
MachiningsMgr* GetCurrMachiningsMgr( void) const ;
|
|
// MachineCalc
|
|
int GetCurrLinAxes( void) ;
|
|
int GetCurrRotAxes( void) ;
|
|
bool GetAllCurrAxesName( STRVECTOR& vAxName) ;
|
|
bool GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) ;
|
|
double GetCalcRot1W( void) ;
|
|
// operations
|
|
bool GetOperationNewName( std::string& sName) const ;
|
|
const ToolData* GetMachiningToolData( void) const ;
|
|
|
|
private :
|
|
// Basic
|
|
void Clear( void) ;
|
|
bool IsMachBase( int nId) const ;
|
|
int FindMachBase( int nGroupId) const ;
|
|
bool VerifyMachBase( void) const ;
|
|
bool CreateMachBase( void) ;
|
|
bool IsMachAux( int nId) const ;
|
|
bool VerifyMachAux( void) const ;
|
|
bool CreateMachAux( void) ;
|
|
// MachGroups
|
|
bool VerifyMachGroup( int nId, MachGrp& mgData) const ;
|
|
bool ExistsCurrMachGroup( void) const
|
|
{ return ( m_pGeomDB != nullptr && m_nCurrMGrpId != GDB_ID_NULL) ; }
|
|
// Machines
|
|
bool LoadMachine( const std::string& sMachineName) ;
|
|
int GetMachine( const std::string& sMachineName) const ;
|
|
int GetCurrMGeoId( void) const ;
|
|
// RawParts
|
|
int AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) ;
|
|
int AddRawPart( int nSurfId, Color cCol) ;
|
|
bool VerifyRawPart( int nRawId) const ;
|
|
bool SetRawPartCenter( int nRawId) ;
|
|
bool ResetRawPartCenter( int nRawId) ;
|
|
// Parts
|
|
bool AddPartToRawPart( int nPartId, int nRawId) ;
|
|
bool SwapParts( bool bToRawPart) ;
|
|
bool SwapRawPartParts( int nRawId, bool bToRawPart) ;
|
|
bool ShowRootParts( bool bShow) ;
|
|
|
|
private :
|
|
typedef std::vector<MachineData> MCHDATAVECTOR ;
|
|
|
|
private :
|
|
int m_nContextId ; // indice contesto corrente (1-based)
|
|
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico del contesto corrente
|
|
std::string m_sMachinesDir ; // direttorio delle macchine
|
|
std::string m_sLuaLibsDir ; // direttorio delle librerie lua
|
|
std::string m_sLuaLastRequire ; // nome ultima libreria caricata
|
|
int m_nMachBaseId ; // identificativo gruppo base per le macchinate
|
|
int m_nMachAuxId ; // identificativo gruppo base per le macchine
|
|
int m_nCurrMGrpId ; // identificativo macchinata corrente
|
|
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
|
|
Simulator* m_pSimul ; // puntatore al simulatore attivo
|
|
} ;
|