forward_open_success.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
00027 #define ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
00028 
00029 #include <string>
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/make_shared.hpp>
00032 
00033 #include "odva_ethernetip/eip_types.h"
00034 #include "odva_ethernetip/serialization/serializable.h"
00035 #include "odva_ethernetip/serialization/serializable_buffer.h"
00036 #include "odva_ethernetip/serialization/reader.h"
00037 #include "odva_ethernetip/serialization/writer.h"
00038 
00039 using boost::shared_ptr;
00040 using boost::make_shared;
00041 
00042 namespace eip {
00043 
00044 using serialization::Serializable;
00045 using serialization::SerializableBuffer;
00046 using serialization::Reader;
00047 using serialization::Writer;
00048 
00053 class ForwardOpenSuccess : public Serializable
00054 {
00055 public:
00056 
00057   EIP_UDINT o_to_t_connection_id;
00058   EIP_UDINT t_to_o_connection_id;
00059   EIP_UINT connection_sn;
00060   EIP_UINT originator_vendor_id;
00061   EIP_UDINT originator_sn;
00062   EIP_UDINT o_to_t_api;
00063   EIP_UDINT t_to_o_api;
00064 
00069   shared_ptr<Serializable> getResponseData() const
00070   {
00071     return response_data_;
00072   }
00073 
00078   virtual size_t getLength() const
00079   {
00080     size_t result = sizeof(o_to_t_connection_id)
00081       + sizeof(t_to_o_connection_id)
00082       + sizeof(connection_sn)
00083       + sizeof(originator_vendor_id)
00084       + sizeof(originator_sn)
00085       + sizeof(o_to_t_api)
00086       + sizeof(t_to_o_api)
00087       + 2; // reserved byte and data length
00088     if (response_data_)
00089     {
00090       result += response_data_->getLength();
00091     }
00092     return result;
00093   }
00094 
00101   virtual Writer& serialize(Writer& writer) const
00102   {
00103     throw std::logic_error("Not implemented");
00104   }
00105 
00109   virtual Reader& deserialize(Reader& reader, size_t length)
00110   {
00111     return deserialize(reader);
00112   }
00113 
00117   virtual Reader& deserialize(Reader& reader)
00118   {
00119     EIP_USINT data_length;
00120     reader.read(o_to_t_connection_id);
00121     reader.read(t_to_o_connection_id);
00122     reader.read(connection_sn);
00123     reader.read(originator_vendor_id);
00124     reader.read(originator_sn);
00125     reader.read(o_to_t_api);
00126     reader.read(t_to_o_api);
00127     reader.read(data_length);
00128     reader.skip(1);
00129     if (data_length > 0)
00130     {
00131       shared_ptr<SerializableBuffer> sb = make_shared<SerializableBuffer> ();
00132       sb->deserialize(reader, data_length*2);
00133       response_data_ = sb;
00134     }
00135     else
00136     {
00137       response_data_ = shared_ptr<Serializable>();
00138     }
00139     return reader;
00140   }
00141 
00142 private:
00143   shared_ptr<Serializable> response_data_;
00144 
00145 };
00146 
00147 } // namespace eip
00148 
00149 #endif  // ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H


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