trains0.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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="246" y="127">
  123. <name x="229" y="85">Free</name>
  124. </location>
  125. <init ref="id8"/>
  126. </template>
  127. <system>system TrainAB, TrainBA, CTRL;
  128. </system>
  129. <queries>
  130. <query>
  131. <formula>E&lt;&gt; TrainBA(1).BA
  132. </formula>
  133. <comment>
  134. </comment>
  135. </query>
  136. <query>
  137. <formula>A[] forall (i : id_tBA) forall (j : id_tAB) TrainBA(i).BA &amp;&amp; TrainAB(j).AB imply i == j
  138. </formula>
  139. <comment>
  140. </comment>
  141. </query>
  142. <query>
  143. <formula>TrainBA(1).B --&gt; TrainBA(1).BA
  144. </formula>
  145. <comment>
  146. </comment>
  147. </query>
  148. <query>
  149. <formula>A&lt;&gt; TrainBA(1).BA
  150. </formula>
  151. <comment>
  152. </comment>
  153. </query>
  154. <query>
  155. <formula>E&lt;&gt; TrainBA(1).BA &amp; TrainBA(2).BA
  156. </formula>
  157. <comment>
  158. </comment>
  159. </query>
  160. </queries>
  161. </nta>