rename the files and use the new interface to communicate with the backend
This commit is contained in:
@@ -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