ADD: added libs; added CMakeLists.txt; added framework of the app

This commit is contained in:
Henry Winkel
2022-09-15 11:15:11 +02:00
parent b7050044e5
commit 57c69f5e01
5 changed files with 310 additions and 18 deletions

View File

@@ -0,0 +1,93 @@
#ifndef __SIMCONTROL__
#define __SIMCONTROL__
#include "CommService/Message.hpp"
#include <iostream>
#include <atomic>
#include <cstdint>
#include <memory>
#include <thread>
#include <mutex>
#include <queue>
#include <CommService/CommService.hpp>
namespace SimControl {
class SimControl : public std::enable_shared_from_this<SimControl> {
public:
SimControl(const std::string &addr,const std::int16_t port):
// UDPInboundQueue_(std::make_shared<std::queue<std::string>>()),
// UDPOutboundQueue_(std::make_shared<std::queue<std::string>>()),
isMainThreadRunning_(false),
stopMainThread_(false),
isCommServiceThreadRunning_(false),
stopCommServiceThread_(false),
CommServiceThread(nullptr),
MainFunctionThread_(nullptr)
{
OutgoingMessageQueue_ = std::make_shared<ThreadsafeQueue<CommService::Message>>();
IncommingMessageQueue_ = nullptr;
}
void start();
void stop();
private:
std::unique_ptr<std::thread> CommServiceThread = nullptr;
std::unique_ptr<std::thread> MainFunctionThread_ = nullptr;
std::shared_ptr<std::queue<std::string>> UDPInboundQueue_ = nullptr;
std::shared_ptr<std::queue<std::string>> UDPOutboundQueue_ = nullptr;
std::atomic<bool> isCommServiceThreadRunning_;
std::atomic<bool> stopCommServiceThread_;
std::atomic<bool> isMainThreadRunning_;
std::atomic<bool> stopMainThread_;
// std::mutex mutexInboundQueue_;
// std::mutex mutexOutboundQueue_;
///pointer to the commservice
std::unique_ptr<CommService::CommService> CommService_;
///threadsafe message queue from CommService
std::shared_ptr<ThreadsafeQueue<CommService::Message>> IncommingMessageQueue_;
std::shared_ptr<ThreadsafeQueue<CommService::Message>> OutgoingMessageQueue_;
void startMainFunction_();
void stopMainFunction_();
void startCommService_();
void stopCommService_();
void CommServiceFunction_();
void MainFunction_();
};
}
#endif