The QNmeaSatelliteInfoSource class provides satellite information using an NMEA data source. 更多...
头: | #include <QNmeaSatelliteInfoSource> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
qmake: | QT += positioning |
Since: | 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 is a commonly used protocol for the specification of one's global position at a certain point in time. The QNmeaSatelliteInfoSource class reads NMEA data and uses it to provide information about satellites in view and satellites in use in form of lists of QGeoSatelliteInfo 对象。
A QNmeaSatelliteInfoSource instance operates in either RealTimeMode or SimulationMode . These modes allow NMEA data to be read from either a live source of data, or replayed for simulation purposes from previously recorded NMEA data.
The source of NMEA data is set via setDevice ().
使用 startUpdates () to start receiving regular satellite information updates and stopUpdates () to stop these updates. If you only require updates occasionally, you can call requestUpdate () to request a single update of both satellites in view and satellites in use.
The information about satellites in view is received via the satellitesInViewUpdated () 信号。
The information about satellites in use is received via the satellitesInUseUpdated () 信号。
Defines the parse status of satellite information. The satellite information can be split into multiple sentences, and we need to parse all of them.
常量 | 值 | 描述 |
---|---|---|
QNmeaSatelliteInfoSource::NotParsed
|
0
|
The data does not contain information about satellites. |
QNmeaSatelliteInfoSource::PartiallyParsed
|
1
|
A valid satellite information is received and parsed, but it's not complete, so we need to wait for another NMEA sentence. |
QNmeaSatelliteInfoSource::FullyParsed
|
2
|
Satellite information was fully collected and parsed. |
Defines the available update modes.
常量 | 值 | 描述 |
---|---|---|
QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode
|
1
|
Satellite information is read and distributed from the data source as it becomes available. Use this mode if you are using a live source of NMEA data (for example a GPS hardware device). |
QNmeaSatelliteInfoSource::UpdateMode::SimulationMode
|
2
|
Satellite information is read and distributed from the data source at the given rate. The rate is determined by the SimulationUpdateInterval parameter. Use this mode if the data source contains previously recorded NMEA data and you want to replay the data for simulation purposes. |
[explicit]
QNmeaSatelliteInfoSource::
QNmeaSatelliteInfoSource
(
QNmeaSatelliteInfoSource::UpdateMode
mode
,
QObject
*
parent
= nullptr)
构造 QNmeaSatelliteInfoSource instance with the given parent and mode .
[override virtual]
QNmeaSatelliteInfoSource::
~QNmeaSatelliteInfoSource
()
Destroys the satellite information source.
[override virtual]
QVariant
QNmeaSatelliteInfoSource::
backendProperty
(const
QString
&
name
) const
重实现: QGeoSatelliteInfoSource::backendProperty(const QString &name) const .
另请参阅 setBackendProperty ().
Returns the NMEA data source.
另请参阅 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
)
Parses an NMEA sentence string to extract the information about satellites in view.
The default implementation will parse standard NMEA $GPGSV sentences. This method should be reimplemented in a subclass whenever the need to deal with non-standard NMEA sentences arises.
The parser reads size 字节来自 data and uses that information to fill infos 列表。
返回 SatelliteInfoParseStatus with parse result. Modifies infos list in case PartiallyParsed or FullyParsed is returned. Also sets the system to correct satellite system type. This is required to determine the system type in case there are no satellites in view.
[virtual protected]
QGeoSatelliteInfo::SatelliteSystem
QNmeaSatelliteInfoSource::
parseSatellitesInUseFromNmea
(const
char
*
data
,
int
size
,
QList
<
int
> &
pnrsInUse
)
Parses an NMEA sentence string to extract the IDs of satelites in use.
The default implementation will parse standard NMEA $GPGSA sentences. This method should be reimplemented in a subclass whenever the need to deal with non-standard NMEA sentences arises.
The parser reads size 字节来自 data and uses that information to fill pnrsInUse 列表。
Returns system type if the sentence was successfully parsed, otherwise returns QGeoSatelliteInfo::Undefined and should not modifiy 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 ().
Sets the NMEA data source to device . If the device is not open, it will be opened in QIODevice::ReadOnly mode.
The source device can only be set once and must be set before calling startUpdates () 或 requestUpdate ().
注意: The device must emit QIODevice::readyRead () for the source to be notified when data is available for reading. QNmeaSatelliteInfoSource does not assume the ownership of the device, and hence does not deallocate it upon destruction.
另请参阅 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 ().
Returns the update mode.
This variable holds the backend property name for data read rate in the SimulationMode . The value for this property is the integer number representing the amount of milliseconds between the subsequent reads. Use this parameter in the setBackendProperty () 和 backendProperty () 方法。
注意: This property is different from the interval that can be set via setUpdateInterval (). The value set via setUpdateInterval () denotes an interval for the user notification, while this parameter specifies the internal frequency of reading the data from source file. It means that one can have multiple (or none) reads during the updateInterval () period.