-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathondaVerde.xml
401 lines (387 loc) · 12.4 KB
/
ondaVerde.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
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.6//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_6.dtd'>
<nta>
<declaration>clock time;
const int N = 4; // Número de semáforos
typedef int[0, N-1] id_t; // Semáforos
typedef int[0,N-1] pid_t; // Controlador
chan verde[N], vermelho[N], verde_via[N], vermelho_via[N];
chan done, ready, run, Go;
broadcast chan back;
//const int velocidade = 11; // Velocidade do carro em metros/segundo 11,11
// Tempos, em segundos, estimados de chegada em cada semáforo baseado na distância e na velocidade
int tChegSem1 = 108;
int tChegSem2 = 120;
int tChegSem3 = 134;
int tChegSem4 = 149;
int tChegRota = 157;
const int tVerde = 20;
const int tAmarelo = 3;
const int tVermelho = 30;
const int P[pid_t] = {0,1,2,3}; // Priorities
// Task queue
pid_t queue[pid_t];
int[0,N] len = 0;
void initialize()
{
bool picked[pid_t];
for(i : pid_t)
{
int max = 4, t = -1;
for(j : pid_t)
{
if (!picked[j] && P[j] < max)
{
max = P[j];
t = j;
}
}
picked[t] = true;
queue[i] = t;
}
}
pid_t head() { return queue[0]; }
bool isEmpty() { return len == 0; }
void add(pid_t id)
{
pid_t i, tmp;
queue[len] = id;
for(i = len ; i > 0 && P[queue[i]] < P[queue[i-1]]; --i)
{
tmp = queue[i];
queue[i] = queue[i-1];
queue[i-1] = tmp;
}
len++;
}
void remove()
{
int i;
int first=queue[0];
for(i = 0; i+1 < N; ++i)
{
queue[i] = queue[i+1];
}
queue[N - 1] = first;
//queue[--len] = 0;
len=0;
}
</declaration>
<template>
<name x="5" y="5">Semaforo</name>
<parameter>const id_t id</parameter>
<declaration>clock x; // Relógio para controlar o semáforo
</declaration>
<location id="id0" x="-646" y="-442" color="#00ff00">
<name x="-672" y="-476">Verde</name>
</location>
<location id="id1" x="-442" y="-442" color="#ffff00">
<name x="-468" y="-476">Amarelo</name>
<urgent/>
</location>
<location id="id2" x="-544" y="-306" color="#ff0000">
<name x="-578" y="-289">Vermelho</name>
</location>
<init ref="id2"/>
<transition id="id3">
<source ref="id1"/>
<target ref="id2"/>
<label kind="synchronisation" x="-424" y="-459">back?</label>
<nail x="-340" y="-442"/>
<nail x="-340" y="-306"/>
</transition>
<transition id="id4">
<source ref="id0"/>
<target ref="id2"/>
<label kind="synchronisation" x="-764" y="-459">back?</label>
<nail x="-782" y="-442"/>
<nail x="-782" y="-306"/>
</transition>
<transition id="id5">
<source ref="id2"/>
<target ref="id0"/>
<label kind="guard" x="-722" y="-374">head()==id</label>
<label kind="synchronisation" x="-722" y="-400">verde[id]?</label>
<label kind="assignment" x="-722" y="-357">add(id)</label>
</transition>
<transition id="id6">
<source ref="id1"/>
<target ref="id2"/>
<label kind="synchronisation" x="-484" y="-382">vermelho[id]?</label>
</transition>
<transition id="id7">
<source ref="id0"/>
<target ref="id1"/>
<label kind="assignment" x="-628" y="-442">x=0</label>
</transition>
</template>
<template>
<name>Via</name>
<declaration>clock y; // Relógio para controlar a movimentação do carro
</declaration>
<location id="id8" x="-4590" y="-4386">
<name x="-4641" y="-4394">Sem1</name>
</location>
<location id="id9" x="-4862" y="-4386">
<name x="-4845" y="-4394">Sem0</name>
</location>
<location id="id10" x="-5168" y="-4386">
<name x="-5185" y="-4420">Posto</name>
</location>
<location id="id11" x="-4284" y="-4386">
<name x="-4267" y="-4394">Sem2</name>
</location>
<location id="id12" x="-4012" y="-4386">
<name x="-4063" y="-4394">Sem3</name>
</location>
<location id="id13" x="-3808" y="-4386">
<name x="-3825" y="-4420">Rota</name>
</location>
<location id="id14" x="-4862" y="-4556">
<name x="-4879" y="-4590">Wait1</name>
</location>
<location id="id15" x="-4590" y="-4216">
<name x="-4607" y="-4199">Wait2</name>
</location>
<location id="id16" x="-4284" y="-4556">
<name x="-4309" y="-4590">Wait3</name>
</location>
<location id="id17" x="-4012" y="-4216">
<name x="-4029" y="-4199">Wait4</name>
</location>
<location id="id18" x="-5032" y="-4386">
<name x="-5066" y="-4369">Trecho1</name>
</location>
<location id="id19" x="-4590" y="-4556">
<name x="-4581" y="-4590">Trecho2</name>
</location>
<location id="id20" x="-4284" y="-4216">
<name x="-4309" y="-4199">Trecho3</name>
</location>
<location id="id21" x="-4012" y="-4556">
<name x="-4022" y="-4590">Trecho4</name>
</location>
<init ref="id10"/>
<transition id="id22">
<source ref="id13"/>
<target ref="id18"/>
<label kind="synchronisation" x="-4369" y="-4148">back!</label>
<nail x="-3808" y="-4148"/>
<nail x="-5032" y="-4148"/>
</transition>
<transition id="id23">
<source ref="id12"/>
<target ref="id13"/>
<label kind="synchronisation" x="-3978" y="-4403">verde_via[3]?</label>
<label kind="assignment" x="-3978" y="-4386">y = tChegRota</label>
</transition>
<transition id="id24">
<source ref="id17"/>
<target ref="id13"/>
<label kind="synchronisation" x="-3918" y="-4301">done!</label>
</transition>
<transition id="id25">
<source ref="id12"/>
<target ref="id17"/>
<label kind="synchronisation" x="-4148" y="-4284">vermelho_via[3]?</label>
</transition>
<transition id="id26">
<source ref="id11"/>
<target ref="id21"/>
<label kind="synchronisation" x="-4199" y="-4513">verde_via[2]?</label>
</transition>
<transition id="id27">
<source ref="id21"/>
<target ref="id12"/>
<label kind="synchronisation" x="-4003" y="-4505">ready!</label>
<label kind="assignment" x="-4003" y="-4488">y = tChegSem4</label>
</transition>
<transition id="id28">
<source ref="id16"/>
<target ref="id21"/>
<label kind="synchronisation" x="-4173" y="-4581">done!</label>
</transition>
<transition id="id29">
<source ref="id11"/>
<target ref="id16"/>
<label kind="synchronisation" x="-4420" y="-4471">vermelho_via[2]?</label>
</transition>
<transition id="id30">
<source ref="id8"/>
<target ref="id20"/>
<label kind="synchronisation" x="-4471" y="-4335">verde_via[1]?</label>
</transition>
<transition id="id31">
<source ref="id20"/>
<target ref="id11"/>
<label kind="synchronisation" x="-4275" y="-4318">ready!</label>
<label kind="assignment" x="-4275" y="-4301">y = tChegSem3</label>
</transition>
<transition id="id32">
<source ref="id15"/>
<target ref="id20"/>
<label kind="synchronisation" x="-4479" y="-4241">done!</label>
</transition>
<transition id="id33">
<source ref="id8"/>
<target ref="id15"/>
<label kind="synchronisation" x="-4726" y="-4309">vermelho_via[1]?</label>
</transition>
<transition id="id34">
<source ref="id19"/>
<target ref="id8"/>
<label kind="synchronisation" x="-4581" y="-4488">ready!</label>
<label kind="assignment" x="-4581" y="-4471">y = tChegSem2</label>
</transition>
<transition id="id35">
<source ref="id9"/>
<target ref="id19"/>
<label kind="synchronisation" x="-4819" y="-4496">verde_via[0]?</label>
</transition>
<transition id="id36">
<source ref="id14"/>
<target ref="id19"/>
<label kind="synchronisation" x="-4751" y="-4581">done!</label>
</transition>
<transition id="id37">
<source ref="id9"/>
<target ref="id14"/>
<label kind="synchronisation" x="-5006" y="-4479">vermelho_via[0]?</label>
</transition>
<transition id="id38">
<source ref="id18"/>
<target ref="id9"/>
<label kind="synchronisation" x="-4972" y="-4411">ready!</label>
<label kind="assignment" x="-4998" y="-4386">y = tChegSem1</label>
</transition>
<transition id="id39">
<source ref="id10"/>
<target ref="id18"/>
<label kind="synchronisation" x="-5108" y="-4411">Go?</label>
</transition>
</template>
<template>
<name x="40" y="16">Controlador</name>
<location id="id40" x="32" y="56">
<name x="22" y="26">Init</name>
<committed/>
</location>
<location id="id41" x="32" y="144">
<name x="40" y="112">Free</name>
<committed/>
</location>
<location id="id42" x="32" y="216">
</location>
<location id="id43" x="32" y="288">
<name x="51" y="280">Begin</name>
<committed/>
</location>
<location id="id44" x="34" y="408">
<name x="-25" y="391">Green</name>
</location>
<location id="id45" x="34" y="578">
<name x="-34" y="578">Occ</name>
</location>
<location id="id46" x="238" y="408">
<name x="246" y="416">Verm_Occ</name>
</location>
<init ref="id40"/>
<transition id="id47">
<source ref="id45"/>
<target ref="id42"/>
<label kind="synchronisation" x="186" y="238">back?</label>
<label kind="assignment" x="178" y="221">remove()</label>
<nail x="340" y="510"/>
<nail x="340" y="221"/>
</transition>
<transition id="id48">
<source ref="id46"/>
<target ref="id45"/>
<label kind="select" x="136" y="493">e:id_t</label>
<label kind="synchronisation" x="136" y="510">vermelho_via[e]!</label>
</transition>
<transition id="id49">
<source ref="id44"/>
<target ref="id46"/>
<label kind="select" x="59" y="382">e:id_t</label>
<label kind="synchronisation" x="119" y="382">vermelho[e]!</label>
</transition>
<transition id="id50">
<source ref="id44"/>
<target ref="id45"/>
<label kind="select" x="42" y="442">e:id_t</label>
<label kind="synchronisation" x="42" y="459">verde_via[e]!</label>
</transition>
<transition id="id51">
<source ref="id40"/>
<target ref="id41"/>
<label kind="synchronisation" x="42" y="85">Go!</label>
<label kind="assignment" x="40" y="72">initialize()</label>
</transition>
<transition id="id52">
<source ref="id41"/>
<target ref="id42"/>
<label kind="guard" x="-42" y="170">isEmpty()</label>
</transition>
<transition id="id53">
<source ref="id42"/>
<target ref="id43"/>
<label kind="synchronisation" x="-25" y="238">ready?</label>
</transition>
<transition id="id54">
<source ref="id41"/>
<target ref="id43"/>
<label kind="guard" x="-64" y="120">!isEmpty()</label>
<nail x="-64" y="144"/>
<nail x="-64" y="288"/>
</transition>
<transition id="id55">
<source ref="id45"/>
<target ref="id43"/>
<label kind="synchronisation" x="-51" y="485">ready?</label>
<label kind="assignment" x="-51" y="502">remove()</label>
<nail x="-59" y="578"/>
<nail x="-59" y="323"/>
</transition>
<transition id="id56">
<source ref="id45"/>
<target ref="id41"/>
<label kind="synchronisation" x="374" y="348">done?</label>
<label kind="assignment" x="374" y="365">remove()</label>
<nail x="365" y="578"/>
<nail x="365" y="144"/>
</transition>
<transition id="id57">
<source ref="id43"/>
<target ref="id44"/>
<label kind="select" x="42" y="323">e:id_t</label>
<label kind="synchronisation" x="42" y="340">verde[e]!</label>
</transition>
</template>
<system>system Semaforo, Via, Controlador;
</system>
<queries>
<query>
<formula>E<> (Semaforo(0).Verde && Semaforo(1).Verde && Semaforo(2).Verde && Semaforo(3).Vermelho) ||
(Semaforo(0).Verde && Semaforo(1).Verde && Semaforo(2).Vermelho && Semaforo(3).Verde) ||
(Semaforo(0).Verde && Semaforo(1).Vermelho && Semaforo(2).Verde && Semaforo(3).Verde) ||
(Semaforo(0).Vermelho && Semaforo(1).Verde && Semaforo(2).Verde && Semaforo(3).Verde)
</formula>
<comment>3 semáforos ficam verdes e apenas 1 vermelho.</comment>
<result outcome="success" type="quality" timestamp="2024-05-14 21:42:57 -0300">
</result>
</query>
<query>
<formula>E<> Via.Rota</formula>
<comment>Um veículo pode passar por todos os semáforos sem interrupção indevida</comment>
<result outcome="success" type="quality" timestamp="2024-05-14 21:34:14 -0300">
</result>
</query>
<query>
<formula>A[] not deadlock</formula>
<comment>Não existe deadlock no sistema</comment>
<result outcome="success" type="quality" timestamp="2024-05-14 21:39:46 -0300">
</result>
</query>
</queries>
</nta>