10#include <QtCore/QObject>
11#include <QtCore/QPointer>
12#include <QtCore/QString>
13#include <QtQmlIntegration/QtQmlIntegration>
37#ifndef QGC_NO_SERIAL_LINK
48 QML_VALUE_TYPE(gpsSerialPortEntry)
70 QML_UNCREATABLE(
"Managed by GPSManager")
71 Q_MOC_INCLUDE(
"GPSReceiverFactGroup.h")
159#ifdef QGC_NO_SERIAL_LINK
223 void _onGPSConnect();
224 void _onReceiverDetected();
232 bool hasReceiver =
false;
237 bool reconnecting =
false;
240 bool forwardingCorrections =
false;
241 bool operator==(
const ReceiverState&)
const =
default;
247 quint64 configurationRevision = 0;
248 bool persistentChangesAllowed =
false;
249 QString errorMessage;
250 ReceiverState receiver;
253 int _activeManufacturer()
const;
255 void setConnectionError(
const QString& message)
override { _setError(message); }
257 void endConnection(
bool clearError)
override;
258 bool connectTcp(
const QString& host, quint16 port,
GPSType type,
bool allowPersistentChanges)
override;
259 bool connectUdp(quint16 port,
GPSType type)
override;
260#ifndef QGC_NO_SERIAL_LINK
261 bool connectSerial(
const QString& device,
GPSType type, uint32_t baudRate,
bool allowPersistentChanges,
263 bool serialPortAvailable(
const QString& device)
const override;
264 QStringList rtkReceiverPorts()
const override;
267 void _onSerialPortsEnumerated(
const QStringList& devices);
268 void _updateSerialPortEntries();
272 const QString& sourceInstance, uint32_t baudRate,
bool allowPersistentChanges,
273 const QString& serialDevice = {},
const QString& endpoint = {});
276 void _retireSession();
278 void _joinRetiredWorkers();
280 void _setError(
const QString& message = {}) { _errorMessage = message; }
283 void _updateOutputOverflow(uint64_t receiptUs);
284 void _setPersistentChangesAllowed(
bool allowed);
286 void _updateLabels();
288 void _clearStaleSolution();
289 ReceiverState _receiverState()
const;
296 QList<QPointer<GPSReceiverWorker>> _retiredWorkers;
297 const QPointer<GPSCorrectionManager> _correctionManager;
298 const QPointer<PositionManager> _positionManager;
303 quint64 _sessionCount = 0;
304 QString _errorMessage;
305 QString _summaryLabel;
307 QString _outputOverflowWarning;
308 uint64_t _outputOverflowUs = 0;
309 std::unique_ptr<GPSReceiverConnectionPolicy> _connection;
312 quint64 _configurationRevision = 0;
314 bool _destroying =
false;
315 bool _persistentChangesAllowed =
false;
316 QList<GPSSerialPortEntry> _serialPortEntries;
317#ifndef QGC_NO_SERIAL_LINK
318 const QPointer<SerialPortManager> _serialPorts;
321 QHash<QString, std::weak_ptr<const SerialPortManager::Reservation>> _serialClaims;
322 std::function<std::unique_ptr<GPSTransport>(
const QString&,
GPSCancelToken)> _serialTransportFactory;
std::function< GPSReceiverWorker *(GPSReceiverWorker::TransportFactory, GPSType, const GPSReceiverConfig &, QObject *)> GPSReceiverWorkerFactory
Creates a receiver session's worker; tests inject scripted workers.
SerialPortManager::ReservationPtr GPSSerialClaim
Holds a serial device for one receiver session until the last copy is released.
std::function< std::unique_ptr< GPSTransport >(GPSCancelToken)> TransportFactory
Consumed on the worker thread, so transport construction, I/O and destruction share that thread.
void summaryLabelChanged()
friend class GPSReceiverConnectionPolicyTest
static constexpr std::chrono::seconds POLL_INTERVAL
How often connection polling ticks the receiver.
void startConnectionPolling(std::function< bool()> suspended={})
Runs tick() every POLL_INTERVAL until shutdown(), skipping ticks while suspended returns true.
RTKSettings::ConnectionType effectiveConnectionType() const
QString detectedReceiver() const
bool persistentChangesAllowed() const
friend class GPSReceiverSettingsBindingTest
static QList< int > serialBaudRates()
The application's serial rates that a receiver accepts as an explicit rate; empty without serial link...
const Configuration & configuration() const
RTKSettings::ReceiverRole activeRole() const
bool connectionSupported() const
UDP only receives, so a receiver QGroundControl configures needs serial or TCP.
QString statusText() const
QString activeEndpoint() const
Serial device or TCP host:port of the active receiver.
void configurationChanged()
Q_INVOKABLE GPSReceiverPresentation capabilitiesFor(int role, int manufacturer) const
Editable settings for a role; configured bases also depend on the manufacturer.
bool hasReceiver() const override
void persistentChangesAllowedChanged()
void serialPortEntriesChanged()
bool forwardingCorrections() const
friend class GPSReceiverTest
The active receiver's RTCM output is a correction source.
GPSReceiverWorkerFactory WorkerFactory
QList< GPSSerialPortEntry > serialPortEntries() const
static constexpr std::chrono::seconds SHUTDOWN_TIMEOUT
How long shutdown() waits for the workers of retired sessions.
int activeBaseMode() const
GPSReceiverFactGroup * facts() const
The receiver's reported state; with no receiver, every Fact is at its metadata default.
bool reconnecting() const
The saved receiver is being connected automatically, at startup or after its connection was lost.
void setWorkerFactory(WorkerFactory factory)
Inject before connecting; an empty factory restores the real worker.
GPSReceiverPresentation activePresentation() const
Presentation capabilities of the connected receiver family.
QString summaryLabel() const
void errorMessageChanged()
static constexpr std::chrono::seconds OUTPUT_OVERFLOW_WARNING_DURATION
How long the warning about output the receiver dropped stays after the last report of it.
std::optional< GPSObservation > acceptedPositionObservation(GPSObservation::PositionUse use) const
Latest receiver solution that passes the consumer's gates; empty without a fresh fix.
QString errorMessage() const
The connection or input problem, else a recent report that the receiver dropped output.
GPSReceiverConfiguration Configuration
void setConfiguration(const Configuration &configuration)
bool serialSupported() const
Q_INVOKABLE bool connectReceiver()
void tick()
One step of automatic connection: connections due, reconnections, and USB discovery.
bool baseModeSupported() const
void setPersistentChangesAllowed(bool allowed)
Granting permission only lasts until the configuration changes, a session starts or ends,...
Q_INVOKABLE void disconnectReceiver()
Disconnects and pauses automatic connection until the user connects again.
QString receiverIdentity() const
Session health is independent of transport readiness and RTK survey-in validity.
ConnectionType
Persisted values of connectionType. The storage type keeps any saved value a valid enum value.
ReceiverRole
Persisted values of receiverRole. The storage type keeps any saved value a valid enum value.
Shared serial inventory and exclusive claims. Called on the application thread.
GPSInputProblem
Why a receiver that stays connected while silent reports no position.
The receiver configuration the application's settings binding supplies as values.
RTKSettings::ConnectionType effectiveConnectionType() const
The connection this configuration uses; builds without serial links connect a serial selection over T...
Services a GPSReceiver uses, which must outlive it.
SerialPortManager * serialPorts
GPSCorrectionManager * corrections
Receives a forwarding receiver's RTCM output as the local correction source.
PositionManager * positions
Ready receivers publish their solution here as the GCS "RTK receiver" position source.
A serial device the receiver settings offer.
QString value
The system location, which the device setting stores.
QString label
What the picker shows.
bool operator==(const GPSSerialPortEntry &) const =default