|
@@ -131,11 +131,7 @@ aman::Aircraft* PlugIn::generateAircraftMessage(const EuroScopePlugIn::CRadarTar
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarget) {
|
|
|
- /* do nothing if the reporter is not initialized and ignore invalid targets */
|
|
|
- if (false == AircraftReporter::instance().initialized() || false == radarTarget.IsValid())
|
|
|
- return;
|
|
|
-
|
|
|
+void PlugIn::generateAircraftReportMessage(const EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report) {
|
|
|
auto flightPlan = radarTarget.GetCorrelatedFlightPlan();
|
|
|
|
|
|
/* ignore invalid flightplans */
|
|
@@ -178,26 +174,25 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
|
|
|
coordinate->set_longitude(radarTarget.GetPosition().GetPosition().m_Longitude);
|
|
|
|
|
|
/* create the report */
|
|
|
- aman::AircraftReport report;
|
|
|
switch (this->ControllerMyself().GetFacility()) {
|
|
|
case 1:
|
|
|
case 6:
|
|
|
- report.set_reportedby(aman::AircraftReport::CENTER);
|
|
|
+ report->set_reportedby(aman::AircraftReport::CENTER);
|
|
|
break;
|
|
|
case 2:
|
|
|
- report.set_reportedby(aman::AircraftReport::DELIVERY);
|
|
|
+ report->set_reportedby(aman::AircraftReport::DELIVERY);
|
|
|
break;
|
|
|
case 3:
|
|
|
- report.set_reportedby(aman::AircraftReport::GROUND);
|
|
|
+ report->set_reportedby(aman::AircraftReport::GROUND);
|
|
|
break;
|
|
|
case 4:
|
|
|
- report.set_reportedby(aman::AircraftReport::TOWER);
|
|
|
+ report->set_reportedby(aman::AircraftReport::TOWER);
|
|
|
break;
|
|
|
case 5:
|
|
|
- report.set_reportedby(aman::AircraftReport::APPROACH);
|
|
|
+ report->set_reportedby(aman::AircraftReport::APPROACH);
|
|
|
break;
|
|
|
default:
|
|
|
- report.set_reportedby(aman::AircraftReport::UNKNOWN);
|
|
|
+ report->set_reportedby(aman::AircraftReport::UNKNOWN);
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -221,7 +216,7 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
|
|
|
if (1.0f >= flightPlan.GetExtractedRoute().GetPointPosition(i).DistanceTo(position)) {
|
|
|
iafPosition = flightPlan.GetExtractedRoute().GetPointPosition(i);
|
|
|
iafName = flightPlan.GetExtractedRoute().GetPointName(i);
|
|
|
- report.set_initialapproachfix(iafName);
|
|
|
+ report->set_initialapproachfix(iafName);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -253,12 +248,18 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
|
|
|
}
|
|
|
if (0.01f >= std::abs(distanceToIaf))
|
|
|
distanceToIaf = iafDistance;
|
|
|
- report.set_distancetoiaf(static_cast<int>(std::round(distanceToIaf)));
|
|
|
+ report->set_distancetoiaf(static_cast<int>(std::round(distanceToIaf)));
|
|
|
}
|
|
|
- report.set_destination(std::string(destination));
|
|
|
- report.set_allocated_aircraft(aircraft);
|
|
|
- report.set_allocated_dynamics(dynamics);
|
|
|
- report.set_allocated_position(coordinate);
|
|
|
+ report->set_destination(std::string(destination));
|
|
|
+ report->set_allocated_aircraft(aircraft);
|
|
|
+ report->set_allocated_dynamics(dynamics);
|
|
|
+ report->set_allocated_position(coordinate);
|
|
|
+
|
|
|
+ /* 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]);
|
|
|
|
|
|
/* send the report */
|
|
|
if (false == BackendNotification::instance().send(update))
|