ADD: updated Sensor class

This commit is contained in:
Henry Winkel
2023-11-08 15:04:58 +01:00
parent 44f5ce09de
commit ab32c5e8df
3 changed files with 190 additions and 205 deletions

View File

@@ -1,6 +1,8 @@
#pragma once
#include "DirectCommunicationClient.hpp"
#include "SimCore/Messages/SimTrack.hpp"
#include "WHISPER/InternalUDPListener.hpp"
#include <WHISPER/InternalUDPService.hpp>
#include <SimCore/Identifier.hpp>
@@ -9,66 +11,68 @@
#include <SimCore/SimCore.hpp>
#include <SimCore/Identifier.hpp>
#include <SimCore/Position.hpp>
#include <atomic>
#include <memory>
#include <string>
#include <thread>
namespace Entities {
class Sensor {
public:
Sensor(SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress);
~Sensor();
Sensor(
SimCore::Identifier OwnID,
SimCore::Identifier OwnShipID,
SimCore::SensorKinds SensorKind,
std::string GroundTruthAddress,
std::uint32_t GroundTruthPort,
std::uint32_t ParentPort,
std::string ParentIPAddress);
void start();
void stop();
protected:
std::shared_ptr<WHISPER::threadSafeQueue<std::shared_ptr<SimCore::SimTrack>>> incommingTrackMessages = nullptr;
virtual void specificSensorCalculations(std::unique_ptr<SimCore::SimTrack> track) = 0;
std::shared_ptr<SimCore::SimTrack> OwnShipTrack_ = nullptr;
const SimCore::Identifier OwnID_;
const SimCore::Identifier OwnShipID;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingGroundThruthMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> outgoingGroundThruthMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingParentMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> outgoingParentMessages = nullptr;
virtual void specificSensorCalculations() = 0;
virtual void specificReloadCharacteristicts() = 0;
std::shared_ptr<SimCore::Position> ownShipPosition_ = nullptr;
SimCore::Identifier OwnID_;
SimCore::SensorKinds SensorKind_;
std::shared_ptr<WHISPER::threadSafeQueue<std::shared_ptr<SimCore::SimTrack>>> recognisedTracks_ = nullptr;
private:
SimCore::Identifier ParentID_;
SimCore::SensorKinds SensorKind_;
std::uint32_t GroundTruthPort_;
std::string GroundTruthAddr_;
std::uint32_t ParentPort_;
std::string ParentIPAddress_;
std::shared_ptr<WHISPER::InternalUDPService> GroundTruthUDPService_ = nullptr;
std::shared_ptr<WHISPER::InternalUDPService> ParentUDPService_ = nullptr;
std::unique_ptr<WHISPER::InternalUDPListener> GroundTruthUDPListener_;
void groundThruthData();
void parentData();
void SensorCalculations();
void ReloadCharacteristicts();
std::atomic<bool> stopReceivingGroundThruth = false;
std::atomic<bool> ReceivingGroundThruthIsRunnung = false;
std::atomic<bool> stopsendCalculatedData = false;
std::atomic<bool> sendCalculatedDataIsRunnung = false;
std::atomic<bool> stopCalculationData = false;
std::atomic<bool> CalculationIsRunnung = false;
std::unique_ptr<DirectCommunication::DirectCommunicationClient> client_;
std::thread receiveGroundTruthThread;
std::thread sendCalculatedDataThread;
std::thread sensorCalculationThread;
std::thread UpdateOwnShipThread_;
std::atomic_bool stopOwnShipUpdater_ = false;
void handleGroundThruthMessage(std::string msg);
void updateOwnShipFunction();
void handlServerMessages(std::string msg);
void HandleOrders(WHISPER::Message WHmsg);
void setupOwnShip(std::shared_ptr<SimCore::SimTrack> ownShipTracK);
};