123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
- <nta>
- <declaration>/*
- OR - 2019
- */
- const int NAB = 3; // # trains
- const int NBA = 3;
- const int N = 6;
- typedef int[0,NAB-1] id_tAB;
- typedef int[0,NBA-1] id_tBA;
- int ab=0, ba=0;
- chan accesAB[NAB], accesBA[NBA], libAB[NAB], libBA[NBA];
- </declaration>
- <template>
- <name>TrainBA</name>
- <parameter>const id_tBA id</parameter>
- <declaration>clock x;</declaration>
- <location id="id0" x="-51" y="0">
- <name x="-59" y="17">A</name>
- </location>
- <location id="id1" x="102" y="0">
- <name x="102" y="17">BA</name>
- <label kind="invariant" x="119" y="0">x<=10</label>
- </location>
- <location id="id2" x="102" y="-127">
- <name x="92" y="-161">B</name>
- </location>
- <location id="id3" x="-51" y="-127">
- <name x="-61" y="-161">Safe</name>
- </location>
- <init ref="id3"/>
- <transition>
- <source ref="id0"/>
- <target ref="id3"/>
- <label kind="synchronisation" x="-51" y="-80">libBA[id] !</label>
- </transition>
- <transition>
- <source ref="id1"/>
- <target ref="id0"/>
- </transition>
- <transition>
- <source ref="id2"/>
- <target ref="id1"/>
- <label kind="synchronisation" x="102" y="-80">accesBA[id] ?</label>
- <label kind="assignment" x="102" y="-63">x:=0</label>
- </transition>
- <transition>
- <source ref="id3"/>
- <target ref="id2"/>
- </transition>
- </template>
- <template>
- <name x="40" y="16">TrainAB</name>
- <parameter>const id_tAB id</parameter>
- <declaration>clock x;</declaration>
- <location id="id4" x="96" y="96">
- <name x="48" y="80">Safe</name>
- </location>
- <location id="id5" x="256" y="96">
- <name x="272" y="80">A</name>
- </location>
- <location id="id6" x="96" y="232">
- <name x="32" y="216">B</name>
- </location>
- <location id="id7" x="256" y="232">
- <name x="272" y="216">AB</name>
- <label kind="invariant" x="246" y="249">x<=10</label>
- </location>
- <init ref="id4"/>
- <transition>
- <source ref="id6"/>
- <target ref="id4"/>
- <label kind="synchronisation" x="96" y="147">libAB[id] !</label>
- </transition>
- <transition>
- <source ref="id7"/>
- <target ref="id6"/>
- </transition>
- <transition>
- <source ref="id5"/>
- <target ref="id7"/>
- <label kind="synchronisation" x="256" y="147">accesAB[id] ?</label>
- <label kind="assignment" x="256" y="164">x:=0</label>
- </transition>
- <transition>
- <source ref="id4"/>
- <target ref="id5"/>
- </transition>
- </template>
- <template>
- <name x="40" y="16">CTRL</name>
- <declaration>id_tAB list[N+1];
- int[0,N] len;
- // Put an element at the end of the queue
- void enqueue(id_tAB element)
- {
- list[len++] = element;
- }
- // Remove the front element of the queue
- void dequeue()
- {
- int i = 0;
- len -= 1;
- while (i < len)
- {
- list[i] = list[i + 1];
- i++;
- }
- list[i] = 0;
- }
- // Returns the front element of the queue
- id_tAB front()
- {
- return list[0];
- }
- // Returns the last element of the queue
- id_tAB tail()
- {
- return list[len - 1];
- }</declaration>
- <location id="id8" x="-42" y="59">
- <name x="-93" y="51">Free</name>
- </location>
- <location id="id9" x="212" y="-68">
- <name x="202" y="-102">AB</name>
- <label kind="comments" x="204" y="-127">At least one train is going from A to B</label>
- </location>
- <location id="id10" x="212" y="187">
- <name x="204" y="204">BA</name>
- <label kind="comments" x="204" y="229">At least one from B to A</label>
- </location>
- <init ref="id8"/>
- <transition>
- <source ref="id10"/>
- <target ref="id8"/>
- <label kind="synchronisation" x="-119" y="144">libBA[1] ?</label>
- <label kind="comments" x="-255" y="170">Last train leaving BA section</label>
- <nail x="-42" y="187"/>
- </transition>
- <transition>
- <source ref="id8"/>
- <target ref="id10"/>
- <label kind="synchronisation" x="238" y="102">accesBA[1] !</label>
- <label kind="comments" x="238" y="127">First train from B to A</label>
- <nail x="212" y="85"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id8"/>
- <label kind="synchronisation" x="-119" y="-85">libAB[1] ?</label>
- <label kind="comments" x="-255" y="-59">Last train leaving AB section</label>
- <nail x="-42" y="-68"/>
- </transition>
- <transition>
- <source ref="id8"/>
- <target ref="id9"/>
- <label kind="synchronisation" x="229" y="-34">accesAB[1] !</label>
- <label kind="comments" x="229" y="-8">First train from A heading to B</label>
- <nail x="212" y="17"/>
- </transition>
- </template>
- <system>system TrainAB, TrainBA, CTRL;
- </system>
- <queries>
- <query>
- <formula>E<> TrainBA(1).BA</formula>
- <comment></comment>
- </query>
- <query>
- <formula>E<> TrainBA(2).BA
- </formula>
- <comment>
- </comment>
- </query>
- <query>
- <formula>A[] forall (i : id_tBA) forall (j : id_tAB) TrainBA(i).BA && TrainAB(j).AB imply i == j
- </formula>
- <comment>
- </comment>
- </query>
- <query>
- <formula>TrainBA(1).B --> TrainBA(1).BA
- </formula>
- <comment>
- </comment>
- </query>
- <query>
- <formula>A<> TrainBA(1).BA
- </formula>
- <comment>
- </comment>
- </query>
- <query>
- <formula>E<> TrainBA(1).BA & TrainBA(2).BA
- </formula>
- <comment>
- </comment>
- </query>
- </queries>
- </nta>
|