use only one backend and adapt to the new communication structure
avoid empty messages
This commit is contained in:
@@ -15,11 +15,10 @@
|
||||
#include <Shlwapi.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <aman/com/BackendReceiver.h>
|
||||
#include <aman/com/BackendNotification.h>
|
||||
#include <curl/curl.h>
|
||||
#include <json/json.h>
|
||||
|
||||
#include <aman/com/Backend.h>
|
||||
#include <aman/config/CommunicationFileFormat.h>
|
||||
#include <aman/config/IdentifierFileFormat.h>
|
||||
#include <aman/helper/String.h>
|
||||
@@ -81,22 +80,14 @@ PlugIn::PlugIn() :
|
||||
|
||||
ZmqContext::instance().initialize();
|
||||
|
||||
if (false == BackendNotification::instance().initialize(this->m_configuration)) {
|
||||
if (false == Backend::instance().initialize(this->m_configuration))
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to initialize the reporter-connection to the backend", true, true, true, true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (false == BackendReceiver::instance().initialize(this->m_configuration)) {
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to initialize the scheduling-connection to the backend", true, true, true, true, true);
|
||||
BackendNotification::instance().deinitialize();
|
||||
return;
|
||||
}
|
||||
this->validateBackendData();
|
||||
}
|
||||
|
||||
PlugIn::~PlugIn() noexcept {
|
||||
BackendReceiver::instance().deinitialize();
|
||||
BackendNotification::instance().deinitialize();
|
||||
Backend::instance().deinitialize();
|
||||
ZmqContext::instance().deinitialize();
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
@@ -356,7 +347,9 @@ void PlugIn::generateAircraftReportMessage(const EuroScopePlugIn::CRadarTarget&
|
||||
|
||||
void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarget) {
|
||||
/* do nothing if the reporter is not initialized and ignore invalid targets */
|
||||
if (false == BackendNotification::instance().initialized() || false == radarTarget.IsValid())
|
||||
if (false == this->m_compatible || false == Backend::instance().initialized() || false == radarTarget.IsValid())
|
||||
return;
|
||||
if (false == radarTarget.GetCorrelatedFlightPlan().GetTrackingControllerIsMe())
|
||||
return;
|
||||
|
||||
std::lock_guard guard(this->m_updateQueueLock);
|
||||
@@ -364,17 +357,19 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
|
||||
}
|
||||
|
||||
void PlugIn::OnTimer(int counter) {
|
||||
if (false == BackendNotification::instance().initialized() || 0 != (counter % 10))
|
||||
if (false == this->m_compatible || false == Backend::instance().initialized() || 0 != (counter % 10))
|
||||
return;
|
||||
|
||||
this->m_updateQueueLock.lock();
|
||||
aman::AircraftUpdate update;
|
||||
bool inserted = false;
|
||||
|
||||
for (auto target = this->RadarTargetSelectFirst(); true == target.IsValid(); target = this->RadarTargetSelectNext(target)) {
|
||||
auto it = std::find(this->m_updateQueue.cbegin(), this->m_updateQueue.cend(), target.GetCallsign());
|
||||
if (this->m_updateQueue.cend() != it) {
|
||||
auto report = update.add_reports();
|
||||
this->generateAircraftReportMessage(target, report);
|
||||
inserted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +377,6 @@ void PlugIn::OnTimer(int counter) {
|
||||
this->m_updateQueueLock.unlock();
|
||||
|
||||
/* send the report */
|
||||
if (false == BackendNotification::instance().send(update))
|
||||
if (true == inserted && nullptr != Backend::instance().update(update))
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to send a new aircraft report update", true, true, true, true, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user