QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RetryTransition.cc
Go to the documentation of this file.
1#include "RetryTransition.h"
2#include "QGCState.h"
3#include "WaitStateBase.h"
4
5#include <QtCore/QLoggingCategory>
6
7Q_DECLARE_LOGGING_CATEGORY(QGCStateMachineLog)
8
9bool RetryTransition::eventTest(QEvent* event)
10{
11 if (!QGCSignalTransition::eventTest(event)) {
12 return false;
13 }
14
15 // Get source state name for logging
16 QString stateName = QStringLiteral("unknown");
17 if (auto* state = qobject_cast<QGCState*>(sourceState())) {
18 stateName = state->stateName();
19 }
20
21 if (_retryCount < _maxRetries) {
22 _retryCount++;
23 qCDebug(QGCStateMachineLog) << stateName << "timeout, retry" << _retryCount << "of" << _maxRetries;
24
25 if (auto* waitState = qobject_cast<WaitStateBase*>(sourceState())) {
26 waitState->restartWait();
27 }
28
29 if (_retryAction) {
30 _retryAction();
31 }
32
33 // Block the transition - stay in current state
34 return false;
35 }
36
37 // Max retries exhausted - allow transition
38 qCWarning(QGCStateMachineLog) << stateName << "timeout after" << _maxRetries << "retries, advancing";
39 return true;
40}
41
43{
44 Q_UNUSED(event);
45
46 // Reset for potential future use (if state is re-entered)
47 _retryCount = 0;
48}
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
void onTransition(QEvent *event) override
Called when transition fires (after max retries)