trains0.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
  3. <nta>
  4. <declaration>/*
  5. OR - 2019
  6. */
  7. const int NAB = 3; // # trains
  8. const int NBA = 3;
  9. const int N = 6;
  10. typedef int[0,NAB-1] id_tAB;
  11. typedef int[0,NBA-1] id_tBA;
  12. int ab=0, ba=0;
  13. chan accesAB[NAB], accesBA[NBA], libAB[NAB], libBA[NBA];
  14. </declaration>
  15. <template>
  16. <name>TrainBA</name>
  17. <parameter>const id_tBA id</parameter>
  18. <declaration>clock x;</declaration>
  19. <location id="id0" x="-51" y="0">
  20. <name x="-59" y="17">A</name>
  21. </location>
  22. <location id="id1" x="102" y="0">
  23. <name x="102" y="17">BA</name>
  24. <label kind="invariant" x="119" y="0">x&lt;=10</label>
  25. </location>
  26. <location id="id2" x="102" y="-127">
  27. <name x="92" y="-161">B</name>
  28. </location>
  29. <location id="id3" x="-51" y="-127">
  30. <name x="-61" y="-161">Safe</name>
  31. </location>
  32. <init ref="id3"/>
  33. <transition>
  34. <source ref="id0"/>
  35. <target ref="id3"/>
  36. <label kind="synchronisation" x="-51" y="-80">libBA[id] !</label>
  37. </transition>
  38. <transition>
  39. <source ref="id1"/>
  40. <target ref="id0"/>
  41. </transition>
  42. <transition>
  43. <source ref="id2"/>
  44. <target ref="id1"/>
  45. <label kind="synchronisation" x="102" y="-80">accesBA[id] ?</label>
  46. <label kind="assignment" x="102" y="-63">x:=0</label>
  47. </transition>
  48. <transition>
  49. <source ref="id3"/>
  50. <target ref="id2"/>
  51. </transition>
  52. </template>
  53. <template>
  54. <name x="40" y="16">TrainAB</name>
  55. <parameter>const id_tAB id</parameter>
  56. <declaration>clock x;</declaration>
  57. <location id="id4" x="96" y="96">
  58. <name x="48" y="80">Safe</name>
  59. </location>
  60. <location id="id5" x="256" y="96">
  61. <name x="272" y="80">A</name>
  62. </location>
  63. <location id="id6" x="96" y="232">
  64. <name x="32" y="216">B</name>
  65. </location>
  66. <location id="id7" x="256" y="232">
  67. <name x="272" y="216">AB</name>
  68. <label kind="invariant" x="246" y="249">x&lt;=10</label>
  69. </location>
  70. <init ref="id4"/>
  71. <transition>
  72. <source ref="id6"/>
  73. <target ref="id4"/>
  74. <label kind="synchronisation" x="96" y="147">libAB[id] !</label>
  75. </transition>
  76. <transition>
  77. <source ref="id7"/>
  78. <target ref="id6"/>
  79. </transition>
  80. <transition>
  81. <source ref="id5"/>
  82. <target ref="id7"/>
  83. <label kind="synchronisation" x="256" y="147">accesAB[id] ?</label>
  84. <label kind="assignment" x="256" y="164">x:=0</label>
  85. </transition>
  86. <transition>
  87. <source ref="id4"/>
  88. <target ref="id5"/>
  89. </transition>
  90. </template>
  91. <template>
  92. <name x="40" y="16">CTRL</name>
  93. <declaration>id_tAB list[N+1];
  94. int[0,N] len;
  95. // Put an element at the end of the queue
  96. void enqueue(id_tAB element)
  97. {
  98. list[len++] = element;
  99. }
  100. // Remove the front element of the queue
  101. void dequeue()
  102. {
  103. int i = 0;
  104. len -= 1;
  105. while (i &lt; len)
  106. {
  107. list[i] = list[i + 1];
  108. i++;
  109. }
  110. list[i] = 0;
  111. }
  112. // Returns the front element of the queue
  113. id_tAB front()
  114. {
  115. return list[0];
  116. }
  117. // Returns the last element of the queue
  118. id_tAB tail()
  119. {
  120. return list[len - 1];
  121. }</declaration>
  122. <location id="id8" x="-42" y="59">
  123. <name x="-93" y="51">Free</name>
  124. </location>
  125. <location id="id9" x="212" y="-68">
  126. <name x="202" y="-102">AB</name>
  127. <label kind="comments" x="204" y="-127">At least one train is going from A to B</label>
  128. </location>
  129. <location id="id10" x="212" y="187">
  130. <name x="204" y="204">BA</name>
  131. <label kind="comments" x="204" y="229">At least one from B to A</label>
  132. </location>
  133. <init ref="id8"/>
  134. <transition>
  135. <source ref="id10"/>
  136. <target ref="id8"/>
  137. <label kind="synchronisation" x="-119" y="144">libBA[1] ?</label>
  138. <label kind="comments" x="-255" y="170">Last train leaving BA section</label>
  139. <nail x="-42" y="187"/>
  140. </transition>
  141. <transition>
  142. <source ref="id8"/>
  143. <target ref="id10"/>
  144. <label kind="synchronisation" x="238" y="102">accesBA[1] !</label>
  145. <label kind="comments" x="238" y="127">First train from B to A</label>
  146. <nail x="212" y="85"/>
  147. </transition>
  148. <transition>
  149. <source ref="id9"/>
  150. <target ref="id8"/>
  151. <label kind="synchronisation" x="-119" y="-85">libAB[1] ?</label>
  152. <label kind="comments" x="-255" y="-59">Last train leaving AB section</label>
  153. <nail x="-42" y="-68"/>
  154. </transition>
  155. <transition>
  156. <source ref="id8"/>
  157. <target ref="id9"/>
  158. <label kind="synchronisation" x="229" y="-34">accesAB[1] !</label>
  159. <label kind="comments" x="229" y="-8">First train from A heading to B</label>
  160. <nail x="212" y="17"/>
  161. </transition>
  162. </template>
  163. <system>system TrainAB, TrainBA, CTRL;
  164. </system>
  165. <queries>
  166. <query>
  167. <formula>E&lt;&gt; TrainBA(1).BA</formula>
  168. <comment></comment>
  169. </query>
  170. <query>
  171. <formula>E&lt;&gt; TrainBA(2).BA
  172. </formula>
  173. <comment>
  174. </comment>
  175. </query>
  176. <query>
  177. <formula>A[] forall (i : id_tBA) forall (j : id_tAB) TrainBA(i).BA &amp;&amp; TrainAB(j).AB imply i == j
  178. </formula>
  179. <comment>
  180. </comment>
  181. </query>
  182. <query>
  183. <formula>TrainBA(1).B --&gt; TrainBA(1).BA
  184. </formula>
  185. <comment>
  186. </comment>
  187. </query>
  188. <query>
  189. <formula>A&lt;&gt; TrainBA(1).BA
  190. </formula>
  191. <comment>
  192. </comment>
  193. </query>
  194. <query>
  195. <formula>E&lt;&gt; TrainBA(1).BA &amp; TrainBA(2).BA
  196. </formula>
  197. <comment>
  198. </comment>
  199. </query>
  200. </queries>
  201. </nta>