debugging_environment.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!DOCTYPE html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script type="text/javascript" src="http://code.jquery.com/jquery-2.2.1.min.js"></script>
  5. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  6. <link rel="stylesheet" type="text/css" href="javascript_runtime/libs/w2ui-1.4.3.min.css" />
  7. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  8. <script src="javascript_runtime/libs/w2ui-1.4.3.min.js"></script>
  9. <script src="http://d3js.org/d3.v3.min.js"></script>
  10. <script type="text/javascript" src="javascript_runtime/libs/ui.js"></script>
  11. <script type="text/javascript" src="javascript_runtime/statecharts_core.js"></script>
  12. <script src="/socket.io/socket.io.js"></script>
  13. <style type="text/css">
  14. .w2ui-icon.simulate { background: url('img/simulate.png') no-repeat center !important; }
  15. .w2ui-icon.simulatert { background: url('img/simulatert.png') no-repeat center !important; }
  16. .w2ui-icon.pause { background: url('img/pause.png') no-repeat center !important; }
  17. .w2ui-icon.bigstep { background: url('img/bigstep.png') no-repeat center !important; }
  18. .w2ui-icon.smallstep { background: url('img/smallstep.png') no-repeat center !important; }
  19. .w2ui-icon.reset { background: url('img/reset.png') no-repeat center !important; }
  20. .w2ui-icon.breakpoint { background: url('img/breakpoint.png') no-repeat center !important; }
  21. </style>
  22. <style type="text/css">
  23. .node rect {
  24. fill: #fff;
  25. stroke: #000;
  26. stroke-width: 1px;
  27. fill-opacity: 0.7;
  28. }
  29. .imminent rect {
  30. fill: lightblue;
  31. }
  32. .INTERNAL rect {
  33. fill: lightblue;
  34. }
  35. .EXTERNAL rect {
  36. fill: tomato;
  37. }
  38. text { font: bold 12px sans-serif; }
  39. .timeNext { font: bold 10px sans-serif; }
  40. .link {
  41. fill: none;
  42. stroke: #bbb;
  43. }
  44. .portConnection {
  45. fill: none;
  46. stroke: red;
  47. marker-mid: url(#marker_arrow);
  48. }
  49. .input {
  50. stroke: green;
  51. marker-mid: url(#marker_arrow_green);
  52. }
  53. .invisibleLink {
  54. stroke-width: 0;
  55. }
  56. .invisible text {
  57. fill-opacity: 0;
  58. }
  59. .visible text {
  60. fill-opacity: 1;
  61. }
  62. .outmessage {
  63. fill: yellow;
  64. stroke: #000;
  65. fill-opacity: 0.7;
  66. }
  67. .inmessage {
  68. fill: orange;
  69. stroke: #000;
  70. fill-opacity: 0.7;
  71. }
  72. .invisibleInfo tspan {
  73. fill-opacity: 0;
  74. }
  75. .smallStepInfo {
  76. border: 1px solid black;
  77. background-color: blue;
  78. width: 7px;
  79. height: 7px;
  80. float: left;
  81. }
  82. .inactive {
  83. opacity: 0.3;
  84. }
  85. .invisibleInfo {
  86. display: none;
  87. }
  88. .coupled text {
  89. font-style: italic;
  90. }
  91. form { display: table; }
  92. form p { display: table-row; }
  93. form p label { display: table-cell; }
  94. form p input { display: table-cell; }
  95. </style>
  96. </head>
  97. <body>
  98. <div id="godEventPopup" class="popupWindow" title="Insert God Event">
  99. <form>
  100. <p>
  101. <label for="godEventName">Name:</label>
  102. <input type="text" id="godEventName" class="text ui-widget-content ui-corner-all" />
  103. </p>
  104. <p>
  105. <label for="godEventValue">Value:</label>
  106. <input type="text" id="godEventValue" class="text ui-widget-content ui-corner-all" />
  107. </p>
  108. </form>
  109. </div>
  110. <div id="injectEventPopup" class="popupWindow" title="Inject Event">
  111. <form>
  112. <p>
  113. <label for="injectEvent">Event:</label>
  114. <input type="text" id="injectEvent" class="text ui-widget-content ui-corner-all" />
  115. </p>
  116. <p>
  117. <label for="injectTime">Time:</label>
  118. <input type="text" id="injectTime" class="text ui-widget-content ui-corner-all" />
  119. </p>
  120. </form>
  121. </div>
  122. <div id="breakpointPopup" class="popupWindow" title="Add Breakpoint">
  123. <form>
  124. <p>
  125. <label for="breakpointName">Name:</label>
  126. <input type="text" id="breakpointName" class="text ui-widget-content ui-corner-all" />
  127. </p>
  128. <p>
  129. <label for="breakpointFunction">Function:</label>
  130. <textarea id="breakpointFunction" class="text ui-widget-content ui-corner-all" style="width:400px;height:150px;">def breakpoint(t, m, tr, ob, ib):
  131. </textarea>
  132. </p>
  133. <p>
  134. <label for="breakpointEnabled">Enabled:</label>
  135. <input type="checkbox" id="breakpointEnabled" class="ui-widget-content ui-corner-all" checked />
  136. </p>
  137. <p>
  138. <label for="breakpointDisableOnTrigger">Disable on Trigger:</label>
  139. <input type="checkbox" id="breakpointDisableOnTrigger" class="ui-widget-content ui-corner-all" checked />
  140. </p>
  141. </form>
  142. </div>
  143. <script type="text/javascript" src="debugging_environment.js"></script>
  144. <script>
  145. var controller = new DebuggingEnvironment.Controller();
  146. var ui_reply_port = controller.addOutputListener('output');
  147. var socket = io();
  148. /*
  149. Check whether the user interacted with the debugging UI. If so, forward to communication layer.
  150. */
  151. setInterval(function() {
  152. while (true) {
  153. reply_msg = ui_reply_port.fetch(0)
  154. if (reply_msg == undefined) {
  155. break
  156. }
  157. // console.log(JSON.stringify(reply_msg));
  158. socket.emit('message', JSON.stringify(reply_msg) + "\n");
  159. }
  160. }, 5)
  161. /*
  162. When we receive a message from the communication layer (either from the simulator itself or the visualization interface),
  163. translate it to the correct event for the visualization Statechart.
  164. */
  165. socket.on('msg', function(msg){
  166. if (msg.substring(0, 4) == "vis_") {
  167. // message from the visualization interface
  168. msg = JSON.parse(msg.substring(4));
  169. cmd = msg["name"];
  170. if (cmd == "select_instance") {
  171. controller.addInput(new Event("select_instance", "ui_input", msg["parameters"]), 0.0);
  172. }
  173. } else {
  174. // message from the simulator (a state update, breakpoint trigger, ...)
  175. // console.log(msg);
  176. msg = JSON.parse(msg)[0];
  177. if (msg["name"] == "all_states"
  178. || msg["name"] == "all_states_reset"
  179. || msg["name"] == "new_states"
  180. || msg["name"] == "imminents"
  181. || msg["name"] == "selected_imminent"
  182. || msg["name"] == "outbag"
  183. || msg["name"] == "inbags"
  184. || msg["name"] == "transitioning"
  185. || msg["name"] == "new_internal_states"
  186. || msg["name"] == "new_tn"
  187. || msg["name"] == "structural_changes"
  188. || msg["name"] == "god_event_ok"
  189. || msg["name"] == "inject_ok"
  190. || msg["name"] == "breakpoint_triggered") {
  191. controller.addInput(new Event(msg["name"], "simulation_input", [msg["parameters"]]), 0.0)
  192. }
  193. }
  194. });
  195. controller.start();
  196. </script>
  197. <span id="currLoc" style="display:none" />
  198. </body>