#include "messagebasic.h" #include 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; } Get3DVolume::Get3DVolume() { } void Get3DVolume::reset(uint64_t from, uint64_t to) { _from_id = from; _to_id = to; } void Get3DVolume::recoveryFrom(const QJsonObject& obj) { from_to_recovery(_from_id, _to_id, obj); } void Get3DVolume::saveTo(QJsonObject& obj) const { from_to_save(_from_id, _to_id, obj); } QString Get3DVolume::topicString() const { return NAME(Get3DVolume); } uint64_t Get3DVolume::targetEntity() const { return _to_id; } uint64_t Get3DVolume::sourceEntity() const { return _from_id; } Volume3DDesc::Volume3DDesc() { } void Volume3DDesc::reset(uint64_t from, uint64_t to, double l, double w, double h, double azi) { _from_id = from; _to_id = to; _length = l; _width = w; _height = h; _azimuth_deg = azi; } void Volume3DDesc::recoveryFrom(const QJsonObject& obj) { from_to_recovery(_from_id, _to_id, obj); _length = obj["length"].toDouble(); _width = obj["width"].toDouble(); _height = obj["height"].toDouble(); _azimuth_deg = obj["azimuth_deg"].toDouble(); } void Volume3DDesc::saveTo(QJsonObject& obj) const { from_to_save(_from_id, _to_id, obj); obj["length"] = _length; obj["width"] = _width; obj["height"] = _height; obj["azimuth_deg"] = _azimuth_deg; } QString Volume3DDesc::topicString() const { return NAME(Volume3DDesc); } uint64_t Volume3DDesc::targetEntity() const { return _to_id; } uint64_t Volume3DDesc::sourceEntity() const { return _from_id; }