QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TimeoutTransition.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QtCore/QTimer>
6
19{
20 Q_OBJECT
21 Q_DISABLE_COPY(TimeoutTransition)
22
23public:
27 explicit TimeoutTransition(int timeoutMsecs, QAbstractState* target = nullptr);
28
31 void attachToSourceState(QState* source);
32
34 int timeoutMsecs() const { return _timeoutMsecs; }
35
37 void setTimeoutMsecs(int msecs) { _timeoutMsecs = msecs; }
38
40 bool isTimerActive() const { return _timer.isActive(); }
41
42signals:
44 void timeout();
45
46protected:
47 bool event(QEvent* e) override;
48 void onTransition(QEvent* event) override;
49
50private slots:
51 void _onSourceStateEntered();
52 void _onSourceStateExited();
53
54private:
55 void _onAddedToState();
56
57 int _timeoutMsecs;
58 QTimer _timer;
59 bool _sourceAttached = false;
60};
Base class for signal-based transitions that need access to QGCStateMachine and Vehicle.
void onTransition(QEvent *event) override
void setTimeoutMsecs(int msecs)
Set the timeout duration (only effective before state is entered)
bool event(QEvent *e) override
int timeoutMsecs() const
Get the timeout duration.
void timeout()
Emitted when the timeout expires (internal use - triggers transition)
void attachToSourceState(QState *source)
bool isTimerActive() const
Check if the timer is currently running.