Newer
Older
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
package AvatarInstance {
private import AvatarGeneral::*;
private import AvatarBlockTypes::*;
private import AvatarCommunication::*;
private import AvatarTransitionServer::*;
// DATATYPES $$$$$$$$$$$$$$$$$$$$$$$$
attribute def 'Point' :> '#AvatarDataType' {
attribute x : Integer default := 0;
attribute y : Integer default := 0;
}
// COMMUNICATIONS $$$$$$$$$$$$$$$$$$$$$$$$
// Relation Sync_Relation =============
part Sync_Relation: '#Sync_Rel' = '#Sync_Rel'('@block1' = blk0, '@block2' = blk1_0, '@private'=true);
// Channel syn_in0_out1-------------
part syn_in0_out1 : '#Sync' = '#Sync'('@relation' = Sync_Relation);
binding : '#InSignalBinding' bind blk0.sig_in0 = syn_in0_out1;
binding : '#OutSignalBinding' bind blk1_0.sig_out1 = syn_in0_out1;
// Message of signal blk0.sig_in0............
part def msg_in0 :> '#InMessage' {
private part '@channel' : '#Channel' = syn_in0_out1;
attribute x : Integer;
attribute p : 'Point';
attribute b : Boolean;
}
// Message of signal blk1_0.sig_out1............
part def msg_out1 :> '#OutMessage', msg_in0 {
attribute x redefines x;
attribute p redefines p;
attribute b redefines b;
}
// Channel syn_out0_in1-------------
part syn_out0_in1 : '#Sync' = '#Sync'('@relation' = Sync_Relation);
binding : '#OutSignalBinding' bind blk0.sig_out0 = syn_out0_in1;
binding : '#InSignalBinding' bind blk1_0.sig_in1 = syn_out0_in1;
// Message of signal blk1_0.sig_in1............
part def msg_in1 :> '#InMessage' {
private part '@channel' : '#Channel' = syn_out0_in1;
attribute x : Integer;
attribute p : 'Point';
attribute b : Boolean;
}
// Message of signal blk0.sig_out0............
part def msg_out0 :> '#OutMessage', msg_in1 {
attribute x redefines x;
attribute p redefines p;
attribute b redefines b;
}
// BLOCKS $$$$$$$$$$$$$$$$$$$$$$$$
// Block blk1=============
part blk1 : '#AvatarBlock' {
// state-machine -------------------
exhibit state '@statemachine' : '#AvatarStateMachine' {
entry action startstate :'#AvatarStartState';
transition : '#AvatarTransition' first startstate
then stopstate;
exit action stopstate :'#AvatarStopState';
}
// Sub-Blocks øøøøøøøøøøøøøøøøøøøøøøø
// Block blk1_0=============
part blk1_0 : '#AvatarBlock' {
// Attributes ---------------------
attribute x : Integer := 0;
attribute b : Boolean := false;
attribute p : 'Point';
// Signals ---------------------
part sig_in1 : '#Channel';
part sig_out1 : '#Channel';
// Timers ---------------------
part tmr: '#AvatarTimer' = '#AvatarTimer'();
// state-machine -------------------
exhibit state '@statemachine' : '#AvatarStateMachine' {
state send_out1_0 : '#AvatarSendState';
transition : '#AvatarTransition' first send_out1_0
then stopstate;
state receive_in1_0 : '#AvatarReceiveState' = '#AvatarReceiveState'(
'@request' = {
'#SendRequest'(
'@channel'= sig_out1,
'@payload' = msg_out1(
x,
p,
b )
)
}
);
transition : '#AvatarTransition' first receive_in1_0
then send_out1_0;
state state1 : '#AvatarStandardState' = '#AvatarStandardState'(
'@pool' = {(
'#AvatarSetTimerRequest'(
'@channel'= tmr.'@set',
'@payload' = '#TimerSetMsg'(10)
),
'#ReceiveRequest'(
'@index' = 2,
'@channel'= sig_in1
)
)}
);
transition : '#AvatarTransition' first state1 if '@index' == 1
then set_tmr_0;
transition : '#AvatarTransition' first state1 if '@index' == 2
do action : '#ReceiveAction' {
item '@msg' : msg_in1 = '@payload' as msg_in1;
first start;
then assign x := '@msg'.x;
then assign p := '@msg'.p;
then assign b := '@msg'.b;
then done;
} then receive_in1_0;
state set_tmr_0 : '#AvatarSetTimerState';
transition : '#AvatarTransition' first set_tmr_0
then state2;
state expire_tmr_0 : '#AvatarExpireTimerState';
transition : '#AvatarTransition' first expire_tmr_0
then state1;
state state2 : '#AvatarStandardState' = '#AvatarStandardState'(
'@pool' = {(
'#AvatarExpireTimerRequest'(
'@channel'= tmr.'@expire'
),
'#AvatarResetTimerRequest'(
'@index' = 2,
'@channel'= tmr.'@reset',
'@payload' = '#TimerResetMsg'()
)
)}
);
transition : '#AvatarTransition' first state2 if '@index' == 1
then expire_tmr_0;
transition : '#AvatarTransition' first state2 if '@index' == 2
then reset_tmr_0;
entry action startstate :'#AvatarStartState';
transition : '#AvatarTransition' first startstate
then state1;
state reset_tmr_0 : '#AvatarResetTimerState';
transition : '#AvatarTransition' first reset_tmr_0
then state2;
exit action stopstate :'#AvatarStopState';
}
}
}
// Block blk0=============
part blk0 : '#AvatarBlock' {
// Attributes ---------------------
attribute x : Integer default := 0;
attribute b : Boolean default := false;
attribute p : 'Point';
attribute y : Integer default := 0;
// Methods ---------------------
calc make: '#AvatarCalcMethod' {
attribute x : Integer;
attribute y : Integer;
return : 'Point';
}
calc getx: '#AvatarCalcMethod' {
attribute p : 'Point';
return : Integer;
}
action foo: '#AvatarVoidMethod' {
attribute b : Boolean;
attribute p : 'Point';
attribute x : Integer;
}
// Signals ---------------------
part sig_in0 : '#Channel';
part sig_out0 : '#Channel';
// state-machine -------------------
exhibit state '@statemachine' : '#AvatarStateMachine' {
state random_0 : '#AvatarRandomState' = '#AvatarRandomState'(
'@request' = {
if p.x > 4 ?
'#immediate_request'
else '#nok_request'(1)
},
'@state_action' = '#Assignment'(
'@target' = x,
'@value' = '#bound_random'(0, p.y)
)
);
transition : '#AvatarTransition' first random_0
do action : '#TransitionAction' {
first start;
then action = foo(b, p, x);
then done;
} then prercv_in0_0;
state prercv_in0_0 : '#AvatarPreReceiveState' = '#AvatarPreReceiveState' (
'@request' = {
'#ReceiveRequest'(
'@channel'= sig_in0
)
}
);
transition : '#AvatarTransition' first prercv_in0_0
do action : '#ReceiveAction' {
item '@msg' : msg_in0 = '@payload' as msg_in0;
first start;
then assign x := '@msg'.x;
then assign p := '@msg'.p;
then assign b := '@msg'.b;
then done;
} then rcv_in0_0;
exit action stopstate :'#AvatarStopState';
state snd_out0_0 : '#AvatarSendState';
transition : '#AvatarTransition' first snd_out0_0
do action : '#TransitionAction' {
first start;
then assign p:= make(x, y);
then assign x:= getx(p);
then done;
} then random_0;
entry action startstate :'#AvatarStartState' = '#AvatarStartState'(
'@request' = {
'#TrivialRequest'('@delay' = '#bound_random'(1, p.x))
}
);
transition : '#AvatarTransition' first startstate
do action : '#TransitionAction' {
first start;
then assign x:= 1;
then assign b:= true;
then assign p::x:= x;
then done;
} then presnd_out0_0;
state presnd_out0_0 : '#AvatarPreSendState' = '#AvatarPreSendState' (
'@request' = {
'#SendRequest'(
'@channel'= sig_out0,
'@payload' = msg_out0(
x,
p,
b )
)
}
);
transition : '#AvatarTransition' first presnd_out0_0 then snd_out0_0;
state rcv_in0_0 : '#AvatarReceiveState';
transition : '#AvatarTransition' first rcv_in0_0
then stopstate;
}
}
// Block Shortcut Links $$$$$$$$$$$$
part blk1_0 : '#AvatarBlock' :> blk1.blk1_0 = blk1.blk1_0;
}