-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_RequestIdle_behaviour.xml
104 lines (86 loc) · 2.75 KB
/
test_RequestIdle_behaviour.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?xml version="1.0"?>
<!--
This XML is a simple test to validate the behaviour of requestIdle.
The supervisor will print "State 0 from device" followed by "State 1 from device"
if requestIdle is respected.
Otherwise, the Supervisor will print "State 0 from device" followed by two prints
of "State 1 from device". The Supervisor will then exit via an API call.
-->
<Graphs xmlns="" appname="RequestIdleBehaviourApp">
<GraphType id="RequestIdleBehaviour">
<SharedCode><![CDATA[
#include <stdlib.h>
]]></SharedCode>
<MessageTypes>
<MessageType id="exfil">
<Message><![CDATA[
uint32_t state;
]]></Message>
</MessageType>
</MessageTypes>
<DeviceTypes>
<DeviceType id="dev1">
<State><![CDATA[
uint32_t lState = 0;
uint32_t sSent = 0;
]]></State>
<SharedCode><![CDATA[
]]></SharedCode>
<ReadyToSend><![CDATA[
if(DEVICESTATE(lState) == 0)
{
*requestIdle = true;
}
if(DEVICESTATE(sSent) == 0)
{
RTSSUP();
}
]]></ReadyToSend>
<OnInit><![CDATA[
return 1; // Trigger RTS
]]></OnInit>
<OnDeviceIdle><![CDATA[
DEVICESTATE(sSent) = 0;
DEVICESTATE(lState) = 1;
]]></OnDeviceIdle>
<SupervisorOutPin messageTypeId="exfil">
<OnSend><![CDATA[
PKT(state) = DEVICESTATE(lState);
DEVICESTATE(sSent) = 1; // Flag Supervisor not sent
]]></OnSend>
</SupervisorOutPin>
</DeviceType>
<SupervisorType id="supervisorNode">
<Code><![CDATA[
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
]]></Code>
<State><![CDATA[
uint32_t s1count = 0;
]]></State>
<SupervisorInPin id="updateIn" messageTypeId="exfil">
<OnReceive><![CDATA[
std::cout << "State " << PKT(state) << " from device" << std::endl;
if(PKT(state) == 1)
{
SUPSTATE(s1count)++;
}
if(SUPSTATE(s1count) > 1)
{
Super::stop_application();
}
]]></OnReceive>
</SupervisorInPin>
</SupervisorType>
</DeviceTypes>
</GraphType>
<GraphInstance id="RequestIdleBehaviourInst" graphTypeId="RequestIdleBehaviour">
<DeviceInstances>
<DevI id="d1" type="dev1"/>
</DeviceInstances>
<EdgeInstances>
</EdgeInstances>
</GraphInstance>
</Graphs>