7 , _timeoutMsecs(timeoutMsecs > 0 ? timeoutMsecs : 0)
9 _timeoutTimer.setSingleShot(
true);
10 connect(&_timeoutTimer, &QTimer::timeout,
this, &WaitStateBase::_onTimeout);
11 connect(
this, &QState::entered,
this, &WaitStateBase::_onEntered);
12 connect(
this, &QState::exited,
this, &WaitStateBase::_onExited);
15void WaitStateBase::_onEntered()
22 int effectiveTimeout = _timeoutMsecs;
26 effectiveTimeout =
override;
27 qCDebug(QGCStateMachineLog) <<
stateName() <<
"using timeout override:" << effectiveTimeout <<
"ms";
31 if (effectiveTimeout > 0) {
32 _timeoutTimer.start(effectiveTimeout);
36void WaitStateBase::_onExited()
43void WaitStateBase::_onTimeout()
49 qCDebug(QGCStateMachineLog) <<
"Timeout" <<
stateName();
114 int effectiveTimeout = _timeoutMsecs;
118 effectiveTimeout =
override;
122 if (effectiveTimeout > 0) {
123 _timeoutTimer.start(effectiveTimeout);
QString stateName() const
QGCStateMachine * machine() const
void recordTimeout(const QString &stateName)
Record a timeout for statistics.
int timeoutOverride(const QString &stateName) const
Get the timeout override for a state, or -1 if not set.
Full-featured base class for QGroundControl state machine states.
WaitStateBase(const QString &stateName, QState *parent, int timeoutMsecs=0)
virtual void onWaitTimeout()
Called when the timeout expires - default emits timeout(), subclasses can override.
virtual void onWaitEntered()
Called when the state is entered - subclasses should call base implementation.
virtual void connectWaitSignal()=0
Subclasses override to set up their signal connections.
virtual void disconnectWaitSignal()=0
Subclasses override to tear down their signal connections.
virtual void onWaitExited()
Called when the state is exited - subclasses should call base implementation.