You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3134 lines
109 KiB
C++
3134 lines
109 KiB
C++
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
/*!
|
|
* @file WeighingDDSTypePubSubTypes.cpp
|
|
* This header file contains the implementation of the serialization functions.
|
|
*
|
|
* This file was generated by the tool fastddsgen.
|
|
*/
|
|
|
|
#include "WeighingDDSTypePubSubTypes.hpp"
|
|
|
|
#include <fastdds/dds/log/Log.hpp>
|
|
#include <fastdds/rtps/common/CdrSerialization.hpp>
|
|
|
|
#include "WeighingDDSTypeCdrAux.hpp"
|
|
#include "WeighingDDSTypeTypeObjectSupport.hpp"
|
|
|
|
using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t;
|
|
using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t;
|
|
using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t;
|
|
|
|
namespace WeighingSystem {
|
|
ScaleInfoPubSubType::ScaleInfoPubSubType()
|
|
{
|
|
set_name("WeighingSystem::ScaleInfo");
|
|
uint32_t type_size = WeighingSystem_ScaleInfo_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_ScaleInfo_max_key_cdr_typesize > 16 ? WeighingSystem_ScaleInfo_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
ScaleInfoPubSubType::~ScaleInfoPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool ScaleInfoPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const ScaleInfo* p_type = static_cast<const ScaleInfo*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool ScaleInfoPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
ScaleInfo* p_type = static_cast<ScaleInfo*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t ScaleInfoPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const ScaleInfo*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* ScaleInfoPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new ScaleInfo());
|
|
}
|
|
|
|
void ScaleInfoPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<ScaleInfo*>(data));
|
|
}
|
|
|
|
bool ScaleInfoPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ScaleInfo data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ScaleInfoPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const ScaleInfo* p_type = static_cast<const ScaleInfo*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_ScaleInfo_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_ScaleInfo_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void ScaleInfoPubSubType::register_type_object_representation()
|
|
{
|
|
register_ScaleInfo_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
ScaleCommandPubSubType::ScaleCommandPubSubType()
|
|
{
|
|
set_name("WeighingSystem::ScaleCommand");
|
|
uint32_t type_size = WeighingSystem_ScaleCommand_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_ScaleCommand_max_key_cdr_typesize > 16 ? WeighingSystem_ScaleCommand_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
ScaleCommandPubSubType::~ScaleCommandPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool ScaleCommandPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const ScaleCommand* p_type = static_cast<const ScaleCommand*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool ScaleCommandPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
ScaleCommand* p_type = static_cast<ScaleCommand*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t ScaleCommandPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const ScaleCommand*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* ScaleCommandPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new ScaleCommand());
|
|
}
|
|
|
|
void ScaleCommandPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<ScaleCommand*>(data));
|
|
}
|
|
|
|
bool ScaleCommandPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ScaleCommand data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ScaleCommandPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const ScaleCommand* p_type = static_cast<const ScaleCommand*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_ScaleCommand_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_ScaleCommand_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void ScaleCommandPubSubType::register_type_object_representation()
|
|
{
|
|
register_ScaleCommand_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
WeightInfoOkPubSubType::WeightInfoOkPubSubType()
|
|
{
|
|
set_name("WeighingSystem::WeightInfoOk");
|
|
uint32_t type_size = WeighingSystem_WeightInfoOk_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_WeightInfoOk_max_key_cdr_typesize > 16 ? WeighingSystem_WeightInfoOk_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
WeightInfoOkPubSubType::~WeightInfoOkPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool WeightInfoOkPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const WeightInfoOk* p_type = static_cast<const WeightInfoOk*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool WeightInfoOkPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
WeightInfoOk* p_type = static_cast<WeightInfoOk*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t WeightInfoOkPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const WeightInfoOk*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* WeightInfoOkPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new WeightInfoOk());
|
|
}
|
|
|
|
void WeightInfoOkPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<WeightInfoOk*>(data));
|
|
}
|
|
|
|
bool WeightInfoOkPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WeightInfoOk data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool WeightInfoOkPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const WeightInfoOk* p_type = static_cast<const WeightInfoOk*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_WeightInfoOk_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_WeightInfoOk_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void WeightInfoOkPubSubType::register_type_object_representation()
|
|
{
|
|
register_WeightInfoOk_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
WeightInfoErrorPubSubType::WeightInfoErrorPubSubType()
|
|
{
|
|
set_name("WeighingSystem::WeightInfoError");
|
|
uint32_t type_size = WeighingSystem_WeightInfoError_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_WeightInfoError_max_key_cdr_typesize > 16 ? WeighingSystem_WeightInfoError_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
WeightInfoErrorPubSubType::~WeightInfoErrorPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool WeightInfoErrorPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const WeightInfoError* p_type = static_cast<const WeightInfoError*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool WeightInfoErrorPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
WeightInfoError* p_type = static_cast<WeightInfoError*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t WeightInfoErrorPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const WeightInfoError*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* WeightInfoErrorPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new WeightInfoError());
|
|
}
|
|
|
|
void WeightInfoErrorPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<WeightInfoError*>(data));
|
|
}
|
|
|
|
bool WeightInfoErrorPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WeightInfoError data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool WeightInfoErrorPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const WeightInfoError* p_type = static_cast<const WeightInfoError*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_WeightInfoError_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_WeightInfoError_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void WeightInfoErrorPubSubType::register_type_object_representation()
|
|
{
|
|
register_WeightInfoError_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
BarCommandUpdatePubSubType::BarCommandUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::BarCommandUpdate");
|
|
uint32_t type_size = WeighingSystem_BarCommandUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_BarCommandUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_BarCommandUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
BarCommandUpdatePubSubType::~BarCommandUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool BarCommandUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const BarCommandUpdate* p_type = static_cast<const BarCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool BarCommandUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
BarCommandUpdate* p_type = static_cast<BarCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t BarCommandUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const BarCommandUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* BarCommandUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new BarCommandUpdate());
|
|
}
|
|
|
|
void BarCommandUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<BarCommandUpdate*>(data));
|
|
}
|
|
|
|
bool BarCommandUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
BarCommandUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool BarCommandUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const BarCommandUpdate* p_type = static_cast<const BarCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_BarCommandUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_BarCommandUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void BarCommandUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_BarCommandUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
LightsCommandUpdatePubSubType::LightsCommandUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::LightsCommandUpdate");
|
|
uint32_t type_size = WeighingSystem_LightsCommandUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
LightsCommandUpdatePubSubType::~LightsCommandUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool LightsCommandUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const LightsCommandUpdate* p_type = static_cast<const LightsCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool LightsCommandUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
LightsCommandUpdate* p_type = static_cast<LightsCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t LightsCommandUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const LightsCommandUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* LightsCommandUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new LightsCommandUpdate());
|
|
}
|
|
|
|
void LightsCommandUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<LightsCommandUpdate*>(data));
|
|
}
|
|
|
|
bool LightsCommandUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
LightsCommandUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool LightsCommandUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const LightsCommandUpdate* p_type = static_cast<const LightsCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void LightsCommandUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_LightsCommandUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
InfraredCommandUpdatePubSubType::InfraredCommandUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::InfraredCommandUpdate");
|
|
uint32_t type_size = WeighingSystem_InfraredCommandUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
InfraredCommandUpdatePubSubType::~InfraredCommandUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool InfraredCommandUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const InfraredCommandUpdate* p_type = static_cast<const InfraredCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool InfraredCommandUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
InfraredCommandUpdate* p_type = static_cast<InfraredCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t InfraredCommandUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const InfraredCommandUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* InfraredCommandUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new InfraredCommandUpdate());
|
|
}
|
|
|
|
void InfraredCommandUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<InfraredCommandUpdate*>(data));
|
|
}
|
|
|
|
bool InfraredCommandUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
InfraredCommandUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool InfraredCommandUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const InfraredCommandUpdate* p_type = static_cast<const InfraredCommandUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void InfraredCommandUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_InfraredCommandUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
BarUpdatePubSubType::BarUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::BarUpdate");
|
|
uint32_t type_size = WeighingSystem_BarUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_BarUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_BarUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
BarUpdatePubSubType::~BarUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool BarUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const BarUpdate* p_type = static_cast<const BarUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool BarUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
BarUpdate* p_type = static_cast<BarUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t BarUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const BarUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* BarUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new BarUpdate());
|
|
}
|
|
|
|
void BarUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<BarUpdate*>(data));
|
|
}
|
|
|
|
bool BarUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
BarUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool BarUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const BarUpdate* p_type = static_cast<const BarUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_BarUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_BarUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void BarUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_BarUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
LightsUpdatePubSubType::LightsUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::LightsUpdate");
|
|
uint32_t type_size = WeighingSystem_LightsUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_LightsUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_LightsUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
LightsUpdatePubSubType::~LightsUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool LightsUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const LightsUpdate* p_type = static_cast<const LightsUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool LightsUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
LightsUpdate* p_type = static_cast<LightsUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t LightsUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const LightsUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* LightsUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new LightsUpdate());
|
|
}
|
|
|
|
void LightsUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<LightsUpdate*>(data));
|
|
}
|
|
|
|
bool LightsUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
LightsUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool LightsUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const LightsUpdate* p_type = static_cast<const LightsUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_LightsUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_LightsUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void LightsUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_LightsUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
InfraredUpdatePubSubType::InfraredUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::InfraredUpdate");
|
|
uint32_t type_size = WeighingSystem_InfraredUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_InfraredUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_InfraredUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
InfraredUpdatePubSubType::~InfraredUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool InfraredUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const InfraredUpdate* p_type = static_cast<const InfraredUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool InfraredUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
InfraredUpdate* p_type = static_cast<InfraredUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t InfraredUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const InfraredUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* InfraredUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new InfraredUpdate());
|
|
}
|
|
|
|
void InfraredUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<InfraredUpdate*>(data));
|
|
}
|
|
|
|
bool InfraredUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
InfraredUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool InfraredUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const InfraredUpdate* p_type = static_cast<const InfraredUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_InfraredUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_InfraredUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void InfraredUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_InfraredUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
LicenseSnapUpdatePubSubType::LicenseSnapUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::LicenseSnapUpdate");
|
|
uint32_t type_size = WeighingSystem_LicenseSnapUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
LicenseSnapUpdatePubSubType::~LicenseSnapUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool LicenseSnapUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const LicenseSnapUpdate* p_type = static_cast<const LicenseSnapUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool LicenseSnapUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
LicenseSnapUpdate* p_type = static_cast<LicenseSnapUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t LicenseSnapUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const LicenseSnapUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* LicenseSnapUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new LicenseSnapUpdate());
|
|
}
|
|
|
|
void LicenseSnapUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<LicenseSnapUpdate*>(data));
|
|
}
|
|
|
|
bool LicenseSnapUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
LicenseSnapUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool LicenseSnapUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const LicenseSnapUpdate* p_type = static_cast<const LicenseSnapUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void LicenseSnapUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_LicenseSnapUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
VoicePubSubType::VoicePubSubType()
|
|
{
|
|
set_name("WeighingSystem::Voice");
|
|
uint32_t type_size = WeighingSystem_Voice_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_Voice_max_key_cdr_typesize > 16 ? WeighingSystem_Voice_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
VoicePubSubType::~VoicePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool VoicePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const Voice* p_type = static_cast<const Voice*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool VoicePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
Voice* p_type = static_cast<Voice*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t VoicePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const Voice*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* VoicePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new Voice());
|
|
}
|
|
|
|
void VoicePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<Voice*>(data));
|
|
}
|
|
|
|
bool VoicePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Voice data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool VoicePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const Voice* p_type = static_cast<const Voice*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_Voice_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_Voice_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void VoicePubSubType::register_type_object_representation()
|
|
{
|
|
register_Voice_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
SummaryUpdatePubSubType::SummaryUpdatePubSubType()
|
|
{
|
|
set_name("WeighingSystem::SummaryUpdate");
|
|
uint32_t type_size = WeighingSystem_SummaryUpdate_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_SummaryUpdate_max_key_cdr_typesize > 16 ? WeighingSystem_SummaryUpdate_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
SummaryUpdatePubSubType::~SummaryUpdatePubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool SummaryUpdatePubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const SummaryUpdate* p_type = static_cast<const SummaryUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool SummaryUpdatePubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
SummaryUpdate* p_type = static_cast<SummaryUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t SummaryUpdatePubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const SummaryUpdate*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* SummaryUpdatePubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new SummaryUpdate());
|
|
}
|
|
|
|
void SummaryUpdatePubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<SummaryUpdate*>(data));
|
|
}
|
|
|
|
bool SummaryUpdatePubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
SummaryUpdate data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool SummaryUpdatePubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const SummaryUpdate* p_type = static_cast<const SummaryUpdate*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_SummaryUpdate_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_SummaryUpdate_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void SummaryUpdatePubSubType::register_type_object_representation()
|
|
{
|
|
register_SummaryUpdate_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
ReadCardReqPubSubType::ReadCardReqPubSubType()
|
|
{
|
|
set_name("WeighingSystem::ReadCardReq");
|
|
uint32_t type_size = WeighingSystem_ReadCardReq_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_ReadCardReq_max_key_cdr_typesize > 16 ? WeighingSystem_ReadCardReq_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
ReadCardReqPubSubType::~ReadCardReqPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool ReadCardReqPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const ReadCardReq* p_type = static_cast<const ReadCardReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool ReadCardReqPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
ReadCardReq* p_type = static_cast<ReadCardReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t ReadCardReqPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const ReadCardReq*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* ReadCardReqPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new ReadCardReq());
|
|
}
|
|
|
|
void ReadCardReqPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<ReadCardReq*>(data));
|
|
}
|
|
|
|
bool ReadCardReqPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ReadCardReq data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ReadCardReqPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const ReadCardReq* p_type = static_cast<const ReadCardReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_ReadCardReq_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_ReadCardReq_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void ReadCardReqPubSubType::register_type_object_representation()
|
|
{
|
|
register_ReadCardReq_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
ReadCardRspPubSubType::ReadCardRspPubSubType()
|
|
{
|
|
set_name("WeighingSystem::ReadCardRsp");
|
|
uint32_t type_size = WeighingSystem_ReadCardRsp_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_ReadCardRsp_max_key_cdr_typesize > 16 ? WeighingSystem_ReadCardRsp_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
ReadCardRspPubSubType::~ReadCardRspPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool ReadCardRspPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const ReadCardRsp* p_type = static_cast<const ReadCardRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool ReadCardRspPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
ReadCardRsp* p_type = static_cast<ReadCardRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t ReadCardRspPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const ReadCardRsp*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* ReadCardRspPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new ReadCardRsp());
|
|
}
|
|
|
|
void ReadCardRspPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<ReadCardRsp*>(data));
|
|
}
|
|
|
|
bool ReadCardRspPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ReadCardRsp data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ReadCardRspPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const ReadCardRsp* p_type = static_cast<const ReadCardRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_ReadCardRsp_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_ReadCardRsp_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void ReadCardRspPubSubType::register_type_object_representation()
|
|
{
|
|
register_ReadCardRsp_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
PrintReqPubSubType::PrintReqPubSubType()
|
|
{
|
|
set_name("WeighingSystem::PrintReq");
|
|
uint32_t type_size = WeighingSystem_PrintReq_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_PrintReq_max_key_cdr_typesize > 16 ? WeighingSystem_PrintReq_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
PrintReqPubSubType::~PrintReqPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool PrintReqPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const PrintReq* p_type = static_cast<const PrintReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool PrintReqPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
PrintReq* p_type = static_cast<PrintReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t PrintReqPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const PrintReq*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* PrintReqPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new PrintReq());
|
|
}
|
|
|
|
void PrintReqPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<PrintReq*>(data));
|
|
}
|
|
|
|
bool PrintReqPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
PrintReq data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool PrintReqPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const PrintReq* p_type = static_cast<const PrintReq*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_PrintReq_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_PrintReq_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void PrintReqPubSubType::register_type_object_representation()
|
|
{
|
|
register_PrintReq_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
PrintRspPubSubType::PrintRspPubSubType()
|
|
{
|
|
set_name("WeighingSystem::PrintRsp");
|
|
uint32_t type_size = WeighingSystem_PrintRsp_max_cdr_typesize;
|
|
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
|
|
max_serialized_type_size = type_size + 4; /*encapsulation*/
|
|
is_compute_key_provided = false;
|
|
uint32_t key_length = WeighingSystem_PrintRsp_max_key_cdr_typesize > 16 ? WeighingSystem_PrintRsp_max_key_cdr_typesize : 16;
|
|
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
|
|
memset(key_buffer_, 0, key_length);
|
|
}
|
|
|
|
PrintRspPubSubType::~PrintRspPubSubType()
|
|
{
|
|
if (key_buffer_ != nullptr)
|
|
{
|
|
free(key_buffer_);
|
|
}
|
|
}
|
|
|
|
bool PrintRspPubSubType::serialize(
|
|
const void* const data,
|
|
SerializedPayload_t& payload,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
const PrintRsp* p_type = static_cast<const PrintRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
ser.set_encoding_flag(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
|
|
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
|
|
|
|
try
|
|
{
|
|
// Serialize encapsulation
|
|
ser.serialize_encapsulation();
|
|
// Serialize the object.
|
|
ser << *p_type;
|
|
ser.set_dds_cdr_options({0,0});
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Get the serialized length
|
|
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
|
|
return true;
|
|
}
|
|
|
|
bool PrintRspPubSubType::deserialize(
|
|
SerializedPayload_t& payload,
|
|
void* data)
|
|
{
|
|
try
|
|
{
|
|
// Convert DATA to pointer of your type
|
|
PrintRsp* p_type = static_cast<PrintRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
|
|
|
|
// Object that deserializes the data.
|
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
|
|
|
|
// Deserialize encapsulation.
|
|
deser.read_encapsulation();
|
|
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
|
|
|
// Deserialize the object.
|
|
deser >> *p_type;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
uint32_t PrintRspPubSubType::calculate_serialized_size(
|
|
const void* const data,
|
|
DataRepresentationId_t data_representation)
|
|
{
|
|
try
|
|
{
|
|
eprosima::fastcdr::CdrSizeCalculator calculator(
|
|
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
|
|
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
size_t current_alignment {0};
|
|
return static_cast<uint32_t>(calculator.calculate_serialized_size(
|
|
*static_cast<const PrintRsp*>(data), current_alignment)) +
|
|
4u /*encapsulation*/;
|
|
}
|
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void* PrintRspPubSubType::create_data()
|
|
{
|
|
return reinterpret_cast<void*>(new PrintRsp());
|
|
}
|
|
|
|
void PrintRspPubSubType::delete_data(
|
|
void* data)
|
|
{
|
|
delete(reinterpret_cast<PrintRsp*>(data));
|
|
}
|
|
|
|
bool PrintRspPubSubType::compute_key(
|
|
SerializedPayload_t& payload,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
PrintRsp data;
|
|
if (deserialize(payload, static_cast<void*>(&data)))
|
|
{
|
|
return compute_key(static_cast<void*>(&data), handle, force_md5);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool PrintRspPubSubType::compute_key(
|
|
const void* const data,
|
|
InstanceHandle_t& handle,
|
|
bool force_md5)
|
|
{
|
|
if (!is_compute_key_provided)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const PrintRsp* p_type = static_cast<const PrintRsp*>(data);
|
|
|
|
// Object that manages the raw buffer.
|
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
|
|
WeighingSystem_PrintRsp_max_key_cdr_typesize);
|
|
|
|
// Object that serializes the data.
|
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
|
|
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
|
|
eprosima::fastcdr::serialize_key(ser, *p_type);
|
|
if (force_md5 || WeighingSystem_PrintRsp_max_key_cdr_typesize > 16)
|
|
{
|
|
md5_.init();
|
|
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
|
|
md5_.finalize();
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = md5_.digest[i];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (uint8_t i = 0; i < 16; ++i)
|
|
{
|
|
handle.value[i] = key_buffer_[i];
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void PrintRspPubSubType::register_type_object_representation()
|
|
{
|
|
register_PrintRsp_type_identifier(type_identifiers_);
|
|
}
|
|
|
|
} // namespace WeighingSystem
|
|
|
|
|
|
// Include auxiliary functions like for serializing/deserializing.
|
|
#include "WeighingDDSTypeCdrAux.ipp"
|