231 lines
4.4 KiB
C++
231 lines
4.4 KiB
C++
#include "messagebasic.h"
|
|
#include <QVariant>
|
|
|
|
void from_to_save(uint64_t f, uint64_t t, QJsonObject& o) {
|
|
o["source_entity"] = QJsonValue::fromVariant(QVariant::fromValue(f));
|
|
o["target_entity"] = QJsonValue::fromVariant(QVariant::fromValue(t));
|
|
}
|
|
void from_to_recovery(uint64_t& f, uint64_t& t, const QJsonObject& o) {
|
|
f = o["source_entity"].toVariant().toULongLong();
|
|
t = o["target_entity"].toVariant().toULongLong();
|
|
}
|
|
|
|
DeduceRequest::DeduceRequest() {}
|
|
|
|
void DeduceRequest::reset(uint64_t from, uint64_t to) {
|
|
_from_id = from;
|
|
_to_id = to;
|
|
}
|
|
|
|
void DeduceRequest::recoveryFrom(const QJsonObject& obj)
|
|
{
|
|
from_to_recovery(_from_id, _to_id, obj);
|
|
}
|
|
|
|
void DeduceRequest::saveTo(QJsonObject& obj) const
|
|
{
|
|
from_to_save(_from_id, _to_id, obj);
|
|
}
|
|
|
|
QString DeduceRequest::topicString() const
|
|
{
|
|
return NAME(DeduceRequest);
|
|
}
|
|
|
|
uint64_t DeduceRequest::targetEntity() const
|
|
{
|
|
return _to_id;
|
|
}
|
|
|
|
uint64_t DeduceRequest::sourceEntity() const
|
|
{
|
|
return _from_id;
|
|
}
|
|
|
|
SyncRequest::SyncRequest() {
|
|
}
|
|
|
|
void SyncRequest::reset(uint64_t from, uint64_t to, double timepoint)
|
|
{
|
|
_from_id = from;
|
|
_to_id = to;
|
|
this->_time_current = timepoint;
|
|
}
|
|
|
|
void SyncRequest::recoveryFrom(const QJsonObject& obj)
|
|
{
|
|
from_to_recovery(_from_id, _to_id, obj);
|
|
this->_time_current = obj["current_time"].toDouble();
|
|
}
|
|
|
|
void SyncRequest::saveTo(QJsonObject& obj) const
|
|
{
|
|
from_to_save(_from_id, _to_id, obj);
|
|
obj["current_time"] = this->_time_current;
|
|
}
|
|
|
|
QString SyncRequest::topicString() const
|
|
{
|
|
return NAME(SyncRequest);
|
|
}
|
|
|
|
uint64_t SyncRequest::targetEntity() const
|
|
{
|
|
return _to_id;
|
|
}
|
|
|
|
uint64_t SyncRequest::sourceEntity() const
|
|
{
|
|
return _from_id;
|
|
}
|
|
|
|
RespondDefault::RespondDefault() {
|
|
}
|
|
|
|
void RespondDefault::reset(uint64_t from, uint64_t to, double consume) {
|
|
_from_id = from;
|
|
_to_id = to;
|
|
_time_consume = consume;
|
|
}
|
|
|
|
double RespondDefault::consume() const {
|
|
return this->_time_consume;
|
|
}
|
|
|
|
void RespondDefault::recoveryFrom(const QJsonObject& obj)
|
|
{
|
|
from_to_recovery(_from_id, _to_id, obj);
|
|
this->_time_consume = obj["time_consume"].toDouble();
|
|
}
|
|
|
|
void RespondDefault::saveTo(QJsonObject& obj) const
|
|
{
|
|
from_to_save(_from_id, _to_id, obj);
|
|
obj["time_consume"] = this->_time_consume;
|
|
}
|
|
|
|
QString RespondDefault::topicString() const
|
|
{
|
|
return NAME(DeduceRequest);
|
|
}
|
|
|
|
uint64_t RespondDefault::targetEntity() const
|
|
{
|
|
return _to_id;
|
|
}
|
|
|
|
uint64_t RespondDefault::sourceEntity() const
|
|
{
|
|
return _from_id;
|
|
}
|
|
|
|
Get3DBox::Get3DBox()
|
|
{
|
|
}
|
|
|
|
void Get3DBox::reset(uint64_t from, uint64_t to)
|
|
{
|
|
_from_id = from;
|
|
_to_id = to;
|
|
}
|
|
|
|
void Get3DBox::recoveryFrom(const QJsonObject& obj)
|
|
{
|
|
from_to_recovery(_from_id, _to_id, obj);
|
|
}
|
|
|
|
void Get3DBox::saveTo(QJsonObject& obj) const
|
|
{
|
|
from_to_save(_from_id, _to_id, obj);
|
|
}
|
|
|
|
QString Get3DBox::topicString() const
|
|
{
|
|
return NAME(Get3DBox);
|
|
}
|
|
|
|
uint64_t Get3DBox::targetEntity() const
|
|
{
|
|
return _to_id;
|
|
}
|
|
|
|
uint64_t Get3DBox::sourceEntity() const
|
|
{
|
|
return _from_id;
|
|
}
|
|
|
|
Box3DDesc::Box3DDesc()
|
|
{
|
|
}
|
|
|
|
void Box3DDesc::setTarget(uint64_t from, uint64_t to) {
|
|
_from_id = from;
|
|
_to_id = to;
|
|
}
|
|
|
|
void Box3DDesc::setVolume(const D3Data& d) {
|
|
this->_d3_data = d;
|
|
}
|
|
|
|
D3Data Box3DDesc::volume() const { return this->_d3_data; }
|
|
|
|
void Box3DDesc::setPosture(const Posture& p) {
|
|
_posture_d3 = p;
|
|
}
|
|
|
|
Posture Box3DDesc::posture() const { return this->_posture_d3; }
|
|
|
|
void Box3DDesc::setPosition(const LLAPos& lla) {
|
|
_lla_pos = lla;
|
|
}
|
|
|
|
LLAPos Box3DDesc::position() const { return this->_lla_pos; }
|
|
|
|
void Box3DDesc::recoveryFrom(const QJsonObject& obj)
|
|
{
|
|
from_to_recovery(_from_id, _to_id, obj);
|
|
DOUOBLE_PEAK(this->_d3_data._height_m);
|
|
DOUOBLE_PEAK(this->_d3_data._length_m);
|
|
DOUOBLE_PEAK(this->_d3_data._width_m);
|
|
|
|
DOUOBLE_PEAK(this->_lla_pos._lon_deg);
|
|
DOUOBLE_PEAK(this->_lla_pos._lat_deg);
|
|
DOUOBLE_PEAK(this->_lla_pos._alt_m);
|
|
|
|
DOUOBLE_PEAK(this->_posture_d3._azimuth_deg);
|
|
DOUOBLE_PEAK(this->_posture_d3._pitch_deg);
|
|
DOUOBLE_PEAK(this->_posture_d3._roll_deg);
|
|
}
|
|
|
|
void Box3DDesc::saveTo(QJsonObject& obj) const
|
|
{
|
|
from_to_save(_from_id, _to_id, obj);
|
|
|
|
DOUBLE_SAVE(this->_d3_data._height_m);
|
|
DOUBLE_SAVE(this->_d3_data._length_m);
|
|
DOUBLE_SAVE(this->_d3_data._width_m);
|
|
|
|
DOUBLE_SAVE(this->_lla_pos._lon_deg);
|
|
DOUBLE_SAVE(this->_lla_pos._lat_deg);
|
|
DOUBLE_SAVE(this->_lla_pos._alt_m);
|
|
|
|
DOUBLE_SAVE(this->_posture_d3._azimuth_deg);
|
|
DOUBLE_SAVE(this->_posture_d3._pitch_deg);
|
|
DOUBLE_SAVE(this->_posture_d3._roll_deg);
|
|
}
|
|
|
|
QString Box3DDesc::topicString() const
|
|
{
|
|
return NAME(Box3DDesc);
|
|
}
|
|
|
|
uint64_t Box3DDesc::targetEntity() const
|
|
{
|
|
return _to_id;
|
|
}
|
|
|
|
uint64_t Box3DDesc::sourceEntity() const
|
|
{
|
|
return _from_id;
|
|
}
|