diff --git a/include/Entities/SensorControl.hpp b/include/Entities/SensorControl.hpp index bdbaeff..656c357 100644 --- a/include/Entities/SensorControl.hpp +++ b/include/Entities/SensorControl.hpp @@ -1,5 +1,6 @@ #pragma once #include "SimCore/Identifier.hpp" +#include "SimCore/Messages/SensorTracklistItem.hpp" #include "SimCore/SimCore.hpp" #include #include @@ -20,7 +21,8 @@ namespace Sensor SensorControl(SimCore::Identifier ID, std::string Name, std::string IP, SimCore::SensorKinds sensorKind); - + SimCore::SensorTracklistItem getSensorTracklistItem(); + TrackList::TrackList TrackStore; diff --git a/include/Entities/SensorManager.hpp b/include/Entities/SensorManager.hpp index b1d2b3b..84273cf 100644 --- a/include/Entities/SensorManager.hpp +++ b/include/Entities/SensorManager.hpp @@ -4,6 +4,7 @@ #include "Entities/SensorControl.hpp" #include "Entities/Tracklist/Trackfusion.hpp" #include "SimCore/Identifier.hpp" +#include "SimCore/Messages/SensorTracklistUpdate.hpp" #include "SimCore/Messages/SimTrack.hpp" #include "SimCore/Messages/TracklistUpdate.hpp" #include "SimCore/SimCore.hpp" @@ -117,7 +118,17 @@ namespace Entities * * @return std::unique_ptr */ - std::unique_ptr getTrackListUpdate(); + std::unique_ptr getTrackListUpdateFusioned(); + + /** + * @brief Get the Track List Update Raw + * + * in this list every sensor has its own tracks without a sensorfusion over all sensors + * + * @return std::unique_ptr + */ + std::unique_ptr getTrackListUpdateRaw(); + /** * @brief send the ownShipTrack to all connected Sensors diff --git a/include/Entities/Tracklist/Tracklist.hpp b/include/Entities/Tracklist/Tracklist.hpp index 79c5a81..4a7a646 100644 --- a/include/Entities/Tracklist/Tracklist.hpp +++ b/include/Entities/Tracklist/Tracklist.hpp @@ -3,6 +3,7 @@ #include "SimCore/Identifier.hpp" #include "SimCore/IdentifierMaker.hpp" +#include "SimCore/Messages/SensorTrack.hpp" #include "SimCore/Messages/SimTrack.hpp" #include "nlohmann/json.hpp" #include @@ -24,21 +25,22 @@ namespace TrackList { public: TrackList(); - void addTrack(std::shared_ptr Track); - std::shared_ptr getTrack(SimCore::Identifier); + void addTrack(std::shared_ptr Track); + std::shared_ptr getTrack(SimCore::Identifier); void deleteTrack(std::string ID); void deleteTrack(SimCore::Identifier); - std::shared_ptr getTrackBySringID(std::string ID); + std::shared_ptr getTrackBySringID(std::string ID); size_t getSize(); void getJsonTRackList(nlohmann::json &message); + std::map> getTrackStore(); private: mutable std::mutex mx_; - std::map> TrackStore_; + std::map> TrackStore_; }; diff --git a/libs/OrderLibrary b/libs/OrderLibrary index c3335db..20c1465 160000 --- a/libs/OrderLibrary +++ b/libs/OrderLibrary @@ -1 +1 @@ -Subproject commit c3335db37b8bcfb4f84e787480a8311e9f28f007 +Subproject commit 20c1465b53e3cb2794910cc81b00bb7620be87ff diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5cf1758..3754734 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -303,8 +303,15 @@ namespace Entities } if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier()) { + if (TrackListRequest->requestedFusioned() == true) + { std::string senderUUID = whisperMsg.senderUUID_; - CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdate()->buildMessage(),senderUUID); + CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdateFusioned()->buildMessage(),senderUUID); + }else { + std::string senderUUID = whisperMsg.senderUUID_; + CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdateRaw()->buildMessage(),senderUUID); + } + } break; } diff --git a/src/Entities/SensorControl.cpp b/src/Entities/SensorControl.cpp index 369ba07..ed53bec 100644 --- a/src/Entities/SensorControl.cpp +++ b/src/Entities/SensorControl.cpp @@ -1,6 +1,7 @@ #include #include "Entities/Tracklist/Tracklist.hpp" #include "SimCore/Identifier.hpp" +#include "SimCore/Messages/SensorTracklistItem.hpp" #include "nlohmann/json_fwd.hpp" #include #include @@ -17,6 +18,22 @@ namespace Sensor { } + + + SimCore::SensorTracklistItem SensorControl::getSensorTracklistItem() + { + auto data = std::make_shared(this->getID(),this->getName(),this->getIP(),this->getSensorKind()); + SimCore::SensorTracklistItem item(data); + + for(auto [key, track]: TrackStore.getTrackStore()) + { + item.updateTrack(track); + } + + return item; + } + + diff --git a/src/Entities/SensorManager.cpp b/src/Entities/SensorManager.cpp index 89dd149..5fadb09 100644 --- a/src/Entities/SensorManager.cpp +++ b/src/Entities/SensorManager.cpp @@ -246,12 +246,28 @@ namespace Entities } - std::unique_ptr SensorManager::getTrackListUpdate() + std::unique_ptr SensorManager::getTrackListUpdateFusioned() { return std::move(Trackfusion_.getTrackListUpdate(OwnId_)); } + std::unique_ptr SensorManager::getTrackListUpdateRaw() + { + + auto Update = std::make_unique(OwnId_); + + for(auto [key,item]: SensorStore) + { + Update->addTrack(item->getSensorTracklistItem()); + } + + return Update; + + + } + + void SensorManager::sendOwnShipTrackToSensors() { diff --git a/src/Entities/Tracklist/Tracklist.cpp b/src/Entities/Tracklist/Tracklist.cpp index bc252ed..5d15345 100644 --- a/src/Entities/Tracklist/Tracklist.cpp +++ b/src/Entities/Tracklist/Tracklist.cpp @@ -1,4 +1,5 @@ #include +#include "SimCore/Messages/SensorTrack.hpp" #include "SimCore/Messages/SimTrack.hpp" @@ -9,10 +10,10 @@ namespace TrackList TrackList::TrackList() { - TrackStore_ = std::map>(); + TrackStore_ = std::map>(); } - void TrackList::addTrack(std::shared_ptr Track) + void TrackList::addTrack(std::shared_ptr Track) { std::lock_guard lock(mx_); @@ -22,7 +23,7 @@ namespace TrackList } - std::shared_ptr TrackList::getTrack(const SimCore::Identifier ID) + std::shared_ptr TrackList::getTrack(const SimCore::Identifier ID) { std::lock_guard lock(mx_); @@ -30,7 +31,7 @@ namespace TrackList return it->second; } - std::shared_ptr TrackList::getTrackBySringID(std::string ID) + std::shared_ptr TrackList::getTrackBySringID(std::string ID) { std::lock_guard lock(mx_); @@ -52,12 +53,17 @@ namespace TrackList TrackStore_.erase(it); } + std::map> TrackList::getTrackStore() + { + return TrackStore_; + } + void TrackList::getJsonTRackList(nlohmann::json &message) { std::lock_guard lock(mx_); try { - for (std::map>::iterator it=TrackStore_.begin(); it!=TrackStore_.end(); ++it) + for (std::map>::iterator it=TrackStore_.begin(); it!=TrackStore_.end(); ++it) { nlohmann::json j; j["id"] = it->first;