122 lines
2.9 KiB
C++
122 lines
2.9 KiB
C++
#pragma once
|
|
|
|
|
|
|
|
#include "DirectCommunicationServer.hpp"
|
|
#include "Entities/Movement.hpp"
|
|
#include "SimCore/Messages/SimTrack.hpp"
|
|
#include "SimCore/Orientation.hpp"
|
|
#include "SimCore/SafeMap.hpp"
|
|
#include "SimCore/SimCore.hpp"
|
|
#include "kubecontrol/PodController.hpp"
|
|
|
|
#include <WHISPER/InternalUDPService.hpp>
|
|
#include <WHISPER/InternalUDPSender.hpp>
|
|
#include <WHISPER/InternalUDPListener.hpp>
|
|
|
|
#include <WHISPER/Messages/Message.hpp>
|
|
#include <WHISPER/threadSafeQueue.hpp>
|
|
#include <SimCore/Identifier.hpp>
|
|
#include <SimCore/Position.hpp>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <atomic>
|
|
#include <chrono>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <utility>
|
|
|
|
|
|
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 {
|
|
public:
|
|
Entity(const SimCore::Identifier OwnID,
|
|
std::string EnttityName,
|
|
WHISPER::SourceType OwnType,
|
|
SimCore::EntityKind EntityKind,
|
|
std::uint32_t GroundTruthPort,
|
|
ushort CommandPort,
|
|
bool online);
|
|
~Entity();
|
|
|
|
void start();
|
|
void stop();
|
|
void setPosition(SimCore::Position);
|
|
void setSpeed(double speed);
|
|
void setCourse(double course);
|
|
void setPitch( double pitch);
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual void childWorker() = 0;
|
|
|
|
|
|
protected:
|
|
|
|
std::shared_ptr<SimCore::SimTrack> OwnShipTrack = nullptr;
|
|
|
|
std::string EntityName_;
|
|
SimCore::EntityKind EntityKind_;
|
|
|
|
ushort MovemntWorkerPort_;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
bool online_;
|
|
|
|
std::vector<std::thread> threads;
|
|
|
|
std::atomic<bool> stopMainLoop = false;
|
|
void MainLoop();
|
|
|
|
|
|
void startMovementWorker();
|
|
std::atomic<bool> MovementWorkerStarted = false;
|
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> MovemtServer_ = nullptr;
|
|
void handleMovement();
|
|
|
|
|
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> CommandCommsServer_ = nullptr;
|
|
|
|
void handleExternalComms(std::string msg);
|
|
|
|
|
|
|
|
void startSensor();
|
|
|
|
|
|
std::unique_ptr<kubecontrol::PodController> PodController_;
|
|
|
|
|
|
std::shared_ptr<std::list<Entities::SensorClientData>> SensorStore_;
|
|
|
|
std::shared_ptr<SimCore::SafeMap<SimCore::Identifier, std::shared_ptr< SimCore::SimTrack>>> Trackstore_;
|
|
|
|
|
|
};
|
|
} |