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/data.hpp>
|
||||||
|
|
||||||
#include <SimCore/Messages/Emission.hpp>
|
#include <SimCore/Messages/Emission.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace SimCore
|
namespace SimCore
|
||||||
{
|
{
|
||||||
@@ -52,13 +53,18 @@ namespace SimCore
|
|||||||
/// @brief return a WHISPER Message out of a simtrack object
|
/// @brief return a WHISPER Message out of a simtrack object
|
||||||
/// @param parentID
|
/// @param parentID
|
||||||
/// @return WHISPER::Message
|
/// @return WHISPER::Message
|
||||||
WHISPER::Message buildMessage(SimCore::Identifier parentID);
|
WHISPER::Message buildMessage();
|
||||||
|
|
||||||
/// @brief creates a SimTrack out of a whisper message
|
/// @brief creates a SimTrack out of a whisper message
|
||||||
/// @param msg
|
/// @param msg
|
||||||
/// @return SimTrack Oject
|
/// @return SimTrack Oject
|
||||||
static SimTrack unpack(WHISPER::Message msg);
|
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:
|
public:
|
||||||
Data<double> Speed;
|
Data<double> Speed;
|
||||||
Data<double> Course;
|
Data<double> Course;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
#include "WHISPER/Messages/Message.hpp"
|
||||||
#include <SimCore/Messages/SimTrack.hpp>
|
#include <SimCore/Messages/SimTrack.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
namespace SimCore
|
namespace SimCore
|
||||||
@@ -7,6 +11,11 @@ namespace SimCore
|
|||||||
:ID_(SimCore::Identifier()),SourceType_(WHISPER::SourceType::SIMCOMTROLER)
|
: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)
|
SimTrack::SimTrack(WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind)
|
||||||
@@ -14,6 +23,10 @@ namespace SimCore
|
|||||||
{
|
{
|
||||||
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 )
|
SimTrack::SimTrack(SimCore::Identifier id ,WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind )
|
||||||
@@ -21,6 +34,10 @@ namespace SimCore
|
|||||||
{
|
{
|
||||||
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;
|
messages::SimTrack::SimTrack SimTrack;
|
||||||
@@ -183,6 +200,22 @@ namespace SimCore
|
|||||||
return track;
|
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)
|
void SimTrack::addEmission(Emission emission)
|
||||||
{
|
{
|
||||||
auto tmp = std::make_shared<Emission>(std::move(emission));
|
auto tmp = std::make_shared<Emission>(std::move(emission));
|
||||||
|
|||||||
Reference in New Issue
Block a user