SimsWorld/MessageBasic/messagebasic.cpp

231 lines
4.4 KiB
C++
Raw Normal View History

2025-05-25 04:43:37 +00:00
#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;
}
2025-05-31 03:57:32 +00:00
Get3DBox::Get3DBox()
2025-05-25 04:43:37 +00:00
{
}
2025-05-31 03:57:32 +00:00
void Get3DBox::reset(uint64_t from, uint64_t to)
2025-05-25 04:43:37 +00:00
{
_from_id = from;
_to_id = to;
}
2025-05-31 03:57:32 +00:00
void Get3DBox::recoveryFrom(const QJsonObject& obj)
2025-05-25 04:43:37 +00:00
{
from_to_recovery(_from_id, _to_id, obj);
}
2025-05-31 03:57:32 +00:00
void Get3DBox::saveTo(QJsonObject& obj) const
2025-05-25 04:43:37 +00:00
{
from_to_save(_from_id, _to_id, obj);
}
2025-05-31 03:57:32 +00:00
QString Get3DBox::topicString() const
2025-05-25 04:43:37 +00:00
{
2025-05-31 03:57:32 +00:00
return NAME(Get3DBox);
2025-05-25 04:43:37 +00:00
}
2025-05-31 03:57:32 +00:00
uint64_t Get3DBox::targetEntity() const
2025-05-25 04:43:37 +00:00
{
return _to_id;
}
2025-05-31 03:57:32 +00:00
uint64_t Get3DBox::sourceEntity() const
2025-05-25 04:43:37 +00:00
{
return _from_id;
}
2025-05-31 03:57:32 +00:00
Box3DDesc::Box3DDesc()
2025-05-25 04:43:37 +00:00
{
}
2025-05-31 03:57:32 +00:00
void Box3DDesc::setTarget(uint64_t from, uint64_t to) {
2025-05-25 04:43:37 +00:00
_from_id = from;
_to_id = to;
}
2025-05-31 03:57:32 +00:00
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)
2025-05-25 04:43:37 +00:00
{
from_to_recovery(_from_id, _to_id, obj);
2025-05-31 04:18:43 +00:00
DOUOBLE_PEAK(this->_d3_data._height_m);
DOUOBLE_PEAK(this->_d3_data._length_m);
DOUOBLE_PEAK(this->_d3_data._width_m);
2025-05-31 03:57:32 +00:00
2025-05-31 04:18:43 +00:00
DOUOBLE_PEAK(this->_lla_pos._lon_deg);
DOUOBLE_PEAK(this->_lla_pos._lat_deg);
DOUOBLE_PEAK(this->_lla_pos._alt_m);
2025-05-31 03:57:32 +00:00
2025-05-31 04:18:43 +00:00
DOUOBLE_PEAK(this->_posture_d3._azimuth_deg);
DOUOBLE_PEAK(this->_posture_d3._pitch_deg);
DOUOBLE_PEAK(this->_posture_d3._roll_deg);
2025-05-25 04:43:37 +00:00
}
2025-05-31 03:57:32 +00:00
void Box3DDesc::saveTo(QJsonObject& obj) const
2025-05-25 04:43:37 +00:00
{
from_to_save(_from_id, _to_id, obj);
2025-05-31 03:57:32 +00:00
2025-05-31 04:18:43 +00:00
DOUBLE_SAVE(this->_d3_data._height_m);
DOUBLE_SAVE(this->_d3_data._length_m);
DOUBLE_SAVE(this->_d3_data._width_m);
2025-05-31 03:57:32 +00:00
2025-05-31 04:18:43 +00:00
DOUBLE_SAVE(this->_lla_pos._lon_deg);
DOUBLE_SAVE(this->_lla_pos._lat_deg);
DOUBLE_SAVE(this->_lla_pos._alt_m);
2025-05-31 03:57:32 +00:00
2025-05-31 04:18:43 +00:00
DOUBLE_SAVE(this->_posture_d3._azimuth_deg);
DOUBLE_SAVE(this->_posture_d3._pitch_deg);
DOUBLE_SAVE(this->_posture_d3._roll_deg);
2025-05-25 04:43:37 +00:00
}
2025-05-31 03:57:32 +00:00
QString Box3DDesc::topicString() const
2025-05-25 04:43:37 +00:00
{
2025-05-31 03:57:32 +00:00
return NAME(Box3DDesc);
2025-05-25 04:43:37 +00:00
}
2025-05-31 03:57:32 +00:00
uint64_t Box3DDesc::targetEntity() const
2025-05-25 04:43:37 +00:00
{
return _to_id;
}
2025-05-31 03:57:32 +00:00
uint64_t Box3DDesc::sourceEntity() const
2025-05-25 04:43:37 +00:00
{
return _from_id;
}