123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?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
- Adapted by Jovian HERSEMEULE - 2020
- */
- const int NAB = 3;
- 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 libAB[NAB], libBA[NBA], requestAB[NAB], requestBA[NBA];
- urgent chan accesAB[NAB], accesBA[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="-51" y="17">A</name>
- <urgent/>
- </location>
- <location id="id1" x="93" y="0">
- <name x="84" y="17">BA</name>
- <label kind="invariant" x="110" y="-8">x<=10</label>
- </location>
- <location id="id2" x="93" y="-127">
- <name x="93" y="-161">B</name>
- </location>
- <location id="id3" x="-51" y="-127">
- <name x="-59" y="-161">Safe</name>
- </location>
- <init ref="id3"/>
- <transition>
- <source ref="id0"/>
- <target ref="id3"/>
- <label kind="synchronisation" x="-51" y="-68">libBA[id] !</label>
- </transition>
- <transition>
- <source ref="id1"/>
- <target ref="id0"/>
- </transition>
- <transition>
- <source ref="id2"/>
- <target ref="id1"/>
- <label kind="synchronisation" x="101" y="-85">accesBA[id] ?</label>
- <label kind="assignment" x="101" y="-68">x:=0</label>
- </transition>
- <transition>
- <source ref="id3"/>
- <target ref="id2"/>
- <label kind="synchronisation" x="-33" y="-144">requestBA[id] !</label>
- </transition>
- </template>
- <template>
- <name x="40" y="16">TrainAB</name>
- <parameter>const id_tAB id</parameter>
- <declaration>clock x;</declaration>
- <location id="id4" x="127" y="93">
- <name x="116" y="65">Safe</name>
- </location>
- <location id="id5" x="280" y="93">
- <name x="279" y="65">A</name>
- </location>
- <location id="id6" x="127" y="229">
- <name x="124" y="243">B</name>
- <urgent/>
- </location>
- <location id="id7" x="280" y="229">
- <name x="270" y="243">AB</name>
- <label kind="invariant" x="296" y="218">x<=10</label>
- </location>
- <init ref="id4"/>
- <transition>
- <source ref="id6"/>
- <target ref="id4"/>
- <label kind="synchronisation" x="127" y="144">libAB[id] !</label>
- </transition>
- <transition>
- <source ref="id7"/>
- <target ref="id6"/>
- </transition>
- <transition>
- <source ref="id5"/>
- <target ref="id7"/>
- <label kind="synchronisation" x="280" y="144">accesAB[id] ?</label>
- <label kind="assignment" x="280" y="161">x:=0</label>
- </transition>
- <transition>
- <source ref="id4"/>
- <target ref="id5"/>
- <label kind="synchronisation" x="145" y="76">requestAB[id] !</label>
- </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="314" y="102">
- <name x="331" y="94">Free</name>
- </location>
- <location id="id9" x="212" y="-68">
- <name x="238" y="-59">OnlyAB</name>
- <label kind="comments" x="297" y="-59">At least one train on AB ;
- and no train blocked on B</label>
- </location>
- <location id="id10" x="212" y="263">
- <name x="229" y="238">OnlyBA</name>
- </location>
- <location id="id11" x="-153" y="-68">
- <name x="-272" y="-68">RequestFromB</name>
- <label kind="comments" x="-484" y="-42">Waiting for AB trains to leave shared section;
- some other trains are waiting on B.</label>
- </location>
- <location id="id12" x="-153" y="263">
- <name x="-272" y="246">RequestFromA</name>
- </location>
- <init ref="id8"/>
- <transition>
- <source ref="id11"/>
- <target ref="id11"/>
- <label kind="select" x="-263" y="-221">e:id_tAB</label>
- <label kind="synchronisation" x="-263" y="-204">accesAB[e]!</label>
- <nail x="-187" y="-187"/>
- <nail x="-263" y="-187"/>
- </transition>
- <transition>
- <source ref="id12"/>
- <target ref="id12"/>
- <label kind="select" x="-255" y="323">e:id_tBA</label>
- <label kind="synchronisation" x="-255" y="340">accesBA[e] !</label>
- <nail x="-196" y="323"/>
- <nail x="-256" y="323"/>
- </transition>
- <transition>
- <source ref="id8"/>
- <target ref="id9"/>
- <label kind="select" x="144" y="17">e:id_tAB</label>
- <label kind="synchronisation" x="102" y="34">requestAB[e] ?</label>
- <label kind="assignment" x="161" y="51">ab ++</label>
- <nail x="212" y="59"/>
- </transition>
- <transition>
- <source ref="id8"/>
- <target ref="id10"/>
- <label kind="select" x="144" y="136">e:id_tBA</label>
- <label kind="synchronisation" x="102" y="153">requestBA[e] ?</label>
- <label kind="assignment" x="161" y="170">ba ++</label>
- <nail x="212" y="144"/>
- </transition>
- <transition>
- <source ref="id12"/>
- <target ref="id9"/>
- <label kind="select" x="-221" y="153">e:id_tAB</label>
- <label kind="guard" x="-221" y="136">ba == 0</label>
- <label kind="synchronisation" x="-246" y="170">accesAB[e] !</label>
- <nail x="-153" y="144"/>
- </transition>
- <transition>
- <source ref="id10"/>
- <target ref="id8"/>
- <label kind="guard" x="263" y="186">ba == 0</label>
- </transition>
- <transition>
- <source ref="id12"/>
- <target ref="id12"/>
- <label kind="select" x="-153" y="322">e:id_tBA</label>
- <label kind="synchronisation" x="-153" y="339">libBA[e] ?</label>
- <label kind="assignment" x="-153" y="356">ba --</label>
- <nail x="-85" y="322"/>
- <nail x="-153" y="322"/>
- </transition>
- <transition>
- <source ref="id10"/>
- <target ref="id12"/>
- <label kind="select" x="-42" y="212">e:id_tAB</label>
- <label kind="synchronisation" x="-42" y="229">requestAB[e] ?</label>
- <label kind="assignment" x="-42" y="246">ab ++</label>
- </transition>
- <transition>
- <source ref="id10"/>
- <target ref="id10"/>
- <label kind="select" x="323" y="263">e:id_tBA</label>
- <label kind="synchronisation" x="323" y="280">requestBA[e] ?</label>
- <label kind="assignment" x="323" y="298">ba ++</label>
- <nail x="314" y="323"/>
- <nail x="314" y="263"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id9"/>
- <label kind="select" x="331" y="-153">e:id_tAB</label>
- <label kind="synchronisation" x="331" y="-136">requestAB[e] ?</label>
- <label kind="assignment" x="331" y="-119">ab ++</label>
- <nail x="323" y="-153"/>
- <nail x="323" y="-68"/>
- </transition>
- <transition>
- <source ref="id11"/>
- <target ref="id10"/>
- <label kind="select" x="-221" y="17">e:id_tBA</label>
- <label kind="guard" x="-221" y="0">ab == 0</label>
- <label kind="synchronisation" x="-246" y="34">accesBA[e] !</label>
- <nail x="-153" y="50"/>
- </transition>
- <transition>
- <source ref="id11"/>
- <target ref="id11"/>
- <label kind="select" x="-144" y="-238">e:id_tAB</label>
- <label kind="synchronisation" x="-144" y="-221">libAB[e] ?</label>
- <label kind="assignment" x="-144" y="-204">ab--</label>
- <nail x="-68" y="-187"/>
- <nail x="-153" y="-187"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id11"/>
- <label kind="select" x="-34" y="-119">e:id_tBA</label>
- <label kind="synchronisation" x="-34" y="-102">requestBA[e] ?</label>
- <label kind="assignment" x="-34" y="-85">ba ++</label>
- </transition>
- <transition>
- <source ref="id10"/>
- <target ref="id10"/>
- <label kind="select" x="221" y="339">e:id_tBA</label>
- <label kind="synchronisation" x="221" y="356">libBA[e] ?</label>
- <label kind="assignment" x="221" y="373">ba --</label>
- <nail x="280" y="331"/>
- <nail x="212" y="331"/>
- </transition>
- <transition>
- <source ref="id10"/>
- <target ref="id10"/>
- <label kind="select" x="110" y="340">e:id_tBA</label>
- <label kind="synchronisation" x="110" y="357">accesBA[e] !</label>
- <nail x="195" y="331"/>
- <nail x="110" y="331"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id9"/>
- <label kind="select" x="85" y="-229">e:id_tAB</label>
- <label kind="synchronisation" x="85" y="-212">accesAB[e] !</label>
- <nail x="187" y="-187"/>
- <nail x="85" y="-187"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id9"/>
- <label kind="select" x="212" y="-238">e:id_tAB</label>
- <label kind="synchronisation" x="212" y="-221">libAB[e] ?</label>
- <label kind="assignment" x="212" y="-204">ab--</label>
- <nail x="289" y="-187"/>
- <nail x="212" y="-187"/>
- </transition>
- <transition>
- <source ref="id9"/>
- <target ref="id8"/>
- <label kind="guard" x="272" y="8">ab == 0</label>
- </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>A[] not deadlock</formula>
- <comment></comment>
- </query>
- <query>
- <formula>E<> TrainBA(1).BA & TrainBA(2).BA
- </formula>
- <comment>
- </comment>
- </query>
- </queries>
- </nta>
|