ADD: added Json Library,

FIX: fixed issue with dealing with GroundThruthTracks to using sharedpointer
This commit is contained in:
Henry Winkel
2023-02-17 09:03:38 +01:00
parent 9d76994e31
commit 422fdd4e7a
4 changed files with 32 additions and 12 deletions

View File

@@ -4,10 +4,11 @@
#include "SimCore/SimCore.hpp"
#include "SimCore/UtilFunctions.hpp"
#include "WHISPER/Messages/Message.hpp"
#include <SimCore/Templates/Sensor.hpp>
#include <Entities/Sensor.hpp>
#include <memory>
#include <utility>
namespace SimCore {
namespace Entities {
Sensor::Sensor(SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress):
OwnID_(OwnID),ParentID_(ParentID),SensorKind_(SensorKind),GroundTruthPort_(GroundTruthPort),ParentPort_(ParentPort),ParentIPAddress_(ParentIPAddress)
@@ -23,7 +24,7 @@ namespace SimCore {
incommingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
outgoingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
incommingTrackMessages = std::make_shared<WHISPER::threadSafeQueue<SimCore::GroundTruthTrack>>();
incommingTrackMessages = std::make_shared<WHISPER::threadSafeQueue<std::shared_ptr<SimCore::GroundTruthTrack>>>();
GroundTruthUDPService_ = std::make_shared<WHISPER::InternalUDPService>(OwnID.getParentNumber(),OwnID.getNumber(),WHISPER::SENSOR,GroundTruthPort_,SimCore::UtilFunctions::implode(ip,'.'),ownIP);
@@ -121,9 +122,8 @@ namespace SimCore {
WHISPER::Message msg;
incommingGroundThruthMessages->get(msg);
if (msg.msgType_ == WHISPER::MsgType::GROUND_TRUTH_TRACK) {
auto elem = GroundTruthTrack::unpack(msg);
// auto Track = SimCore::Track(msg.serialize());
incommingTrackMessages->addElement(elem);
auto GTrack = std::make_shared<SimCore::GroundTruthTrack>(std::move(SimCore::GroundTruthTrack::unpack(msg)));
incommingTrackMessages->addElement(GTrack);
}
}
@@ -152,8 +152,10 @@ namespace SimCore {
incommingParentMessages->get(msg);
LOG_S(INFO)<< "Message received from Parent is" << msg.msgType_;
std::uint32_t type = 0;
if (msg.msgType_ == WHISPER::MsgType::OWN_TRACK) {
switch (msg.msgType_) {
case WHISPER::MsgType::OWN_TRACK :{
auto OwnTrack = SimCore::GroundTruthTrack::unpack(msg);
// SimCore::Track OwnTrack(msg.serialize());
auto tmpPos = OwnTrack.getPostion().getGeocentricPos();
@@ -169,8 +171,22 @@ namespace SimCore {
tmpPos[SimCore::GeocentricPosition::Y],
tmpPos[SimCore::GeocentricPosition::Z]);
}
break;
}
case WHISPER::MsgType::COMMAND: {
break;
}
default: {
break;
}
}
}