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 } |
受保护函数
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) |
详细说明
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 实例。
[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
返回更新模式。
成员变量文档
QString QNmeaSatelliteInfoSource::SimulationUpdateInterval
该变量用于保存SimulationMode 中数据读取速率的后端属性名称。该属性的值为整数,代表两次读取之间的毫秒间隔。在setBackendProperty() 和backendProperty() 方法中使用此参数。
注意: 该属性与通过setUpdateInterval() 设置的时间间隔不同。通过setUpdateInterval() 设置的值表示用户通知的时间间隔,而该参数指定从源文件读取数据的内部频率。这意味着在updateInterval() 期间可以多次(或不)读取数据。
© 2025 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.