connection.cpp
Go to the documentation of this file.
1 
27 
28 #include <boost/make_shared.hpp>
29 #include <iostream>
30 
31 using std::cout;
32 using std::endl;
33 using boost::shared_ptr;
34 using boost::make_shared;
35 
36 namespace eip {
37 
39 {
40  o_to_t_rpi = o_to_t.rpi;
41  t_to_o_rpi = t_to_o.rpi;
45  timeout_ticks = 80;
47  o_to_t_api = 0;
48  t_to_o_api = 0;
50 }
51 
53 {
54  path_.reset();
55  path_.addLogicalClass(0x04);
59 }
60 
61 shared_ptr<ForwardOpenRequest> Connection::createForwardOpenRequest()
62 {
63  shared_ptr<ForwardOpenRequest> req = make_shared<ForwardOpenRequest> ();
64 
65  req->originator_vendor_id = originator_vendor_id;
66  req->originator_sn = originator_sn;
67  req->connection_sn = connection_sn;
68 
69  req->o_to_t_connection_id = o_to_t_connection_id;
70  req->t_to_o_connection_id = t_to_o_connection_id;
71 
72  req->timeout_tick_size = timeout_tick_size;
73  req->timeout_ticks = timeout_ticks;
74  req->timeout_multiplyer = timeout_multiplyer;
75 
76  req->o_to_t_rpi = o_to_t_rpi;
77  req->t_to_o_rpi = t_to_o_rpi;
78  req->conn_type = 1;
79 
80  // TODO: need connection size info here
81  req->setOriginToTargetParams(o_to_t_buffer_size, false, CONN_PRIORITY_SCHEDULED, CONN_TYPE_P2P, false);
82  req->setTargetToOriginParams(t_to_o_buffer_size, true, CONN_PRIORITY_SCHEDULED, CONN_TYPE_P2P, false);
83 
84  req->getPath() = path_;
85  return req;
86 }
87 
88 shared_ptr<ForwardCloseRequest> Connection::createForwardCloseRequest()
89 {
90  shared_ptr<ForwardCloseRequest> req = make_shared<ForwardCloseRequest> ();
91 
92  req->originator_vendor_id = originator_vendor_id;
93  req->originator_sn = originator_sn;
94  req->connection_sn = connection_sn;
95 
96  req->timeout_tick_size = timeout_tick_size;
97  req->timeout_ticks = timeout_ticks;
98 
99  // path is actually to the connection manager, not the path of the assemblies
100  // don't really understand why, but the example from Omron does this
101  req->getPath() = Path(0x02, 0x01);
102  return req;
103 }
104 
106 {
107  if (result.connection_sn != connection_sn
109  || result.originator_sn != originator_sn)
110  {
111  return false;
112  }
114  {
115  cout << "Replacing our o_to_t connection ID (" << o_to_t_connection_id
116  << ") with connection ID provided by target ("
117  << result.o_to_t_connection_id << ")" << endl;
119  }
121  {
122  cout << "Replacing our t_to_o connection ID (" << t_to_o_connection_id
123  << ") with connection ID provided by target ("
124  << result.t_to_o_connection_id << ")" << endl;
126  }
127  o_to_t_api = result.o_to_t_api;
128  t_to_o_api = result.t_to_o_api;
129  return true;
130 }
131 
133 {
134  // printf("Comparing Forward Close Result: Expected vs Actual\n");
135  // printf("Vendor ID: 0x%08X vs 0x%08X\n", originator_vendor_id, result.originator_vendor_id);
136  // printf("Origin SN: 0x%08X vs 0x%08X\n", originator_sn, result.originator_sn);
137  printf("Connection SN: 0x%08X vs 0x%08X\n", connection_sn, result.connection_sn);
138  return (result.connection_sn == connection_sn
140  && result.originator_sn == originator_sn);
141 }
142 
143 } // namespace eip
uint8_t EIP_USINT
Definition: eip_types.h:36
shared_ptr< ForwardCloseRequest > createForwardCloseRequest()
Definition: connection.cpp:88
EIP_USINT assembly_id
Assembly ID for this endpoint of the connection.
Definition: eip_types.h:100
void addLogicalClass(EIP_USINT class_id)
Definition: path.cpp:59
EIP_USINT timeout_multiplyer
Definition: connection.h:59
EIP_UINT t_to_o_buffer_size
Definition: connection.h:67
EIP_USINT timeout_ticks
Definition: connection.h:58
void addLogicalConnectionPoint(EIP_USINT connection_id)
Definition: path.cpp:74
shared_ptr< ForwardOpenRequest > createForwardOpenRequest()
Definition: connection.cpp:61
EIP_UDINT t_to_o_connection_id
Definition: connection.h:55
bool verifyForwardOpenResult(const ForwardOpenSuccess &result)
Definition: connection.cpp:105
EIP_UDINT o_to_t_rpi
Definition: connection.h:61
EIP_UDINT originator_sn
Definition: connection.h:51
EIP_UINT o_to_t_buffer_size
Definition: connection.h:66
EIP_UDINT o_to_t_connection_id
Definition: connection.h:54
EIP_UINT buffer_size
Buffer size to be used for routing.
Definition: eip_types.h:102
bool verifyForwardCloseResult(const ForwardCloseSuccess &result)
Definition: connection.cpp:132
Definition: path.h:50
Definition: connection.h:41
void setConnectionPoints(EIP_USINT origin, EIP_USINT target)
Definition: connection.cpp:52
void addLogicalInstance(EIP_USINT instance_id)
Definition: path.cpp:64
EIP_UDINT o_to_t_api
Definition: connection.h:63
EIP_UDINT rpi
Request packet interval.
Definition: eip_types.h:104
EIP_UDINT t_to_o_rpi
Definition: connection.h:62
EIP_UDINT t_to_o_api
Definition: connection.h:64
EIP_BYTE timeout_tick_size
Definition: connection.h:57
void reset()
Definition: path.h:120
EIP_UINT originator_vendor_id
Definition: connection.h:50
EIP_UINT connection_sn
Definition: connection.h:52
Connection(const EIP_CONNECTION_INFO_T &o_to_t, const EIP_CONNECTION_INFO_T &t_to_o)
Definition: connection.cpp:38


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16