Skip to content

Commit c2076bf

Browse files
committed
Example how to pass event data to callstack
1 parent 45bcb48 commit c2076bf

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Doc/DebugScxmlStateCharts.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,36 @@ For Qt SCXML applications you may include [scxmlexternmonitor2.h](../Include/scx
159159

160160
![CalculatorDebug](../Images/CalculatorDebug.gif)
161161

162+
#### Option to pass event or custom data to CallStack View
163+
If you need to pass event or custom data to CallStack view, you can override monitor class.
164+
165+
![Debug_ProcessEventData](../Images/Debug_ProcessEventData.png)
166+
167+
```cpp
168+
class MyMonitor: public Scxmlmonitor::UDPScxmlExternMonitor {
169+
public:
170+
inline explicit MyMonitor(QObject *parent = nullptr): Scxmlmonitor::UDPScxmlExternMonitor(parent) {}
171+
protected:
172+
inline virtual void processEventMessage(QScxmlStateMachine *machine, const QString &id, const QScxmlEvent &event) {
173+
const QString sEventData = event.data().toString();
174+
processMonitorMessage(machine->name(),
175+
id,
176+
sEventData.isEmpty() ? event.name() : (event.name() + ": [" + sEventData + "]"),
177+
Scxmlmonitor::smttBeforeTakingTransition);
178+
// ---> example: add custom info to all events, that starts with 'in.'
179+
if (event.name().startsWith("in.")) {
180+
processMonitorMessage(machine->name(),
181+
id,
182+
"my custom data: " + sEventData,
183+
Scxmlmonitor::smttBeforeProcessingEvent);
184+
}
185+
}
186+
};
187+
```
188+
189+
You should enable custom data types in ScxmlEditor settings if you want to receive it in CallStack View
190+
![process_events_settings](../Images/Debug_ProcessEventData_settings.png)
191+
162192
## Custom testing application setup
163193
Since version 2.1.8 there is an option to communicate with testing applications via pipes.
164194
#### Example: how to setup [The SCION command-line tool](https://gitlab.com/scion-scxml/cli) as custom testing application

Images/Debug_ProcessEventData.png

44.5 KB
Loading
54.2 KB
Loading

0 commit comments

Comments
 (0)