QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSReceiverWorker Class Reference

#include <GPSReceiverWorker.h>

+ Inheritance diagram for GPSReceiverWorker:
+ Collaboration diagram for GPSReceiverWorker:

Public Types

using TransportFactory = std::function< std::unique_ptr< GPSTransport >(GPSCancelToken)>
 Consumed on the worker thread, so transport construction, I/O and destruction share that thread.
 

Signals

void satelliteInfoUpdated (const GPSSatelliteReport &message)
 
void positionUpdated (const GPSPositionReport &report)
 
void rtcmDataReceived (const QByteArray &message, qint64 receivedAtMs)
 RTCM output the receiver sent, stamped with the steady clock when it was read.
 
void surveyInStatusUpdated (const GPSSurveyReport &report)
 
void connectionError (GPSConnectionError error, const QString &detail={})
 detail is the transport's or the protocol's diagnostic, or empty when it gave none.
 
void receiverDetected (GPSType type)
 
void inputProblem (GPSInputProblem problem)
 
void receiverReady (const QString &identity={})
 identity is the receiver model and firmware, or empty when the family does not report them.
 
void finished ()
 Delivered on this object's thread once the session thread has finished.
 

Public Member Functions

 GPSReceiverWorker (TransportFactory transportFactory, GPSType type, const GPSReceiverConfig &config, QObject *parent=nullptr, GPSClock clock={})
 The session's receive deadlines and inactivity limit run on clock; the default is the steady clock.
 
 ~GPSReceiverWorker () override
 
virtual void start ()
 Starts the session once; later calls are ignored.
 
virtual void stop ()
 
bool wait (QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
 Waits for the worker to exit; returns true at once when the session never started.
 
void setEndsWhenIdle (bool endsWhenIdle)
 

Static Public Attributes

static constexpr std::chrono::milliseconds RECEIVE_TIMEOUT {1200}
 Longest wait for one read before the session re-checks cancellation.
 
static constexpr std::chrono::milliseconds USEFUL_DATA_TIMEOUT = 3 * RECEIVE_TIMEOUT
 

Friends

class GPSReceiverWorkerTest
 
class GPSReceiverTest
 

Detailed Description

One receiver session hosted on a dedicated thread. The object lives on its creator's thread; only the session body runs on that thread, which it owns and joins before destruction.

Definition at line 25 of file GPSReceiverWorker.h.

Member Typedef Documentation

◆ TransportFactory

using GPSReceiverWorker::TransportFactory = std::function<std::unique_ptr<GPSTransport>(GPSCancelToken)>

Consumed on the worker thread, so transport construction, I/O and destruction share that thread.

Definition at line 34 of file GPSReceiverWorker.h.

Constructor & Destructor Documentation

◆ GPSReceiverWorker()

GPSReceiverWorker::GPSReceiverWorker ( TransportFactory  transportFactory,
GPSType  type,
const GPSReceiverConfig &  config,
QObject *  parent = nullptr,
GPSClock  clock = {} 
)

The session's receive deadlines and inactivity limit run on clock; the default is the steady clock.

Definition at line 15 of file GPSReceiverWorker.cc.

◆ ~GPSReceiverWorker()

GPSReceiverWorker::~GPSReceiverWorker ( )
override

Definition at line 26 of file GPSReceiverWorker.cc.

References stop(), and wait().

Member Function Documentation

◆ connectionError

void GPSReceiverWorker::connectionError ( GPSConnectionError  error,
const QString &  detail = {} 
)
signal

detail is the transport's or the protocol's diagnostic, or empty when it gave none.

Referenced by GPSReceiverSession::start().

◆ finished

void GPSReceiverWorker::finished ( )
signal

Delivered on this object's thread once the session thread has finished.

Referenced by start(), and GPSReceiverSession::start().

◆ inputProblem

void GPSReceiverWorker::inputProblem ( GPSInputProblem  problem)
signal

Why a session that does not end when idle has delivered no position for USEFUL_DATA_TIMEOUT; None once positions arrive. The session keeps running.

Referenced by GPSReceiverSession::start().

◆ positionUpdated

void GPSReceiverWorker::positionUpdated ( const GPSPositionReport &  report)
signal

◆ receiverDetected

void GPSReceiverWorker::receiverDetected ( GPSType  type)
signal

The family a GPSType::automatic session detected, before it configures the receiver, or the protocol a passive session's input carries (GPSDriverSinks::onReceiverDetected).

Referenced by GPSReceiverSession::start().

◆ receiverReady

void GPSReceiverWorker::receiverReady ( const QString &  identity = {})
signal

identity is the receiver model and firmware, or empty when the family does not report them.

Referenced by GPSReceiverSession::start().

◆ rtcmDataReceived

void GPSReceiverWorker::rtcmDataReceived ( const QByteArray &  message,
qint64  receivedAtMs 
)
signal

RTCM output the receiver sent, stamped with the steady clock when it was read.

Referenced by GPSReceiverSession::start().

◆ satelliteInfoUpdated

void GPSReceiverWorker::satelliteInfoUpdated ( const GPSSatelliteReport &  message)
signal

◆ setEndsWhenIdle()

void GPSReceiverWorker::setEndsWhenIdle ( bool  endsWhenIdle)

Configured receivers must keep producing data; passive links stay open while the receiver is silent. Ignored once the session started, as its worker reads the setting.

Definition at line 49 of file GPSReceiverWorker.cc.

◆ start()

void GPSReceiverWorker::start ( )
virtual

Starts the session once; later calls are ignored.

Definition at line 33 of file GPSReceiverWorker.cc.

References finished().

◆ stop()

void GPSReceiverWorker::stop ( )
virtual

Requests cooperative cancellation. Network waits and serial reads wake at once; serial writes observe it within their polling interval.

Definition at line 44 of file GPSReceiverWorker.cc.

References GPSCancelSource::cancel().

Referenced by ~GPSReceiverWorker().

◆ surveyInStatusUpdated

void GPSReceiverWorker::surveyInStatusUpdated ( const GPSSurveyReport &  report)
signal

◆ wait()

bool GPSReceiverWorker::wait ( QDeadlineTimer  deadline = QDeadlineTimer(QDeadlineTimer::Forever))

Waits for the worker to exit; returns true at once when the session never started.

Definition at line 56 of file GPSReceiverWorker.cc.

Referenced by ~GPSReceiverWorker().

Friends And Related Symbol Documentation

◆ GPSReceiverTest

friend class GPSReceiverTest
friend

Definition at line 30 of file GPSReceiverWorker.h.

◆ GPSReceiverWorkerTest

friend class GPSReceiverWorkerTest
friend

Definition at line 29 of file GPSReceiverWorker.h.

Member Data Documentation

◆ RECEIVE_TIMEOUT

constexpr std::chrono::milliseconds GPSReceiverWorker::RECEIVE_TIMEOUT {1200}
staticconstexpr

Longest wait for one read before the session re-checks cancellation.

Definition at line 57 of file GPSReceiverWorker.h.

◆ USEFUL_DATA_TIMEOUT

constexpr std::chrono::milliseconds GPSReceiverWorker::USEFUL_DATA_TIMEOUT = 3 * RECEIVE_TIMEOUT
staticconstexpr

A receiver that ends when idle ends after this long without useful data; one that stays connected reports inputProblem() after this long without a position.

Definition at line 60 of file GPSReceiverWorker.h.


The documentation for this class was generated from the following files: