EtherCAT Client Library Code 0.0.1
EtherCAT Client library that uses different communication protocols with EtherCAT Master server.
Loading...
Searching...
No Matches
ec_pipe_pdo.h
1#ifndef __EC_PIPE_PDO__
2#define __EC_PIPE_PDO__
3
4#include <memory>
5
6#include <pb_utils.h>
7
8class EcPipePdo;
9using SH_IDP = std::shared_ptr<IDDP_pipe>;
10
11
13//
15enum class EcPipePdoErrorNum
16{
17 NO_ERROR = 0, //
18 CONNECT_FAIL,
19 BIND_FAIL,
20 INVALID_TYPE,
21 RUNTIME_ERROR,
22};
23class EcPipePdoError : public std::runtime_error {
24using errno_t = std::underlying_type<EcPipePdoErrorNum>::type;
25public:
26 EcPipePdoError (EcPipePdoErrorNum err_no, const std::string & what_arg) :
27 std::runtime_error(make_what(what_arg,static_cast<errno_t>(err_no))),
28 error_num(static_cast<errno_t>(err_no))
29 {}
30
31 int get_error_num(void) { return error_num; }
32
33private:
34 std::string make_what(std::string what_arg, int err_no) {
35 std::ostringstream msg;
36 msg << "EcPipePdoError " << err_no << " : " << what_arg;
37 return msg.str();
38 }
39 int error_num;
40};
41
43//
45class EcPipePdo {
46
47protected:
48
49 bool initialized;
50 std::string name;
51 int32_t id;
52 uint32_t type;
53 std::string rd_pp_name, wr_pp_name;
54 IDDP_pipe rd_iddp, wr_iddp;
55 iit::advr::Ec_slave_pdo pb_rx_pdos, pb_tx_pdos;
56 uint8_t pb_buf_rd[MAX_PB_SIZE];
57 uint8_t pb_buf_wr[MAX_PB_SIZE];
58
59 virtual void get_from_pb(void) = 0;
60 virtual void set_to_pb(void) = 0;
61
62public:
63
64 EcPipePdo( int32_t id, uint32_t type, const std::string);
65
66 EcPipePdo( int32_t id, const std::string esc_name, const std::string);
67
68 EcPipePdo( int32_t id, uint32_t type,
69 std::string rd_pp_name,
70 std::string wr_pp_name );
71 /*
72 EcPipePdo( const EcPipePdo& rhs ):
73 name(rhs.name),id(rhs.id),
74 rd_pp_name(rhs.rd_pp_name),
75 wr_pp_name(rhs.wr_pp_name) {};
76 */
77
78 virtual ~EcPipePdo () {
79 }
80
81 virtual void init(void);
82
83 iit::advr::Ec_slave_pdo* pb_rx() { return &pb_rx_pdos; }
84 iit::advr::Ec_slave_pdo* pb_tx() { return &pb_tx_pdos; }
85
86 std::string get_name() const { return name; }
87 uint32_t get_type() const { return type; }
88
89 SH_IDP get_rd_iddp() { return std::make_shared<IDDP_pipe>(rd_iddp); }
90 SH_IDP get_wr_iddp() { return std::make_shared<IDDP_pipe>(wr_iddp); }
91
92 int read(void);
93 int write(void);
94 int write_dummy(void);
95 int write_connect(void);
96 int write_quit(void);
97};
98#endif
Definition ec_pipe_pdo.h:45