libcpp4ec
C++ for EtherCat Library
 All Classes Functions Variables Typedefs Enumerations Enumerator
EcSlave.h
1 #ifndef ECSLAVE_H
2 #define ECSLAVE_H
3 
4 #include "EcError.h"
5 // #include <iostream>
6 // #include <sstream>
7 #include <vector>
8 #include <stdint.h>
9 
10 extern "C"
11 {
12 #include <soem/ethercattype.h>
13 #include <soem/nicdrv.h>
14 #include <soem/ethercatbase.h>
15 #include <soem/ethercatmain.h>
16 #include <soem/ethercatconfig.h>
17 #include <soem/ethercatdc.h>
18 #include <soem/ethercatcoe.h>
19 #include <soem/ethercatprint.h>
20 }
21 
22 #include <boost/signals2/signal.hpp>
23 
24 
25 typedef struct
26 {
27  uint16_t index;
28  uint8_t subindex;
29  uint8_t size;
30  int param;
31  std::string name;
32  std::string description;
33 } CoEparameter;
34 
35 typedef struct
36 {
37  uint16_t idn;
38  uint8_t elementflags;
39  uint8_t size;
40  int param;
41  std::string name;
42  std::string description;
43 } SoEparameter;
44 
45 
46 namespace cpp4ec
47 {
53 class EcSlave
54 {
55 public:
60  virtual ~EcSlave();
61 
66  const std::string& getName() const;
67 
72  virtual bool configure();
73 
78  virtual void start();
79 
84  virtual void update()=0;
85 
90  virtual void stop();
91 
96  virtual bool requestState( ec_state state);
97 
102  virtual bool checkState( ec_state state);
103 
108  virtual ec_state getState();
109 
114  virtual void setDC(bool active, unsigned int sync0Time, unsigned int sync0Shift);
115 
120  virtual void setPDOBuffer(char * input, char * output);
121 
126  boost::signals2::signal<void ()> updateMaster;
127 
128 
129 protected:
130  EcSlave(ec_slavet* mem_loc);
132  ec_slavet* m_datap;
133  std::string m_name;
134  unsigned int m_slave_nr;
135 };
136 }
137 #endif
const std::string & getName() const
Get the slave name.
Definition: EcSlave.cpp:11
virtual bool checkState(ec_state state)
Checks the slave state.
Definition: EcSlave.cpp:39
Class EcSlave.
Definition: EcSlave.h:53
virtual bool requestState(ec_state state)
Requests the slave state.
Definition: EcSlave.cpp:30
unsigned int m_slave_nr
Definition: EcSlave.h:134
virtual void update()=0
Updates the slave.
virtual void start()
Starts the slave.
Definition: EcSlave.cpp:21
virtual void setDC(bool active, unsigned int sync0Time, unsigned int sync0Shift)
Set the Distributed clock.
Definition: EcSlave.cpp:25
virtual bool configure()
Configures the slave.
Definition: EcSlave.cpp:16
boost::signals2::signal< void()> updateMaster
Update Master outputs.
Definition: EcSlave.h:126
ec_slavet * m_datap
Definition: EcSlave.h:132
virtual void stop()
Stops the slave.
Definition: EcSlave.cpp:23
Definition: EcSlave.h:35
virtual ec_state getState()
Gets the slave state.
Definition: EcSlave.cpp:46
virtual void setPDOBuffer(char *input, char *output)
Set PDO buffer.
Definition: EcSlave.cpp:28
EcSlave(ec_slavet *mem_loc)
Definition: EcSlave.cpp:6
Definition: EcSlave.h:25
virtual ~EcSlave()
Destructor.
Definition: EcSlave.cpp:9
Definition: EcMaster.h:37
std::string m_name
Definition: EcSlave.h:133