5#include "private/qnmeasatelliteinfosource_p.h"
6#include <QtPositioning/private/qgeosatelliteinfo_p.h>
7#include <QtPositioning/private/qgeosatelliteinfosource_p.h>
8#include <QtPositioning/private/qlocationutils_p.h>
16#include <QtCore/QtNumeric>
20#if USE_SATELLITE_NMEA_PIMPL
26 virtual ~QGeoSatelliteInfoPrivateNmea();
28 QList<QByteArray> nmeaSentences;
39 nmeaSentences =
other.nmeaSentences;
42QGeoSatelliteInfoPrivateNmea::~QGeoSatelliteInfoPrivateNmea() {}
49 m_updateMode(updateMode)
86#if USE_SATELLITE_NMEA_PIMPL
90 if (!
info.satellitesInUse.isEmpty()) {
91 for (
auto &
s :
info.satellitesInUse) {
93 ->nmeaSentences.append(updateInfo.
gsa);
95 for (
auto &
s :
info.satellitesInView) {
97 ->nmeaSentences.append(updateInfo.
gsa);
112#if USE_SATELLITE_NMEA_PIMPL
116#if USE_SATELLITE_NMEA_PIMPL
122 pimpl->nmeaSentences.append(updateInfo.
gsa);
123 pimpl->nmeaSentences.append(updateInfo.
gsv);
193 if (msec <= 0 || msec < m_source->minimumUpdateInterval()) {
251 qWarning(
"QNmeaSatelliteInfoSource: no QIODevice data source, call setDevice() first");
256 qWarning(
"QNmeaSatelliteInfoSource: cannot open QIODevice data source");
298 bool fromRequestUpdate)
300 bool emitted =
false;
305 bool inUseUpdated =
false;
306 bool inViewUpdated =
false;
307 if (!fromRequestUpdate) {
320 inViewUpdated =
true;
450 qWarning(
"QNmeaSatelliteInfoSource: source device has already been set");
500 const int interval =
value.toInt(&
ok);
504 reader->setUpdateInterval(interval);
523 return reader->updateInterval();
568#if QT_DEPRECATED_SINCE(7, 0)
571 QList<int> &pnrsInUse)
573#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
583 QList<int> &pnrsInUse)
585#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
621#if QT_DEPRECATED_SINCE(7, 0)
624 QList<QGeoSatelliteInfo> &infos,
627#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
638 QList<QGeoSatelliteInfo> &infos,
641#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
658 QList<QGeoSatelliteInfo>
result;
666 QList<QGeoSatelliteInfo>
result;
673 const QList<QGeoSatelliteInfo> &inView)
676 info.updatingGSV =
false;
678 info.satellitesInView = inView;
679 info.validInView =
true;
681 if (!
info.satellitesInUseReceived) {
690 info.satellitesInUse.clear();
691 info.inUseIds.clear();
692 info.validInUse =
true;
694 info.satellitesInUseReceived =
false;
696 if (
info.satellitesInView.isEmpty()) {
701 info.satellitesInUse.clear();
702 info.inUseIds.clear();
703 info.validInUse =
true;
704 }
else if (!
info.inUseIds.isEmpty()) {
707 info.satellitesInUse.clear();
708 info.validInUse =
false;
709 bool corrupt =
false;
710 for (
const auto id :
info.inUseIds) {
712 for (
const auto &
s :
info.satellitesInView) {
713 if (
s.satelliteIdentifier() ==
id) {
714 info.satellitesInUse.append(
s);
722 info.satellitesInUse.clear();
727 info.validInUse = !corrupt;
728 info.inUseIds.clear();
737 const QList<int> &inUse)
743 info.satellitesInUse.clear();
745 info.satellitesInUseReceived =
true;
746 info.inUseIds = inUse;
748 if (
info.updatingGSV) {
749 info.validInView =
false;
754 for (
const auto id : inUse) {
756 for (
const auto &
s :
info.satellitesInView) {
757 if (
s.satelliteIdentifier() ==
id) {
758 info.satellitesInUse.append(
s);
765 info.satellitesInView.clear();
766 info.validInView =
false;
772 info.inUseIds.clear();
774 info.validInUse =
true;
798#if USE_SATELLITE_NMEA_PIMPL
829 : m_proxy(sourcePrivate)
867 m_timer->
start(m_updateInterval);
876 int numSatInUseMsgs = 0;
877 int numSatInViewMsgs = 0;
888 if (numSatInUseMsgs > 2 || numSatInViewMsgs > 2) {
889 const QString msgType = (numSatInUseMsgs > numSatInViewMsgs)
892 qWarning() <<
"nmea simulation reader: possibly incorrect message order. Got too "
894 << msgType <<
"messages";
907 m_timer->
start(m_updateInterval);
912 return m_updateInterval;
917#include "moc_qnmeasatelliteinfosource_p.cpp"
918#include "moc_qnmeasatelliteinfosource.cpp"
IOBluetoothDevice * device
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
void stop()
Stops the timer.
bool isActive() const noexcept
Returns true if the timer is running and has not been stopped; otherwise returns false.
void clear()
Clears the contents of the byte array and makes it null.
static QGeoSatelliteInfoPrivate * get(const QGeoSatelliteInfo &info)
virtual void setUpdateInterval(int msec)
Error
The Error enumeration represents the errors which can occur.
int updateInterval
This property holds the requested interval in milliseconds between each update.
void satellitesInViewUpdated(const QList< QGeoSatelliteInfo > &satellites)
If startUpdates() or requestUpdate() is called, this signal is emitted when an update is available on...
void satellitesInUseUpdated(const QList< QGeoSatelliteInfo > &satellites)
If startUpdates() or requestUpdate() is called, this signal is emitted when an update is available on...
void errorOccurred(QGeoSatelliteInfoSource::Error)
This signal is emitted after an error occurred.
SatelliteSystem
Defines the GNSS system of the satellite.
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
bool isOpen() const
Returns true if the device is open; otherwise returns false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void replace(qsizetype i, parameter_type t)
void append(parameter_type t)
static QGeoSatelliteInfo::SatelliteSystem getSatInUseFromNmea(QByteArrayView bv, QList< int > &pnrsInUse)
static QNmeaSatelliteInfoSource::SatelliteInfoParseStatus getSatInfoFromNmea(QByteArrayView bv, QList< QGeoSatelliteInfo > &infos, QGeoSatelliteInfo::SatelliteSystem &system)
const_iterator cend() const
const_iterator cbegin() const
bool emitUpdated(QNmeaSatelliteInfoUpdate &update, bool fromRequestUpdate)
bool m_noUpdateLastInterval
QScopedPointer< QNmeaSatelliteReader > m_nmeaReader
void prepareSourceDevice()
QNmeaSatelliteInfoUpdate m_lastUpdate
QNmeaSatelliteInfoUpdate m_pendingUpdate
~QNmeaSatelliteInfoSourcePrivate()
bool m_connectedReadyRead
QNmeaSatelliteInfoSource * m_source
void processNmeaData(QNmeaSatelliteInfoUpdate &updateInfo)
void requestUpdate(int msec)
QNmeaSatelliteInfoSourcePrivate(QNmeaSatelliteInfoSource *parent, QNmeaSatelliteInfoSource::UpdateMode updateMode)
QBasicTimer * m_updateTimer
QNmeaSatelliteInfoSource::UpdateMode m_updateMode
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void updateRequestTimeout()
int m_simulationUpdateInterval
QPointer< QIODevice > m_device
QGeoSatelliteInfoSource::Error m_satelliteError
void setUpdateInterval(int msec) override
\reimp
UpdateMode
Defines the available update modes.
SatelliteInfoParseStatus
Defines the parse status of satellite information.
int minimumUpdateInterval() const override
\reimp
bool setBackendProperty(const QString &name, const QVariant &value) override
\reimp
UpdateMode updateMode() const
Returns the update mode.
void stopUpdates() override
\reimp
void startUpdates() override
\reimp
SatelliteInfoParseStatus parseSatelliteInfoFromNmea(QByteArrayView data, QList< QGeoSatelliteInfo > &infos, QGeoSatelliteInfo::SatelliteSystem &system)
Parses an NMEA sentence string to extract the information about satellites in view.
QVariant backendProperty(const QString &name) const override
\reimp
QNmeaSatelliteInfoSourcePrivate * d
QGeoSatelliteInfo::SatelliteSystem parseSatellitesInUseFromNmea(QByteArrayView data, QList< int > &pnrsInUse)
Parses an NMEA sentence string to extract the IDs of satelites in use.
static QString SimulationUpdateInterval
\variable QNmeaSatelliteInfoSource::SimulationUpdateInterval
QNmeaSatelliteInfoSource(UpdateMode mode, QObject *parent=nullptr)
Constructs a \l QNmeaSatelliteInfoSource instance with the given parent and mode.
void setDevice(QIODevice *source)
Sets the NMEA data source to device.
~QNmeaSatelliteInfoSource() override
Destroys the satellite information source.
QIODevice * device() const
Returns the NMEA data source.
Error error() const override
\reimp
void setError(QGeoSatelliteInfoSource::Error satelliteError)
void requestUpdate(int timeout=0) override
\reimp
virtual void readAvailableData()=0
QNmeaSatelliteInfoSourcePrivate * m_proxy
QNmeaSatelliteReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
virtual ~QNmeaSatelliteReader()
QNmeaSatelliteRealTimeReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
void readAvailableData() override
void setUpdateInterval(int msec)
int updateInterval() const
void readAvailableData() override
QNmeaSatelliteSimulationReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
void stop()
Stops the timer.
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
QT_BEGIN_NAMESPACE typedef QGeoSatelliteInfoPrivate QGeoSatelliteInfoPrivateNmea
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield GLuint64 timeout
[4]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
#define QStringLiteral(str)
QMap< QGeoSatelliteInfo::SatelliteSystem, SatelliteInfo > m_satellites
bool setSatellitesInUse(QGeoSatelliteInfo::SatelliteSystem system, const QList< int > &inUse)
QList< QGeoSatelliteInfo > allSatellitesInView() const
bool calculateValidInView() const
bool calculateValidInUse() const
QList< QGeoSatelliteInfo > allSatellitesInUse() const
QList< QGeoSatelliteInfo > m_satellitesInViewParsed
void setSatellitesInView(QGeoSatelliteInfo::SatelliteSystem system, const QList< QGeoSatelliteInfo > &inView)