116 lines
2.5 KiB
C++
116 lines
2.5 KiB
C++
|
#include "motion_access.h"
|
||
|
#include <QVariant>
|
||
|
|
||
|
NavigateWithRoute::NavigateWithRoute()
|
||
|
:AbstractMessage(NAME(NavigateWithRoute)) {
|
||
|
}
|
||
|
|
||
|
void NavigateWithRoute::recoveryFrom(const QJsonObject& obj)
|
||
|
{
|
||
|
AbstractMessage::recoveryFrom(obj);
|
||
|
|
||
|
STRING_PEAK(_route_name);
|
||
|
}
|
||
|
|
||
|
void NavigateWithRoute::saveTo(QJsonObject& obj) const
|
||
|
{
|
||
|
AbstractMessage::saveTo(obj);
|
||
|
|
||
|
STRING_SAVE(_route_name);
|
||
|
}
|
||
|
|
||
|
PlatformMotionCommand::PlatformMotionCommand()
|
||
|
:AbstractMessage(NAME(PlatformMotionCommand))
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
#include <QJsonArray>
|
||
|
#include <QJsonObject>
|
||
|
void PlatformMotionCommand::recoveryFrom(const QJsonObject& obj)
|
||
|
{
|
||
|
AbstractMessage::recoveryFrom(obj);
|
||
|
DOUBLE_PEAK(_arrived_time);
|
||
|
DOUBLE_PEAK(_start_time);
|
||
|
|
||
|
auto cmd_array = obj["array"].toArray();
|
||
|
for (auto idx = 0; idx < cmd_array.size(); ++idx) {
|
||
|
auto cmd_obj = cmd_array.at(idx).toObject();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void PlatformMotionCommand::saveTo(QJsonObject& obj) const
|
||
|
{
|
||
|
AbstractMessage::saveTo(obj);
|
||
|
DOUBLE_SAVE(_arrived_time);
|
||
|
DOUBLE_SAVE(_start_time);
|
||
|
|
||
|
QJsonArray cmd_array;
|
||
|
for (auto k : this->_motion_set.keys()) {
|
||
|
QJsonObject cmd;
|
||
|
cmd["type"] = (int)k;
|
||
|
QJsonObject objx;
|
||
|
this->_motion_set[k]->saveTo(objx);
|
||
|
cmd["content"] = objx;
|
||
|
|
||
|
cmd_array.append(cmd);
|
||
|
}
|
||
|
obj["array"] = cmd_array;
|
||
|
}
|
||
|
|
||
|
MotionSequencePreviewGet::MotionSequencePreviewGet()
|
||
|
:AbstractMessage(NAME(MotionSequencePreviewGet)) {
|
||
|
}
|
||
|
|
||
|
|
||
|
PlatformMotionSequence::PlatformMotionSequence()
|
||
|
:AbstractMessage(NAME(PlatformMotionSequence))
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void PlatformMotionSequence::recoveryFrom(const QJsonObject& obj)
|
||
|
{
|
||
|
this->_cmd_sequence.clear();
|
||
|
|
||
|
AbstractMessage::recoveryFrom(obj);
|
||
|
auto cmd_array = obj["cmd_array"].toArray();
|
||
|
for (auto idx = 0; idx < cmd_array.size(); idx++) {
|
||
|
auto cmd_object = cmd_array.at(idx).toObject();
|
||
|
auto ptr = std::make_shared<PlatformMotionCommand>();
|
||
|
ptr->recoveryFrom(cmd_object);
|
||
|
this->_cmd_sequence.append(ptr);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void PlatformMotionSequence::saveTo(QJsonObject& obj) const
|
||
|
{
|
||
|
AbstractMessage::saveTo(obj);
|
||
|
|
||
|
QJsonArray cmd_array;
|
||
|
for (auto info : _cmd_sequence) {
|
||
|
QJsonObject cmd_object;
|
||
|
info->saveTo(cmd_object);
|
||
|
cmd_array.append(cmd_object);
|
||
|
}
|
||
|
obj["cmd_array"] = cmd_array;
|
||
|
}
|
||
|
|
||
|
HorizontalLineMotionCmd::HorizontalLineMotionCmd(){}
|
||
|
|
||
|
MotionRotate HorizontalLineMotionCmd::rotateType() const
|
||
|
{
|
||
|
MotionRotate::Horizontal;
|
||
|
}
|
||
|
|
||
|
MotionType HorizontalLineMotionCmd::motionType() const
|
||
|
{
|
||
|
MotionType::ParabolaLine;
|
||
|
}
|
||
|
|
||
|
LonLatAltPos HorizontalLineMotionCmd::posAtPercent(double percent)
|
||
|
{
|
||
|
throw std::logic_error("The method or operation is not implemented.");
|
||
|
}
|