trafficlight.sccd 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Diagram(name = 'Statechart', author = 'MSDL', description = 'Exported SCCD HUTN'):
  2. Top {
  3. import httplib
  4. import json
  5. method = 'PUT'
  6. host = 'localhost:8124'
  7. uri = '/GET/console?wid=5'
  8. timeout = 5000
  9. }
  10. Inport(name = 'ui')
  11. Class(name = 'MainApp', default = True):
  12. Method highlightState(nodeId) {
  13. headers = ['Content-Type': 'text/plain']
  14. data = json->dumps(['text':'CLIENT_BDAPI :: ["func":"_highlightState","args":["asid":'+str(nodeId)+',"followCrossFormalismLinks":"*"]]'])
  15. conn = httplib->HTTPConnection(host)
  16. conn->request(method, uri, data, headers)
  17. resp = conn->getresponse()
  18. conn->close()
  19. }
  20. Method unhighlightState(nodeId) {
  21. headers = ['Content-Type': 'text/plain']
  22. data = json->dumps(['text':'CLIENT_BDAPI :: ["func":"_unhighlightState","args":["asid":'+str(nodeId)+']]'])
  23. conn = httplib->HTTPConnection(host)
  24. conn->request(method, uri, data, headers)
  25. resp = conn->getresponse()
  26. conn->close()
  27. }
  28. StateMachine:
  29. initial = 'normal'
  30. State('normal'):
  31. initial = 'red'
  32. State('red'):
  33. OnEnter {
  34. self->setRed()
  35. self->highlightState(5)
  36. }
  37. OnExit {
  38. self->unhighlightState(5)
  39. }
  40. Transition(after=3.0, target='../green')
  41. State('green'):
  42. OnEnter {
  43. self->setGreen()
  44. self->highlightState(6)
  45. }
  46. OnExit {
  47. self->unhighlightState(6)
  48. }
  49. Transition(after=2.0, target='../yellow')
  50. State('yellow'):
  51. OnEnter {
  52. self->setYellow()
  53. self->highlightState(7)
  54. }
  55. OnExit {
  56. self->unhighlightState(7)
  57. }
  58. Transition(after=1.0, target='../red')
  59. OnEnter {
  60. }
  61. OnExit {
  62. }
  63. Transition(target='../interrupted'):
  64. event = police_interrupt_clicked()
  65. State('interrupted'):
  66. initial = 'yellow'
  67. State('yellow'):
  68. OnEnter {
  69. self->setYellow()
  70. self->highlightState(14)
  71. }
  72. OnExit {
  73. self->unhighlightState(14)
  74. }
  75. Transition(after=5.0, target='../black')
  76. State('black'):
  77. OnEnter {
  78. self->clear()
  79. self->highlightState(15)
  80. }
  81. OnExit {
  82. self->unhighlightState(15)
  83. }
  84. Transition(after=5.0, target='../yellow')
  85. OnEnter {
  86. }
  87. OnExit {
  88. }
  89. Transition(target='../normal'):
  90. event = police_interrupt_clicked()