ADD: added Movement calculation and a Tracklist class
This commit is contained in:
62
include/Entities/Tracklist/Tracklist.hpp
Normal file
62
include/Entities/Tracklist/Tracklist.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "SimCore/IdentifierMaker.hpp"
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include <SimCore/Position.hpp>
|
||||
#include <SimCore/Messages/Track.hpp>
|
||||
#include <SimCore/SafeMap.hpp>
|
||||
#include <Entities/Tracklist/TracklistItem.hpp>
|
||||
#include <thread>
|
||||
#include <loguru.hpp>
|
||||
|
||||
namespace TrackList
|
||||
{
|
||||
|
||||
class TrackList
|
||||
{
|
||||
public:
|
||||
TrackList(SimCore::Identifier OwnID);
|
||||
~TrackList();
|
||||
|
||||
void stopSanitizer();
|
||||
|
||||
SimCore::Identifier getTrackID(SimCore::ObjectSource source);
|
||||
|
||||
void addTrack(std::shared_ptr<SimCore::Track> track,SensorData sensorData);
|
||||
|
||||
std::shared_ptr<TracklistItem> getTrack(SimCore::Identifier TrackID);
|
||||
|
||||
std::vector<SimCore::Identifier> getAllIDs();
|
||||
|
||||
size_t size();
|
||||
|
||||
private:
|
||||
|
||||
const SimCore::Identifier OwnID_;
|
||||
|
||||
SimCore::IdentifierMaker IDMaker;
|
||||
|
||||
void tracklistSanitizer();
|
||||
|
||||
void addNewTrack(std::shared_ptr<SimCore::Track> track,SensorData sensorData);
|
||||
|
||||
std::map<std::string, std::shared_ptr<TracklistItem>> TrackList_;
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
std::thread sanitizerThread_;
|
||||
std::atomic_bool sanitizerIsRunning_;
|
||||
std::atomic_bool stopSanitizer_;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
100
include/Entities/Tracklist/TracklistItem.hpp
Normal file
100
include/Entities/Tracklist/TracklistItem.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "SimCore/Messages/Track.hpp"
|
||||
#include "SimCore/SimCore.hpp"
|
||||
#include <SimCore/Position.hpp>
|
||||
#include <chrono>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace TrackList {
|
||||
|
||||
struct SensorData {
|
||||
SimCore::Identifier sensorID;
|
||||
// SimCore::Identifier SensorTrackID;
|
||||
std::string Sensorname;
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline bool operator==(const SensorData& lhs, const SensorData& rhs)
|
||||
{
|
||||
return lhs.sensorID == rhs.sensorID;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TracklistItem
|
||||
{
|
||||
public:
|
||||
TracklistItem(std::shared_ptr<SimCore::Track> track,SensorData sensorData);
|
||||
|
||||
SimCore::Identifier getID();
|
||||
|
||||
void setPosition(SimCore::Position position);
|
||||
SimCore::Position getPosition();
|
||||
|
||||
void setSpeed(double speed);
|
||||
double getSpeed();
|
||||
|
||||
void setCourse(double course);
|
||||
double getCourse();
|
||||
|
||||
void setPitch(double pitch);
|
||||
double getpitch();
|
||||
|
||||
double getBearing();
|
||||
double getRange();
|
||||
|
||||
SimCore::ObjectSource getObjectSource();
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> getLastUpdateTimestamp();
|
||||
|
||||
void updateTrack(std::shared_ptr<SimCore::Track> track,SensorData sensorData);
|
||||
|
||||
bool checkIfSensorIDIsIn(SimCore::Identifier SensorTrackID);
|
||||
|
||||
bool isSensorIDKnown(SimCore::Identifier);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
const SimCore::Identifier trackID_;
|
||||
|
||||
/// position of the track
|
||||
SimCore::Position position_;
|
||||
/// speed the track
|
||||
double speed_ = 0;
|
||||
/// course of the track
|
||||
double course_ = 0;
|
||||
|
||||
double pitch_ = 0;
|
||||
|
||||
/// bearing
|
||||
double bearing_;
|
||||
///range in meters
|
||||
double range_;
|
||||
//environment (AIR,SURFACE,SUBSURFACE,SPACE)
|
||||
SimCore::EntityKind environemnt_;
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> lastUpdateTimestamp_;
|
||||
|
||||
SimCore::ObjectSource ObjectSource_;
|
||||
|
||||
std::vector<SensorData> SensorList;
|
||||
|
||||
|
||||
bool isSensorinSensorlist(SensorData sensorData);
|
||||
|
||||
void addSensorDataToSensorList(SensorData sensorData);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user