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")
162#ifdef QGC_NO_SERIAL_LINK
229 void _onGPSConnect();
230 void _onReceiverDetected();
247 bool operator==(
const ReceiverState&)
const =
default;
253 quint64 configurationRevision = 0;
256 ReceiverState receiver;
259 int _activeManufacturer()
const;
261 void setConnectionError(
const QString& message)
override { _setError(message); }
263 void endConnection(
bool clearError)
override;
264 bool connectTcp(
const QString& host, quint16 port,
GPSType type,
bool allowPersistentChanges)
override;
265 bool connectUdp(quint16 port,
GPSType type)
override;
266#ifndef QGC_NO_SERIAL_LINK
267 bool connectSerial(
const QString& device,
GPSType type, uint32_t baudRate,
bool allowPersistentChanges,
269 bool serialPortAvailable(
const QString& device)
const override;
270 QString serialPortLabel(
const QString& device)
const override;
271 bool serialPortAllowed(
const QString& device)
const override;
276 void _onSerialPortsEnumerated(
const QStringList& devices);
277 void _updateSerialPortEntries();
280 QString _serialLocation(
const QString& device)
const;
283 void _usePersistentSerialDevice();
287 const QString& sourceInstance, uint32_t baudRate,
bool allowPersistentChanges,
288 const QString& serialDevice = {},
const QString& endpoint = {});
291 void _retireSession();
293 void _joinRetiredWorkers();
295 void _setError(
const QString& message = {}) { _errorMessage = message; }
298 void _updateOutputOverflow(uint64_t receiptUs);
299 void _setPersistentChangesAllowed(
bool allowed);
301 void _updateLabels();
303 void _clearStaleSolution();
304 ReceiverState _receiverState()
const;
309 GPSReceiverSession* _session =
nullptr;
311 QList<QPointer<GPSReceiverWorker>> _retiredWorkers;
312 const QPointer<GPSCorrectionManager> _correctionManager;
313 const QPointer<PositionManager> _positionManager;
314 RuntimeScheduler*
const _scheduler;
315 GPSSourceHealth*
const _positionHealth;
316 ScheduledTask _outputOverflowTask;
317 ScheduledTask _pollTask;
318 quint64 _sessionCount = 0;
319 QString _errorMessage;
320 QString _summaryLabel;
322 QString _outputOverflowWarning;
323 uint64_t _outputOverflowUs = 0;
324 std::unique_ptr<GPSReceiverConnectionPolicy> _connection;
325 GPSReceiverFactGroup* _facts =
nullptr;
327 quint64 _configurationRevision = 0;
329 bool _destroying =
false;
330 bool _persistentChangesAllowed =
false;
331 QList<GPSSerialPortEntry> _serialPortEntries;
332#ifndef QGC_NO_SERIAL_LINK
333 const QPointer<SerialPortManager> _serialPorts;
336 QHash<QString, std::weak_ptr<const SerialPortManager::Reservation>> _serialClaims;
337 std::function<std::unique_ptr<GPSTransport>(
const QString&, GPSCancelToken)> _serialTransportFactory;
GPSConnectionErrors::GPSInputProblem GPSInputProblem
GPSConnectionErrors::GPSConnectionError GPSConnectionError
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.
GPSTypes::GPSType GPSType
virtual QStringList rtkReceiverPorts() const =0
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...
GPSReceiver(QObject *parent=nullptr, RuntimeScheduler *scheduler=nullptr, const Dependencies &dependencies={})
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.
void serialDeviceRenamed(const QString &device)
GPSReceiverPresentation activePresentation() const
Presentation capabilities of the connected receiver family.
GPSReceiverDependencies Dependencies
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.
The receiver configuration the application's settings binding supplies as values.
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 name the device setting stores for the port.
QString label
What the picker shows.
bool operator==(const GPSSerialPortEntry &) const =default