forward_open_request.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H
00027 #define ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H
00028 
00029 #include <string>
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include "odva_ethernetip/eip_types.h"
00033 #include "odva_ethernetip/serialization/serializable.h"
00034 #include "odva_ethernetip/serialization/reader.h"
00035 #include "odva_ethernetip/serialization/writer.h"
00036 #include "odva_ethernetip/path.h"
00037 
00038 using boost::shared_ptr;
00039 
00040 namespace eip {
00041 
00042 using serialization::Serializable;
00043 using serialization::Reader;
00044 using serialization::Writer;
00045 
00046 typedef enum
00047 {
00048   CONN_PRIORITY_LOW       = 0,
00049   CONN_PRIORITY_HIGH      = 1,
00050   CONN_PRIORITY_SCHEDULED = 2,
00051   CONN_PRIORITY_URGENT    = 3,
00052 } CONN_PRIORITY_T;
00053 
00054 typedef enum
00055 {
00056   CONN_TYPE_NULL      = 0,
00057   CONN_TYPE_MULTICAST = 1,
00058   CONN_TYPE_P2P       = 2,
00059   CONN_TYPE_RESERVED  = 3,
00060 } CONN_TYPE_T;
00061 
00066 class ForwardOpenRequest : public Serializable
00067 {
00068 public:
00069 
00070   EIP_BYTE timeout_tick_size;
00071   EIP_USINT timeout_ticks;
00072   EIP_UDINT o_to_t_connection_id;
00073   EIP_UDINT t_to_o_connection_id;
00074   EIP_UINT connection_sn;
00075   EIP_UINT originator_vendor_id;
00076   EIP_UDINT originator_sn;
00077   EIP_USINT timeout_multiplyer;
00078   EIP_UDINT o_to_t_rpi;
00079   EIP_DWORD o_to_t_conn_params;
00080   EIP_UDINT t_to_o_rpi;
00081   EIP_DWORD t_to_o_conn_params;
00082   EIP_BYTE conn_type;
00083 
00092   static EIP_DWORD calcConnectionParams(EIP_UINT size, bool variable, EIP_BYTE priority,
00093     EIP_BYTE type, bool shared)
00094   {
00095     return (size & 0x7FFF) | (variable ? 0x2000000 : 0) | (priority & 0x03) << 26
00096       | (type & 0x03) << 29 | (shared ? 0x80000000 : 0);
00097   }
00098 
00102   EIP_DWORD setOriginToTargetParams(EIP_UINT size, bool variable, EIP_BYTE priority,
00103     EIP_BYTE type, bool shared)
00104   {
00105     o_to_t_conn_params = calcConnectionParams(size, variable, priority, type, shared);
00106     return 0;
00107   }
00108 
00112   EIP_DWORD setTargetToOriginParams(EIP_UINT size, bool variable, EIP_BYTE priority,
00113     EIP_BYTE type, bool shared)
00114   {
00115     t_to_o_conn_params = calcConnectionParams(size, variable, priority, type, shared);
00116     return 0;
00117   }
00118 
00123   Path& getPath()
00124   {
00125     return path_;
00126   }
00127 
00132   virtual size_t getLength() const
00133   {
00134     return sizeof(timeout_tick_size)
00135           + sizeof(timeout_ticks)
00136           + sizeof(o_to_t_connection_id)
00137           + sizeof(t_to_o_connection_id)
00138           + sizeof(connection_sn)
00139           + sizeof(originator_vendor_id)
00140           + sizeof(originator_sn)
00141           + sizeof(timeout_multiplyer)
00142           + sizeof(o_to_t_rpi)
00143           + sizeof(o_to_t_conn_params)
00144           + sizeof(t_to_o_rpi)
00145           + sizeof(t_to_o_conn_params)
00146           + sizeof(conn_type)
00147           + 3 // reserved bytes
00148           + path_.getLength();
00149   }
00150 
00157   virtual Writer& serialize(Writer& writer) const
00158   {
00159     EIP_BYTE reserved = 0;
00160     writer.write(timeout_tick_size);
00161     writer.write(timeout_ticks);
00162     writer.write(o_to_t_connection_id);
00163     writer.write(t_to_o_connection_id);
00164     writer.write(connection_sn);
00165     writer.write(originator_vendor_id);
00166     writer.write(originator_sn);
00167     writer.write(timeout_multiplyer);
00168     writer.write(reserved);
00169     writer.write(reserved);
00170     writer.write(reserved);
00171     writer.write(o_to_t_rpi);
00172     writer.write(o_to_t_conn_params);
00173     writer.write(t_to_o_rpi);
00174     writer.write(t_to_o_conn_params);
00175     writer.write(conn_type);
00176     path_.serialize(writer);
00177     return writer;
00178   }
00179 
00183   virtual Reader& deserialize(Reader& reader, size_t length)
00184   {
00185     throw std::logic_error("Not implemented");
00186   }
00187 
00191   virtual Reader& deserialize(Reader& reader)
00192   {
00193     throw std::logic_error("Not implemented");
00194   }
00195 
00196 private:
00197   Path path_;
00198 };
00199 
00200 } // namespace eip
00201 
00202 #endif  // ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23