use only one backend and adapt to the new communication structure
avoid empty messages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @brief Defines the backend notification module to communicate with the backend
|
||||
* @file aman/com/BackendNotification.h
|
||||
* @brief Defines the backend module to communicate with the backend
|
||||
* @file aman/com/Backend.h
|
||||
* @author Sven Czarnian <devel@svcz.de>
|
||||
* @copyright Copyright 2021 Sven Czarnian
|
||||
* @license This project is published under the GNU General Public License v3 (GPLv3)
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
namespace aman {
|
||||
/**
|
||||
* @brief Defines the bakcend notification class which sends aircraft information to the backend
|
||||
* @brief Defines the bakcend class which sends and receives aircraft information to and from the backend
|
||||
* @ingroup com
|
||||
*/
|
||||
class BackendNotification {
|
||||
class Backend {
|
||||
private:
|
||||
std::unique_ptr<zmq::socket_t> m_socket;
|
||||
|
||||
BackendNotification() noexcept;
|
||||
Backend() noexcept;
|
||||
|
||||
template <typename T>
|
||||
bool setSocketKey(const std::string& key, T entry) {
|
||||
@@ -38,11 +38,13 @@ namespace aman {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<aman::AircraftSequence> receiveSequence();
|
||||
|
||||
public:
|
||||
BackendNotification(const BackendNotification&) = delete;
|
||||
BackendNotification(BackendNotification&&) = delete;
|
||||
BackendNotification& operator=(const BackendNotification&) = delete;
|
||||
BackendNotification& operator=(BackendNotification&&) = delete;
|
||||
Backend(const Backend&) = delete;
|
||||
Backend(Backend&&) = delete;
|
||||
Backend& operator=(const Backend&) = delete;
|
||||
Backend& operator=(Backend&&) = delete;
|
||||
|
||||
/**
|
||||
* @brief Initializes the aircraft reporter
|
||||
@@ -62,13 +64,13 @@ namespace aman {
|
||||
/**
|
||||
* @brief Sends a new message to the backend
|
||||
* @param[in] report The new aircraft update
|
||||
* @return True if the report is sent, else false
|
||||
* @return Receives the current sequence of the airport
|
||||
*/
|
||||
bool send(aman::AircraftUpdate& report);
|
||||
std::shared_ptr<aman::AircraftSequence> update(aman::AircraftUpdate& report);
|
||||
/**
|
||||
* @brief Returns the reporter instance
|
||||
* @return The system-wide instance
|
||||
*/
|
||||
static BackendNotification& instance() noexcept;
|
||||
static Backend& instance() noexcept;
|
||||
};
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* @brief Defines the aircraft scheduling notifier module to receive plans from the backend
|
||||
* @file aman/com/BackendReceiver.h
|
||||
* @author Sven Czarnian <devel@svcz.de>
|
||||
* @copyright Copyright 2021 Sven Czarnian
|
||||
* @license This project is published under the GNU General Public License v3 (GPLv3)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <zmq.hpp>
|
||||
|
||||
#include <aman/types/Communication.h>
|
||||
|
||||
#pragma warning(push, 0)
|
||||
#include "protobuf/Communication.pb.h"
|
||||
#pragma warning(pop)
|
||||
|
||||
namespace aman {
|
||||
/**
|
||||
* @brief Defines the aircraft scheduling notification class to receive scheduling sequences
|
||||
* @ingroup com
|
||||
*/
|
||||
class BackendReceiver {
|
||||
private:
|
||||
std::unique_ptr<zmq::socket_t> m_socket;
|
||||
std::thread m_receiverThread;
|
||||
std::atomic_bool m_stopReceiver;
|
||||
std::list<std::shared_ptr<aman::AircraftSequence>> m_sequences;
|
||||
std::mutex m_sequencesLock;
|
||||
|
||||
BackendReceiver() noexcept;
|
||||
|
||||
template <typename T>
|
||||
bool setSocketKey(const std::string& key, T entry) {
|
||||
try {
|
||||
this->m_socket->set(entry, key);
|
||||
return true;
|
||||
}
|
||||
catch (std::exception&) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void receiveSequence();
|
||||
void run();
|
||||
|
||||
public:
|
||||
BackendReceiver(const BackendReceiver&) = delete;
|
||||
BackendReceiver(BackendReceiver&&) = delete;
|
||||
BackendReceiver& operator=(const BackendReceiver&) = delete;
|
||||
BackendReceiver& operator=(BackendReceiver&&) = delete;
|
||||
|
||||
/**
|
||||
* @brief Initializes the aircraft scheduler
|
||||
* @param[in] configuration The current AMAM communication configuration
|
||||
* @return True if the initialization is done, else false
|
||||
*/
|
||||
bool initialize(const Communication& configuration);
|
||||
/**
|
||||
* @brief Terminates the scheduler connection
|
||||
*/
|
||||
bool deinitialize();
|
||||
/**
|
||||
* @brief Checks if the scheduler is initialized
|
||||
* @return True if it is initialized, else false
|
||||
*/
|
||||
bool initialized() const noexcept;
|
||||
/**
|
||||
* @brief Returns the current sequence of the receiver queue
|
||||
* @return The sequence queue
|
||||
*/
|
||||
std::shared_ptr<aman::AircraftSequence> receive();
|
||||
/**
|
||||
* @brief Returns the scheduling instance
|
||||
* @return The system-wide instance
|
||||
*/
|
||||
static BackendReceiver& instance() noexcept;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user