00001 // $Id: ethercat_slave_conf.h,v 1.14 2006/02/20 15:57:33 kgad Exp $ 00002 //=========================================================================== 00003 // This file is part of "EtherCAT Master Library". 00004 // Copyright (C) 2005 FMTC vzw, Diamant Building, A. Reyerslaan 80, 00005 // B-1030 Brussels, Belgium. 00006 // 00007 // EtherCAT Master Library is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 or 00010 // (at your option) any later version. 00011 // 00012 // EtherCAT Master Code is distributed in the hope that it will be 00013 // useful, but WITHOUT ANY WARRANTY; without even the implied 00014 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 // PURPOSE. See the GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with the EtherCAT Master Library; if not, write to the Free 00019 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00020 // 02111-1307 USA. 00021 // 00022 // EtherCAT, the EtherCAT trade name and logo are the intellectual 00023 // property of, and protected by Beckhoff. You can use "EtherCAT 00024 // Master Library" for creating and/or selling or otherwise 00025 // distributing an EtherCAT network master under the terms of the 00026 // EtherCAT Master License. 00027 // 00028 // You should have received a copy of the EtherCAT Master License 00029 // along with the EtherCAT Master Library; if not, write to Beckhoff 00030 // Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany. 00031 //=========================================================================== 00032 00033 #ifndef __ethercat_slave_conf__ 00034 #define __ethercat_slave_conf__ 00035 00036 #include "ros_ethercat_eml/ethercat_defs.h" 00037 #include "ros_ethercat_eml/ethercat_slave_memory.h" 00038 00040 00041 class EtherCAT_FMMU_Config 00042 { 00043 public: 00045 00048 EtherCAT_FMMU_Config(unsigned int a_num_used_fmmus); 00049 ~EtherCAT_FMMU_Config() 00050 { 00051 delete[] fmmus; 00052 } 00053 00055 00057 unsigned int get_num_used_fmmus() const 00058 { 00059 return m_num_used_fmmus; 00060 } 00061 00063 00066 EC_FMMU & operator[](unsigned int i); 00068 00071 const EC_FMMU & operator[](unsigned int i) const; 00072 00073 protected: 00074 EC_FMMU * fmmus; 00075 unsigned int m_num_used_fmmus; 00076 }; 00077 00079 00083 class EtherCAT_PD_Config 00084 { 00085 public: 00087 00090 EtherCAT_PD_Config(unsigned int a_num_used_sms); 00091 ~EtherCAT_PD_Config() 00092 { 00093 delete[] sms; 00094 } 00095 00097 00099 unsigned int get_num_used_sms() const 00100 { 00101 return m_num_used_sms; 00102 } 00103 00105 00108 EC_SyncMan & operator[](unsigned int i); 00110 00113 const EC_SyncMan & operator[](unsigned int i) const; 00114 00115 protected: 00117 EC_SyncMan * sms; 00119 unsigned int m_num_used_sms; 00120 }; 00121 00123 00124 typedef struct 00125 { 00127 EC_SyncMan SM0; 00129 EC_SyncMan SM1; 00130 } EtherCAT_MbxConfig; 00131 00133 00136 class EtherCAT_SlaveConfig 00137 { 00138 public: 00140 00158 EtherCAT_SlaveConfig(uint32_t a_product_code, 00159 uint32_t a_revision, 00160 EC_FixedStationAddress a_station_address, 00161 EtherCAT_FMMU_Config * a_fmmu_config, 00162 EtherCAT_PD_Config * a_pd_config, 00163 EtherCAT_MbxConfig * a_mbx_config = NULL); 00164 00165 public: 00167 bool is_complex(void) const 00168 { 00169 return m_complex; 00170 } 00171 ; 00173 uint32_t get_product_code() const 00174 { 00175 return m_product_code; 00176 } 00178 uint32_t get_revision() const 00179 { 00180 return m_revision; 00181 } 00183 EC_FixedStationAddress get_station_address() const 00184 { 00185 return m_station_address; 00186 } 00188 const EtherCAT_FMMU_Config * get_fmmu_config() const 00189 { 00190 return m_fmmu_config; 00191 } 00192 void set_fmmu_config(EtherCAT_FMMU_Config *new_config) 00193 { 00194 m_fmmu_config = new_config; 00195 } 00197 const EtherCAT_PD_Config * get_pd_config() const 00198 { 00199 return m_pd_config; 00200 } 00201 void set_pd_config(EtherCAT_PD_Config *new_config) 00202 { 00203 m_pd_config = new_config; 00204 } 00206 00209 const EtherCAT_MbxConfig * get_mbx_config() const 00210 { 00211 return m_mbx_config; 00212 } 00213 void set_mbx_config(EtherCAT_MbxConfig *new_config); 00215 bool is_used() 00216 { 00217 return used; 00218 } 00220 void set_used() 00221 { 00222 used = true; 00223 } 00224 00225 protected: 00227 uint32_t m_product_code; 00229 uint32_t m_revision; 00231 EC_FixedStationAddress m_station_address; 00233 EtherCAT_FMMU_Config * m_fmmu_config; 00235 EtherCAT_PD_Config * m_pd_config; 00236 00237 EtherCAT_MbxConfig * m_mbx_config; 00238 00239 bool m_complex; 00240 bool used; 00241 }; 00242 00244 00248 class EtherCAT_SlaveDb 00249 { 00250 public: 00252 static EtherCAT_SlaveDb * instance(unsigned int num_slaves = 0); 00253 ~EtherCAT_SlaveDb() 00254 { 00255 delete[] m_sc; 00256 } 00257 00258 EtherCAT_SlaveConfig * operator[](unsigned int i); 00259 const EtherCAT_SlaveConfig * operator[](unsigned int i) const; 00260 void set_conf(EtherCAT_SlaveConfig * conf, unsigned int i); 00261 00263 00268 const EtherCAT_SlaveConfig * find(uint32_t productcode, 00269 uint32_t revision) const; 00270 protected: 00272 EtherCAT_SlaveDb(unsigned int num_slaves); 00273 00274 private: 00275 static EtherCAT_SlaveDb * m_instance; 00276 00277 EtherCAT_SlaveConfig ** m_sc; 00278 unsigned int m_num_slaves; 00279 00280 }; 00281 00282 #endif // __ethercat_slave_conf__