|
@@ -34,7 +34,10 @@ PlugIn::PlugIn() :
|
|
|
PLUGIN_VERSION,
|
|
|
PLUGIN_DEVELOPER,
|
|
|
PLUGIN_COPYRIGHT),
|
|
|
- m_configuration() {
|
|
|
+ m_configuration(),
|
|
|
+ m_screen(),
|
|
|
+ m_updateQueueLock(),
|
|
|
+ m_updateQueue() {
|
|
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
|
|
|
|
this->DisplayUserMessage(PLUGIN_NAME, "INFO", (std::string("Loaded ") + PLUGIN_NAME + " " + PLUGIN_VERSION).c_str(), true, true, false, false, false);
|
|
@@ -201,8 +204,8 @@ void PlugIn::generateAircraftReportMessage(const EuroScopePlugIn::CRadarTarget&
|
|
|
std::string iafName;
|
|
|
|
|
|
for (auto element = this->SectorFileElementSelectFirst(EuroScopePlugIn::SECTOR_ELEMENT_STAR);
|
|
|
- true == element.IsValid();
|
|
|
- element = this->SectorFileElementSelectNext(element, EuroScopePlugIn::SECTOR_ELEMENT_STAR))
|
|
|
+ true == element.IsValid();
|
|
|
+ element = this->SectorFileElementSelectNext(element, EuroScopePlugIn::SECTOR_ELEMENT_STAR))
|
|
|
{
|
|
|
auto split = String::splitString(element.GetName(), " ");
|
|
|
|
|
@@ -260,6 +263,34 @@ void PlugIn::generateAircraftReportMessage(const EuroScopePlugIn::CRadarTarget&
|
|
|
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]);
|
|
|
+}
|
|
|
+
|
|
|
+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())
|
|
|
+ return;
|
|
|
+
|
|
|
+ std::lock_guard guard(this->m_updateQueueLock);
|
|
|
+ this->m_updateQueue.push_back(radarTarget.GetCallsign());
|
|
|
+}
|
|
|
+
|
|
|
+void PlugIn::OnTimer(int counter) {
|
|
|
+ if (false == BackendNotification::instance().initialized() || 0 != (counter % 10))
|
|
|
+ return;
|
|
|
+
|
|
|
+ this->m_updateQueueLock.lock();
|
|
|
+ aman::AircraftUpdate update;
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this->m_updateQueue.clear();
|
|
|
+ this->m_updateQueueLock.unlock();
|
|
|
|
|
|
/* send the report */
|
|
|
if (false == BackendNotification::instance().send(update))
|