Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ETHERCAT_MANAGER_H
00031 #define ETHERCAT_MANAGER_H
00032
00033 #include <stdexcept>
00034 #include <string>
00035
00036 #include <stdint.h>
00037
00038 #include <boost/scoped_array.hpp>
00039 #include <boost/thread.hpp>
00040 #include <boost/thread/mutex.hpp>
00041
00042 namespace ethercat {
00043
00048 class EtherCatError : public std::runtime_error
00049 {
00050 public:
00051 explicit EtherCatError(const std::string& what)
00052 : std::runtime_error(what)
00053 {}
00054 };
00055
00065 class EtherCatManager
00066 {
00067 public:
00077 EtherCatManager(const std::string& ifname);
00078
00079 ~EtherCatManager();
00080
00091 void write(int slave_no, uint8_t channel, uint8_t value);
00092
00099 uint8_t readInput(int slave_no, uint8_t channel) const;
00100
00107 uint8_t readOutput(int slave_no, uint8_t channel) const;
00108
00117 template <typename T>
00118 uint8_t writeSDO(int slave_no, uint16_t index, uint8_t subidx, T value) const;
00119
00127 template <typename T>
00128 T readSDO(int slave_no, uint16_t index, uint8_t subidx) const;
00129
00133 int getNumClinets() const;
00134
00138 void getStatus(int slave_no, std::string &name, int &eep_man, int &eep_id, int &eep_rev, int &obits, int &ibits, int &state, int &pdelay, int &hasdc, int &activeports, int &configadr) const;
00139
00140 private:
00141 bool initSoem(const std::string& ifname);
00142
00143 const std::string ifname_;
00144 uint8_t iomap_[4096];
00145 int num_clients_;
00146 boost::thread cycle_thread_;
00147 mutable boost::mutex iomap_mutex_;
00148 bool stop_flag_;
00149 };
00150
00151 }
00152
00153 #endif
00154