|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <StateHistoryRecorder.h>
Inheritance diagram for StateHistoryRecorder:
Collaboration diagram for StateHistoryRecorder:Classes | |
| struct | HistoryEntry |
| A recorded state transition entry. More... | |
Public Types | |
| enum | TransitionReason { Entered , Exited , Timeout , Error , Signal , Event , Unknown } |
| Reason for a state transition. More... | |
Public Member Functions | |
| StateHistoryRecorder (QGCStateMachine *machine, int maxEntries=1000) | |
| ~StateHistoryRecorder () override=default | |
| void | setEnabled (bool enabled) |
| Enable or disable recording. | |
| bool | isEnabled () const |
| void | setMaxEntries (int max) |
| Set the maximum number of entries to keep (circular buffer) | |
| int | maxEntries () const |
| void | clear () |
| Clear all recorded history. | |
| int | count () const |
| Get the number of recorded entries. | |
| QList< HistoryEntry > | history () const |
| Get all history entries (oldest first) | |
| QList< HistoryEntry > | lastEntries (int n) const |
| Get the last N entries. | |
| QList< HistoryEntry > | entriesForState (const QString &stateName) const |
| Get entries for a specific state. | |
| QString | dumpHistory () const |
| Get a human-readable dump of the history. | |
| QJsonArray | toJson () const |
| Export history as JSON array. | |
| void | logHistory () const |
| Log history to debug output. | |
| void | addEntry (const QString &stateName, TransitionReason reason, const QString &details=QString()) |
| Manually add an entry (for custom transition types) | |
Records state machine transitions for debugging and analysis.
Maintains a circular buffer of state transitions with timestamps, transition reasons, and optional metadata.
Usage:
Definition at line 28 of file StateHistoryRecorder.h.
Reason for a state transition.
Definition at line 34 of file StateHistoryRecorder.h.
|
explicit |
Definition at line 40 of file StateHistoryRecorder.cc.
|
overridedefault |
| void StateHistoryRecorder::addEntry | ( | const QString & | stateName, |
| TransitionReason | reason, | ||
| const QString & | details = QString() |
||
| ) |
Manually add an entry (for custom transition types)
Definition at line 147 of file StateHistoryRecorder.cc.
References StateHistoryRecorder::HistoryEntry::details, StateHistoryRecorder::HistoryEntry::reason, StateHistoryRecorder::HistoryEntry::stateName, and StateHistoryRecorder::HistoryEntry::timestamp.
| void StateHistoryRecorder::clear | ( | ) |
Clear all recorded history.
Definition at line 90 of file StateHistoryRecorder.cc.
|
inline |
Get the number of recorded entries.
Definition at line 71 of file StateHistoryRecorder.h.
| QString StateHistoryRecorder::dumpHistory | ( | ) | const |
Get a human-readable dump of the history.
Definition at line 114 of file StateHistoryRecorder.cc.
Referenced by logHistory().
| QList< StateHistoryRecorder::HistoryEntry > StateHistoryRecorder::entriesForState | ( | const QString & | stateName | ) | const |
Get entries for a specific state.
Definition at line 103 of file StateHistoryRecorder.cc.
|
inline |
Get all history entries (oldest first)
Definition at line 74 of file StateHistoryRecorder.h.
|
inline |
Definition at line 61 of file StateHistoryRecorder.h.
| QList< StateHistoryRecorder::HistoryEntry > StateHistoryRecorder::lastEntries | ( | int | n | ) | const |
Get the last N entries.
Definition at line 95 of file StateHistoryRecorder.cc.
| void StateHistoryRecorder::logHistory | ( | ) | const |
Log history to debug output.
Definition at line 137 of file StateHistoryRecorder.cc.
References dumpHistory().
|
inline |
Definition at line 65 of file StateHistoryRecorder.h.
| void StateHistoryRecorder::setEnabled | ( | bool | enabled | ) |
Enable or disable recording.
Definition at line 47 of file StateHistoryRecorder.cc.
| void StateHistoryRecorder::setMaxEntries | ( | int | max | ) |
Set the maximum number of entries to keep (circular buffer)
Definition at line 80 of file StateHistoryRecorder.cc.
| QJsonArray StateHistoryRecorder::toJson | ( | ) | const |
Export history as JSON array.
Definition at line 128 of file StateHistoryRecorder.cc.