ADD: added new function to unpack a SimTrack message from a string
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <SimCore/data.hpp>
|
||||
|
||||
#include <SimCore/Messages/Emission.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace SimCore
|
||||
{
|
||||
@@ -52,13 +53,18 @@ namespace SimCore
|
||||
/// @brief return a WHISPER Message out of a simtrack object
|
||||
/// @param parentID
|
||||
/// @return WHISPER::Message
|
||||
WHISPER::Message buildMessage(SimCore::Identifier parentID);
|
||||
WHISPER::Message buildMessage();
|
||||
|
||||
/// @brief creates a SimTrack out of a whisper message
|
||||
/// @param msg
|
||||
/// @return SimTrack Oject
|
||||
static SimTrack unpack(WHISPER::Message msg);
|
||||
|
||||
/// @brief creates a SimTrack out of a string message
|
||||
/// @param msg
|
||||
/// @return SimTrack Oject
|
||||
static std::unique_ptr<SimCore::SimTrack> unpack(std::string msg);
|
||||
|
||||
public:
|
||||
Data<double> Speed;
|
||||
Data<double> Course;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "WHISPER/Messages/Message.hpp"
|
||||
#include <SimCore/Messages/SimTrack.hpp>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
/// @brief
|
||||
namespace SimCore
|
||||
@@ -6,21 +10,34 @@ namespace SimCore
|
||||
SimTrack::SimTrack()
|
||||
:ID_(SimCore::Identifier()),SourceType_(WHISPER::SourceType::SIMCOMTROLER)
|
||||
{
|
||||
EntityKind.setValue(SimCore::EntityKind::UNKNOWN);
|
||||
EntityKind.setValue(SimCore::EntityKind::UNKNOWN);
|
||||
|
||||
Speed.setValue(0);
|
||||
Course.setValue(0);
|
||||
Pitch.setValue(0);
|
||||
RCS.setValue(0);
|
||||
}
|
||||
|
||||
SimTrack::SimTrack(WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind)
|
||||
:ID_(SimCore::Identifier()),SourceType_(sourcetype)
|
||||
{
|
||||
EntityKind.setValue(entityKind);
|
||||
EntityKind.setValue(entityKind);
|
||||
|
||||
Speed.setValue(0);
|
||||
Course.setValue(0);
|
||||
Pitch.setValue(0);
|
||||
RCS.setValue(0);
|
||||
}
|
||||
|
||||
SimTrack::SimTrack(SimCore::Identifier id ,WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind )
|
||||
:ID_(id),SourceType_(sourcetype)
|
||||
{
|
||||
EntityKind.setValue(entityKind);
|
||||
EntityKind.setValue(entityKind);
|
||||
|
||||
Speed.setValue(0);
|
||||
Course.setValue(0);
|
||||
Pitch.setValue(0);
|
||||
RCS.setValue(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +68,9 @@ namespace SimCore
|
||||
}
|
||||
|
||||
|
||||
WHISPER::Message SimTrack::buildMessage(SimCore::Identifier parentID)
|
||||
WHISPER::Message SimTrack::buildMessage()
|
||||
{
|
||||
WHISPER::Message msg(parentID.getParentNumber(), parentID.getNumber(),WHISPER::MsgTopics::TRACK , WHISPER::MsgType::GROUND_TRUTH_TRACK, this->SourceType_);
|
||||
WHISPER::Message msg(ID_.getUUID(),WHISPER::MsgTopics::TRACK , WHISPER::MsgType::GROUND_TRUTH_TRACK, this->SourceType_);
|
||||
|
||||
|
||||
messages::SimTrack::SimTrack SimTrack;
|
||||
@@ -183,6 +200,22 @@ namespace SimCore
|
||||
return track;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::unique_ptr<SimCore::SimTrack> SimTrack::unpack(std::string msg)
|
||||
{
|
||||
if (std::empty(msg) == false && msg != "NULL")
|
||||
{
|
||||
WHISPER::Message whisperMessage(msg);
|
||||
return std::make_unique<SimTrack>(std::move(unpack(whisperMessage)));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SimTrack::addEmission(Emission emission)
|
||||
{
|
||||
auto tmp = std::make_shared<Emission>(std::move(emission));
|
||||
|
||||
Reference in New Issue
Block a user