-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbasic-02.xml
More file actions
140 lines (129 loc) · 5.23 KB
/
basic-02.xml
File metadata and controls
140 lines (129 loc) · 5.23 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0"?>
<Graphs xmlns="https://poets-project.org/schemas/virtual-graph-schema-v2">
<GraphType id="test">
<Documentation>PSIM Test</Documentation>
<MetaData>"native_dimension":2</MetaData>
<Properties/>
<SharedCode>
<![CDATA[
]]>
</SharedCode>
<MessageTypes>
<MessageType id="__init__">
<Documentation>Initialize state</Documentation>
</MessageType>
<MessageType id="message_type_a">
<Documentation>Test Message (Type A)</Documentation>
<Message>
<Scalar type="uint32_t" name="value">
<Documentation>Test Value</Documentation>
</Scalar>
</Message>
</MessageType>
<MessageType id="message_type_b">
<Documentation>Test Message (Type B)</Documentation>
<Message>
<Scalar type="uint32_t" name="value">
<Documentation>Test Value</Documentation>
</Scalar>
</Message>
</MessageType>
</MessageTypes>
<DeviceTypes>
<DeviceType id="device_type_x">
<Properties>
<Scalar name="id" type="uint32_t"></Scalar>
</Properties>
<State>
<Scalar name="counter" type="uint32_t"></Scalar>
<Scalar name="rts" type="uint32_t"></Scalar>
</State>
<ReadyToSend>
<![CDATA[
rts = deviceState->rts;
]]>
</ReadyToSend>
<InputPin messageTypeId="__init__" name="__init__">
<OnReceive>
<![CDATA[
deviceState->counter = 0;
deviceState->rts = 1;
]]>
</OnReceive>
</InputPin>
<InputPin messageTypeId="message_type_b" name="input">
<OnReceive>
<![CDATA[
message->value = deviceState->counter;
handler_log(1, "Received message (value = %d)", message->value);
deviceState->rts = deviceState->counter < 10;
if (deviceState->counter >= 10)
handler_exit(0); // return successfully
]]>
</OnReceive>
</InputPin>
<OutputPin messageTypeId="message_type_a" name="output">
<OnSend>
<![CDATA[
deviceState->counter++;
message->value = deviceState->counter;
handler_log(1, "Sending message (value = %d)", message->value);
deviceState->rts = 0;
]]>
</OnSend>
</OutputPin>
</DeviceType>
<DeviceType id="device_type_y">
<Properties>
<Scalar name="id" type="uint32_t"></Scalar>
</Properties>
<State>
<Scalar name="counter" type="uint32_t"></Scalar>
<Scalar name="rts" type="uint32_t"></Scalar>
</State>
<ReadyToSend>
<![CDATA[
rts = deviceState->rts;
]]>
</ReadyToSend>
<InputPin messageTypeId="__init__" name="__init__">
<OnReceive>
<![CDATA[
deviceState->counter = 0;
deviceState->rts = 0;
]]>
</OnReceive>
</InputPin>
<InputPin messageTypeId="message_type_a" name="input">
<OnReceive>
<![CDATA[
deviceState->rts = 1;
deviceState->counter = message->value;
handler_log(1, "Received message (value = %d)", message->value);
]]>
</OnReceive>
</InputPin>
<OutputPin messageTypeId="message_type_b" name="output">
<OnSend>
<![CDATA[
message->value = deviceState->counter;
deviceState->rts = 0;
handler_log(1, "Sending message (value = %d)", message->value);
message->value = deviceState->counter;
]]>
</OnSend>
</OutputPin>
</DeviceType>
</DeviceTypes>
</GraphType>
<GraphInstance id="graph1" graphTypeId="test">
<DeviceInstances>
<DevI id="device0" type="device_type_x"><P>"id": 0</P></DevI>
<DevI id="device1" type="device_type_y"><P>"id": 1</P></DevI>
</DeviceInstances>
<EdgeInstances>
<EdgeI path="device1:input-device0:output"/>
<EdgeI path="device0:input-device1:output"/>
</EdgeInstances>
</GraphInstance>
</Graphs>