range_and_reflectance_measurement.h
Go to the documentation of this file.
00001 
00026 #ifndef OMRON_OS32C_DRIVER_RANGE_AND_REFLECTANCE_MEASUREMENT_H
00027 #define OMRON_OS32C_DRIVER_RANGE_AND_REFLECTANCE_MEASUREMENT_H
00028 
00029 #include <string>
00030 #include <vector>
00031 
00032 #include "odva_ethernetip/eip_types.h"
00033 #include "odva_ethernetip/serialization/reader.h"
00034 #include "odva_ethernetip/serialization/writer.h"
00035 #include "odva_ethernetip/serialization/serializable.h"
00036 #include "omron_os32c_driver/measurement_report_header.h"
00037 
00038 using std::vector;
00039 using eip::serialization::Serializable;
00040 using eip::serialization::Reader;
00041 using eip::serialization::Writer;
00042 
00043 namespace omron_os32c_driver {
00044 
00050 class RangeAndReflectanceMeasurement : public Serializable
00051 {
00052 public:
00053   MeasurementReportHeader header;
00054   vector<EIP_UINT> range_data;
00055   vector<EIP_UINT> reflectance_data;
00056 
00060   virtual size_t getLength() const
00061   {
00062     return header.getLength() + range_data.size() * sizeof(EIP_UINT)
00063       + reflectance_data.size() * sizeof(EIP_UINT);
00064   }
00065 
00072   virtual Writer& serialize(Writer& writer) const
00073   {
00074     header.serialize(writer);
00075     writer.writeBytes(&range_data[0], range_data.size() * sizeof(EIP_UINT));
00076     writer.writeBytes(&reflectance_data[0], reflectance_data.size() * sizeof(EIP_UINT));
00077     return writer;
00078   }
00079 
00083   virtual Reader& deserialize(Reader& reader, size_t length)
00084   {
00085     deserialize(reader);
00086     return reader;
00087   }
00088 
00095   virtual Reader& deserialize(Reader& reader)
00096   {
00097     header.deserialize(reader);
00098     range_data.resize(header.num_beams);
00099     reflectance_data.resize(header.num_beams);
00100     reader.readBytes(&range_data[0], range_data.size() * sizeof(EIP_UINT));
00101     reader.readBytes(&reflectance_data[0], reflectance_data.size() * sizeof(EIP_UINT));
00102     return reader;
00103   }
00104 };
00105 
00106 } // namespace omron_os32c_driver
00107 
00108 #endif  // OS32C_RANGE_AND_REFLECTANCE_MEASUREMENT_H


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Thu Jun 6 2019 19:00:54