QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSDriver.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <functional>
6#include <memory>
7#include <vector>
8
9#include <QtCore/QByteArray>
10#include <QtCore/QString>
11
12#include "GPSClock.h"
13#include "GPSCommand.h"
14#include "GPSProtocolEvent.h"
15#include "GPSReceiverConfig.h"
16#include "GPSReceiverReports.h"
17#include "GPSType.h"
18
19class GPSTransport;
20struct GPSConfig;
22struct GPSRuntimeIO;
24
28{
29 std::function<void(const GPSPositionReport&)> onPosition;
30 std::function<void(const GPSSatelliteReport&)> onSatelliteInfo;
32 std::function<void(const QByteArray&)> onRTCM;
33 std::function<void(const GPSSurveyReport&)> onSurveyIn;
37 std::function<void(GPSType)> onReceiverDetected;
38};
39
49
50struct [[nodiscard]] GPSReceiveResult
51{
56 GPSReceiveUpdates updates = {};
57 QString detail = {};
58
59 [[nodiscard]] bool terminal() const
60 {
62 }
63};
64
70{
71public:
73 GPSDriver(GPSType type, GPSTransport& transport, const GPSReceiverConfig& config, GPSDriverSinks sinks,
74 GPSClock clock = {});
76
77 Q_DISABLE_COPY(GPSDriver)
78
79
80 bool configure();
81
84 [[nodiscard]] GPSReceiveResult receiveOutcome(std::chrono::milliseconds timeout);
85
87 [[nodiscard]] const std::vector<GPSConfigurationEvidence>& configurationEvidence() const;
88
90 [[nodiscard]] const QString& configurationError() const;
91
93 [[nodiscard]] bool configurationNeedsConsent() const;
94
96 [[nodiscard]] QString receiverIdentity() const;
97
98private:
99 bool _configureDetected(GPSRuntimeIO io, GPSRuntimeObserver observer, unsigned baudrate);
101 bool _configureFamily(const GPSReceiverFamily& family, GPSRuntimeIO io, GPSRuntimeObserver observer,
102 const GPSConfig& config, unsigned baudrate, const QString& detected);
103 void _publish(const GPSEventBatch& batch);
104 void _handle(const GPSIntegrityReport& report);
105 void _handle(const GPSDecodedPosition& report);
106 void _handle(const GPSDecodedSatellites& report);
107 void _handle(const GPSDecodedSatelliteUsage& report);
108 void _handle(const GPSSurveyReport& report);
109 void _handle(const GPSRTCMFrame& report);
110 void _handle(const GPSInputProtocol& report);
111 void _handleSatellites(const GPSSatelliteReport& report);
112 void _publishExpiredSatellites();
113 void _publishSatellites(const GPSSatelliteReport& report);
114
115 GPSType _type;
116 GPSTransport& _transport;
117 GPSReceiverConfig _config;
118 GPSDriverSinks _sinks;
119 GPSClock _clock;
120
121 struct State;
122 std::unique_ptr<State> _state;
123};
GPSProtocolError
Sticky failure of the current receiver session; I/O and control stop until the next configure().
Definition GPSCommand.h:23
@ Cancelled
A stop was requested; not a receiver or link fault.
Definition GPSCommand.h:25
GPSReceiveLiveness
What one receive cycle heard from the receiver.
Definition GPSDriver.h:42
@ Activity
Diagnostics or partial input, never proof of navigation liveness.
Definition GPSDriver.h:45
@ Data
Useful reports, even without a registered sink.
Definition GPSDriver.h:47
GPSTypes::GPSType GPSType
Definition GPSType.h:25
QString receiverIdentity() const
Receiver model and firmware reported by the configured protocol; empty when unknown.
Definition GPSDriver.cc:91
const QString & configurationError() const
Diagnostic from the latest configure() failure; cleared when a new attempt starts.
Definition GPSDriver.cc:81
bool configurationNeedsConsent() const
Whether the latest configure() failed because the receiver needs persistent changes the request did n...
Definition GPSDriver.cc:86
GPSReceiveResult receiveOutcome(std::chrono::milliseconds timeout)
Definition GPSDriver.cc:253
bool configure()
Create and configure the underlying driver.
Definition GPSDriver.cc:96
GPSDriver(GPSType type, GPSTransport &transport, const GPSReceiverConfig &config, GPSDriverSinks sinks, GPSClock clock={})
Deadlines, report times and satellite freshness run on clock; the default is the steady clock.
Definition GPSDriver.cc:64
const std::vector< GPSConfigurationEvidence > & configurationEvidence() const
Latest configure() attempt; remains available after failure. Caller-thread access only.
Definition GPSDriver.cc:76
The monotonic clock receiver sessions run on: the steady clock unless tests inject a virtual one.
Definition GPSClock.h:11
The receiver configuration requested for one configure() attempt.
Decoded navigation plus whether the producer accepted its velocity solution.
std::function< void(const GPSSatelliteReport &)> onSatelliteInfo
Definition GPSDriver.h:30
std::function< void(const GPSPositionReport &)> onPosition
Definition GPSDriver.h:29
std::function< void(const GPSSurveyReport &)> onSurveyIn
Definition GPSDriver.h:33
std::function< void(const QByteArray &)> onRTCM
One complete frame; copying it shares the receiver's buffer.
Definition GPSDriver.h:32
std::function< void(GPSType)> onReceiverDetected
Definition GPSDriver.h:37
Events decoded from one span of received bytes, in publication order.
One RTCM3 frame the receiver produced, including its header and CRC.
GPSProtocolError error
The failure that ended the session, or None.
Definition GPSDriver.h:53
GPSReceiveLiveness liveness
Definition GPSDriver.h:54
bool terminal() const
Definition GPSDriver.h:59
GPSReceiveUpdates updates
Position and satellite reports published to the sinks.
Definition GPSDriver.h:56
Observers of runtime output, invoked synchronously on the runtime thread.