2019-04-20 16:50:22 +00:00
|
|
|
/*!
|
|
|
|
* \file serdes_monitor_pvt.h
|
|
|
|
* \brief Serialization / Deserialization of Monitor_Pvt objects using
|
|
|
|
* Protocol Buffers
|
|
|
|
* \author Carles Fernandez-Prades, 2019. cfernandez(at)cttc.es
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2019-04-20 16:50:22 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2019-04-20 16:50:22 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-04-20 16:50:22 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2019-04-20 16:50:22 +00:00
|
|
|
*/
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_SERDES_MONITOR_PVT_H
|
|
|
|
#define GNSS_SDR_SERDES_MONITOR_PVT_H
|
2019-04-20 16:50:22 +00:00
|
|
|
|
|
|
|
#include "monitor_pvt.h"
|
|
|
|
#include "monitor_pvt.pb.h" // file created by Protocol Buffers at compile time
|
2019-07-11 16:39:28 +00:00
|
|
|
#include <memory>
|
2019-08-17 11:56:54 +00:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2019-04-20 16:50:22 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This class implements serialization and deserialization of
|
|
|
|
* Monitor_Pvt objects using Protocol Buffers.
|
|
|
|
*/
|
|
|
|
class Serdes_Monitor_Pvt
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Serdes_Monitor_Pvt()
|
|
|
|
{
|
|
|
|
// Verify that the version of the library that we linked against is
|
|
|
|
// compatible with the version of the headers we compiled against.
|
|
|
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
|
|
}
|
2019-07-03 21:47:42 +00:00
|
|
|
|
2019-04-20 16:50:22 +00:00
|
|
|
~Serdes_Monitor_Pvt()
|
|
|
|
{
|
|
|
|
// google::protobuf::ShutdownProtobufLibrary();
|
|
|
|
}
|
|
|
|
|
2020-05-16 12:39:34 +00:00
|
|
|
inline Serdes_Monitor_Pvt(const Serdes_Monitor_Pvt& other) noexcept //!< Copy constructor
|
2019-07-05 14:13:35 +00:00
|
|
|
{
|
|
|
|
this->monitor_ = other.monitor_;
|
|
|
|
}
|
|
|
|
|
2020-05-16 12:39:34 +00:00
|
|
|
inline Serdes_Monitor_Pvt& operator=(const Serdes_Monitor_Pvt& rhs) noexcept //!< Copy assignment operator
|
2019-07-05 14:13:35 +00:00
|
|
|
{
|
2019-07-07 19:44:58 +00:00
|
|
|
this->monitor_ = rhs.monitor_;
|
2019-07-05 14:13:35 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-05-16 12:39:34 +00:00
|
|
|
inline Serdes_Monitor_Pvt(Serdes_Monitor_Pvt&& other) noexcept //!< Move constructor
|
2019-07-05 14:13:35 +00:00
|
|
|
{
|
|
|
|
this->monitor_ = std::move(other.monitor_);
|
|
|
|
}
|
|
|
|
|
2020-05-16 12:39:34 +00:00
|
|
|
inline Serdes_Monitor_Pvt& operator=(Serdes_Monitor_Pvt&& other) noexcept //!< Move assignment operator
|
2019-07-05 14:13:35 +00:00
|
|
|
{
|
|
|
|
if (this != &other)
|
|
|
|
{
|
|
|
|
this->monitor_ = std::move(other.monitor_);
|
|
|
|
}
|
|
|
|
return *this;
|
2019-07-07 19:44:58 +00:00
|
|
|
}
|
2019-07-05 14:13:35 +00:00
|
|
|
|
2020-07-26 21:56:36 +00:00
|
|
|
inline std::string createProtobuffer(const Monitor_Pvt* const monitor) //!< Serialization into a string
|
2019-04-20 16:50:22 +00:00
|
|
|
{
|
|
|
|
monitor_.Clear();
|
|
|
|
|
|
|
|
std::string data;
|
|
|
|
|
2019-07-11 16:39:28 +00:00
|
|
|
monitor_.set_tow_at_current_symbol_ms(monitor->TOW_at_current_symbol_ms);
|
|
|
|
monitor_.set_week(monitor->week);
|
|
|
|
monitor_.set_rx_time(monitor->RX_time);
|
|
|
|
monitor_.set_user_clk_offset(monitor->user_clk_offset);
|
|
|
|
monitor_.set_pos_x(monitor->pos_x);
|
|
|
|
monitor_.set_pos_y(monitor->pos_y);
|
|
|
|
monitor_.set_pos_z(monitor->pos_z);
|
|
|
|
monitor_.set_vel_x(monitor->vel_x);
|
|
|
|
monitor_.set_vel_y(monitor->vel_y);
|
|
|
|
monitor_.set_vel_z(monitor->vel_z);
|
|
|
|
monitor_.set_cov_xx(monitor->cov_xx);
|
|
|
|
monitor_.set_cov_yy(monitor->cov_yy);
|
|
|
|
monitor_.set_cov_zz(monitor->cov_zz);
|
|
|
|
monitor_.set_cov_xy(monitor->cov_xy);
|
|
|
|
monitor_.set_cov_yz(monitor->cov_yz);
|
|
|
|
monitor_.set_cov_zx(monitor->cov_zx);
|
|
|
|
monitor_.set_latitude(monitor->latitude);
|
|
|
|
monitor_.set_longitude(monitor->longitude);
|
|
|
|
monitor_.set_height(monitor->height);
|
|
|
|
monitor_.set_valid_sats(monitor->valid_sats);
|
|
|
|
monitor_.set_solution_status(monitor->solution_status);
|
|
|
|
monitor_.set_solution_type(monitor->solution_type);
|
|
|
|
monitor_.set_ar_ratio_factor(monitor->AR_ratio_factor);
|
|
|
|
monitor_.set_ar_ratio_threshold(monitor->AR_ratio_threshold);
|
|
|
|
monitor_.set_gdop(monitor->gdop);
|
|
|
|
monitor_.set_pdop(monitor->pdop);
|
|
|
|
monitor_.set_hdop(monitor->hdop);
|
|
|
|
monitor_.set_vdop(monitor->vdop);
|
2019-11-05 09:45:11 +00:00
|
|
|
monitor_.set_user_clk_drift_ppm(monitor->user_clk_drift_ppm);
|
2019-04-20 16:50:22 +00:00
|
|
|
|
|
|
|
monitor_.SerializeToString(&data);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2020-07-26 21:56:36 +00:00
|
|
|
inline Monitor_Pvt readProtobuffer(const gnss_sdr::MonitorPvt& mon) const //!< Deserialization
|
2019-04-20 16:50:22 +00:00
|
|
|
{
|
|
|
|
Monitor_Pvt monitor;
|
|
|
|
|
|
|
|
monitor.TOW_at_current_symbol_ms = mon.tow_at_current_symbol_ms();
|
|
|
|
monitor.week = mon.week();
|
|
|
|
monitor.RX_time = mon.rx_time();
|
|
|
|
monitor.user_clk_offset = mon.user_clk_offset();
|
|
|
|
monitor.pos_x = mon.pos_x();
|
|
|
|
monitor.pos_y = mon.pos_y();
|
|
|
|
monitor.pos_z = mon.pos_z();
|
|
|
|
monitor.vel_x = mon.vel_x();
|
|
|
|
monitor.vel_y = mon.vel_y();
|
|
|
|
monitor.vel_z = mon.vel_z();
|
|
|
|
monitor.cov_xx = mon.cov_xx();
|
|
|
|
monitor.cov_yy = mon.cov_yy();
|
|
|
|
monitor.cov_zz = mon.cov_zz();
|
|
|
|
monitor.cov_xy = mon.cov_xy();
|
|
|
|
monitor.cov_yz = mon.cov_yz();
|
|
|
|
monitor.cov_zx = mon.cov_zx();
|
|
|
|
monitor.latitude = mon.latitude();
|
|
|
|
monitor.longitude = mon.longitude();
|
|
|
|
monitor.height = mon.height();
|
|
|
|
monitor.valid_sats = static_cast<uint8_t>(mon.valid_sats());
|
|
|
|
monitor.solution_status = static_cast<uint8_t>(mon.solution_status());
|
|
|
|
monitor.solution_type = static_cast<uint8_t>(mon.solution_type());
|
|
|
|
monitor.AR_ratio_factor = mon.ar_ratio_factor();
|
|
|
|
monitor.AR_ratio_threshold = mon.ar_ratio_threshold();
|
|
|
|
monitor.gdop = mon.gdop();
|
|
|
|
monitor.pdop = mon.pdop();
|
|
|
|
monitor.hdop = mon.hdop();
|
|
|
|
monitor.vdop = mon.vdop();
|
2019-11-05 09:45:11 +00:00
|
|
|
monitor.user_clk_drift_ppm = mon.user_clk_drift_ppm();
|
2019-04-20 16:50:22 +00:00
|
|
|
|
|
|
|
return monitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-07-07 17:56:23 +00:00
|
|
|
gnss_sdr::MonitorPvt monitor_{};
|
2019-04-20 16:50:22 +00:00
|
|
|
};
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_SERDES_MONITOR_PVT_H
|