//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : Machine.h Data : 06.05.15 Versione : 1.6e3 // Contenuto : Dichiarazione della classe Machine. // // // // Modifiche : 06.05.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGnLuaMgr.h" #include class MachMgr ; //---------------------------------------------------------------------------- union STROKE { struct { double Min ; double Max ; } ; double v[2] ; } ; //---------------------------------------------------------------------------- struct MuExit { Point3d ptPos ; Vector3d vtTDir ; MuExit( const Point3d& ptP, const Vector3d& vtTD) : ptPos( ptP), vtTDir( vtTD) {} } ; typedef std::vector MUEXITVECTOR ; //---------------------------------------------------------------------------- struct KinAxis { int nGrpId ; bool bLinear ; bool bHead ; Point3d ptPos ; Vector3d vtDir ; STROKE stroke ; }; typedef std::vector KINAXISVECTOR ; //---------------------------------------------------------------------------- class Machine { public : Machine( void) ; ~Machine( void) ; bool Init( const std::string& sMachineName, MachMgr* pMchMgr) ; int GetMGeoId( void) { return m_nGroupId ; } const std::string& GetMachineName( void) { return m_sName ; } 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 GetAxisPos( const std::string& sAxis, double& dVal) ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ; bool ResetAxisPos( const std::string& sAxis) ; bool SetCurrTable( const std::string& sTable) ; bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ; bool GetAngles( const Vector3d& vtDirT, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ; bool GetPositions( const Point3d& ptP, double dA, double dB, int& nStat, double& dX, double& dY, double& dZ) ; bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; private : void Clear( void) ; bool LoadMachineGeometry( const std::string& sMGeoName, const Vector3d& vtOffset) ; bool LoadMachineBase( const std::string& sName, const std::string& sGeo) ; bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType, const std::string& sGeo) ; bool LoadMachineAxis( const std::string& sName, const std::string& sParent, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, const std::string& sGeo, double dVal) ; bool AddAxisVector( int nLay, const Point3d& ptPos, const Vector3d& vtDir, const std::string& sName) ; bool LoadMachineStdHead( const std::string& sName, const std::string& sParent, const std::string& sHSet, const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir, const std::string& sGeo) ; bool LoadMachineMultiHead( const std::string& sName, const std::string& sParent, const std::string& sHSet, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir, const std::string& sGeo) ; int GetGroup( const std::string& sGroup) ; bool IsAxisGroup( int nGroup) ; bool IsTableGroup( int nGroup) ; bool IsHeadGroup( int nGroup) ; bool AddHeadToSet( const std::string& sHSet, const std::string& sName) ; bool GetHSet( const std::string& sHead, STRVECTOR& vsHSet) ; bool EnableHeadInSet( const std::string& sHead) ; bool CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) ; bool CalculateKinematicChain( void) ; bool AddKinematicAxis( bool bOnHead, int nId) ; bool LuaInit( const std::string& sMachineName) ; bool LuaExit( void) ; bool LuaExecFile( const std::string& sFile) ; private : typedef std::unordered_map< std::string, int> STRINT_UMAP ; private : MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni LuaMgr m_LuaMgr ; // interprete lua della macchina std::string m_sName ; // nome della macchina std::string m_sMachineDir ; // direttorio della macchina int m_nGroupId ; // Id del gruppo della macchina int m_nTempGroupId ; // Id del gruppo temporaneo macchina per carico STRINT_UMAP m_mapGroups ; // dizionario dei gruppi della macchina int m_nCalcTabId ; // tavola corrente per calcoli int m_nCalcHeadId ; // testa corrente per calcoli int m_nCalcExitId ; // uscita corrente per calcoli int m_nCalcToolId ; // utensile corrente per calcoli Point3d m_ptCalcPos ; // posizione utensile a riposo per calcoli Vector3d m_vtCalcDir ; // direzione utensile a riposo per calcoli double m_dCalcTLen ; // lunghezza utensile corrente per calcoli KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli // Static per interprete Lua di macchina private : static Machine* m_pMchLua ; private : static int LuaEmtGeneral( lua_State* L) ; static int LuaEmtBase( lua_State* L) ; static int LuaEmtTable( lua_State* L) ; static int LuaEmtAxis( lua_State* L) ; static int LuaEmtHead( lua_State* L) ; static int LuaEmtStdHead( lua_State* L) ; static int LuaEmtMultiHead( lua_State* L) ; } ;