rename the files and use the new interface to communicate with the backend
This commit is contained in:
@@ -32,7 +32,7 @@ SET(SOURCE_FILES
|
||||
)
|
||||
|
||||
SET(SOURCE_COM_FILES
|
||||
com/AircraftReporter.cpp
|
||||
com/BackendNotification.cpp
|
||||
com/AircraftScheduler.cpp
|
||||
com/ZmqContext.cpp
|
||||
com/ZmqContext.h
|
||||
@@ -51,7 +51,7 @@ SET(SOURCE_FILES_RES
|
||||
)
|
||||
|
||||
SET(INCLUDE_COM_FILES
|
||||
${CMAKE_SOURCE_DIR}/include/aman/com/AircraftReporter.h
|
||||
${CMAKE_SOURCE_DIR}/include/aman/com/BackendNotification.h
|
||||
${CMAKE_SOURCE_DIR}/include/aman/com/AircraftScheduler.h
|
||||
)
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include <Shlwapi.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <aman/com/AircraftReporter.h>
|
||||
#include <aman/com/AircraftScheduler.h>
|
||||
#include <aman/com/BackendNotification.h>
|
||||
#include <aman/config/CommunicationFileFormat.h>
|
||||
#include <aman/config/IdentifierFileFormat.h>
|
||||
#include <aman/helper/String.h>
|
||||
@@ -76,7 +76,7 @@ PlugIn::PlugIn() :
|
||||
|
||||
PlugIn::~PlugIn() noexcept {
|
||||
AircraftScheduler::instance().deinitialize();
|
||||
AircraftReporter::instance().deinitialize();
|
||||
BackendNotification::instance().deinitialize();
|
||||
ZmqContext::instance().deinitialize();
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
@@ -260,6 +260,6 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
|
||||
report.set_allocated_position(coordinate);
|
||||
|
||||
/* send the report */
|
||||
if (false == AircraftReporter::instance().send(report))
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "ERROR", ("Unable to send a report for " + aircraft->callsign()).c_str(), true, true, true, true, true);
|
||||
if (false == BackendNotification::instance().send(update))
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to send a new aircraft report update", true, true, true, true, true);
|
||||
}
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
* Author:
|
||||
* Sven Czarnian <devel@svcz.de>
|
||||
* Brief:
|
||||
* Implements the aircraft reporter
|
||||
* Implements the backend notification
|
||||
* Copyright:
|
||||
* 2021 Sven Czarnian
|
||||
* License:
|
||||
* GNU General Public License v3 (GPLv3)
|
||||
*/
|
||||
|
||||
#include <aman/com/AircraftReporter.h>
|
||||
#include <aman/com/BackendNotification.h>
|
||||
#include <aman/helper/String.h>
|
||||
|
||||
#include "ZmqContext.h"
|
||||
|
||||
using namespace aman;
|
||||
|
||||
AircraftReporter::AircraftReporter() noexcept :
|
||||
BackendNotification::BackendNotification() noexcept :
|
||||
m_socket() { }
|
||||
|
||||
bool AircraftReporter::initialize(const Communication& configuration) {
|
||||
bool BackendNotification::initialize(const Communication& configuration) {
|
||||
if (nullptr != this->m_socket)
|
||||
return true;
|
||||
if (false == configuration.valid)
|
||||
@@ -48,7 +48,7 @@ bool AircraftReporter::initialize(const Communication& configuration) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AircraftReporter::deinitialize() {
|
||||
bool BackendNotification::deinitialize() {
|
||||
if (nullptr == this->m_socket)
|
||||
return true;
|
||||
|
||||
@@ -58,20 +58,14 @@ bool AircraftReporter::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AircraftReporter::initialized() const noexcept {
|
||||
bool BackendNotification::initialized() const noexcept {
|
||||
return nullptr != this->m_socket;
|
||||
}
|
||||
|
||||
bool AircraftReporter::send(aman::AircraftReport& report) {
|
||||
bool BackendNotification::send(aman::AircraftUpdate& report) {
|
||||
bool retval = false;
|
||||
|
||||
if (nullptr != this->m_socket) {
|
||||
/* set the report time */
|
||||
std::stringstream stream;
|
||||
auto reportTime = std::chrono::utc_clock::now();
|
||||
stream << std::format("{0:%Y%m%d%H%M%S}", reportTime);
|
||||
report.set_reporttime(String::splitString(stream.str(), ".")[0]);
|
||||
|
||||
/* serialize the report */
|
||||
std::string serialized = report.SerializeAsString();
|
||||
zmq::message_t message(serialized.size());
|
||||
@@ -90,7 +84,7 @@ bool AircraftReporter::send(aman::AircraftReport& report) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
AircraftReporter& AircraftReporter::instance() noexcept {
|
||||
static AircraftReporter __instance;
|
||||
BackendNotification& BackendNotification::instance() noexcept {
|
||||
static BackendNotification __instance;
|
||||
return __instance;
|
||||
}
|
||||
Reference in New Issue
Block a user