QNmeaSatelliteInfoSource Class
QNmeaSatelliteInfoSource 类通过 NMEA 数据源提供卫星信息。更多内容...
| 标题: | #include <QNmeaSatelliteInfoSource> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
| qmake: | QT += positioning |
| 自: | Qt 6.2 |
| 继承自: | QGeoSatelliteInfoSource |
公共类型
| enum class | UpdateMode { RealTimeMode, SimulationMode } |
公共函数
| QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode mode, QObject *parent = nullptr) | |
| virtual | ~QNmeaSatelliteInfoSource() override |
| QIODevice * | device() const |
| void | setDevice(QIODevice *device) |
| QNmeaSatelliteInfoSource::UpdateMode | updateMode() const |
重新实现的公共函数
| virtual QVariant | backendProperty(const QString &name) const override |
| virtual QGeoSatelliteInfoSource::Error | error() const override |
| virtual int | minimumUpdateInterval() const override |
| virtual bool | setBackendProperty(const QString &name, const QVariant &value) override |
| virtual void | setUpdateInterval(int msec) override |
公共槽
| virtual void | requestUpdate(int msec = 0) override |
| virtual void | startUpdates() override |
| virtual void | stopUpdates() override |
静态公共成员
| QString | SimulationUpdateInterval |
受保护类型
| enum | SatelliteInfoParseStatus { NotParsed, PartiallyParsed, FullyParsed } |
受保护函数
| QNmeaSatelliteInfoSource(const QNmeaSatelliteInfoSource &) | |
| virtual QNmeaSatelliteInfoSource::SatelliteInfoParseStatus | parseSatelliteInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system) |
| virtual QGeoSatelliteInfo::SatelliteSystem | parseSatellitesInUseFromNmea(const char *data, int size, QList<int> &pnrsInUse) |
| QNmeaSatelliteInfoSource & | operator=(const QNmeaSatelliteInfoSource &) |
详细说明
NMEA 是一种常用的协议,用于指定某个时间点上的全球位置。QNmeaSatelliteInfoSource 类读取 NMEA 数据,并利用这些数据以QGeoSatelliteInfo 对象列表的形式提供可见卫星和正在使用的卫星的相关信息。
QNmeaSatelliteInfoSource 实例可在RealTimeMode 或SimulationMode 模式下运行。这些模式允许从实时数据源读取 NMEA 数据,或为模拟目的从先前记录的 NMEA 数据中回放数据。
NMEA 数据的来源通过setDevice() 进行设置。
使用startUpdates() 开始接收定期的卫星信息更新,使用stopUpdates() 停止这些更新。如果您仅需偶尔获取更新,可以调用requestUpdate() 来请求一次关于可见卫星和正在使用的卫星的更新。
关于可见卫星的信息是通过satellitesInViewUpdated() 信号接收的。
关于正在使用的卫星的信息是通过satellitesInUseUpdated() 信号接收的。
成员类型文档
enum QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
定义卫星信息的解析状态。卫星信息可拆分为多个句子,我们需要对所有句子进行解析。
| 常量 | 值 | 描述 |
|---|---|---|
QNmeaSatelliteInfoSource::NotParsed | 0 | 数据中不包含卫星信息。 |
QNmeaSatelliteInfoSource::PartiallyParsed | 1 | 已接收并解析了有效的卫星信息,但信息不完整,因此需要等待另一条 NMEA 句子。 |
QNmeaSatelliteInfoSource::FullyParsed | 2 | 已完整收集并解析卫星信息。 |
enum class QNmeaSatelliteInfoSource::UpdateMode
定义可用的更新模式。
| 常量 | 值 | 描述 |
|---|---|---|
QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode | 1 | 卫星信息会在数据源提供时被读取并分发。如果您使用的是 NMEA 数据的实时数据源(例如 GPS 硬件设备),请使用此模式。 |
QNmeaSatelliteInfoSource::UpdateMode::SimulationMode | 2 | 以指定的速率从数据源读取并分发卫星信息。该速率由SimulationUpdateInterval 参数决定。如果数据源包含先前记录的NMEA数据,且您希望为模拟目的重放这些数据,请使用此模式。 |
成员函数文档
[explicit] QNmeaSatelliteInfoSource::QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode mode, QObject *parent = nullptr)
根据给定的parent 和mode ,创建一个QNmeaSatelliteInfoSource 实例。
[protected delete] QNmeaSatelliteInfoSource::QNmeaSatelliteInfoSource(const QNmeaSatelliteInfoSource &)
复制并构造一个QNmeaSatelliteInfoSource 实例。该函数已被删除。
[override virtual noexcept] QNmeaSatelliteInfoSource::~QNmeaSatelliteInfoSource()
摧毁了卫星信息源。
[override virtual] QVariant QNmeaSatelliteInfoSource::backendProperty(const QString &name) const
重写了:QGeoSatelliteInfoSource::backendProperty(const QString &name) const。
另请参阅 setBackendProperty()。
QIODevice *QNmeaSatelliteInfoSource::device() const
返回 NMEA 数据源。
另请参阅 setDevice()。
[override virtual] QGeoSatelliteInfoSource::Error QNmeaSatelliteInfoSource::error() const
重新实现了:QGeoSatelliteInfoSource::error() const。
[override virtual] int QNmeaSatelliteInfoSource::minimumUpdateInterval() const
重新实现了属性QGeoSatelliteInfoSource::minimumUpdateInterval 的访问函数。
[virtual protected] QNmeaSatelliteInfoSource::SatelliteInfoParseStatus QNmeaSatelliteInfoSource::parseSatelliteInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system)
解析 NMEA 语句字符串,以提取可见卫星的相关信息。
默认实现将解析标准的 NMEA $GPGSV 语句。当需要处理非标准 NMEA 语句时,应在子类中重写此方法。
解析器从data 读取size 字节数据,并利用这些信息填充infos 列表。
返回包含解析结果的SatelliteInfoParseStatus 。若返回PartiallyParsed 或FullyParsed ,则修改infos 列表。同时将system 设置为正确的卫星系统类型。当视野内无卫星时,此操作对于确定系统类型是必需的。
[virtual protected] QGeoSatelliteInfo::SatelliteSystem QNmeaSatelliteInfoSource::parseSatellitesInUseFromNmea(const char *data, int size, QList<int> &pnrsInUse)
解析 NMEA 语句字符串,以提取正在使用的卫星的 ID。
默认实现将解析标准的 NMEA $GPGSA 语句。当需要处理非标准 NMEA 语句时,应在子类中重写此方法。
解析器从data 读取size 字节数据,并利用这些信息填充pnrsInUse 列表。
如果语句解析成功,则返回系统类型;否则返回QGeoSatelliteInfo::Undefined ,且不应修改pnrsInUse 。
[override virtual slot] void QNmeaSatelliteInfoSource::requestUpdate(int msec = 0)
重新实现了:QGeoSatelliteInfoSource::requestUpdate(int timeout)。
[override virtual] bool QNmeaSatelliteInfoSource::setBackendProperty(const QString &name, const QVariant &value)
重写了:QGeoSatelliteInfoSource::setBackendProperty (const QString &name, const QVariant &value)。
另请参见 backendProperty()。
void QNmeaSatelliteInfoSource::setDevice(QIODevice *device)
将 NMEA 数据源设置为device 。如果该设备尚未打开,则将以ReadOnly 模式打开它。
数据源设备只能设置一次,且必须在调用startUpdates() 或requestUpdate() 之前完成设置。
注意: device 必须调用QIODevice::readyRead(),才能在有数据可供读取时通知源设备。QNmeaSatelliteInfoSource 不拥有该设备,因此不会在销毁时释放该设备。
另请参阅 device()。
[override virtual] void QNmeaSatelliteInfoSource::setUpdateInterval(int msec)
重新实现了属性QGeoSatelliteInfoSource::updateInterval 的访问函数。
[override virtual slot] void QNmeaSatelliteInfoSource::startUpdates()
重写了:QGeoSatelliteInfoSource::startUpdates()。
[override virtual slot] void QNmeaSatelliteInfoSource::stopUpdates()
重写了:QGeoSatelliteInfoSource::stopUpdates()。
QNmeaSatelliteInfoSource::UpdateMode QNmeaSatelliteInfoSource::updateMode() const
返回更新模式。
[protected delete] QNmeaSatelliteInfoSource &QNmeaSatelliteInfoSource::operator=(const QNmeaSatelliteInfoSource &)
将 `other ` 通过复制赋值给此 `QNmeaSatelliteInfoSource ` 实例。该函数已被删除。
成员变量文档
QString QNmeaSatelliteInfoSource::SimulationUpdateInterval
该变量存储了SimulationMode 中数据读取速率的后端属性名称。该属性的值是一个整数,表示两次连续读取之间的时间间隔(以毫秒为单位)。请在setBackendProperty()和backendProperty()方法中使用此参数。
注意:此 属性与可通过setUpdateInterval() 设置的间隔不同。通过setUpdateInterval() 设置的值表示用户通知的间隔,而此参数则指定从源文件读取数据的内部频率。这意味着在updateInterval() 的周期内,可能会发生多次(或零次)读取操作。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.