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


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:38:55