23#include <QGeoPositionInfo>
26#include "traffic/TrafficDataSource_Abstract.h"
28using namespace Qt::Literals::StringLiterals;
56 [[nodiscard]] QString
dataFormat()
const override {
return u
"FLARM/NMEA"_s; }
65 [[nodiscard]] QString
icon()
const override {
return u
"/icons/material/ic_file_download.svg"_s; }
74 [[nodiscard]]
auto sourceName() const -> QString
override
76 return tr(
"Simulator data");
100 barometricHeight = barAlt;
109 geoInfo.setCoordinate(coordinate);
110 geoInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, 0.0);
119 geoInfo.setAttribute(QGeoPositionInfo::GroundSpeed, GS.
toMPS());
128 geoInfo.setAttribute(QGeoPositionInfo::Direction, TT.
toDEG());
138 delete trafficFactor_DistanceOnly;
139 if (factor !=
nullptr) {
140 factor->setParent(
this );
141 trafficFactor_DistanceOnly = factor;
151 geoInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, vSpeed.
toMPS());
161 factor->setParent(
this);
162 trafficFactors.append(factor);
168 qDeleteAll(trafficFactors);
169 trafficFactors.clear();
175 void sendSimulatorData();
181 QTimer simulatorTimer;
182 QGeoPositionInfo geoInfo;
184 QVector<QPointer<TrafficFactor_WithPosition>> trafficFactors;
185 QPointer<TrafficFactor_DistanceOnly> trafficFactor_DistanceOnly;
TrafficDataSource_Abstract(bool isCanonical, QObject *parent)
Default constructor.
Traffic receiver: Simulator that provides constant data.
void setTrafficFactor_DistanceOnly(Traffic::TrafficFactor_DistanceOnly *factor=nullptr)
Set traffic factor (distance only) that is to be reported by this class.
void setTT(Units::Angle TT)
Set angle that is to be reported by this class as the true track of ownship.
void setVSpeed(Units::Speed vSpeed)
Set speed that is to be reported by this class as the vertical speed of ownship.
void setGS(Units::Speed GS)
Set speed that is to be reported by this class as the ground speed of ownship.
void addTraffic(Traffic::TrafficFactor_WithPosition *factor)
Add a traffic factor that is to be reported by this class.
TrafficDataSource_Simulate(bool isCanonical, QObject *parent)
Default constructor.
QString icon() const override
Getter function for the property with the same name.
void connectToTrafficReceiver() override
Start attempt to connect to traffic receiver.
QString dataFormat() const override
Getter function for the property with the same name.
auto sourceName() const -> QString override
Getter function for the property with the same name.
void setCoordinate(const QGeoCoordinate &coordinate)
Set coordinate that is to be reported by this class as the position of ownship.
void setBarometricHeight(Units::Distance barAlt)
Set distance that is to be reported by this class as the barometric altitude of ownship.
void removeTraffic()
Remove all traffic factors (with position)
void disconnectFromTrafficReceiver() override
Disconnect from traffic receiver.
Traffic factor where only distance is known.
Traffic factor whose precise position is known.
Convenience class for angle computations.
Q_INVOKABLE double toDEG() const
Convert angle to degrees.
Convenience class for distance computations.
Convenience class for speed computations.
Q_INVOKABLE double toMPS() const
Convert to meters per second.