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
21{
22 Q_OBJECT
23 Q_DISABLE_COPY(TimeoutTransition)
24
25public:
29 explicit TimeoutTransition(int timeoutMsecs, QAbstractState* target = nullptr);
30
33 void attachToSourceState(QState* source);
34
36 int timeoutMsecs() const { return _timeoutMsecs; }
37
39 void setTimeoutMsecs(int msecs) { _timeoutMsecs = msecs; }
40
42 bool isTimerActive() const { return _timer.isActive(); }
43
44signals:
46 void timeout();
47
48protected:
49 bool event(QEvent* e) override;
50 void onTransition(QEvent* event) override;
51
52private slots:
53 void _onSourceStateEntered();
54 void _onSourceStateExited();
55
56private:
57 void _onAddedToState();
58
59 int _timeoutMsecs;
60 QTimer _timer;
61 bool _sourceAttached = false;
62};
Base class for signal-based transitions that need access to QGCStateMachine and Vehicle.
Transition that fires automatically after a specified delay.
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.