Compare commits
10 Commits
80f5c68466
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5eb76771d | ||
|
|
0ec7bb4c66 | ||
|
|
b2da644fa2 | ||
|
|
e039b36ed5 | ||
|
|
671f763f45 | ||
|
|
87368640e2 | ||
|
|
d56df03ed4 | ||
|
|
56577388e8 | ||
|
|
453d3c27c4 | ||
|
|
ae7a65dff9 |
52
.drone.yml
Normal file
52
.drone.yml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: kubernetes
|
||||||
|
name: default-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: submodules
|
||||||
|
image: alpine/git
|
||||||
|
commands:
|
||||||
|
- sed -i 's/ssh\\:..git@/https\\:\\/\\//' .gitmodules
|
||||||
|
- sed -i 's/\:12000//' .gitmodules
|
||||||
|
- git submodule update --init --recursive --jobs=4
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
image: kmaster.ti.unibw-hamburg.de:30808/debianbullseye
|
||||||
|
commands:
|
||||||
|
- sed -i 's/ssh\\:..git@/https\\:\\/\\//' .gitmodules
|
||||||
|
- sed -i 's/\:12000//' .gitmodules
|
||||||
|
- git submodule update --init --recursive --jobs=4
|
||||||
|
- mkdir -p build && cd build
|
||||||
|
- CC=clang-11 CXX=clang++-11 cmake -DCMAKE_BUILD_TYPE=DEBUG ..
|
||||||
|
- make -j
|
||||||
|
- make test
|
||||||
|
|
||||||
|
# - name: EntiyLibrary
|
||||||
|
# image: kmaster.ti.unibw-hamburg.de:30808/drone-ftewa-codechecker
|
||||||
|
# pull: always
|
||||||
|
# settings:
|
||||||
|
# CODECHECKER_URL: "http://codechecker:8001"
|
||||||
|
# CODECHECKER_PRODUCT: "EntiyLibrary"
|
||||||
|
# CODECHECKER_USER:
|
||||||
|
# from_secret: CODECHECKER_USER_SECRET
|
||||||
|
# CODECHECKER_PASS:
|
||||||
|
# from_secret: CODECHECKER_PASS_SECRET
|
||||||
|
# when:
|
||||||
|
# event:
|
||||||
|
# include:
|
||||||
|
# - push
|
||||||
|
# - pull_request
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: secret
|
||||||
|
name: CODECHECKER_USER_SECRET
|
||||||
|
get:
|
||||||
|
path: codechecker-client
|
||||||
|
name: username
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: secret
|
||||||
|
name: CODECHECKER_PASS_SECRET
|
||||||
|
get:
|
||||||
|
path: codechecker-client
|
||||||
|
name: password
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
build/
|
build/
|
||||||
.cache
|
.cache
|
||||||
|
.vscode
|
||||||
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Debug-SensorManager",
|
|
||||||
"type": "gdb",
|
|
||||||
"request": "launch",
|
|
||||||
"target": "./test_SensorManager",
|
|
||||||
"cwd": "${workspaceRoot}/build",
|
|
||||||
"valuesFormatting": "parseText"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,7 @@ function(protobuf_generate_cpp)
|
|||||||
${ARGN})
|
${ARGN})
|
||||||
|
|
||||||
FILE(GLOB PROTO_FILES ${protobuf_PROTO_PATH}/*.proto)
|
FILE(GLOB PROTO_FILES ${protobuf_PROTO_PATH}/*.proto)
|
||||||
set(PROTOC ${CMAKE_BINARY_DIR}/libs/OrderLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/protoc)
|
set(PROTOC ${CMAKE_BINARY_DIR}/libs/OrderLibrary/libs/SimCore/libs/SimCom/libs/protobuf/protoc)
|
||||||
message(STATUS "protoc path: " ${PROTOC})
|
message(STATUS "protoc path: " ${PROTOC})
|
||||||
|
|
||||||
FOREACH(proto ${PROTO_FILES})
|
FOREACH(proto ${PROTO_FILES})
|
||||||
@@ -29,7 +29,7 @@ function(protobuf_generate_cpp)
|
|||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${protoDIR}/${protoFILENAME}.pb.cc"
|
OUTPUT "${protoDIR}/${protoFILENAME}.pb.cc"
|
||||||
DEPENDS "${protoDIR}/${protoFILENAME}.proto"
|
DEPENDS "${protoDIR}/${protoFILENAME}.proto"
|
||||||
COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path="${CMAKE_SOURCE_DIR}/libs/OrderLibrary/libs/SimCore/include/SimCore/Messages/Protos" --proto_path="${CMAKE_SOURCE_DIR}/libs/OrderLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto"
|
COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path="${CMAKE_SOURCE_DIR}/libs/OrderLibrary/libs/SimCore/include/SimCore/Messages/Protos" --proto_path="${CMAKE_SOURCE_DIR}/libs/OrderLibrary/libs/SimCore/libs/SimCom/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
4
codecheck.skip
Normal file
4
codecheck.skip
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
-/usr/*
|
||||||
|
-*/tests/test_*
|
||||||
|
-*/libs/*
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define LOGURU_WITH_STREAMS 1
|
||||||
|
#include <loguru.hpp>
|
||||||
#include <Entities/Tracklist/Tracklist.hpp>
|
#include <Entities/Tracklist/Tracklist.hpp>
|
||||||
|
|
||||||
#include "DirectCommunicationServer.hpp"
|
#include "DirectCommunicationServer.hpp"
|
||||||
@@ -31,24 +33,6 @@
|
|||||||
|
|
||||||
namespace Entities {
|
namespace Entities {
|
||||||
|
|
||||||
// struct SensorClientData
|
|
||||||
// {
|
|
||||||
// std::string SensorName;
|
|
||||||
// bool isActive;
|
|
||||||
// SimCore::Identifier SensorID;
|
|
||||||
// // std::shared_ptr<WHISPER::InternalUDPSender> SensorSender;
|
|
||||||
// };
|
|
||||||
|
|
||||||
struct EffectorClientData
|
|
||||||
{
|
|
||||||
std::string EffectorName;
|
|
||||||
bool isActive;
|
|
||||||
SimCore::Identifier EffectorID;
|
|
||||||
std::shared_ptr<WHISPER::InternalUDPSender> EffectorSender;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
Entity(const SimCore::Identifier OwnID,
|
Entity(const SimCore::Identifier OwnID,
|
||||||
@@ -64,59 +48,95 @@ namespace Entities {
|
|||||||
bool online);
|
bool online);
|
||||||
~Entity();
|
~Entity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief starts the Entity APP
|
||||||
|
*/
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief stops the Entity
|
||||||
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
void setPosition(SimCore::Position);
|
|
||||||
|
/**
|
||||||
|
* @brief sets the current entity position
|
||||||
|
*/
|
||||||
|
void setPosition(SimCore::Position pos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sets the speed of the Entity
|
||||||
|
* @param speed - double
|
||||||
|
*/
|
||||||
void setSpeed(double speed);
|
void setSpeed(double speed);
|
||||||
|
/**
|
||||||
|
* @brief set the course of the entity (heading, course over ground) in degree
|
||||||
|
* @param course - double
|
||||||
|
*/
|
||||||
void setCourse(double course);
|
void setCourse(double course);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sets the pitch (climb angle) in degree
|
||||||
|
* @param pitch - double
|
||||||
|
*/
|
||||||
void setPitch( double pitch);
|
void setPitch( double pitch);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief is the child worker function which is called on every circle
|
||||||
|
*/
|
||||||
virtual void childWorker() = 0;
|
virtual void childWorker() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief is function whick is called to stop the specific child class
|
||||||
|
*/
|
||||||
virtual void stopChild() = 0;
|
virtual void stopChild() = 0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// @brief shared_ptr of the own track
|
||||||
std::shared_ptr<SimCore::SimTrack> OwnShipTrack = nullptr;
|
std::shared_ptr<SimCore::SimTrack> OwnShipTrack = nullptr;
|
||||||
|
/// @brief name of the entity (marking)
|
||||||
std::unique_ptr<TrackList::TrackList> TrackList_ = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
std::string EntityName_;
|
std::string EntityName_;
|
||||||
|
/// @brief Entity Kind var (is enum)
|
||||||
SimCore::Kind::EntityKind EntityKind_;
|
SimCore::Kind::EntityKind EntityKind_;
|
||||||
|
/// @brief Entity Side (is enum)
|
||||||
SimCore::Side::EntitySide EntitySide_;
|
SimCore::Side::EntitySide EntitySide_;
|
||||||
|
/// @brief Radar cross section
|
||||||
double RCS_;
|
double RCS_;
|
||||||
|
/// @brief port of the movement worker
|
||||||
ushort MovemntWorkerPort_;
|
ushort MovemntWorkerPort_;
|
||||||
|
/// @brief port which the sensor are connecting to
|
||||||
ushort SensorPort_;
|
ushort SensorPort_;
|
||||||
|
/// @brief shared ptr of the Podcontroller
|
||||||
|
|
||||||
std::shared_ptr<kubecontrol::PodController> PodController_;
|
std::shared_ptr<kubecontrol::PodController> PodController_;
|
||||||
|
/// @brief unique ptr of the sensor manager
|
||||||
std::unique_ptr<SensorManager> SensorManager_;
|
std::unique_ptr<SensorManager> SensorManager_;
|
||||||
|
/// @brief broadcast server the own ship message is use to send
|
||||||
std::shared_ptr<WHISPER::InternalUDPSender> BroadcastServer_;
|
std::shared_ptr<WHISPER::InternalUDPSender> BroadcastServer_;
|
||||||
|
/// @brief address of the ground thruth (default = 239.0.0.1)
|
||||||
|
|
||||||
std::string GroundTruthAddr_;
|
std::string GroundTruthAddr_;
|
||||||
|
/// @brief port of the ground thruth
|
||||||
std::uint32_t GroundTruthPort_;
|
std::uint32_t GroundTruthPort_;
|
||||||
|
/// @brief port on which commands are received
|
||||||
|
ushort CommandPort_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// @brief indicates if entity is startet in a kubernetes cluster
|
||||||
bool online_;
|
bool online_;
|
||||||
|
/// @brief vector of all startet threads
|
||||||
|
std::vector<std::thread> threads_;
|
||||||
std::vector<std::thread> threads;
|
///
|
||||||
|
std::atomic_bool stopMainLoop_ = false;
|
||||||
std::atomic<bool> stopMainLoop = false;
|
|
||||||
void MainLoop();
|
void MainLoop();
|
||||||
|
|
||||||
|
|
||||||
void startMovementWorker();
|
void startMovementWorker();
|
||||||
std::atomic<bool> MovementWorkerStarted = false;
|
std::atomic_bool MovementWorkerStarted_ = false;
|
||||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> MovemtServer_ = nullptr;
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> MovemtServer_ = nullptr;
|
||||||
void handleMovement();
|
void handleMovement();
|
||||||
std::string MovementPodUUID_;
|
std::string MovementPodUUID_;
|
||||||
@@ -124,7 +144,7 @@ namespace Entities {
|
|||||||
|
|
||||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> CommandCommsServer_ = nullptr;
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> CommandCommsServer_ = nullptr;
|
||||||
|
|
||||||
void handleExternalComms(std::string msg);
|
void handleExternalComms(const std::string &msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "SimCore/Identifier.hpp"
|
#include "SimCore/Identifier.hpp"
|
||||||
|
#include "SimCore/Messages/SensorTracklistItem.hpp"
|
||||||
#include "SimCore/SimCore.hpp"
|
#include "SimCore/SimCore.hpp"
|
||||||
#include <SimCore/Messages/SimTrack.hpp>
|
#include <SimCore/Messages/SimTrack.hpp>
|
||||||
#include <kubecontrol/KubePod.hpp>
|
#include <kubecontrol/KubePod.hpp>
|
||||||
@@ -20,7 +21,8 @@ namespace Sensor
|
|||||||
SensorControl(SimCore::Identifier ID, std::string Name, std::string IP, SimCore::SensorKinds sensorKind);
|
SensorControl(SimCore::Identifier ID, std::string Name, std::string IP, SimCore::SensorKinds sensorKind);
|
||||||
|
|
||||||
|
|
||||||
|
SimCore::SensorTracklistItem getSensorTracklistItem();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TrackList::TrackList TrackStore;
|
TrackList::TrackList TrackStore;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Entities/SensorControl.hpp"
|
#include "Entities/SensorControl.hpp"
|
||||||
#include "Entities/Tracklist/Trackfusion.hpp"
|
#include "Entities/Tracklist/Trackfusion.hpp"
|
||||||
#include "SimCore/Identifier.hpp"
|
#include "SimCore/Identifier.hpp"
|
||||||
|
#include "SimCore/Messages/SensorTracklistUpdate.hpp"
|
||||||
#include "SimCore/Messages/SimTrack.hpp"
|
#include "SimCore/Messages/SimTrack.hpp"
|
||||||
#include "SimCore/Messages/TracklistUpdate.hpp"
|
#include "SimCore/Messages/TracklistUpdate.hpp"
|
||||||
#include "SimCore/SimCore.hpp"
|
#include "SimCore/SimCore.hpp"
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <vector>
|
||||||
namespace Entities
|
namespace Entities
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -68,6 +70,20 @@ namespace Entities
|
|||||||
*/
|
*/
|
||||||
std::shared_ptr<Sensor::SensorControl> getSensorByUUID(std::string uuid);
|
std::shared_ptr<Sensor::SensorControl> getSensorByUUID(std::string uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Sensor List As Vector of shared pointer of sensorcontrols
|
||||||
|
*
|
||||||
|
* @return std::vector<std::shared_ptr<Sensor::SensorControl>>
|
||||||
|
*/
|
||||||
|
std::vector<std::shared_ptr<Sensor::SensorControl>> getSensorListAsVector();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Sensor List As Map of shared pointer of sensorcontrols
|
||||||
|
*
|
||||||
|
* @return std::map<std::string, std::shared_ptr<Sensor::SensorControl>>
|
||||||
|
*/
|
||||||
|
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> getSensorListAsMap();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +133,17 @@ namespace Entities
|
|||||||
*
|
*
|
||||||
* @return std::unique_ptr<SimCore::TracklistUpdate>
|
* @return std::unique_ptr<SimCore::TracklistUpdate>
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<SimCore::TracklistUpdate> getTrackListUpdate();
|
std::unique_ptr<SimCore::TracklistUpdate> 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<SimCore::SensorTracklistUpdate>
|
||||||
|
*/
|
||||||
|
std::unique_ptr<SimCore::SensorTracklistUpdate> getTrackListUpdateRaw();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief send the ownShipTrack to all connected Sensors
|
* @brief send the ownShipTrack to all connected Sensors
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "SimCore/Identifier.hpp"
|
#include "SimCore/Identifier.hpp"
|
||||||
#include "SimCore/IdentifierMaker.hpp"
|
#include "SimCore/IdentifierMaker.hpp"
|
||||||
|
#include "SimCore/Messages/SensorTrack.hpp"
|
||||||
#include "SimCore/Messages/SimTrack.hpp"
|
#include "SimCore/Messages/SimTrack.hpp"
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
#include <SimCore/CallBackTimer.hpp>
|
||||||
|
|
||||||
namespace TrackList
|
namespace TrackList
|
||||||
{
|
{
|
||||||
@@ -24,21 +26,36 @@ namespace TrackList
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TrackList();
|
TrackList();
|
||||||
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
~TrackList();
|
||||||
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
TrackList(const TrackList &other);
|
||||||
|
TrackList& operator=(const TrackList & oter);
|
||||||
|
|
||||||
|
void addTrack(std::shared_ptr<SimCore::SensorTrack> Track);
|
||||||
|
std::shared_ptr<SimCore::SensorTrack> getTrack(SimCore::Identifier);
|
||||||
|
|
||||||
void deleteTrack(std::string ID);
|
void deleteTrack(std::string ID);
|
||||||
void deleteTrack(SimCore::Identifier);
|
void deleteTrack(SimCore::Identifier);
|
||||||
std::shared_ptr<SimCore::SimTrack> getTrackBySringID(std::string ID);
|
std::shared_ptr<SimCore::SensorTrack> getTrackBySringID(std::string ID);
|
||||||
|
|
||||||
size_t getSize();
|
size_t getSize();
|
||||||
|
|
||||||
void getJsonTRackList(nlohmann::json &message);
|
void getJsonTRackList(nlohmann::json &message);
|
||||||
|
std::map<std::string, std::shared_ptr<SimCore::SensorTrack>> getTrackStore();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief cheks the trackstore for old tracks to delete
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void checkTrackStore();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::mutex mx_;
|
mutable std::mutex mx_;
|
||||||
std::map<std::string, std::shared_ptr<SimCore::SimTrack>> TrackStore_;
|
std::map<std::string, std::shared_ptr<SimCore::SensorTrack>> TrackStore_;
|
||||||
|
|
||||||
|
/// seconds after the last updated a track gets deleted
|
||||||
|
const int trackNoUpdateTime = 10;
|
||||||
|
|
||||||
|
CallBackTimer timer_;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Submodule libs/KubeControl updated: e38214f4d0...ada77d0e45
Submodule libs/OrderLibrary updated: c3335db37b...c72e6c0d8b
@@ -1,4 +1,4 @@
|
|||||||
#include "DirectCommunicationServer.hpp"
|
#include <DirectCommunicationServer.hpp>
|
||||||
#include "Entities/Movement.hpp"
|
#include "Entities/Movement.hpp"
|
||||||
#include "Entities/SensorManager.hpp"
|
#include "Entities/SensorManager.hpp"
|
||||||
#include "Orders/MoveOrder.hpp"
|
#include "Orders/MoveOrder.hpp"
|
||||||
@@ -56,6 +56,7 @@ namespace Entities
|
|||||||
EntitySide_(EntitySide),
|
EntitySide_(EntitySide),
|
||||||
GroundTruthPort_(GroundTruthPort),
|
GroundTruthPort_(GroundTruthPort),
|
||||||
GroundTruthAddr_(GroundTruthAddr),
|
GroundTruthAddr_(GroundTruthAddr),
|
||||||
|
CommandPort_(CommandPort),
|
||||||
SensorPort_(SensorPort),
|
SensorPort_(SensorPort),
|
||||||
online_(online)
|
online_(online)
|
||||||
|
|
||||||
@@ -79,7 +80,6 @@ namespace Entities
|
|||||||
|
|
||||||
// BroadcastServer_ = std::make_shared<WHISPER::InternalUDPSender>("239.0.0.1", 10000);
|
// BroadcastServer_ = std::make_shared<WHISPER::InternalUDPSender>("239.0.0.1", 10000);
|
||||||
|
|
||||||
// TrackList_ = std::make_unique<TrackList::TrackList>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ namespace Entities
|
|||||||
|
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.setPosition(pos);
|
moveorder.setPosition(pos);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send";
|
LOG_S(INFO)<<"Move Order send";
|
||||||
@@ -109,7 +109,7 @@ namespace Entities
|
|||||||
OwnShipTrack->Speed.setValue(val);
|
OwnShipTrack->Speed.setValue(val);
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.Speed.setValue(val);
|
moveorder.Speed.setValue(val);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send with Speed";
|
LOG_S(INFO)<<"Move Order send with Speed";
|
||||||
@@ -120,7 +120,7 @@ namespace Entities
|
|||||||
OwnShipTrack->Course.setValue(val);
|
OwnShipTrack->Course.setValue(val);
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.Course.setValue(val);
|
moveorder.Course.setValue(val);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send with Course";
|
LOG_S(INFO)<<"Move Order send with Course";
|
||||||
@@ -135,13 +135,9 @@ namespace Entities
|
|||||||
|
|
||||||
void Entity::start()
|
void Entity::start()
|
||||||
{
|
{
|
||||||
|
stopMainLoop_ = false;
|
||||||
stopMainLoop = false;
|
|
||||||
|
|
||||||
|
threads_.emplace_back(std::thread(&Entity::MainLoop,this));
|
||||||
threads.emplace_back(std::thread(&Entity::MainLoop,this));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,18 +156,18 @@ namespace Entities
|
|||||||
SensorManager_->stop();
|
SensorManager_->stop();
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<std::thread>::iterator it = threads.begin(); it != threads.end();)
|
for (std::vector<std::thread>::iterator it = threads_.begin(); it != threads_.end();)
|
||||||
{
|
{
|
||||||
if (it->joinable())
|
if (it->joinable())
|
||||||
{
|
{
|
||||||
|
|
||||||
it->join();
|
it->join();
|
||||||
it = threads.erase(it);
|
it = threads_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_S(ERROR)<< "Remaining Threads: " << threads.size();
|
LOG_S(ERROR)<< "Remaining Threads: " << threads_.size();
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(30000));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(30000));
|
||||||
|
|
||||||
// exit(0);
|
// exit(0);
|
||||||
@@ -184,10 +180,13 @@ namespace Entities
|
|||||||
LOG_S(INFO)<<"__ONLINE__";
|
LOG_S(INFO)<<"__ONLINE__";
|
||||||
MovementPodUUID_ = xg::newGuid().str();
|
MovementPodUUID_ = xg::newGuid().str();
|
||||||
LOG_S(INFO)<<this->OwnShipTrack->getIdentifier().getUUID();
|
LOG_S(INFO)<<this->OwnShipTrack->getIdentifier().getUUID();
|
||||||
kubecontrol::KubePod MovementPod(this->OwnShipTrack->getIdentifier().getUUID(),MovementPodUUID_,"movementimage:latest");
|
std::string MovementImage = "movementimage:latest";
|
||||||
|
std::string component = "MovementCalculation";
|
||||||
|
std::string uuid = this->OwnShipTrack->getIdentifier().getUUID();
|
||||||
|
kubecontrol::KubePod MovementPod(uuid,MovementPodUUID_,MovementImage);
|
||||||
|
|
||||||
MovementPod.setEnvironmentVar("SERVER_IP", SimCore::UtilFunctions::getOwnIP());
|
MovementPod.setEnvironmentVar("SERVER_IP", SimCore::UtilFunctions::getOwnIP());
|
||||||
MovementPod.setComponent("MovementCalculation");
|
MovementPod.setComponent(component);
|
||||||
|
|
||||||
PodController_->startPod(MovementPod);
|
PodController_->startPod(MovementPod);
|
||||||
LOG_S(INFO)<<PodController_->getServerAddress();
|
LOG_S(INFO)<<PodController_->getServerAddress();
|
||||||
@@ -204,7 +203,7 @@ namespace Entities
|
|||||||
{
|
{
|
||||||
LOG_S(INFO)<< "POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
|
LOG_S(INFO)<< "POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
|
||||||
|
|
||||||
MovementWorkerStarted = true;
|
MovementWorkerStarted_ = true;
|
||||||
MovemtServer_->sendMessage(OwnShipTrack->buildMessage());
|
MovemtServer_->sendMessage(OwnShipTrack->buildMessage());
|
||||||
LOG_S(INFO)<< "Initial Message send to MovementWorker";
|
LOG_S(INFO)<< "Initial Message send to MovementWorker";
|
||||||
}
|
}
|
||||||
@@ -214,7 +213,7 @@ namespace Entities
|
|||||||
|
|
||||||
void Entity::handleMovement()
|
void Entity::handleMovement()
|
||||||
{
|
{
|
||||||
if (!MovementWorkerStarted)
|
if (!MovementWorkerStarted_)
|
||||||
{
|
{
|
||||||
startMovementWorker();
|
startMovementWorker();
|
||||||
}else
|
}else
|
||||||
@@ -229,20 +228,20 @@ namespace Entities
|
|||||||
|
|
||||||
if (MovemtServer_->countClients() == 0)
|
if (MovemtServer_->countClients() == 0)
|
||||||
{
|
{
|
||||||
MovementWorkerStarted = false;
|
MovementWorkerStarted_ = false;
|
||||||
LOG_S(WARNING)<<"Movementclient lost";
|
LOG_S(WARNING)<<"Movementclient lost";
|
||||||
}
|
}
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::handleExternalComms(std::string msg)
|
void Entity::handleExternalComms(const std::string &msg)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
WHISPER::Message whisperMsg(msg);
|
WHISPER::Message whisperMsg(msg);
|
||||||
LOG_S(INFO)<<"New Message from TCP Client";
|
// LOG_S(INFO)<<"New Message from TCP Client";
|
||||||
LOG_S(INFO)<<"Message Type is: " << whisperMsg.msgType_;
|
// LOG_S(INFO)<<"Message Type is: " << whisperMsg.msgType_;
|
||||||
|
|
||||||
switch (whisperMsg.msgType_)
|
switch (whisperMsg.msgType_)
|
||||||
{
|
{
|
||||||
@@ -303,8 +302,15 @@ namespace Entities
|
|||||||
}
|
}
|
||||||
if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier())
|
if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier())
|
||||||
{
|
{
|
||||||
|
if (TrackListRequest->requestedFusioned() == true)
|
||||||
|
{
|
||||||
std::string senderUUID = whisperMsg.senderUUID_;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
@@ -339,7 +345,7 @@ namespace Entities
|
|||||||
case SimCore::START:
|
case SimCore::START:
|
||||||
case SimCore::STOP :
|
case SimCore::STOP :
|
||||||
case SimCore::SHUT_DOWN :
|
case SimCore::SHUT_DOWN :
|
||||||
{
|
{
|
||||||
LOG_S(INFO)<<"shutdown received";
|
LOG_S(INFO)<<"shutdown received";
|
||||||
|
|
||||||
this->stop();
|
this->stop();
|
||||||
@@ -355,6 +361,7 @@ namespace Entities
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
DLOG_S(INFO)<<"Message Type is: " << whisperMsg.msgType_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +379,7 @@ namespace Entities
|
|||||||
void Entity::MainLoop()
|
void Entity::MainLoop()
|
||||||
{
|
{
|
||||||
LOG_S(INFO)<< "main loop started";
|
LOG_S(INFO)<< "main loop started";
|
||||||
while (!stopMainLoop)
|
while (!stopMainLoop_)
|
||||||
{
|
{
|
||||||
handleMovement();
|
handleMovement();
|
||||||
childWorker();
|
childWorker();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <SimCore/Messages/SensorData.hpp>
|
#include <SimCore/Messages/SensorData.hpp>
|
||||||
#include "Entities/Tracklist/Tracklist.hpp"
|
#include "Entities/Tracklist/Tracklist.hpp"
|
||||||
#include "SimCore/Identifier.hpp"
|
#include "SimCore/Identifier.hpp"
|
||||||
|
#include "SimCore/Messages/SensorTracklistItem.hpp"
|
||||||
#include "nlohmann/json_fwd.hpp"
|
#include "nlohmann/json_fwd.hpp"
|
||||||
#include <Entities/SensorControl.hpp>
|
#include <Entities/SensorControl.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -17,6 +18,22 @@ namespace Sensor
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SimCore::SensorTracklistItem SensorControl::getSensorTracklistItem()
|
||||||
|
{
|
||||||
|
auto data = std::make_shared<SimCore::SensorData>(this->getID(),this->getName(),this->getIP(),this->getSensorKind());
|
||||||
|
SimCore::SensorTracklistItem item(data);
|
||||||
|
|
||||||
|
for(auto [key, track]: TrackStore.getTrackStore())
|
||||||
|
{
|
||||||
|
item.updateTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Entities
|
|||||||
void SensorManager::startSensor(std::shared_ptr<kubecontrol::KubePod> pod,SimCore::SensorKinds SensorKind)
|
void SensorManager::startSensor(std::shared_ptr<kubecontrol::KubePod> pod,SimCore::SensorKinds SensorKind)
|
||||||
{
|
{
|
||||||
PodController_->startPod(pod);
|
PodController_->startPod(pod);
|
||||||
SensorStore[pod->getUUID()] = std::make_unique<Sensor::SensorControl>(SimCore::Identifier(pod->getUUID()),pod->getName(),pod->getIp(),SensorKind);
|
// SensorStore[pod->getUUID()] = std::make_unique<Sensor::SensorControl>(SimCore::Identifier(pod->getUUID()),pod->getName(),pod->getIp(),SensorKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,6 +87,26 @@ namespace Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Sensor::SensorControl>> SensorManager::getSensorListAsVector()
|
||||||
|
{
|
||||||
|
std::vector<std::shared_ptr<Sensor::SensorControl>> SensorVector;
|
||||||
|
for (auto [key, value] : SensorStore)
|
||||||
|
{
|
||||||
|
SensorVector.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SensorVector;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> SensorManager::getSensorListAsMap()
|
||||||
|
{
|
||||||
|
return SensorStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t SensorManager::getSensorCount()
|
size_t SensorManager::getSensorCount()
|
||||||
{
|
{
|
||||||
return SensorStore.size();
|
return SensorStore.size();
|
||||||
@@ -96,6 +116,7 @@ namespace Entities
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SensorManager::handlSensorMessages(std::string Message)
|
void SensorManager::handlSensorMessages(std::string Message)
|
||||||
{
|
{
|
||||||
WHISPER::Message msg(Message);
|
WHISPER::Message msg(Message);
|
||||||
@@ -129,20 +150,17 @@ namespace Entities
|
|||||||
void SensorManager::updateTracklistForSensor(std::string uuidSensor, std::shared_ptr<SimCore::SensorTrack> track)
|
void SensorManager::updateTracklistForSensor(std::string uuidSensor, std::shared_ptr<SimCore::SensorTrack> track)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto sensor= getSensorByUUID(uuidSensor);
|
auto sensor = getSensorByUUID(uuidSensor);
|
||||||
|
|
||||||
|
|
||||||
if(sensor == nullptr)
|
if(sensor == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
SensorStore[track->getSensorData()->getID().getUUID()] = std::make_unique<Sensor::SensorControl>(track->getSensorData()->getID(),track->getSensorData()->getName(),track->getSensorData()->getIP(),track->getSensorData()->getSensorKind());
|
||||||
|
sensor = getSensorByUUID(uuidSensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor->TrackStore.addTrack(track);
|
sensor->TrackStore.addTrack(track);
|
||||||
// auto it = SensorStore.find(uuidSensor);
|
|
||||||
// if( it != SensorStore.end())
|
|
||||||
// {
|
|
||||||
// it->second->TrackStore.addTrack(std::move(track));
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,29 +187,29 @@ namespace Entities
|
|||||||
nlohmann::json sonar;
|
nlohmann::json sonar;
|
||||||
nlohmann::json visual;
|
nlohmann::json visual;
|
||||||
|
|
||||||
for(const auto& [key, value] : SensorStore )
|
for(const auto& [key, sensorItem] : SensorStore )
|
||||||
{
|
{
|
||||||
|
|
||||||
nlohmann::json sensor;
|
nlohmann::json sensor;
|
||||||
sensor["SensorName"] = value->getName();
|
sensor["SensorName"] = sensorItem->getName();
|
||||||
sensor["SensorID"] = value->getID().getUUID();
|
sensor["SensorID"] = sensorItem->getID().getUUID();
|
||||||
sensor["SensorStatus"] = SimCore::toString(value->getSensorStatus());
|
sensor["SensorStatus"] = SimCore::toString(sensorItem->getSensorStatus());
|
||||||
sensor["SensorEnabled"] = "false";
|
sensor["SensorEnabled"] = "false";
|
||||||
if (value->getSensorStatus() == SimCore::Status::ACTIVE)
|
if (sensorItem->getSensorStatus() == SimCore::Status::ACTIVE)
|
||||||
{
|
{
|
||||||
sensor["SensorEnabled"] = "true";
|
sensor["SensorEnabled"] = "true";
|
||||||
}
|
}
|
||||||
sensor["SensorDamaged"] = "false";
|
sensor["SensorDamaged"] = "false";
|
||||||
if (value->getSensorStatus() == SimCore::Status::DEFEKT || value->getSensorStatus() == SimCore::Status::DEGRADED)
|
if (sensorItem->getSensorStatus() == SimCore::Status::DEFEKT || sensorItem->getSensorStatus() == SimCore::Status::DEGRADED)
|
||||||
{
|
{
|
||||||
sensor["SensorDamaged"] = "true";
|
sensor["SensorDamaged"] = "true";
|
||||||
}
|
}
|
||||||
nlohmann::json contacts;
|
nlohmann::json contacts;
|
||||||
value->TrackStore.getJsonTRackList(contacts);
|
sensorItem->TrackStore.getJsonTRackList(contacts);
|
||||||
sensor["SensorContacts"] = contacts["Entities"];
|
sensor["SensorContacts"] = contacts["Entities"];
|
||||||
|
|
||||||
|
|
||||||
switch (value->getSensorKind()) {
|
switch (sensorItem->getSensorKind()) {
|
||||||
case SimCore::SensorKinds::RADAR:
|
case SimCore::SensorKinds::RADAR:
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -246,12 +264,32 @@ namespace Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<SimCore::TracklistUpdate> SensorManager::getTrackListUpdate()
|
std::unique_ptr<SimCore::TracklistUpdate> SensorManager::getTrackListUpdateFusioned()
|
||||||
{
|
{
|
||||||
|
|
||||||
return std::move(Trackfusion_.getTrackListUpdate(OwnId_));
|
return std::move(Trackfusion_.getTrackListUpdate(OwnId_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<SimCore::SensorTracklistUpdate> SensorManager::getTrackListUpdateRaw()
|
||||||
|
{
|
||||||
|
|
||||||
|
auto Update = std::make_unique<SimCore::SensorTracklistUpdate>(OwnId_);
|
||||||
|
|
||||||
|
|
||||||
|
for(auto [key,item]: SensorStore)
|
||||||
|
{
|
||||||
|
Update->addTrack(item->getSensorTracklistItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Update;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SensorManager::sendOwnShipTrackToSensors()
|
void SensorManager::sendOwnShipTrackToSensors()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include <Entities/Tracklist/Tracklist.hpp>
|
#include <Entities/Tracklist/Tracklist.hpp>
|
||||||
|
#include <chrono>
|
||||||
|
#include "SimCore/Messages/SensorTrack.hpp"
|
||||||
#include "SimCore/Messages/SimTrack.hpp"
|
#include "SimCore/Messages/SimTrack.hpp"
|
||||||
|
|
||||||
|
|
||||||
@@ -6,83 +8,126 @@
|
|||||||
namespace TrackList
|
namespace TrackList
|
||||||
{
|
{
|
||||||
|
|
||||||
TrackList::TrackList()
|
TrackList::TrackList():mx_()
|
||||||
{
|
{
|
||||||
|
|
||||||
TrackStore_ = std::map<std::string, std::shared_ptr<SimCore::SimTrack>>();
|
TrackStore_ = std::map<std::string, std::shared_ptr<SimCore::SensorTrack>>();
|
||||||
|
timer_.start(1000, std::bind(&TrackList::checkTrackStore,this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TrackList::~TrackList()
|
||||||
|
{
|
||||||
|
if (timer_.is_running()) {
|
||||||
|
timer_.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TrackList::TrackList(const TrackList &other):mx_()
|
||||||
|
{
|
||||||
|
this->TrackStore_ = other.TrackStore_;
|
||||||
|
}
|
||||||
|
TrackList& TrackList::operator=(const TrackList & other)
|
||||||
|
{
|
||||||
|
this->TrackStore_ = other.TrackStore_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackList::addTrack(std::shared_ptr<SimCore::SensorTrack> Track)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
|
auto [iterator, inserted] = TrackStore_.try_emplace(Track->getIdentifier().getUUID(),Track);
|
||||||
|
// LOG_S(INFO)<< Track->Name.getValue()<<" was: " << (inserted ? "inserted: " : "ignored: ");
|
||||||
|
if (!inserted) { TrackStore_[Track->getIdentifier().getUUID()] = Track; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
std::shared_ptr<SimCore::SensorTrack> TrackList::getTrack(const SimCore::Identifier ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
|
auto it = TrackStore_.find(ID.getUUID());
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SimCore::SensorTrack> TrackList::getTrackBySringID(std::string ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
|
auto it = TrackStore_.find(ID);
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackList::deleteTrack(std::string ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
auto it = TrackStore_.find(ID);
|
||||||
|
TrackStore_.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackList::deleteTrack(SimCore::Identifier ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
auto it = TrackStore_.find(ID.getUUID());
|
||||||
|
TrackStore_.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::shared_ptr<SimCore::SensorTrack>> TrackList::getTrackStore()
|
||||||
|
{
|
||||||
|
return TrackStore_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackList::addTrack(std::shared_ptr<SimCore::SimTrack> Track)
|
|
||||||
|
void TrackList::getJsonTRackList(nlohmann::json &message)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
try {
|
||||||
|
for (std::map<std::string, std::shared_ptr<SimCore::SensorTrack>>::iterator it=TrackStore_.begin(); it!=TrackStore_.end(); ++it)
|
||||||
|
{
|
||||||
|
nlohmann::json j;
|
||||||
|
j["id"] = it->first;
|
||||||
|
j["Name"] = it->second->Name.getValue();
|
||||||
|
j["Course"] = it->second->Course.getValue();
|
||||||
|
j["Speed"] = it->second->Speed.getValue();
|
||||||
|
j["External"] = false;
|
||||||
|
j["Position"] = {it->second->getPosition().getGeodesicPos()[SimCore::LATITUDE], it->second->getPosition().getGeodesicPos()[SimCore::LONGITUDE]};
|
||||||
|
j["Height"] = it->second->getPosition().getGeodesicPos()[SimCore::HEIGHT];
|
||||||
|
j["Type"] = SimCore::Kind::EntityKindMap[it->second->EntityKind.getValue()];
|
||||||
|
j["Side"] = SimCore::Side::EntitySideMap[it->second->EntitySide.getValue()];
|
||||||
|
|
||||||
|
message["Entities"].push_back(j);
|
||||||
|
}
|
||||||
|
}catch (const std::exception e) {
|
||||||
|
LOG_S(ERROR)<< e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t TrackList::getSize()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
return TrackStore_.size();
|
||||||
auto [iterator, inserted] = TrackStore_.try_emplace(Track->getIdentifier().getUUID(),Track);
|
|
||||||
// LOG_S(INFO)<< Track->Name.getValue()<<" was: " << (inserted ? "inserted: " : "ignored: ");
|
|
||||||
if (!inserted) { TrackStore_[Track->getIdentifier().getUUID()] = Track; }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
std::shared_ptr<SimCore::SimTrack> TrackList::getTrack(const SimCore::Identifier ID)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
|
||||||
|
|
||||||
auto it = TrackStore_.find(ID.getUUID());
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<SimCore::SimTrack> TrackList::getTrackBySringID(std::string ID)
|
void TrackList::checkTrackStore()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
auto it = TrackStore_.find(ID);
|
for (auto iter = TrackStore_.begin(); iter != TrackStore_.end();)
|
||||||
return it->second;
|
{
|
||||||
}
|
|
||||||
|
if(duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - iter->second->getLastUpdateTime()).count() >= trackNoUpdateTime)
|
||||||
void TrackList::deleteTrack(std::string ID)
|
{
|
||||||
{
|
iter = TrackStore_.erase(iter);
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
}else {
|
||||||
auto it = TrackStore_.find(ID);
|
iter++;
|
||||||
TrackStore_.erase(it);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TrackList::deleteTrack(SimCore::Identifier ID)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
|
||||||
auto it = TrackStore_.find(ID.getUUID());
|
|
||||||
TrackStore_.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TrackList::getJsonTRackList(nlohmann::json &message)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
|
||||||
try {
|
|
||||||
for (std::map<std::string, std::shared_ptr<SimCore::SimTrack>>::iterator it=TrackStore_.begin(); it!=TrackStore_.end(); ++it)
|
|
||||||
{
|
|
||||||
nlohmann::json j;
|
|
||||||
j["id"] = it->first;
|
|
||||||
j["Name"] = it->second->Name.getValue();
|
|
||||||
j["Course"] = it->second->Course.getValue();
|
|
||||||
j["Speed"] = it->second->Speed.getValue();
|
|
||||||
j["External"] = false;
|
|
||||||
j["Position"] = {it->second->getPosition().getGeodesicPos()[SimCore::LATITUDE], it->second->getPosition().getGeodesicPos()[SimCore::LONGITUDE]};
|
|
||||||
j["Height"] = it->second->getPosition().getGeodesicPos()[SimCore::HEIGHT];
|
|
||||||
j["Type"] = SimCore::Kind::EntityKindMap[it->second->EntityKind.getValue()];
|
|
||||||
j["Side"] = SimCore::Side::EntitySideMap[it->second->EntitySide.getValue()];
|
|
||||||
|
|
||||||
message["Entities"].push_back(j);
|
|
||||||
}
|
|
||||||
}catch (const std::exception e) {
|
|
||||||
LOG_S(ERROR)<< e.what();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TrackList::getSize()
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
|
||||||
return TrackStore_.size();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,10 @@ SCENARIO("Testing the SimCore SensorManager with local sensors")
|
|||||||
std::string tracklist1 = SensorManager_->getTracklistStringBySensor();
|
std::string tracklist1 = SensorManager_->getTracklistStringBySensor();
|
||||||
std::string tracklist2 = SensorManager_->getTracklistStringFusioned();
|
std::string tracklist2 = SensorManager_->getTracklistStringFusioned();
|
||||||
|
|
||||||
LOG_S(INFO)<<tracklist2;
|
LOG_S(INFO)<<tracklist1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
THEN("check if Track attributes are correct")
|
THEN("check if Track attributes are correct")
|
||||||
{
|
{
|
||||||
@@ -234,7 +237,14 @@ SCENARIO("Testing the SimCore SensorManager with local sensors")
|
|||||||
REQUIRE( j2.size() == 8);
|
REQUIRE( j2.size() == 8);
|
||||||
|
|
||||||
REQUIRE(SensorManager_->getSensorCount() == 4);
|
REQUIRE(SensorManager_->getSensorCount() == 4);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
||||||
|
|
||||||
|
REQUIRE(SensorManager_->getTrackListUpdateRaw()->getSensors().size() == 4);
|
||||||
|
REQUIRE(SensorManager_->getTrackListUpdateRaw()->getSensors().at(0).getTracksCount() == 3);
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
|
||||||
|
|
||||||
|
REQUIRE(SensorManager_->getSensorListAsVector().at(0)->TrackStore.getSize() == 0);
|
||||||
|
|
||||||
|
|
||||||
SensorManager_->stop();
|
SensorManager_->stop();
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ SCENARIO("Testing the SimCore Sensor")
|
|||||||
track->setPosition(pos);
|
track->setPosition(pos);
|
||||||
track->Speed.setValue(speed);
|
track->Speed.setValue(speed);
|
||||||
track->Course.setValue(course);
|
track->Course.setValue(course);
|
||||||
|
auto SensorTrack = std::make_shared<SimCore::SensorTrack>(track);
|
||||||
|
|
||||||
|
|
||||||
SimCore::SensorData Sensor1(SimCore::Identifier(),"ARPA","127.0.0.1", SimCore::SensorKinds::RADAR);
|
SimCore::SensorData Sensor1(SimCore::Identifier(),"ARPA","127.0.0.1", SimCore::SensorKinds::RADAR);
|
||||||
@@ -45,7 +46,7 @@ SCENARIO("Testing the SimCore Sensor")
|
|||||||
|
|
||||||
WHEN("constructing Track Object with data")
|
WHEN("constructing Track Object with data")
|
||||||
{
|
{
|
||||||
List.addTrack(track);
|
List.addTrack(SensorTrack);
|
||||||
THEN("check if Track attributes are correct")
|
THEN("check if Track attributes are correct")
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ SCENARIO("Testing the SimCore Sensor")
|
|||||||
REQUIRE(List.getTrack(id)->Course.getValue() == course);
|
REQUIRE(List.getTrack(id)->Course.getValue() == course);
|
||||||
// REQUIRE(List.getTrack(id)->getSensorCount() == 1);
|
// REQUIRE(List.getTrack(id)->getSensorCount() == 1);
|
||||||
track->Course.setValue(270);
|
track->Course.setValue(270);
|
||||||
List.addTrack(track);
|
List.addTrack(SensorTrack);
|
||||||
// REQUIRE(List.getTrack(id)->Course.getValue() == 270);
|
// REQUIRE(List.getTrack(id)->Course.getValue() == 270);
|
||||||
// REQUIRE(List.getTrack(id)->getSensorCount() == 2);
|
// REQUIRE(List.getTrack(id)->getSensorCount() == 2);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
|
||||||
|
|||||||
Reference in New Issue
Block a user