diff --git a/Axis.cpp b/Axis.cpp new file mode 100644 index 0000000..6afabcd --- /dev/null +++ b/Axis.cpp @@ -0,0 +1,112 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Axis.cpp Data : 24.05.15 Versione : 1.6e7 +// Contenuto : Oggetto asse per gruppo asse di macchina. +// +// +// +// Modifiche : 24.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Axis.h" +#include "MachConst.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OBJUSER_REGISTER( "EMkAxis", Axis) ; + +//---------------------------------------------------------------------------- +const string& +Axis::GetClassName( void) const +{ + return OBJUSER_GETNAME( Axis) ; +} + +//---------------------------------------------------------------------------- +Axis* +Axis::Clone( void) const +{ + // alloco oggetto + Axis* pAx = new(nothrow) Axis ; + // eseguo copia dei dati + if ( pAx != nullptr) { + try { pAx->m_nOwnerId = GDB_ID_NULL ; + pAx->m_sName = m_sName ; + pAx->m_nType = m_nType ; + pAx->m_ptPos = m_ptPos ; + pAx->m_vtDir = m_vtDir ; + pAx->m_Stroke = m_Stroke ; + pAx->m_dHomeVal = m_dHomeVal ; + pAx->m_dCurrVal = m_dCurrVal ; + } + catch( ...) { + delete pAx ; + return nullptr ; + } + } + // ritorno l'oggetto + return pAx ; +} + +//---------------------------------------------------------------------------- +bool +Axis::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; + sOut += "Name=" + m_sName + szNewLine ; + sOut += "Type=" + ToString( m_nType) + szNewLine ; + sOut += "Pos=" + ToString( m_ptPos) + szNewLine ; + sOut += "Dir=" + ToString( m_vtDir) + szNewLine ; + sOut += "Stroke=" + ToString( m_Stroke.v) + szNewLine ; + sOut += "HVal=" + ToString( m_dHomeVal) + szNewLine ; + sOut += "Val=" + ToString( m_dCurrVal) + szNewLine ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Axis::SetOwner( int nId) +{ + m_nOwnerId = nId ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Axis::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Axis::Axis( void) + : m_nOwnerId( GDB_ID_NULL), m_nType( MCH_AT_NONE), m_Stroke( {{0,0}}), m_dHomeVal( 0), m_dCurrVal( 0) +{ +} + +//---------------------------------------------------------------------------- +bool +Axis::Set( const string& sName, int nType, + const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dVal) +{ + m_sName = sName ; + m_nType = nType ; + m_ptPos = ptPos ; + m_vtDir = vtDir ; + m_Stroke = Stroke ; + m_dHomeVal = dVal ; + m_dCurrVal = dVal ; + return m_vtDir.Normalize() ; +} + diff --git a/Axis.h b/Axis.h new file mode 100644 index 0000000..c3f1257 --- /dev/null +++ b/Axis.h @@ -0,0 +1,52 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Axis.h Data : 24.05.15 Versione : 1.6e7 +// Contenuto : Dichiarazione della classe Axis. +// +// +// +// Modifiche : 24.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machine.h" +#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +//---------------------------------------------------------------------------- +class Axis : public IObjUser +{ + public : + virtual Axis* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool SetOwner( int nId) ; + virtual int GetOwner( void) const ; + + public : + Axis( void) ; + bool Set( const std::string& sName, int nType, + const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dVal) ; + bool SetCurrVal( double dVal) { m_dCurrVal = dVal ; return true ; } + const std::string& GetName( void) { return m_sName ; } + int GetType( void) { return m_nType ; } + const Point3d& GetPos( void) { return m_ptPos ; } + const Vector3d& GetDir( void) { return m_vtDir ; } + const STROKE& GetStroke( void) { return m_Stroke ; } + double GetHomeVal( void) { return m_dHomeVal ; } + double GetCurrVal( void) { return m_dCurrVal ; } + + private : + int m_nOwnerId ; + std::string m_sName ; + int m_nType ; + Point3d m_ptPos ; + Vector3d m_vtDir ; + STROKE m_Stroke ; + double m_dHomeVal ; + double m_dCurrVal ; +} ; \ No newline at end of file diff --git a/Drilling.cpp b/Drilling.cpp new file mode 100644 index 0000000..419a953 --- /dev/null +++ b/Drilling.cpp @@ -0,0 +1,145 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Drilling.cpp Data : 21.05.15 Versione : 1.6e7 +// Contenuto : Implementazione gestione forature. +// +// +// +// Modifiche : 21.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "MachMgr.h" +#include "DllMain.h" +#include "Drilling.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGnStringKeyVal.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OBJUSER_REGISTER( "EMkDrilling", Drilling) ; + +//---------------------------------------------------------------------------- +const string& +Drilling::GetClassName( void) const +{ + return OBJUSER_GETNAME( Drilling) ; +} + +//---------------------------------------------------------------------------- +Drilling* +Drilling::Clone( void) const +{ + // alloco oggetto + Drilling* pDri = new(nothrow) Drilling ; + // eseguo copia dei dati + if ( pDri != nullptr) { + try { pDri->m_nOwnerId = GDB_ID_NULL ; + pDri->m_Params = m_Params ; + pDri->m_TParams = m_TParams ; + } + catch( ...) { + delete pDri ; + return nullptr ; + } + } + // ritorno l'oggetto + return pDri ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += DRI_IDS + EQUAL + ToString( m_Params.m_vId) + szNewLine ; + sOut += DRI_INV + EQUAL + ToString( m_Params.m_bInvert) + szNewLine ; + sOut += DRI_SPS + EQUAL + ToString( m_Params.m_dStartPos) + szNewLine ; + sOut += DRI_SSL + EQUAL + ToString( m_Params.m_dStartSlowLen) + szNewLine ; + sOut += DRI_ESL + EQUAL + ToString( m_Params.m_dEndSlowLen) + szNewLine ; + sOut += DRI_TAL + EQUAL + ToString( m_Params.m_dThroughAddLen) + szNewLine ; + sOut += DRI_STP + EQUAL + ToString( m_Params.m_dStep) + szNewLine ; + sOut += DRI_RPS + EQUAL + ToString( m_Params.m_dReturnPos) + szNewLine ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Save( STRVECTOR& vString) const +{ + try { + vString.insert( vString.begin(), 8, "") ; + if ( ! SetVal( DRI_IDS, m_Params.m_vId, vString[0]) || + ! SetVal( DRI_INV, m_Params.m_bInvert, vString[1]) || + ! SetVal( DRI_SPS, m_Params.m_dStartPos, vString[2]) || + ! SetVal( DRI_SSL, m_Params.m_dStartSlowLen, vString[3]) || + ! SetVal( DRI_ESL, m_Params.m_dEndSlowLen, vString[4]) || + ! SetVal( DRI_TAL, m_Params.m_dThroughAddLen, vString[5]) || + ! SetVal( DRI_STP, m_Params.m_dStep, vString[6]) || + ! SetVal( DRI_RPS, m_Params.m_dReturnPos, vString[7])) + return false ; + } + catch( ...) { return false ;} + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Load( const STRVECTOR& vString) +{ + if ( vString.size() < 8) + return false ; + if ( ! GetVal( vString[0], DRI_IDS, m_Params.m_vId) || + ! GetVal( vString[1], DRI_INV, m_Params.m_bInvert) || + ! GetVal( vString[2], DRI_SPS, m_Params.m_dStartPos) || + ! GetVal( vString[3], DRI_SSL, m_Params.m_dStartSlowLen) || + ! GetVal( vString[4], DRI_ESL, m_Params.m_dEndSlowLen) || + ! GetVal( vString[5], DRI_TAL, m_Params.m_dThroughAddLen) || + ! GetVal( vString[6], DRI_STP, m_Params.m_dStep) || + ! GetVal( vString[7], DRI_RPS, m_Params.m_dReturnPos)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::SetOwner( int nId) +{ + m_nOwnerId = nId ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Drilling::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Drilling::Drilling( void) +{ + m_nOwnerId = GDB_ID_NULL ; + m_Params.m_bInvert = false ; + m_Params.m_dStartPos = 5 ; + m_Params.m_dStartSlowLen = 0 ; + m_Params.m_dEndSlowLen = 0 ; + m_Params.m_dThroughAddLen = 2 ; + m_Params.m_dStep = 0 ; + m_Params.m_dReturnPos= 0 ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Add( const string& sName) +{ + + return true ; +} diff --git a/Drilling.h b/Drilling.h new file mode 100644 index 0000000..5236ba7 --- /dev/null +++ b/Drilling.h @@ -0,0 +1,82 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Drilling.h Data : 21.05.15 Versione : 1.6e7 +// Contenuto : Dichiarazione della classe Drilling. +// +// +// +// Modifiche : 21.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EgtNumCollection.h" +#include + +//---------------------------------------------------------------------------- +struct DrillingParams +{ + INTVECTOR m_vId ; // indici entitā geometriche da lavorare + bool m_bInvert ; // flag di inversione direzione lavorazione per fori aperti + double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0) + double m_dStartSlowLen ; // lunghezza rallentamento iniziale + double m_dEndSlowLen ; // lunghezza rallentamento finale + double m_dThroughAddLen ; // lunghezza aggiuntiva di foratura se passante + double m_dStep ; // passo di affondameto (0=nessun passo) + double m_dReturnPos ; // quota di ritorno (+=fuori, -=dentro) +} ; +static std::string DRI_IDS = "Ids" ; +static std::string DRI_INV = "Inv" ; +static std::string DRI_SPS = "Sps" ; +static std::string DRI_SSL = "Ssl" ; +static std::string DRI_ESL = "Esl" ; +static std::string DRI_TAL = "Tal" ; +static std::string DRI_STP = "Stp" ; +static std::string DRI_RPS = "Rps" ; + +//---------------------------------------------------------------------------- +struct DrillBitParams +{ + std::string m_sName ; // nome dell'utensile + std::string m_sTcPos ; // posizione di attrezzaggio + std::string m_sHead ; // testa di montaggio + int m_nExit ; // uscita di montaggio + int m_nCorr ; // numero di correttore + int m_nType ; // tipo di utensile : foratore, foratore lungo o fresa (lavora di testa) + double m_dMaxSpeed ; // massima velocitā di rotazione ammessa (giri/minuto) + double m_dMaxMat ; // massimo materiale + double m_dSpeed ; // velocitā di rotazione (+ se CCW, - se CW) + double m_dFeed ; // velocitā di lavorazione normale + double m_dStartFeed ; // velocitā di lavorazione iniziale + double m_dEndFeed ; // velocitā di lavorazione finale + double m_dDiam ; // diametro + double m_dLen ; // lunghezza controllata + double m_dTLen ; // lunghezza totale +} ; + +//---------------------------------------------------------------------------- +class Drilling : public IObjUser +{ + public : + virtual Drilling* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool ToSave( void) const { return true ; } + virtual bool Save( STRVECTOR& vString) const ; + virtual bool Load( const STRVECTOR& vString) ; + virtual bool SetOwner( int nId) ; + virtual int GetOwner( void) const ; + + public : + Drilling( void) ; + bool Add( const std::string& sName) ; + + private : + int m_nOwnerId ; + DrillingParams m_Params ; + DrillBitParams m_TParams ; +} ; \ No newline at end of file diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 39b7b75..4b04623 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj index a4c4f5d..0e8e113 100644 --- a/EgtMachKernel.vcxproj +++ b/EgtMachKernel.vcxproj @@ -204,7 +204,10 @@ copy $(TargetPath) \EgtProg\Dll64 + + + @@ -215,6 +218,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -223,17 +227,25 @@ copy $(TargetPath) \EgtProg\Dll64 Create Create + + + + + + + + diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters index fa81ff8..67e0317 100644 --- a/EgtMachKernel.vcxproj.filters +++ b/EgtMachKernel.vcxproj.filters @@ -19,6 +19,12 @@ {eeca69bf-68be-4047-9083-bd9ef0d9f977} + + {d6353594-7db7-4dc2-8d9e-3e7524b9327f} + + + {3e3114d1-29a3-4acb-8f29-916ef8d05592} + @@ -42,27 +48,45 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files + + Source Files + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machinings + + + Source Files\Machine + + + Source Files\Machine + + + Source Files\Machine + @@ -92,6 +116,24 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/Exit.cpp b/Exit.cpp new file mode 100644 index 0000000..273418c --- /dev/null +++ b/Exit.cpp @@ -0,0 +1,110 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Exit.cpp Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Oggetto uscita per gruppo uscita di testa di macchina. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Exit.h" +#include "MachConst.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OBJUSER_REGISTER( "EMkExit", Exit) ; + +//---------------------------------------------------------------------------- +const string& +Exit::GetClassName( void) const +{ + return OBJUSER_GETNAME( Exit) ; +} + +//---------------------------------------------------------------------------- +Exit* +Exit::Clone( void) const +{ + // alloco oggetto + Exit* pExit = new(nothrow) Exit ; + // eseguo copia dei dati + if ( pExit != nullptr) { + try { pExit->m_nOwnerId = GDB_ID_NULL ; + pExit->m_sName = m_sName ; + pExit->m_ptPos = m_ptPos ; + pExit->m_vtTDir = m_vtTDir ; + pExit->m_sTool = m_sTool ; + } + catch( ...) { + delete pExit ; + return nullptr ; + } + } + // ritorno l'oggetto + return pExit ; +} + +//---------------------------------------------------------------------------- +bool +Exit::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; + sOut += "Name=" + m_sName + szNewLine ; + sOut += "Pos=" + ToString( m_ptPos) + szNewLine ; + sOut += "TDir=" + ToString( m_vtTDir) + szNewLine ; + sOut += "Tool=" + m_sTool + szNewLine ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Exit::SetOwner( int nId) +{ + m_nOwnerId = nId ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Exit::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Exit::Exit( void) + : m_nOwnerId( GDB_ID_NULL) +{ +} + +//---------------------------------------------------------------------------- +bool +Exit::Set( const string& sName, const Point3d& ptPos, const Vector3d& vtTDir) +{ + m_sName = sName ; + m_ptPos = ptPos ; + m_vtTDir = vtTDir ; + m_sTool.clear() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Exit::SetTool( const string& sTool) +{ + m_sTool = sTool ; + return true ; +} + diff --git a/Exit.h b/Exit.h new file mode 100644 index 0000000..8c1acf0 --- /dev/null +++ b/Exit.h @@ -0,0 +1,45 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Head.h Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Dichiarazione della classe Head. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machine.h" +#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +//---------------------------------------------------------------------------- +class Exit : public IObjUser +{ + public : + virtual Exit* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool SetOwner( int nId) ; + virtual int GetOwner( void) const ; + + public : + Exit( void) ; + bool Set( const std::string& sName, const Point3d& ptPos, const Vector3d& vtTDir) ; + bool SetTool( const std::string& sTool) ; + const std::string& GetName( void) { return m_sName ; } + const Point3d& GetPos( void) { return m_ptPos ; } + const Vector3d& GetTDir( void) { return m_vtTDir ; } + const std::string& GetTool( void) { return m_sTool ; } + + private : + int m_nOwnerId ; + std::string m_sName ; + Point3d m_ptPos ; + Vector3d m_vtTDir ; + std::string m_sTool ; +} ; \ No newline at end of file diff --git a/Head.cpp b/Head.cpp new file mode 100644 index 0000000..147e110 --- /dev/null +++ b/Head.cpp @@ -0,0 +1,114 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Head.cpp Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Oggetto testa per gruppo testa di macchina. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Head.h" +#include "MachConst.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OBJUSER_REGISTER( "EMkHead", Head) ; + +//---------------------------------------------------------------------------- +const string& +Head::GetClassName( void) const +{ + return OBJUSER_GETNAME( Head) ; +} + +//---------------------------------------------------------------------------- +Head* +Head::Clone( void) const +{ + // alloco oggetto + Head* pHead = new(nothrow) Head ; + // eseguo copia dei dati + if ( pHead != nullptr) { + try { pHead->m_nOwnerId = GDB_ID_NULL ; + pHead->m_sName = m_sName ; + pHead->m_nType = m_nType ; + pHead->m_vsHSet = m_vsHSet ; + pHead->m_vtADir = m_vtADir ; + } + catch( ...) { + delete pHead ; + return nullptr ; + } + } + // ritorno l'oggetto + return pHead ; +} + +//---------------------------------------------------------------------------- +bool +Head::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; + sOut += "Name=" + m_sName + szNewLine ; + sOut += "Type=" + ToString( m_nType) + szNewLine ; + sOut += "HSet=" + ToString( m_vsHSet) + szNewLine ; + sOut += "ADir=" + ToString( m_vtADir) + szNewLine ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Head::SetOwner( int nId) +{ + m_nOwnerId = nId ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Head::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Head::Head( void) + : m_nOwnerId( GDB_ID_NULL), m_nType( MCH_HT_NONE) +{ +} + +//---------------------------------------------------------------------------- +bool +Head::Set( const string& sName, int nType, const string& sHSet, const Vector3d& vtADir) +{ + m_sName = sName ; + m_nType = nType ; + m_vsHSet.clear() ; + m_vsHSet.push_back( sHSet) ; + m_vtADir = vtADir ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Head::AddHeadToHSet( const string& sHead) +{ + // se giā presente non devo fare alcunchč, altrimenti lo aggiungo + if ( find( m_vsHSet.begin(), m_vsHSet.end(), sHead) != m_vsHSet.end()) + return true ; + m_vsHSet.emplace_back( sHead) ; + return true ; +} + diff --git a/Head.h b/Head.h new file mode 100644 index 0000000..5c8c460 --- /dev/null +++ b/Head.h @@ -0,0 +1,45 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Head.h Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Dichiarazione della classe Head. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machine.h" +#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +//---------------------------------------------------------------------------- +class Head : public IObjUser +{ + public : + virtual Head* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool SetOwner( int nId) ; + virtual int GetOwner( void) const ; + + public : + Head( void) ; + bool Set( const std::string& sName, int nType, const std::string& sHSet, const Vector3d& vtADir) ; + bool AddHeadToHSet( const std::string& sHead) ; + const std::string& GetName( void) { return m_sName ; } + int GetType( void) { return m_nType ; } + const STRVECTOR& GetHSet(void) { return m_vsHSet ; } + const Vector3d& GetADir( void) { return m_vtADir ; } + + private : + int m_nOwnerId ; + std::string m_sName ; + int m_nType ; + STRVECTOR m_vsHSet ; + Vector3d m_vtADir ; +} ; \ No newline at end of file diff --git a/MachConst.h b/MachConst.h index 66e59b0..f97ed66 100644 --- a/MachConst.h +++ b/MachConst.h @@ -49,30 +49,3 @@ const std::string TOOLS_DIR = "Tools" ; //---------------------------------------------------------------------------- // Minimo spessore del grezzo const double RAW_MIN_H = 1 ; - -//---------------------------------------------------------------------------- -// Tipo di tavola della macchina -enum MchTabType { MCH_TT_NONE = 0, - MCH_TT_FLAT = 1} ; - -//---------------------------------------------------------------------------- -// Tipo di assi della macchina -enum MchAxisType { MCH_AT_NONE = 0, - MCH_AT_LINEAR = 1, - MCH_AT_ROTARY = 2} ; - -//---------------------------------------------------------------------------- -// Tipo di testa della macchina -enum MchHeadType { MCH_HT_NONE = 0, - MCH_HT_STD = 1, - MCH_HT_MULTI = 2} ; - -//---------------------------------------------------------------------------- -// Identificativi del tipo di oggetto negli info dei gruppi macchina -const char MCH_AXIS = 'A' ; -const char MCH_TAB = 'T' ; -const char MCH_HEAD = 'H' ; - -//---------------------------------------------------------------------------- -// Lunghezza vettore di movimento degli assi macchina -const double AXIS_LEN = 100 ; \ No newline at end of file diff --git a/MachMgr.h b/MachMgr.h index 65928d3..7ef39d8 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -89,11 +89,20 @@ class MachMgr : public IMachMgr virtual bool ResetHeadSet( const std::string& sHead) ; virtual bool SetCalcTable( const std::string& sTable) ; virtual bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) ; - virtual bool GetCalcAngles( const Vector3d& vtDirT, + 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 VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; + // Operations + virtual int GetOperationNbr( void) const ; + virtual int GetFirstOperation( void) const ; + virtual int GetNextOperation( 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 ; + + virtual int AddDrilling( const std::string& sName) ; public : MachMgr( void) ; diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index 4f1e224..a6f44e6 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -2,11 +2,11 @@ // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : MachMgrFixtures.cpp Data : 13.05.15 Versione : 1.6e6 -// Contenuto : Implementazione gestione grezzi e pezzi della classe MachMgr. +// Contenuto : Implementazione gestione ventose e morse della classe MachMgr. // // // -// Modifiche : 16.04.15 DS Creazione modulo. +// Modifiche : 13.05.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- diff --git a/MachMgrMachGroups.cpp b/MachMgrMachGroups.cpp index f4fe3b9..0590d45 100644 --- a/MachMgrMachGroups.cpp +++ b/MachMgrMachGroups.cpp @@ -73,6 +73,9 @@ MachMgr::GetMachGroupNewName( string& sName) const sName = "Mach01" ; return true ; } + // se nome vuoto, assegno radice standard + if ( sName.empty()) + sName = "Mach" ; // verifico che il nome sia unico int nCount = 1 ; string sOrigName = sName ; @@ -210,6 +213,9 @@ MachMgr::GetMachGroupName( int nId) const // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return "" ; + // verifico che il gruppo ricevuto sia corretto + if ( m_pGeomDB->GetParentId( nId) != m_nMachBaseId) + return "" ; // recupero il nome del gruppo riferito string sName ; m_pGeomDB->GetName( nId, sName) ; @@ -234,7 +240,7 @@ MachMgr::GetMachGroupId( const string& sName) const while( bIter) { // verifico il nome string sMGroupName ; - if ( pIter->GetName( sMGroupName) && sMGroupName == sName) + if ( pIter->GetName( sMGroupName) && EqualNoCase( sMGroupName, sName)) return pIter->GetId() ; // passo al successivo bIter = pIter->GoToNextGroup() ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index f471c03..e8dae77 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -54,7 +54,7 @@ MachMgr::GetMachine( const string& sMachineName) const // ciclo sulle macchine for ( size_t i = 0 ; i < m_vMachines.size() ; ++ i) { if ( m_vMachines[i] != nullptr && - CompareNoCase( m_vMachines[i]->GetMachineName(), sMachineName)) + EqualNoCase( m_vMachines[i]->GetMachineName(), sMachineName)) return int( i) ; } return - 1 ; @@ -152,13 +152,13 @@ MachMgr::SetCalcTool( const string& sTool, const string& sHead, int nExit) //---------------------------------------------------------------------------- bool -MachMgr::GetCalcAngles( const Vector3d& vtDirT, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) +MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, + int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; - return m_vMachines[m_nCurrMch]->GetAngles( vtDirT, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ; + return m_vMachines[m_nCurrMch]->GetAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ; } //---------------------------------------------------------------------------- diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp new file mode 100644 index 0000000..5984520 --- /dev/null +++ b/MachMgrOperations.cpp @@ -0,0 +1,159 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : MachMgrMachinings.cpp Data : 21.05.15 Versione : 1.6e7 +// Contenuto : Implementazione gestione lavorazioni della classe MachMgr. +// +// +// +// Modifiche : 16.04.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllMain.h" +#include "MachMgr.h" +#include "MachConst.h" +#include "Drilling.h" +#include "/EgtDev/Include/EGkGdbIterator.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnFileUtils.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +int +MachMgr::GetOperationNbr( void) const +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return 0 ; + // ritorno numero di operazioni + return m_pGeomDB->GetGroupObjs( nOperGrpId) ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetFirstOperation( void) const +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero il primo sottogruppo + int nId = m_pGeomDB->GetFirstGroupInGroup( nOperGrpId) ; + return nId ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetNextOperation( int nId) const +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // verifico che il gruppo ricevuto sia corretto + if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) + return GDB_ID_NULL ; + // recupero il successivo sottogruppo + int nNextId = m_pGeomDB->GetNextGroup( nId) ; + return nNextId ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetOperationNewName( string& sName) const +{ + // il parametro nome deve essere valido + if ( &sName == nullptr) + return false ; + // il gruppo per le operazioni deve essere presente nella macchinata corrente + if ( GetCurrOperId() == GDB_ID_NULL) + return false ; + // se nome vuoto, assegno radice standard + if ( sName.empty()) + sName = "Oper" ; + // verifico che il nome sia unico + int nCount = 1 ; + string sOrigName = sName ; + while ( GetOperationId( sName) != GDB_ID_NULL) { + ++ nCount ; + sName = sOrigName + "_" + ToString( nCount) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +std::string +MachMgr::GetOperationName( int nId) const +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return "" ; + // verifico che il gruppo ricevuto sia corretto + if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) + return "" ; + // recupero il nome del gruppo riferito + string sName ; + m_pGeomDB->GetName( nId, sName) ; + return sName ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetOperationId( const string& sName) const +{ + // verifica dei parametri + if ( &sName == nullptr || sName.empty()) + return false ; + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero l'identificativo del gruppo con il nome indicato + PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; + if ( IsNull( pIter)) + return false ; + bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ; + while( bIter) { + // verifico il nome + string sOperGrpName ; + if ( pIter->GetName( sOperGrpName) && EqualNoCase( sOperGrpName, sName)) + return pIter->GetId() ; + // passo al successivo + bIter = pIter->GoToNextGroup() ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::AddDrilling( const string& sName) +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero nome originale, partendo da quello proposto + string sNewName = sName ; + if ( ! GetOperationNewName( sNewName)) + return GDB_ID_NULL ; + // inserisco il gruppo + int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; + if ( nId == GDB_ID_NULL) + return GDB_ID_NULL ; + // assegno il nome + m_pGeomDB->SetName( nId, sNewName) ; + // installo il gestore della lavorazione + Drilling* pDrilling = new(nothrow) Drilling ; + if ( pDrilling == nullptr) + return GDB_ID_NULL ; + m_pGeomDB->SetObjUser( nId, pDrilling) ; + return nId ; +} diff --git a/Machine.cpp b/Machine.cpp index d5ae6be..e4e1bf8 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -15,6 +15,10 @@ #include "stdafx.h" #include "MachMgr.h" #include "DllMain.h" +#include "Table.h" +#include "Axis.h" +#include "Head.h" +#include "Exit.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGnStringUtils.h" @@ -161,9 +165,12 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType return false ; // gli assegno il nome m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ; - // gli assegno il tipo - string sInfo = MCH_TAB + ToString( nType) ; - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ; + // installo e inizializzo il gestore della tavola + Table* pTab = new(nothrow) Table ; + if ( pTab == nullptr) + return false ; + pTab->Set( sName, nType) ; + m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pTab) ; // lo inserisco nel dizionario dei gruppi della macchina return m_mapGroups.emplace( sName, nLay).second ; } @@ -192,21 +199,12 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType, return false ; // gli assegno il nome m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ; - // gli assegno il tipo - string sInfo = MCH_AXIS + ToString( nType) ; - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ; - // gli assegno la posizione - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Pos", ptPos) ; - // gli assegno la direzione - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Dir", vtDir) ; - // gli assegno i limiti di corsa - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Stroke", ToString( Stroke.v)) ; - // gli assegno il valore iniziale di home - if ( ! m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HVal", dVal)) - return false ; - // gli assegno il valore corrente - if ( ! m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Val", dVal)) + // installo e inizializzo il gestore dell'asse + Axis* pAxis = new(nothrow) Axis ; + if ( pAxis == nullptr) return false ; + pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dVal) ; + m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pAxis) ; // inserisco il vettore rappresentativo dell'asse if ( ! AddAxisVector( nLay, ptPos, vtDir, sName)) return false ; @@ -273,15 +271,15 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; // gli assegno il nome m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ; - // gli assegno l'insieme di teste e aggiorno il capostipite - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HSet", sHSet) ; + // installo e inizializzo il gestore della testa + Head* pHead = new(nothrow) Head ; + if ( pHead == nullptr) + return false ; + pHead->Set( sName, MCH_HT_STD, sHSet, vtADir) ; + m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ; + // aggiorno la testa capostipite if ( ! AddHeadToSet( sHSet, sName)) return false ; - // gli assegno il tipo - string sInfo = MCH_HEAD + ToString( MCH_HT_STD) ; - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ; - // gli assegno la direzione ausiliaria - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "ADir", vtADir) ; // trasformazione del riferimento di uscita in gruppo di uscita MUEXITVECTOR vMuExit ; vMuExit.emplace_back( ptPos, vtTDir) ; @@ -315,15 +313,15 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; // gli assegno il nome m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ; - // gli assegno l'insieme teste e aggiorno il capostipite - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "HSet", sHSet) ; + // installo e inizializzo il gestore della testa + Head* pHead = new(nothrow) Head ; + if ( pHead == nullptr) + return false ; + pHead->Set( sName, MCH_HT_MULTI, sHSet, vtADir) ; + m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ; + // aggiorno la testa capostipite if ( ! AddHeadToSet( sHSet, sName)) return false ; - // gli assegno il tipo - string sInfo = MCH_HEAD + ToString( MCH_HT_MULTI) ; - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "Type", sInfo) ; - // gli assegno la direzione ausiliaria - m_pMchMgr->m_pGeomDB->SetInfo( nLay, "ADir", vtADir) ; // trasformazione dei riferimenti di uscita in gruppi di uscita if ( ! CreateExitGroups( nLay, vMuExit)) return false ; @@ -340,27 +338,31 @@ Machine::GetGroup( const string& sGroup) } //---------------------------------------------------------------------------- -bool -Machine::IsAxisGroup( int nGroup) +Axis* +Machine::GetAxis( int nGroup) { - string sType ; - return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_AXIS) ; + return ( dynamic_cast( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ; } //---------------------------------------------------------------------------- -bool -Machine::IsTableGroup( int nGroup) +Table* +Machine::GetTable( int nGroup) { - string sType ; - return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_TAB) ; + return ( dynamic_cast( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ; } //---------------------------------------------------------------------------- -bool -Machine::IsHeadGroup( int nGroup) +Head* +Machine::GetHead( int nGroup) { - string sType ; - return ( m_pMchMgr->m_pGeomDB->GetInfo( nGroup, "Type", sType) && sType[0] == MCH_HEAD) ; + return ( dynamic_cast( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ; +} + +//---------------------------------------------------------------------------- +Exit* +Machine::GetExit( int nGroup) +{ + return ( dynamic_cast( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ; } //---------------------------------------------------------------------------- @@ -370,36 +372,33 @@ Machine::AddHeadToSet( const string& sHSet, const string& sName) // se il capo-insieme coincide con la testa, non devo fare alcunchč if ( sHSet == sName) return true ; - // recupero le info della testa capo-insieme - int nHGroupId = GetGroup( sHSet) ; - if ( nHGroupId == GDB_ID_NULL) + // recupero la testa capo-insieme + Head* pHead = GetHead( GetGroup( sHSet)) ; + if ( pHead == nullptr) return false ; - STRVECTOR vsHSet ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nHGroupId, "HSet", vsHSet)) - return false ; - // se giā presente non devo fare alcunchč, altrimenti lo aggiungo - if ( find( vsHSet.begin(), vsHSet.end(), sName) != vsHSet.end()) - return true ; - vsHSet.emplace_back( sName) ; - return m_pMchMgr->m_pGeomDB->SetInfo( nHGroupId, "HSet", vsHSet) ; + // aggiungo questa testa all'insieme + return pHead->AddHeadToHSet( sName) ; } //---------------------------------------------------------------------------- -bool -Machine::GetHSet( const string& sHead, STRVECTOR& vsHSet) +const STRVECTOR& +Machine::GetHSet( const string& sHead) { - // recupero l'indice della testa - int nHead = GetGroup( sHead) ; - if ( ! IsHeadGroup( nHead)) - return false ; - // recupero la stringa dell'insieme di teste - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nHead, "HSet", vsHSet)) - return false ; + // vettore di stringhe vuoto, da restituire in caso di errore + static const STRVECTOR vsNull ; + // recupero la testa + Head* pHead = GetHead( GetGroup( sHead)) ; + if ( pHead == nullptr) + return vsNull ; + // recupero l'insieme di teste a cui appartiene + const STRVECTOR& vsTmp = pHead->GetHSet() ; + if ( vsTmp.empty()) + return vsNull ; // se il primo membro coincide con la testa, allora č giā l'insieme di teste - if ( vsHSet[0] == sHead) - return true ; + if ( vsTmp[0] == sHead) + return vsTmp ; // altrimenti cerco l'insieme della prima testa - return GetHSet( vsHSet[0], vsHSet) ; + return GetHSet( vsTmp[0]) ; } //---------------------------------------------------------------------------- @@ -407,8 +406,8 @@ bool Machine::EnableHeadInSet( const string& sHead) { // recupero l'insieme di teste - STRVECTOR vsHSet ; - if ( ! GetHSet( sHead, vsHSet)) + const STRVECTOR& vsHSet = GetHSet( sHead) ; + if ( vsHSet.empty()) return false ; // spengo tutte le teste tranne questa for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) { @@ -425,7 +424,7 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) { // ciclo sulle uscite for ( int i = 0 ; i < int( vMuExit.size()) ; ++ i) { - string sName = "T" + ToString( i+1) ; + string sName = MCH_EXIT + ToString( i+1) ; // se trovo riferimento per uscita, lo sostituisco con gruppo equivalente int nT = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nLay, sName) ; if ( nT != GDB_ID_NULL && m_pMchMgr->m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) { @@ -439,10 +438,12 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) m_pMchMgr->m_pGeomDB->Erase( nT) ; // assegno nome m_pMchMgr->m_pGeomDB->SetName( nGT, sName) ; - // gli assegno la posizione - m_pMchMgr->m_pGeomDB->SetInfo( nGT, "Pos", vMuExit[i].ptPos) ; - // gli assegno la direzione utensile - m_pMchMgr->m_pGeomDB->SetInfo( nGT, "TDir", vMuExit[i].vtTDir) ; + // installo e inizializzo il gestore dell'uscita + Exit* pExit = new(nothrow) Exit ; + if ( pExit == nullptr) + return false ; + pExit->Set( sName, vMuExit[i].ptPos, vMuExit[i].vtTDir) ; + m_pMchMgr->m_pGeomDB->SetObjUser( nGT, pExit) ; } else { string sOut = "Error finding frame " + sName ; diff --git a/Machine.h b/Machine.h index 32e8563..4cd9d32 100644 --- a/Machine.h +++ b/Machine.h @@ -13,40 +13,16 @@ #pragma once +#include "MachineStruConst.h" #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 Axis ; +class Table ; +class Head ; +class Exit ; //---------------------------------------------------------------------------- class Machine @@ -67,7 +43,7 @@ class Machine 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, + 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, int& nStat, double& dX, double& dY, double& dZ) ; @@ -89,15 +65,21 @@ class Machine 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) ; + Axis* GetAxis( int nGroup) ; + bool IsAxisGroup( int nGroup) { return ( GetAxis( nGroup) != nullptr) ; } + Table* GetTable( int nGroup) ; + bool IsTableGroup( int nGroup) { return ( GetTable( nGroup) != nullptr) ; } + Head* GetHead( int nGroup) ; + bool IsHeadGroup( int nGroup) { return ( GetHead( nGroup) != nullptr) ; } + Exit* GetExit( int nGroup) ; + bool IsExitGroup( int nGroup) { return ( GetExit( nGroup) != nullptr) ; } bool AddHeadToSet( const std::string& sHSet, const std::string& sName) ; - bool GetHSet( const std::string& sHead, STRVECTOR& vsHSet) ; + const STRVECTOR& GetHSet( const std::string& sHead) ; bool EnableHeadInSet( const std::string& sHead) ; bool CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) ; bool CalculateKinematicChain( void) ; bool AddKinematicAxis( bool bOnHead, int nId) ; + bool AdjustAngleInStroke( int nId, double& dAng) ; bool LuaInit( const std::string& sMachineName) ; bool LuaExit( void) ; @@ -120,6 +102,7 @@ class Machine 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 + Vector3d m_vtCalcADir ; // direzione ausiliaria 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 diff --git a/MachineAxes.cpp b/MachineAxes.cpp index 00c62e4..92d0660 100644 --- a/MachineAxes.cpp +++ b/MachineAxes.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "MachMgr.h" #include "DllMain.h" +#include "Axis.h" #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -27,21 +28,16 @@ Machine::SetAxisPos( const string& sAxis, double dVal) { // recupero il gruppo dell'asse int nAxGrp = GetGroup( sAxis) ; - if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp)) - return false ; - // recupero il tipo di asse - string sType ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Type", sType)) - return false ; - bool bLinear = ( sType != MCH_AXIS + ToString( MCH_AT_ROTARY)) ; - // recupero la posizione attuale - double dCurrVal ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Val", dCurrVal)) - return false ; - // recupero i limiti della corsa - STROKE Stroke ; string sTmp ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Stroke", sTmp) || ! FromString( sTmp, Stroke.v)) + // recupero il relativo gestore + Axis* pAx = GetAxis( nAxGrp) ; + if ( pAx == nullptr) return false ; + // tipo di asse + bool bLinear = ( pAx->GetType() != MCH_AT_ROTARY) ; + // posizione attuale + double dCurrVal = pAx->GetCurrVal() ; + // limiti della corsa + STROKE Stroke = pAx->GetStroke() ; // recupero il vettore dell'asse int nV = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nAxGrp, sAxis) ; const IGeoVector3d* pGV = GetGeoVector3d( m_pMchMgr->m_pGeomDB->GetGeoObj( nV)) ; @@ -60,44 +56,42 @@ Machine::SetAxisPos( const string& sAxis, double dVal) else m_pMchMgr->m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ; // salvo la nuova posizione - return m_pMchMgr->m_pGeomDB->SetInfo( nAxGrp, "Val", dVal) ; + return pAx->SetCurrVal( dVal) ; } //---------------------------------------------------------------------------- bool Machine::GetAxisPos( const string& sAxis, double& dVal) { - // recupero il gruppo dell'asse - int nAxGrp = GetGroup( sAxis) ; - if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp)) + // recupero il relativo gestore + Axis* pAx = GetAxis( GetGroup( sAxis)) ; + if ( pAx == nullptr) return false ; // recupero la posizione corrente - return m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Val", dVal) ; + dVal = pAx->GetCurrVal() ; + return true ; } //---------------------------------------------------------------------------- bool Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal) { - // recupero il gruppo dell'asse - int nAxGrp = GetGroup( sAxis) ; - if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp)) + // recupero il gestore dell'asse + Axis* pAx = GetAxis( GetGroup( sAxis)) ; + if ( pAx == nullptr) return false ; - // recupero la posizione corrente - return m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "HVal", dHomeVal) ; + // recupero la posizione home + dHomeVal = pAx->GetHomeVal() ; + return true ; } //---------------------------------------------------------------------------- bool Machine::ResetAxisPos( const string& sAxis) { - // recupero il gruppo dell'asse - int nAxGrp = GetGroup( sAxis) ; - if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp)) - return false ; // recupero la posizione home double dHomeVal ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "HVal", dHomeVal)) + if ( ! GetAxisHomePos( sAxis, dHomeVal)) return false ; // eseguo il movimento return SetAxisPos( sAxis, dHomeVal) ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index bb14bb5..2cb070b 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -16,6 +16,9 @@ #include "MachMgr.h" #include "GeoCalc.h" #include "DllMain.h" +#include "Axis.h" +#include "Head.h" +#include "Exit.h" #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -46,19 +49,16 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) m_dCalcTLen = 0 ; // recupero il gruppo della testa int nHeadId = GetGroup( sHead) ; - if ( nHeadId == GDB_ID_NULL || ! IsHeadGroup( nHeadId)) + // recupero i dati della testa + Head* pHead = GetHead( nHeadId) ; + if ( pHead == nullptr) return false ; // recupero il gruppo dell'uscita - string sExit = "T" + ToString( nExit) ; + string sExit = MCH_EXIT + ToString( nExit) ; int nExitId = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHeadId, sExit) ; - if ( nExitId == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nExitId) != GDB_TY_GROUP) - return false ; - // recupero posizione e direzione a riposo - Point3d ptPos ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nExitId, "Pos", ptPos)) - return false ; - Vector3d vtDir ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nExitId, "TDir", vtDir)) + // recupero i dati dell'uscita + Exit* pExit = GetExit( nExitId) ; + if ( pExit == nullptr) return false ; // recupero i dati dell'utensile if ( ! LoadTool( sHead, nExit, sTool)) @@ -73,8 +73,9 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) m_nCalcHeadId = nHeadId ; m_nCalcExitId = nExitId ; m_nCalcToolId = nToolId ; - m_ptCalcPos = ptPos ; - m_vtCalcDir = vtDir ; + m_ptCalcPos = pExit->GetPos() ; + m_vtCalcDir = pExit->GetTDir() ; + m_vtCalcADir = pHead->GetADir() ; m_dCalcTLen = dTLen ; // determino la catena cinematica return CalculateKinematicChain() ; @@ -147,26 +148,18 @@ Machine::CalculateKinematicChain( void) bool Machine::AddKinematicAxis( bool bOnHead, int nId) { + // recupero il gestore dell'asse + Axis* pAx = GetAxis( nId) ; + if ( pAx == nullptr) + return false ; + // ne recupero i dati KinAxis kAx ; - // assegno id kAx.nGrpId = nId ; - // recupero il tipo di asse - string sType ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nId, "Type", sType)) - return false ; - kAx.bLinear = ( sType != MCH_AXIS + ToString( MCH_AT_ROTARY)) ; - // assegno posizione su catena cinematica - kAx.bHead = bOnHead ; - // recupero la posizione - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nId, "Pos", kAx.ptPos)) - return false ; - // recupero la direzione e la normalizzo - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nId, "Dir", kAx.vtDir) || ! kAx.vtDir.Normalize()) - return false ; - // recupero i limiti di corsa - string sStroke ; - if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nId, "Stroke", sStroke) || ! FromString( sStroke, kAx.stroke.v)) - return false ; + kAx.bLinear = ( pAx->GetType() != MCH_AT_ROTARY) ; + kAx.bHead = bOnHead ; // posizione su catena cinematica + kAx.ptPos = pAx->GetPos() ; + kAx.vtDir = pAx->GetDir() ; + kAx.stroke = pAx->GetStroke() ; // se lineare di tavola, devo invertirlo if ( kAx.bLinear && ! kAx.bHead) kAx.vtDir.Invert() ; @@ -180,7 +173,7 @@ Machine::AddKinematicAxis( bool bOnHead, int nId) //---------------------------------------------------------------------------- bool -Machine::GetAngles( const Vector3d& vtDirT, +Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) { // annullo tutti gli angoli @@ -194,8 +187,13 @@ Machine::GetAngles( const Vector3d& vtDirT, Vector3d vtDirTn = vtDirT ; if ( ! vtDirTn.Normalize()) return false ; + // direzione ausiliaria normalizzata + Vector3d vtDirAn = vtDirA ; + vtDirAn.Normalize() ; // direzione fresa su testa a riposo Vector3d vtDirH = m_vtCalcDir ; + // direzione ausiliaria su testa a riposo + Vector3d vtDirI = m_vtCalcADir ; // direzione primo asse rotante Vector3d vtAx1 = m_vCalcRotAx[0].vtDir ; // se asse di tavola, ne inverto la direzione @@ -206,6 +204,7 @@ Machine::GetAngles( const Vector3d& vtDirT, // se c'č secondo asse rotante, si calcola angolo per avere il componente appena calcolato bool bDet = true ; Vector3d vtDirH1, vtDirH2 ; + Vector3d vtDirI1, vtDirI2 ; if ( m_vCalcRotAx.size() == 2) { // direzione secondo asse rotante Vector3d vtAx2 = m_vCalcRotAx[1].vtDir ; @@ -222,10 +221,14 @@ Machine::GetAngles( const Vector3d& vtDirT, // eseguo aggiornamento vtDirH1 = vtDirH ; vtDirH1.Rotate( vtAx2, dAngB1) ; + vtDirI1 = vtDirI ; + vtDirI1.Rotate( vtAx2, dAngB1) ; } if ( nStat == 2) { vtDirH2 = vtDirH ; vtDirH2.Rotate( vtAx2, dAngB2) ; + vtDirI2 = vtDirI ; + vtDirI2.Rotate( vtAx2, dAngB2) ; } } // altrimenti verifico se compatibili @@ -248,33 +251,55 @@ Machine::GetAngles( const Vector3d& vtDirT, } // calcolo primo angolo di rotazione per seconda soluzione + bool bDet2 = true ; if ( nStat == 2) { - bool bDet ; - if ( ! vtDirH2.GetRotation( vtDirTn, vtAx1, dAngA2, bDet) ) + if ( ! vtDirH2.GetRotation( vtDirTn, vtAx1, dAngA2, bDet2) ) nStat = 1 ; else { - // se indeterminato ... - if ( ! bDet) { - nStat = - 2 ; - dAngA2 = 0 ; + // se indeterminato, provo a determinarlo con la direzione ausiliaria + if ( ! bDet2) { + bool bDetX ; + vtDirI2.GetRotation( vtDirAn, vtAx1, dAngA2, bDetX) ; } } } // calcolo primo angolo di rotazione per prima soluzione + bool bDet1 = true ; if ( nStat >= 1) { - bool bDet ; - if ( ! vtDirH1.GetRotation( vtDirTn, vtAx1, dAngA1, bDet) ) + if ( ! vtDirH1.GetRotation( vtDirTn, vtAx1, dAngA1, bDet1) ) nStat = 0 ; else { - // se indeterminato ... - if ( ! bDet) { - nStat = - nStat ; - dAngA1 = 0 ; + // se indeterminato, provo a determinarlo con la direzione ausiliaria + if ( ! bDet1) { + bool bDetX ; + vtDirI1.GetRotation( vtDirAn, vtAx1, dAngA1, bDetX) ; } } } + // verifiche dei limiti di corsa + if ( nStat >= 2) { + // se non riesco ad aggiustare, elimino + if ( ! AdjustAngleInStroke( 1, dAngA2) || ! AdjustAngleInStroke( 2, dAngB2)) + -- nStat ; + } + if ( nStat >= 1) { + // se non riesco ad aggiustare, elimino + if ( ! AdjustAngleInStroke( 1, dAngA1) || ! AdjustAngleInStroke( 2, dAngB1)) { + -- nStat ; + // riloco eventuale soluzione rimasta + if ( nStat >= 1) { + dAngA1 = dAngA2 ; + dAngB1 = dAngB2 ; + } + } + } + + // modifico stato per angolo indeterminato + if ( ( nStat >= 2 && ! bDet2) || ( nStat >= 1 && ! bDet1)) + nStat = - nStat ; + return true ; } @@ -310,6 +335,9 @@ Machine::GetPositions( const Point3d& ptP, double dAngA, double dAngB, vtDirH.Rotate( vtAx1, dAngA) ; } + // assegno l'offset tesat + Vector3d vtDtHe = ORIG - m_ptCalcPos ; + // calcolo il recupero degli assi : č l'opposto dello spostamento della posizione Vector3d vtDtAx = m_ptCalcPos - ptPosH ; @@ -317,13 +345,42 @@ Machine::GetPositions( const Point3d& ptP, double dAngA, double dAngB, Vector3d vtDtTL = vtDirH * m_dCalcTLen ; // calcolo le posizioni degli assi lineari - dX = ptP.x + vtDtAx.x + vtDtTL.x ; - dY = ptP.y + vtDtAx.y + vtDtTL.y ; - dZ = ptP.z + vtDtAx.z + vtDtTL.z ; + dX = ptP.x + vtDtHe.x + vtDtAx.x + vtDtTL.x ; + dY = ptP.y + vtDtHe.y + vtDtAx.y + vtDtTL.y ; + dZ = ptP.z + vtDtHe.z + vtDtAx.z + vtDtTL.z ; return true ; } +//---------------------------------------------------------------------------- +bool +Machine::AdjustAngleInStroke( int nId, double& dAng) +{ + // se non ci sono assi rotanti, non c'č alcunchč da fare + if ( m_vCalcRotAx.size() == 0) + return true ; + // se primo angolo ed esiste primo asse rotante + if ( nId == 1 && m_vCalcRotAx.size() >= 1) { + while ( dAng < m_vCalcRotAx[0].stroke.Min) + dAng += ANG_FULL ; + while ( dAng > m_vCalcRotAx[0].stroke.Max) + dAng -= ANG_FULL ; + return ( dAng >= m_vCalcRotAx[0].stroke.Min && + dAng <= m_vCalcRotAx[0].stroke.Max) ; + } + // se secondo angolo ed esiste secondo asse rotante + if ( nId == 2 && m_vCalcRotAx.size() >= 2) { + while ( dAng < m_vCalcRotAx[1].stroke.Min) + dAng += ANG_FULL ; + while ( dAng > m_vCalcRotAx[1].stroke.Max) + dAng -= ANG_FULL ; + return ( dAng >= m_vCalcRotAx[1].stroke.Min && + dAng <= m_vCalcRotAx[1].stroke.Max) ; + } + // errore + return false ; +} + //---------------------------------------------------------------------------- bool Machine::VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) diff --git a/MachineHeads.cpp b/MachineHeads.cpp index 2603663..58d33fe 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "MachMgr.h" #include "DllMain.h" +#include "Exit.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -26,16 +27,16 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool) { // recupero il gruppo della testa int nHdGrp = GetGroup( sHead) ; - if ( nHdGrp == GDB_ID_NULL || ! IsHeadGroup( nHdGrp)) + if ( ! IsHeadGroup( nHdGrp)) return false ; // cerco il gruppo dell'uscita in quello della testa - string sExit = "T" + ToString( nExit) ; + string sExit = MCH_EXIT + ToString( nExit) ; int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ; - if ( nExGrp == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nExGrp) != GDB_TY_GROUP) + Exit* pExit = GetExit( nExGrp) ; + if ( pExit == nullptr) return false ; // se utensile giā montato, abilito ed esco - string sOldTool ; - if ( m_pMchMgr->m_pGeomDB->GetInfo( nExGrp, "Tool", sOldTool) && sTool == sOldTool) + if ( sTool == pExit->GetTool()) return EnableHeadInSet( sHead) ; // verifico esistenza file utensile string sToolFile = m_sMachineDir + "\\" + TOOLS_DIR + "\\" + sTool + ".Nge" ; @@ -58,7 +59,7 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool) if ( nT == GDB_ID_NULL) return false ; m_pMchMgr->m_pGeomDB->Rotate( nT, ORIG, X_AX, 90) ; - m_pMchMgr->m_pGeomDB->SetInfo( nExGrp, "Tool", sTool) ; + pExit->SetTool( sTool) ; return EnableHeadInSet( sHead) ; } @@ -67,25 +68,27 @@ bool Machine::ResetHeadSet( const string& sHead) { // recupero il set della testa - STRVECTOR vsHSet ; - if ( ! GetHSet( sHead, vsHSet)) + const STRVECTOR& vsHSet = GetHSet( sHead) ; + if ( vsHSet.empty()) return false ; // ciclo su tutte le teste dell'insieme per svuotarle for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) { // recupero il gruppo della testa int nHdGrp = GetGroup( vsHSet[i]) ; - if ( nHdGrp == GDB_ID_NULL || ! IsHeadGroup( nHdGrp)) + if ( ! IsHeadGroup( nHdGrp)) return false ; // ciclo sulle sue uscite for ( int j = 1 ; true ; ++ j) { // recupero il gruppo dell'uscita - string sExit = "T" + ToString( j) ; + string sExit = MCH_EXIT + ToString( j) ; int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ; - if ( nExGrp == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nExGrp) != GDB_TY_GROUP) + // recupero l'oggetto uscita + Exit* pExit = GetExit( nExGrp) ; + if ( pExit == nullptr) break ; // pulisco il gruppo dell'uscita m_pMchMgr->m_pGeomDB->EmptyGroup( nExGrp) ; - m_pMchMgr->m_pGeomDB->RemoveInfo( nExGrp, "Tool") ; + pExit->SetTool( "") ; } // visualizzo solo la prima testa m_pMchMgr->m_pGeomDB->SetStatus( nHdGrp, ( i == 0 ? GDB_ST_ON : GDB_ST_OFF)) ; diff --git a/MachineStruConst.h b/MachineStruConst.h new file mode 100644 index 0000000..935ab7e --- /dev/null +++ b/MachineStruConst.h @@ -0,0 +1,75 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : MachineStruConst.h Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Strutture e costanti di macchina. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" +#include +#include + +//---------------------------------------------------------------------------- +// Corsa utile di un asse +union STROKE { + struct { + double Min ; + double Max ; + } ; + double v[2] ; +} ; + +//---------------------------------------------------------------------------- +// Dati di uscita +struct MuExit { + Point3d ptPos ; + Vector3d vtTDir ; + MuExit( const Point3d& ptP, const Vector3d& vtTD) + : ptPos( ptP), vtTDir( vtTD) {} +} ; +typedef std::vector MUEXITVECTOR ; + +//---------------------------------------------------------------------------- +// Dati asse per catena cinematica +struct KinAxis { + int nGrpId ; + bool bLinear ; + bool bHead ; + Point3d ptPos ; + Vector3d vtDir ; + STROKE stroke ; +}; +typedef std::vector KINAXISVECTOR ; + +//---------------------------------------------------------------------------- +// Tipo di tavola della macchina +enum MchTabType { MCH_TT_NONE = 0, + MCH_TT_FLAT = 1} ; + +//---------------------------------------------------------------------------- +// Tipo di assi della macchina +enum MchAxisType { MCH_AT_NONE = 0, + MCH_AT_LINEAR = 1, + MCH_AT_ROTARY = 2} ; + +//---------------------------------------------------------------------------- +// Tipo di testa della macchina +enum MchHeadType { MCH_HT_NONE = 0, + MCH_HT_STD = 1, + MCH_HT_MULTI = 2} ; + +//---------------------------------------------------------------------------- +// Lunghezza vettore di movimento degli assi macchina +const double AXIS_LEN = 100 ; + +//---------------------------------------------------------------------------- +// Identificativo iniziale gruppo uscita di teste +const std::string MCH_EXIT = "T" ; diff --git a/Table.cpp b/Table.cpp new file mode 100644 index 0000000..3eb4969 --- /dev/null +++ b/Table.cpp @@ -0,0 +1,96 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Table.cpp Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Oggetto tavola per gruppo tavola di macchina. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Table.h" +#include "MachConst.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OBJUSER_REGISTER( "EMkTable", Table) ; + +//---------------------------------------------------------------------------- +const string& +Table::GetClassName( void) const +{ + return OBJUSER_GETNAME( Table) ; +} + +//---------------------------------------------------------------------------- +Table* +Table::Clone( void) const +{ + // alloco oggetto + Table* pAx = new(nothrow) Table ; + // eseguo copia dei dati + if ( pAx != nullptr) { + try { pAx->m_nOwnerId = GDB_ID_NULL ; + pAx->m_sName = m_sName ; + pAx->m_nType = m_nType ; + } + catch( ...) { + delete pAx ; + return nullptr ; + } + } + // ritorno l'oggetto + return pAx ; +} + +//---------------------------------------------------------------------------- +bool +Table::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; + sOut += "Name=" + m_sName + szNewLine ; + sOut += "Type=" + ToString( m_nType) + szNewLine ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Table::SetOwner( int nId) +{ + m_nOwnerId = nId ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Table::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Table::Table( void) + : m_nOwnerId( GDB_ID_NULL), m_nType( MCH_TT_NONE) +{ +} + +//---------------------------------------------------------------------------- +bool +Table::Set( const string& sName, int nType) +{ + m_sName = sName ; + m_nType = nType ; + return true ; +} + diff --git a/Table.h b/Table.h new file mode 100644 index 0000000..be45dee --- /dev/null +++ b/Table.h @@ -0,0 +1,40 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Table.h Data : 25.05.15 Versione : 1.6e7 +// Contenuto : Dichiarazione della classe Table. +// +// +// +// Modifiche : 25.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machine.h" +#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +//---------------------------------------------------------------------------- +class Table : public IObjUser +{ + public : + virtual Table* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool SetOwner( int nId) ; + virtual int GetOwner( void) const ; + + public : + Table( void) ; + bool Set( const std::string& sName, int nType) ; + const std::string& GetName( void) { return m_sName ; } + int GetType( void) { return m_nType ; } + + private : + int m_nOwnerId ; + std::string m_sName ; + int m_nType ; +} ; \ No newline at end of file