QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSReceiverMessages.cc
Go to the documentation of this file.
2
3#include "GPSReceiver.h"
5
6namespace {
7
9QString reconnectingMessage(GPSConnectionError error, const QString& detail)
10{
11 switch (error) {
12 case GPSConnectionError::OpenFailed:
13 return detail.isEmpty()
14 ? GPSReceiver::tr("Failed to open the receiver. Reconnecting automatically.")
15 : GPSReceiver::tr("Failed to open the receiver: %1. Reconnecting automatically.").arg(detail);
16 case GPSConnectionError::ConfigFailed:
17 case GPSConnectionError::ConsentRequired:
18 return detail.isEmpty()
19 ? GPSReceiver::tr("Receiver configuration failed. Reconnecting automatically.")
20 : GPSReceiver::tr("Receiver configuration failed: %1. Reconnecting automatically.").arg(detail);
21 case GPSConnectionError::ProtocolError:
22 return detail.isEmpty()
23 ? GPSReceiver::tr("Receiver protocol error. Reconnecting automatically.")
24 : GPSReceiver::tr("Receiver protocol error: %1. Reconnecting automatically.").arg(detail);
25 case GPSConnectionError::DeviceError:
26 case GPSConnectionError::None:
27 break;
28 }
29 return detail.isEmpty() ? GPSReceiver::tr("Receiver connection lost. Reconnecting automatically.")
30 : GPSReceiver::tr("Receiver connection lost: %1. Reconnecting automatically.").arg(detail);
31}
32
33} // namespace
34
36
37QString sessionEnded(GPSReceiverSessionOutcome outcome, GPSConnectionError error, const QString& detail,
38 bool portRemoved)
39{
40 switch (outcome) {
42 return GPSReceiver::tr("Receiver unplugged.");
45 return reconnectingMessage(error, detail);
47 return GPSReceiver::tr("Receiver unplugged. Reconnecting when it is plugged back in.");
49 break;
50 }
51 if (portRemoved) {
52 return GPSReceiver::tr("Receiver unplugged. Select a device and reconnect.");
53 }
54 switch (error) {
55 case GPSConnectionError::OpenFailed:
56 return detail.isEmpty() ? GPSReceiver::tr(
57 "Failed to open the receiver. Check the device or network "
58 "address, permissions, and other connections.")
59 : GPSReceiver::tr("Failed to open the receiver: %1.").arg(detail);
60 case GPSConnectionError::ConfigFailed:
61 case GPSConnectionError::ConsentRequired:
62 return detail.isEmpty()
63 ? GPSReceiver::tr(
64 "Receiver configuration failed. Check the receiver type, baud rate, and base mode.")
65 : GPSReceiver::tr("Receiver configuration failed: %1").arg(detail);
66 case GPSConnectionError::ProtocolError:
67 //: %1 explains the protocol error
68 return detail.isEmpty()
69 ? GPSReceiver::tr("Receiver protocol error. Check the receiver type and reconnect.")
70 : GPSReceiver::tr("Receiver protocol error: %1. Check the receiver type and reconnect.")
71 .arg(detail);
72 case GPSConnectionError::DeviceError:
73 //: %1 explains why the connection was lost
74 return detail.isEmpty()
75 ? GPSReceiver::tr("Receiver connection lost. Check the device and reconnect.")
76 : GPSReceiver::tr("Receiver connection lost: %1. Check the device and reconnect.").arg(detail);
77 case GPSConnectionError::None:
78 break;
79 }
80 return {};
81}
82
83QString consentRefused(const QString& detail, GPSType family)
84{
85 //: %1 explains the failure; %2 is a receiver manufacturer, such as Quectel
86 return GPSReceiver::tr(
87 "Receiver configuration failed: %1. Automatic connections never save settings to "
88 "the receiver's flash. To let QGroundControl save the %2 receiver's settings, "
89 "connect manually and allow flash save and restart.")
90 .arg(detail, gpsReceiverName(family));
91}
92
93QString inputProblem(GPSInputProblem problem, std::optional<GPSType> detected, const QString& endpoint,
94 bool forwardingCorrections)
95{
96 switch (problem) {
97 case GPSInputProblem::None:
98 break;
99 case GPSInputProblem::NoData:
100 //: %1 is the receiver's serial device or network address
101 return GPSReceiver::tr(
102 "No data from the receiver on %1. Check the device and that no other program is using it.")
103 .arg(endpoint);
104 case GPSInputProblem::NotGNSS:
105 return GPSReceiver::tr("Receiving data that isn't GNSS output. Check the device and baud rate.");
106 case GPSInputProblem::NoPositions:
107 switch (detected.value_or(GPSType::passive)) {
108 case GPSType::ublox:
109 return GPSReceiver::tr(
110 "Receiving u-blox UBX data without position messages. Enable NAV-PVT or NMEA output.");
111 case GPSType::septentrio:
112 return GPSReceiver::tr(
113 "Receiving Septentrio SBF data without position messages. Enable PVTGeodetic or NMEA "
114 "output.");
115 default:
116 return GPSReceiver::tr("Receiving NMEA data without position messages. Enable GGA output.");
117 }
118 case GPSInputProblem::CorrectionsOnly:
119 // Forwarding them is all a corrections-only receiver needs to do.
120 return forwardingCorrections ? QString()
121 : GPSReceiver::tr(
122 "Receiving RTCM corrections without position messages. Turn on "
123 "Forward receiver RTCM to send them to vehicles.");
124 }
125 return {};
126}
127
128QString outputOverflow(RTKSettings::ReceiverRole role, bool compactObservations)
129{
130 if (role == RTKSettings::Passive) {
131 return GPSReceiver::tr(
132 "The receiver produces more output than the connection carries, so data is being lost. Use a "
133 "higher baud rate or reduce the receiver's output.");
134 }
135 if (compactObservations) {
136 return GPSReceiver::tr(
137 "The receiver produces more output than the connection carries, so corrections are being lost. "
138 "Use a higher baud rate.");
139 }
140 //: "Compact RTCM corrections (MSM4)" is the label of the base receiver setting
141 return GPSReceiver::tr(
142 "The receiver produces more output than the connection carries, so corrections are being lost. "
143 "Use a higher baud rate or turn on Compact RTCM corrections (MSM4).");
144}
145
146QString fixLabel(GPSFixQuality fixType)
147{
148 switch (fixType) {
149 case GPSFixQuality::NoFix:
150 return GPSReceiver::tr("No fix");
151 case GPSFixQuality::Fix2D:
152 return GPSReceiver::tr("2D");
153 case GPSFixQuality::Fix3D:
154 return GPSReceiver::tr("3D");
155 case GPSFixQuality::Differential:
156 return GPSReceiver::tr("DGPS");
157 case GPSFixQuality::RTKFloat:
158 return GPSReceiver::tr("Float", "RTK float fix");
159 case GPSFixQuality::RTKFixed:
160 return GPSReceiver::tr("Fixed", "RTK fixed fix");
161 case GPSFixQuality::Extrapolated:
162 return GPSReceiver::tr("DR", "Dead reckoning (extrapolated) fix");
163 case GPSFixQuality::Unknown:
164 break;
165 }
166 return {};
167}
168
169QString receiverStatus(const ReceiverStatus& status)
170{
171 using Mode = BaseModeDefinition::Mode;
172 if (!status.configured) {
173 if (status.hasReceiver) {
174 return status.identifying ? GPSReceiver::tr("Identifying receiver...")
175 : GPSReceiver::tr("Connecting to receiver...");
176 }
177 return status.reconnecting ? GPSReceiver::tr("Connecting automatically...") : QString();
178 }
179 if (status.role == RTKSettings::Passive) {
180 return status.forwardingCorrections ? GPSReceiver::tr("Passive receiver connected; forwarding its RTCM")
181 : GPSReceiver::tr("Passive receiver connected; position only");
182 }
183 if (status.baseMode == static_cast<int>(Mode::BaseReceiverAveraging)) {
184 return GPSReceiver::tr("Receiver-managed averaging — no accuracy guarantee");
185 }
186 if (status.baseMode == static_cast<int>(Mode::BaseFixed)) {
187 return GPSReceiver::tr("Fixed position");
188 }
189 return status.surveyActive ? GPSReceiver::tr("Survey-In active") : GPSReceiver::tr("Receiver connected");
190}
191
192} // namespace GPSReceiverMessages
GPSReceiverSessionOutcome
What the policy does after a receiver session ends; the receiver words the message for it.
@ Unplugged
A discovered receiver was unplugged; discovery connects it again when it returns.
@ None
Nothing reconnects; the receiver's own message for the error applies.
@ AutoRetrying
A discovered receiver failed or was lost; discovery retries it.
@ WaitingForPort
The saved receiver was unplugged; it reconnects when its port returns.
@ Retrying
The saved receiver's connection was lost; a retry is scheduled.
QString gpsReceiverName(GPSType type)
The name of type's receiver family as shown to users; empty when no descriptor exists.
Error error
ReceiverRole
Persisted values of receiverRole. The storage type keeps any saved value a valid enum value.
Definition RTKSettings.h:36
GPSInputProblem
Why a receiver that stays connected while silent reports no position.
The wording of GPSReceiver's errors, warnings and labels, translated in the GPSReceiver context.
QString consentRefused(const QString &detail, GPSType family)
The error of an automatic connection that the family receiver refused for lack of flash-save consent.
QString outputOverflow(RTKSettings::ReceiverRole role, bool compactObservations)
The warning that the receiver produces more output than its connection carries.
QString fixLabel(GPSFixQuality fixType)
The short label of a fix type; empty for an unknown one.
QString receiverStatus(const ReceiverStatus &status)
The receiver status sentence; empty when no receiver is connected or being connected.
QString sessionEnded(GPSReceiverSessionOutcome outcome, GPSConnectionError error, const QString &detail, bool portRemoved)
QString inputProblem(GPSInputProblem problem, std::optional< GPSType > detected, const QString &endpoint, bool forwardingCorrections)
What the receiver status sentence describes.
bool configured
The receiver finished configuration.
bool identifying
An Automatic connection that has not identified the receiver yet.