Sfoglia il codice sorgente

changed structure completely, now has an installer

Simon Van Mierlo 9 anni fa
parent
commit
d0e1721ac9
100 ha cambiato i file con 2984 aggiunte e 2834 eliminazioni
  1. 1 2
      .gitignore
  2. 90 10
      README.md
  3. 16 0
      examples/HTTP_client/Makefile
  4. 4 2
      examples/HTTP_client/client.py
  5. 1 1
      examples/HTTP_client/make.bat
  6. 1 1
      examples/HTTP_client/socket2event.py
  7. 16 0
      examples/HTTP_server/Makefile
  8. 1 1
      examples/HTTP_server/make.bat
  9. 4 2
      examples/HTTP_server/server.py
  10. 1 1
      examples/HTTP_server/socket2event.py
  11. 5 2
      examples/Makefile
  12. 4 1
      examples/bouncingballs/Makefile
  13. 3 4
      examples/bouncingballs/js/Makefile
  14. 6 8
      examples/bouncingballs/js/index.html
  15. 3 1
      examples/bouncingballs/js/target_js/sccd.js
  16. 4 3
      examples/bouncingballs/python/Makefile
  17. 1 1
      examples/bouncingballs/python/make.bat
  18. 5 7
      examples/bouncingballs/python/runner.py
  19. 2 2
      examples/bouncingballs/python/sccd.xml
  20. 0 5
      examples/bouncingballs/python/target_py/__init__.py
  21. 6 4
      examples/bouncingballs/python/target_py/sccd.py
  22. 2 2
      examples/tanks/AITank.py
  23. 17 0
      examples/tanks/Makefile
  24. 3 2
      examples/tanks/PlayerTank.py
  25. 1 1
      examples/tanks/TanksGame.py
  26. 1708 0
      examples/tanks/ai_controller.py
  27. 42 32
      examples/tanks/ai_controller.xml
  28. 512 0
      examples/tanks/player_controller.py
  29. 2 0
      examples/tanks/player_controller.xml
  30. 10 0
      examples/timer-parallel/Makefile
  31. 5 4
      examples/timer-parallel/python/Makefile
  32. 1 1
      examples/timer-parallel/python/make.bat
  33. 3 5
      examples/timer-parallel/python/runner.py
  34. 1 2
      examples/timer-parallel/python/sccd.xml
  35. 0 5
      examples/timer-parallel/python/target_py/__init__.py
  36. 0 171
      examples/timer-parallel/python/target_py/sccd_new.py
  37. 26 25
      examples/timer-parallel/python/target_py/sccd.py
  38. 10 0
      examples/timer-threads/Makefile
  39. 5 4
      examples/timer-threads/python/Makefile
  40. 1 1
      examples/timer-threads/python/make.bat
  41. 3 5
      examples/timer-threads/python/runner.py
  42. 1 2
      examples/timer-threads/python/sccd.xml
  43. 0 5
      examples/timer-threads/python/target_py/__init__.py
  44. 14 13
      examples/timer-threads/python/target_py/sccd.py
  45. 10 0
      examples/timer/Makefile
  46. 3 3
      examples/timer/js/Makefile
  47. 5 5
      examples/timer/js/index.html
  48. 1 1
      examples/timer/js/make.bat
  49. 3 1
      examples/timer/js/target_js/sccd.js
  50. 4 3
      examples/timer/python/Makefile
  51. 1 1
      examples/timer/python/make.bat
  52. 5 5
      examples/timer/python/runner.py
  53. 3 3
      examples/timer/python/sccd.xml
  54. 0 5
      examples/timer/python/target_py/__init__.py
  55. 16 14
      examples/timer/python/target_py/sccd.py
  56. 5 1
      examples/trafficlights/Makefile
  57. 3 3
      examples/trafficlights/js/Makefile
  58. 5 5
      examples/trafficlights/js/index.html
  59. 1 1
      examples/trafficlights/js/make.bat
  60. 3 1
      examples/trafficlights/js/target_js/sccd.js
  61. 4 3
      examples/trafficlights/python/Makefile
  62. 1 1
      examples/trafficlights/python/make.bat
  63. 5 5
      examples/trafficlights/python/runner.py
  64. 1 1
      examples/trafficlights/python/sccd.xml
  65. 0 5
      examples/trafficlights/python/target_py/__init__.py
  66. 0 341
      examples/trafficlights/python/target_py/sccd.py
  67. 320 0
      examples/trafficlights/python/target_py/target.py
  68. 10 0
      examples/train/Makefile
  69. 24 0
      examples/train/python/Makefile
  70. 1 1
      examples/train/python/make.bat
  71. 5 4
      examples/train/python/runner.py
  72. 0 5
      examples/train/python/target_py/__init__.py
  73. 0 171
      examples/train/python/target_py/sccd_new.py
  74. 4 2
      examples/train/python/target_py/sccd.py
  75. 0 41
      src/csharp_sccd_compiler/Action.cs
  76. 0 96
      src/csharp_sccd_compiler/Association.cs
  77. 0 45
      src/csharp_sccd_compiler/Attribute.cs
  78. 0 104
      src/csharp_sccd_compiler/Class.cs
  79. 0 132
      src/csharp_sccd_compiler/ClassDiagram.cs
  80. 0 890
      src/csharp_sccd_compiler/Code Generation/CSharpGenerator.cs
  81. 0 89
      src/csharp_sccd_compiler/Code Generation/CodeGenerator.cs
  82. 0 55
      src/csharp_sccd_compiler/Code Generation/FileOutputer.cs
  83. 0 29
      src/csharp_sccd_compiler/Compiler.cs
  84. 0 17
      src/csharp_sccd_compiler/Constants.cs
  85. 0 28
      src/csharp_sccd_compiler/Constructor.cs
  86. 0 21
      src/csharp_sccd_compiler/Destructor.cs
  87. 0 51
      src/csharp_sccd_compiler/EnterExitAction.cs
  88. 0 22
      src/csharp_sccd_compiler/Exceptions/ActionException.cs
  89. 0 22
      src/csharp_sccd_compiler/Exceptions/CodeBlockException.cs
  90. 0 22
      src/csharp_sccd_compiler/Exceptions/CompilerException.cs
  91. 0 24
      src/csharp_sccd_compiler/Exceptions/LexerException.cs
  92. 0 22
      src/csharp_sccd_compiler/Exceptions/StateReferenceException.cs
  93. 0 22
      src/csharp_sccd_compiler/Exceptions/TransitionException.cs
  94. 0 22
      src/csharp_sccd_compiler/Exceptions/UnprocessedException.cs
  95. 0 87
      src/csharp_sccd_compiler/Expression/Expression.cs
  96. 0 12
      src/csharp_sccd_compiler/Expression/ExpressionPart.cs
  97. 0 20
      src/csharp_sccd_compiler/Expression/ExpressionPartString.cs
  98. 0 20
      src/csharp_sccd_compiler/Expression/InStateCall.cs
  99. 0 12
      src/csharp_sccd_compiler/Expression/LValue.cs
  100. 0 0
      src/csharp_sccd_compiler/Expression/SelfReference.cs

+ 1 - 2
.gitignore

@@ -7,6 +7,5 @@
 RemoteSystemsTempFiles
 csharp_tests/test-results
 csharp_tests/bin
-tanks/python_runtime
-python_sccd_compiler/python_runtime
+src/build
 

File diff suppressed because it is too large
+ 90 - 10
README.md


+ 16 - 0
examples/HTTP_client/Makefile

@@ -0,0 +1,16 @@
+.PHONY: all clean
+
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p threads
+
+SOURCE = client.xml
+TARGET = client.py
+
+all: $(TARGET)
+
+clean:
+	find . -type f -name '$(TARGET)*' -delete
+
+$(TARGET): $(SOURCE)
+	$(SCCDC) $(FLAGS) -o $@ $<
+

+ 4 - 2
examples/HTTP_client/client.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 17:03:50 2016
+Date:   Thu Aug 04 13:29:22 2016
 
 Model author: Yentl Van Tendeloo
 Model name:   HTTP client
@@ -9,7 +9,7 @@ Model description:
 HTTP client in SCCD
 """
 
-from python_runtime.statecharts_core import *
+from sccd.runtime.statecharts_core import *
 import time
 import os
 import urllib
@@ -411,6 +411,8 @@ class ObjectManager(ObjectManagerBase):
             instance = HTTPClient(self.controller, construct_params[0], construct_params[1])
             instance.associations = {}
             instance.associations["parent"] = Association("Prompt", 1, 1)
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(ThreadsControllerBase):

+ 1 - 1
examples/HTTP_client/make.bat

@@ -1 +1 @@
-..\..\python_sccd_compiler\sccdc.py -p threads -l python client.xml
+python -m sccd.compiler.sccdc -p threads -l python client.xml

+ 1 - 1
examples/HTTP_client/socket2event.py

@@ -1,5 +1,5 @@
 import threading
-from python_runtime.statecharts_core import Event
+from sccd.runtime.statecharts_core import Event
 import socket
 
 send_data_queues = {}

+ 16 - 0
examples/HTTP_server/Makefile

@@ -0,0 +1,16 @@
+.PHONY: all clean
+
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p threads
+
+SOURCE = server.xml
+TARGET = server.py
+
+all: $(TARGET)
+
+clean:
+	find . -type f -name '$(TARGET)*' -delete
+
+$(TARGET): $(SOURCE)
+	$(SCCDC) $(FLAGS) -o $@ $<
+

+ 1 - 1
examples/HTTP_server/make.bat

@@ -1 +1 @@
-..\..\python_sccd_compiler\sccdc.py -p threads -l python server.xml
+python -m sccd.compiler.sccdc -p threads -l python server.xml

+ 4 - 2
examples/HTTP_server/server.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 17:03:32 2016
+Date:   Thu Aug 04 13:29:22 2016
 
 Model author: Yentl Van Tendeloo
 Model name:   HTTP Server
@@ -9,7 +9,7 @@ Model description:
 Example HTTP echo server.
 """
 
-from python_runtime.statecharts_core import *
+from sccd.runtime.statecharts_core import *
 import time
 import os
 import urllib
@@ -591,6 +591,8 @@ class ObjectManager(ObjectManagerBase):
             instance = Socket(self.controller, construct_params[0])
             instance.associations = {}
             instance.associations["parent"] = Association("Server", 1, 1)
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(ThreadsControllerBase):

+ 1 - 1
examples/HTTP_server/socket2event.py

@@ -1,5 +1,5 @@
 import threading
-from python_runtime.statecharts_core import Event
+from sccd.runtime.statecharts_core import Event
 import socket
 
 send_data_queues = {}

+ 5 - 2
examples/Makefile

@@ -1,6 +1,9 @@
 .PHONY: all
 
-SUB_DIRS = bouncingballs trafficlights
+SUB_DIRS = $(shell ls .)
 
-all %:
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
 	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done

+ 4 - 1
examples/bouncingballs/Makefile

@@ -2,5 +2,8 @@
 
 SUB_DIRS = js python
 
-all %:
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
 	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done

+ 3 - 4
examples/bouncingballs/js/Makefile

@@ -1,18 +1,17 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l javascript -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_js
-TARGET = $(TARGET_DIR)/sccd.js
-
+TARGET = $(TARGET_DIR)/target.js
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)

+ 6 - 8
examples/bouncingballs/js/index.html

@@ -1,12 +1,10 @@
-<div>
-<script src="../../../javascript_runtime/libs/HackTimer.js"></script>
-<script src="../../../javascript_runtime/statecharts_core.js"></script>
-<script src="../../../javascript_runtime/libs/utils.js"></script>
-<script src="../../../javascript_runtime/libs/svg.js"></script>
-<script src="../../../javascript_runtime/libs/ui.js"></script>
-<script src="target_js/sccd.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/HackTimer.js"></script>
+<script src="../../../src/javascript_sccd_runtime/statecharts_core.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/utils.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/svg.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/ui.js"></script>
+<script src="target_js/target.js"></script>
 <script>
 controller = new Bouncing_Balls_JavaScript_Version.Controller(new JsEventLoop());
 controller.start();
 </script> 
-</div>

+ 3 - 1
examples/bouncingballs/js/target_js/sccd.js

@@ -1,6 +1,6 @@
 /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 16:58:10 2016
+Date:   Thu Aug 04 13:29:22 2016
 
 Model author: Joeri Exelmans+Raphael Mannadiar+Simon Van Mierlo
 Model name:   Bouncing_Balls_JavaScript_Version
@@ -811,6 +811,8 @@ ObjectManager.prototype.instantiate = function(class_name, construct_params) {
         var instance = new Ball(this.controller, construct_params[0], construct_params[1], construct_params[2]);
         instance.associations = new Object();
         instance.associations["parent"] = new Association("Field", 1, 1);
+    } else  {
+        throw new Error("Cannot instantiate class " + class_name);
     }
     return instance;
 };

+ 4 - 3
examples/bouncingballs/python/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l python -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_py
-TARGET = $(TARGET_DIR)/sccd.py
+TARGET = $(TARGET_DIR)/target.py
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)
@@ -20,4 +20,5 @@ $(TARGET): $(SOURCE)
 
 $(TARGET_DIR):
 	-mkdir $@
+	touch $@/__init__.py
 

+ 1 - 1
examples/bouncingballs/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l python -o target_py\target.py sccd.xml

+ 5 - 7
examples/bouncingballs/python/runner.py

@@ -5,16 +5,14 @@ Created on 27-jul.-2014
 '''
 
 import Tkinter as tk
-import target_py.sccd as sccd
-from python_runtime.libs.ui import ui
-from python_runtime.statecharts_core import Event
-from python_runtime.tkinter_eventloop import *
-
-FIXED_UPDATE_TIME = 20	# ms
+import target_py.target as target
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.statecharts_core import Event
+from sccd.runtime.tkinter_eventloop import *
 
 if __name__ == '__main__':
 	ui.window = tk.Tk()
 	ui.window.withdraw()
-	controller = sccd.Controller(TkEventLoop(ui.window))
+	controller = target.Controller(TkEventLoop(ui.window))
 	controller.start()
 	ui.window.mainloop()

+ 2 - 2
examples/bouncingballs/python/sccd.xml

@@ -4,8 +4,8 @@
         Tkinter frame with bouncing balls in it.
     </description>
     <top>
-        from python_runtime.libs.ui import ui
-        from python_runtime.libs.utils import utils
+        from sccd.runtime.libs.ui import ui
+        from sccd.runtime.libs.utils import utils
         import random
     </top>
     <inport name="ui"/>

+ 0 - 5
examples/bouncingballs/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 6 - 4
examples/bouncingballs/python/target_py/sccd.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 15:29:29 2016
+Date:   Thu Aug 04 13:29:22 2016
 
 Model author: Simon Van Mierlo+Raphael Mannadiar
 Model name:   Bouncing_Balls_Python_Version
@@ -9,9 +9,9 @@ Model description:
 Tkinter frame with bouncing balls in it.
 """
 
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import ui
-from python_runtime.libs.utils import utils
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.libs.utils import utils
 import random
 
 # package "Bouncing_Balls_Python_Version"
@@ -712,6 +712,8 @@ class ObjectManager(ObjectManagerBase):
             instance = Ball(self.controller, construct_params[0], construct_params[1], construct_params[2])
             instance.associations = {}
             instance.associations["parent"] = Association("Field", 1, 1)
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(EventLoopControllerBase):

+ 2 - 2
examples/tanks/AITank.py

@@ -2,16 +2,16 @@ from Tank import Tank
 import math
 from mymath import D360
 from ai_controller import Controller, Event
+from sccd.runtime.tkinter_eventloop import *
 
 class AITank(Tank):
 	def __init__(self, field, data):			
 		Tank.__init__(self, field, data)
-		self.controller = Controller(self)
+		self.controller = Controller(self, TkEventLoop(field.canvas.master))
 		self.controller.start()		
 			
 	def update(self, delta):
 		self.controller.addInput(Event("update","engine"))
-		self.controller.update(delta)
 		
 	def angleToDest(self, (dest_x,dest_y)):
 		return math.atan2(self.y- dest_y, dest_x-self.x) % D360

+ 17 - 0
examples/tanks/Makefile

@@ -0,0 +1,17 @@
+.PHONY: all clean
+
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p eventloop
+
+SOURCES = ai_controller.xml player_controller.xml
+TARGETS = ai_controller.py player_controller.py
+PY_BYPRODUCTS = $(TARGETS:%.py=%.pyc)
+
+all: $(TARGETS)
+
+clean:
+	rm -f $(TARGETS) $(PY_BYPRODUCTS)
+
+%.py: %.xml
+	$(SCCDC) $(FLAGS) -o $@ $<
+

+ 3 - 2
examples/tanks/PlayerTank.py

@@ -1,10 +1,12 @@
 from Tank import Tank
 from player_controller import Controller, Event
+from sccd.runtime.tkinter_eventloop import *
+from sccd.runtime.libs.ui import ui
 
 class PlayerTank(Tank):
 	def __init__(self, field, data):		
 		Tank.__init__(self, field, data)
-		self.controller = Controller(self)
+		self.controller = Controller(self, TkEventLoop(field.canvas.master))
 		self.controller.start()
 		
 	def destroy(self):
@@ -18,6 +20,5 @@ class PlayerTank(Tank):
 			
 	def update(self, delta):
 		self.controller.addInput(Event("update","engine"))
-		self.controller.update(delta)
 		
 		

+ 1 - 1
examples/tanks/TanksGame.py

@@ -180,7 +180,7 @@ class TanksGame(tk.Tk):
         else :
             self.elapsed = time.time() - self.schedule_time
             self.after_cancel(self.scheduled_update_id)
-            self.showOverlay()
+            self.showPauseOverlay()
             self.is_paused = True
             self.bind("p", self.pausePressed)
             self.unbind("<KeyPress>")

File diff suppressed because it is too large
+ 1708 - 0
examples/tanks/ai_controller.py


+ 42 - 32
examples/tanks/ai_controller.xml

@@ -51,6 +51,7 @@
                     <transition target="../state_2">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'turret_control'"/>
+                            <parameter expr="'TurretControl'"/>
                             <parameter expr="SELF.tank"/>
                         </raise>
                     </transition>
@@ -62,6 +63,7 @@
                     <transition target="../state_4">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'motor_control'"/>
+                            <parameter expr="'MotorControl'"/>
                             <parameter expr="SELF.tank"/>
                         </raise>
                     </transition>
@@ -73,6 +75,7 @@
                     <transition target="../state_6">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'turret_steering'"/>
+                            <parameter expr="'TurretSteering'"/>
                             <parameter expr="SELF.tank"/>
                         </raise>
                     </transition>
@@ -84,6 +87,7 @@
                     <transition target="../state_8">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'steering'"/>
+                            <parameter expr="'Steering'"/>
                             <parameter expr="SELF.tank"/>
                             <parameter expr="SELF.map"/>
                         </raise>
@@ -96,6 +100,7 @@
                     <transition target="../state_10">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'path_finder'"/>
+                            <parameter expr="'PathFinder'"/>
                             <parameter expr="SELF.tank"/>
                             <parameter expr="SELF.map"/>
                         </raise>
@@ -108,6 +113,7 @@
                     <transition target="../state_12">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'attack_planner'"/>
+                            <parameter expr="'AttackPlanner'"/>
                         </raise>
                     </transition>
                 </state>
@@ -118,6 +124,7 @@
                     <transition target="../state_14">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'explore_planner'"/>
+                            <parameter expr="'ExplorePlanner'"/>
                             <parameter expr="SELF.tank"/>
                             <parameter expr="SELF.map"/>
                         </raise>
@@ -130,6 +137,7 @@
                     <transition target="../state_16">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'pilot_strategy'"/>
+                            <parameter expr="'PilotStrategy'"/>
                         </raise>
                     </transition>
                 </state>
@@ -140,6 +148,7 @@
                     <transition target="../state_18">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'enemy_tracker'"/>
+                            <parameter expr="'EnemyTracker'"/>
                         </raise>
                     </transition>
                 </state>
@@ -150,6 +159,7 @@
                     <transition target="../state_20">
                         <raise event="create_instance" scope="CD">
                             <parameter expr="'radar'"/>
+                            <parameter expr="'Radar'"/>
                             <parameter expr="SELF.tank"/>
                         </raise>
                     </transition>
@@ -322,21 +332,21 @@
         <scxml initial="no_enemy">
             <state id="no_enemy">
                 <transition cond="SELF.isEnemyVisible()" target="../enemy_in_sight">
-                    <raise event="enemy_sighted" target="enemy_tracker">
+                    <raise event="enemy_sighted" target="'enemy_tracker'">
                         <parameter expr="SELF.getEnemyPos()"/>
                     </raise>
-                    <raise event="enemy_sighted" target="pilot_strategy">
+                    <raise event="enemy_sighted" target="'pilot_strategy'">
                         <parameter expr="SELF.getEnemyPos()"/>
                     </raise>
                 </transition>
             </state>
             <state id="enemy_in_sight">
                 <transition cond="not SELF.isEnemyVisible()" target="../no_enemy">
-                    <raise event="enemy_out_of_sight" target="enemy_tracker"/>
+                    <raise event="enemy_out_of_sight" target="'enemy_tracker'"/>
                 </transition>
                 <!-- else, of course this is not present in scxml so add negated cond -->
                 <transition event="update" port="engine" cond="SELF.isEnemyVisible()" target=".">
-                    <raise event="enemy_pos" target="enemy_tracker">
+                    <raise event="enemy_pos" target="'enemy_tracker'">
                         <parameter expr="SELF.getEnemyPos()"/>
                     </raise>
                 </transition> 
@@ -373,17 +383,17 @@
                     <script>
                         self.enemy_pos = position
                     </script>
-                    <raise event="enemy_pos_changed" target="attack_planner">
+                    <raise event="enemy_pos_changed" target="'attack_planner'">
                         <parameter expr="SELF.enemy_pos"/>
                     </raise>
                 </transition>
                 <transition event="enemy_out_of_sight" target="../enemy_pos_unsure">
-                    <raise event="enemy_out_of_sight" target="attack_planner"/>
+                    <raise event="enemy_out_of_sight" target="'attack_planner'"/>
                 </transition>
             </state>
             <state id="enemy_pos_unsure">
                 <transition event="destination_reached" target="../no_enemy">
-                    <raise event="enemy_lost" target="pilot_strategy"/>
+                    <raise event="enemy_lost" target="'pilot_strategy'"/>
                     <log>raise enemy_lost</log>
                 </transition>
                 <transition event="enemy_sighted" target="../enemy_pos_known"> 
@@ -409,21 +419,21 @@
         <scxml initial="exploring">
             <state id="exploring">
                 <onentry>
-                    <raise event="explore" target="explore_planner"/>
+                    <raise event="explore" target="'explore_planner'"/>
                 </onentry>
                 <onexit>
-                    <raise event="stop_exploring" target="explore_planner"/>
+                    <raise event="stop_exploring" target="'explore_planner'"/>
                 </onexit>
                 <transition event="enemy_sighted" target="../attacking">
                     <parameter name="position"/>
-                    <raise event="attack" target="attack_planner">
+                    <raise event="attack" target="'attack_planner'">
                         <parameter expr="position"/>
                     </raise>
                 </transition>
             </state>
             <state id="attacking">
                 <onexit>
-                    <raise event="stop_attacking" target="attack_planner"/>
+                    <raise event="stop_attacking" target="'attack_planner'"/>
                     <log>raise stop_attacking</log>
                 </onexit>
                 <transition event="enemy_lost" target="../exploring">
@@ -459,7 +469,7 @@
                 </transition>
                 <state id="no_destination">
                     <transition target="../destination_set">
-                        <raise event="new_destination" target="path_finder">
+                        <raise event="new_destination" target="'path_finder'">
                             <parameter expr="SELF.map.getNewExplore(self.tank.getPosition(),self.tank.getAngle())"/>
                         </raise>
                     </transition>
@@ -483,10 +493,10 @@
                 <transition event="attack" target="../action">
                     <log>received attack</log>
                     <parameter name="enemy_pos"/>
-                    <raise event="new_destination" target="path_finder">
+                    <raise event="new_destination" target="'path_finder'">
                         <parameter expr="enemy_pos"/>
                     </raise>
-                    <raise event="aim_at" target="turret_steering">
+                    <raise event="aim_at" target="'turret_steering'">
                         <parameter expr="enemy_pos"/>
                     </raise>
                 </transition>
@@ -494,28 +504,28 @@
             <parallel id="action">
                 <transition event="stop_attacking" target="../idle">
                     <log>received stop attack</log>
-                    <raise event="stop_aiming" target="turret_steering"/>
+                    <raise event="stop_aiming" target="'turret_steering'"/>
                 </transition>
                 <state id="movement">
                     <state id="following">
                         <transition event="enemy_pos_changed" target=".">
                             <parameter name="enemy_pos"/>
-                            <raise event="new_destination" target="path_finder">
+                            <raise event="new_destination" target="'path_finder'">
                                 <parameter expr="enemy_pos"/>
                             </raise>
-                            <raise event="aim_at" target="turret_steering">
+                            <raise event="aim_at" target="'turret_steering'">
                                 <parameter expr="enemy_pos"/>
                             </raise>
                         </transition>
                         <transition event="enemy_out_of_sight" target=".">
-                            <raise event="stop_aiming" target="turret_steering"/>
+                            <raise event="stop_aiming" target="'turret_steering'"/>
                         </transition>
                     </state>
                 </state>
                 <state id="shooting" initial="loaded">
                     <state id="loaded">
                         <transition event="ready_to_shoot" target="../reloading">
-                            <raise event="shoot" target="turret_control"/>
+                            <raise event="shoot" target="'turret_control'"/>
                             <log>raise shoot</log>
                         </transition>
                     </state>
@@ -569,7 +579,7 @@
                         self.waypoints = self.calculatePath()
                     </script>
                     <!--  
-                    <raise event="new_waypoint" target="steering">
+                    <raise event="new_waypoint" target="'steering'">
                         <parameter expr="SELF.waypoints[0]"/>
                     </raise>
                     -->
@@ -580,7 +590,7 @@
                     <script>
                         next_waypoint = self.waypoints.pop(0)
                     </script>
-                    <raise event="new_waypoint" target="steering">
+                    <raise event="new_waypoint" target="'steering'">
                         <parameter expr="next_waypoint"/>
                     </raise>
                 </transition>
@@ -691,26 +701,26 @@
             </state>
             <state id="steering" initial="forward_backward">
                 <transition cond="SELF.pointReached()" target="../idle">
-                    <raise event="waypoint_reached" target="path_finder"/>
+                    <raise event="waypoint_reached" target="'path_finder'"/>
                 </transition>
                 
                 <state id="forward_backward">
                     <transition cond="SELF.pointAhead()" target="../left_right">
-                        <raise event="forward" target="motor_control"/>
+                        <raise event="forward" target="'motor_control'"/>
                     </transition>
                     <transition cond="SELF.pointBehind()" target="../left_right">
-                        <raise event="stop" target="motor_control"/>
+                        <raise event="stop" target="'motor_control'"/>
                     </transition>
                 </state>
                 <state id="left_right">
                     <transition cond="SELF.pointStraight()" target="../wait">
-                        <raise event="stop_turning" target="motor_control"/>
+                        <raise event="stop_turning" target="'motor_control'"/>
                     </transition>
                     <transition cond="SELF.pointLeft()" target="../wait">
-                        <raise event="turn_left" target="motor_control"/>
+                        <raise event="turn_left" target="'motor_control'"/>
                     </transition>
                     <transition cond="SELF.pointRight()" target="../wait">
-                        <raise event="turn_right" target="motor_control"/>
+                        <raise event="turn_right" target="'motor_control'"/>
                     </transition>
                 </state>
                 <state id="wait">
@@ -782,7 +792,7 @@
             
             <state id="aiming" initial="adjust">
                 <transition event="stop_aiming" target="../idle">
-                    <raise event="stop_turning" target="turret_control"/>
+                    <raise event="stop_turning" target="'turret_control'"/>
                 </transition>
                 <transition event="aim_at" target=".">
                     <parameter name="target"/>
@@ -793,14 +803,14 @@
                 
                 <state id="adjust">
                     <transition cond="SELF.pointRight()" target="../wait">
-                        <raise event="turn_right" target="turret_control"/>
+                        <raise event="turn_right" target="'turret_control'"/>
                     </transition>
                     <transition cond="SELF.pointLeft()" target="../wait">
-                        <raise event="turn_left" target="turret_control"/>
+                        <raise event="turn_left" target="'turret_control'"/>
                     </transition>
                     <transition cond="SELF.pointCorrect()" target="../wait">
-                        <raise event="stop_turning" target="turret_control"/>
-                        <raise event="ready_to_shoot" target="attack_planner"/>
+                        <raise event="stop_turning" target="'turret_control'"/>
+                        <raise event="ready_to_shoot" target="'attack_planner'"/>
                     </transition>
                 </state>
                 <state id="wait">

+ 512 - 0
examples/tanks/player_controller.py

@@ -0,0 +1,512 @@
+"""
+Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
+
+Date:   Thu Aug 04 13:29:23 2016
+
+Model author: Glenn De Jonghe
+Model name:   Player Tank
+Model description:
+Handling the player tank.
+"""
+
+from sccd.runtime.statecharts_core import *
+
+# package "Player Tank"
+
+class Main(RuntimeClassBase):
+    def __init__(self, controller, tank):
+        RuntimeClassBase.__init__(self, controller)
+        
+        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
+        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
+        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
+        self.semantics.priority = StatechartSemantics.SourceParent
+        self.semantics.concurrency = StatechartSemantics.Single
+        
+        # build Statechart structure
+        self.build_statechart_structure()
+        
+        # user defined attributes
+        self.tank = None
+        
+        # call user defined constructor
+        Main.user_defined_constructor(self, tank)
+    
+    def user_defined_constructor(self, tank):
+        self.tank = tank
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /state_1
+        self.states["/state_1"] = State(1, self)
+        
+        # state /state_2
+        self.states["/state_2"] = State(2, self)
+        
+        # state /state_3
+        self.states["/state_3"] = State(3, self)
+        
+        # state /state_4
+        self.states["/state_4"] = State(4, self)
+        
+        # state /end
+        self.states["/end"] = State(5, self)
+        
+        # add children
+        self.states[""].addChild(self.states["/state_1"])
+        self.states[""].addChild(self.states["/state_2"])
+        self.states[""].addChild(self.states["/state_3"])
+        self.states[""].addChild(self.states["/state_4"])
+        self.states[""].addChild(self.states["/end"])
+        self.states[""].fixTree()
+        self.states[""].default_state = self.states["/state_1"]
+        
+        # transition /state_1
+        _state_1_0 = Transition(self, self.states["/state_1"], [self.states["/state_2"]])
+        _state_1_0.setAction(self._state_1_0_exec)
+        self.states["/state_1"].addTransition(_state_1_0)
+        
+        # transition /state_2
+        _state_2_0 = Transition(self, self.states["/state_2"], [self.states["/state_3"]])
+        _state_2_0.trigger = Event("instance_created", None)
+        self.states["/state_2"].addTransition(_state_2_0)
+        
+        # transition /state_3
+        _state_3_0 = Transition(self, self.states["/state_3"], [self.states["/state_4"]])
+        _state_3_0.setAction(self._state_3_0_exec)
+        self.states["/state_3"].addTransition(_state_3_0)
+        
+        # transition /state_4
+        _state_4_0 = Transition(self, self.states["/state_4"], [self.states["/end"]])
+        _state_4_0.setAction(self._state_4_0_exec)
+        _state_4_0.trigger = Event("instance_created", None)
+        self.states["/state_4"].addTransition(_state_4_0)
+    
+    def _state_1_0_exec(self, parameters):
+        self.big_step.outputEventOM(Event("create_instance", None, [self, 'cannon', 'Cannon', self.tank]))
+    
+    def _state_3_0_exec(self, parameters):
+        self.big_step.outputEventOM(Event("create_instance", None, [self, 'body', 'Body', self.tank]))
+    
+    def _state_4_0_exec(self, parameters):
+        self.big_step.outputEventOM(Event("start_instance", None, [self, 'cannon']))
+        self.big_step.outputEventOM(Event("start_instance", None, [self, 'body']))
+    
+    def initializeStatechart(self):
+        # enter default state
+        states = self.states["/state_1"].getEffectiveTargetStates()
+        self.updateConfiguration(states)
+        for state in states:
+            if state.enter:
+                state.enter()
+
+class Cannon(RuntimeClassBase):
+    def __init__(self, controller, tank):
+        RuntimeClassBase.__init__(self, controller)
+        
+        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
+        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
+        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
+        self.semantics.priority = StatechartSemantics.SourceParent
+        self.semantics.concurrency = StatechartSemantics.Single
+        
+        # build Statechart structure
+        self.build_statechart_structure()
+        
+        # user defined attributes
+        self.tank = None
+        self.reload_time = None
+        
+        # call user defined constructor
+        Cannon.user_defined_constructor(self, tank)
+    
+    def user_defined_constructor(self, tank):
+        self.tank = tank
+        self.reload_time = tank.getReloadTime()
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /container
+        self.states["/container"] = ParallelState(1, self)
+        
+        # state /container/rotating
+        self.states["/container/rotating"] = State(2, self)
+        
+        # state /container/rotating/none
+        self.states["/container/rotating/none"] = State(3, self)
+        
+        # state /container/rotating/left
+        self.states["/container/rotating/left"] = State(4, self)
+        
+        # state /container/rotating/both
+        self.states["/container/rotating/both"] = State(5, self)
+        
+        # state /container/rotating/right
+        self.states["/container/rotating/right"] = State(6, self)
+        
+        # state /container/shoot
+        self.states["/container/shoot"] = State(7, self)
+        
+        # state /container/shoot/hold
+        self.states["/container/shoot/hold"] = State(8, self)
+        
+        # state /container/shoot/shoot
+        self.states["/container/shoot/shoot"] = State(9, self)
+        
+        # state /container/ammo
+        self.states["/container/ammo"] = State(10, self)
+        
+        # state /container/ammo/loaded
+        self.states["/container/ammo/loaded"] = State(11, self)
+        
+        # state /container/ammo/unloaded
+        self.states["/container/ammo/unloaded"] = State(12, self)
+        self.states["/container/ammo/unloaded"].setEnter(self._container_ammo_unloaded_enter)
+        self.states["/container/ammo/unloaded"].setExit(self._container_ammo_unloaded_exit)
+        
+        # add children
+        self.states[""].addChild(self.states["/container"])
+        self.states["/container"].addChild(self.states["/container/rotating"])
+        self.states["/container"].addChild(self.states["/container/shoot"])
+        self.states["/container"].addChild(self.states["/container/ammo"])
+        self.states["/container/rotating"].addChild(self.states["/container/rotating/none"])
+        self.states["/container/rotating"].addChild(self.states["/container/rotating/left"])
+        self.states["/container/rotating"].addChild(self.states["/container/rotating/both"])
+        self.states["/container/rotating"].addChild(self.states["/container/rotating/right"])
+        self.states["/container/shoot"].addChild(self.states["/container/shoot/hold"])
+        self.states["/container/shoot"].addChild(self.states["/container/shoot/shoot"])
+        self.states["/container/ammo"].addChild(self.states["/container/ammo/loaded"])
+        self.states["/container/ammo"].addChild(self.states["/container/ammo/unloaded"])
+        self.states[""].fixTree()
+        self.states[""].default_state = self.states["/container"]
+        self.states["/container/rotating"].default_state = self.states["/container/rotating/none"]
+        self.states["/container/shoot"].default_state = self.states["/container/shoot/hold"]
+        self.states["/container/ammo"].default_state = self.states["/container/ammo/loaded"]
+        
+        # transition /container/rotating/none
+        _container_rotating_none_0 = Transition(self, self.states["/container/rotating/none"], [self.states["/container/rotating/left"]])
+        _container_rotating_none_0.trigger = Event("cannon-left-pressed", "input")
+        self.states["/container/rotating/none"].addTransition(_container_rotating_none_0)
+        _container_rotating_none_1 = Transition(self, self.states["/container/rotating/none"], [self.states["/container/rotating/right"]])
+        _container_rotating_none_1.trigger = Event("cannon-right-pressed", "input")
+        self.states["/container/rotating/none"].addTransition(_container_rotating_none_1)
+        
+        # transition /container/rotating/left
+        _container_rotating_left_0 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/none"]])
+        _container_rotating_left_0.trigger = Event("cannon-left-released", "input")
+        self.states["/container/rotating/left"].addTransition(_container_rotating_left_0)
+        _container_rotating_left_1 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/both"]])
+        _container_rotating_left_1.trigger = Event("cannon-right-pressed", "input")
+        self.states["/container/rotating/left"].addTransition(_container_rotating_left_1)
+        _container_rotating_left_2 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/left"]])
+        _container_rotating_left_2.setAction(self._container_rotating_left_2_exec)
+        _container_rotating_left_2.trigger = Event("update", "engine")
+        self.states["/container/rotating/left"].addTransition(_container_rotating_left_2)
+        
+        # transition /container/rotating/both
+        _container_rotating_both_0 = Transition(self, self.states["/container/rotating/both"], [self.states["/container/rotating/right"]])
+        _container_rotating_both_0.trigger = Event("cannon-left-released", "input")
+        self.states["/container/rotating/both"].addTransition(_container_rotating_both_0)
+        _container_rotating_both_1 = Transition(self, self.states["/container/rotating/both"], [self.states["/container/rotating/left"]])
+        _container_rotating_both_1.trigger = Event("cannon-right-released", "input")
+        self.states["/container/rotating/both"].addTransition(_container_rotating_both_1)
+        
+        # transition /container/rotating/right
+        _container_rotating_right_0 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/both"]])
+        _container_rotating_right_0.trigger = Event("cannon-left-pressed", "input")
+        self.states["/container/rotating/right"].addTransition(_container_rotating_right_0)
+        _container_rotating_right_1 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/none"]])
+        _container_rotating_right_1.trigger = Event("cannon-right-released", "input")
+        self.states["/container/rotating/right"].addTransition(_container_rotating_right_1)
+        _container_rotating_right_2 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/right"]])
+        _container_rotating_right_2.setAction(self._container_rotating_right_2_exec)
+        _container_rotating_right_2.trigger = Event("update", "engine")
+        self.states["/container/rotating/right"].addTransition(_container_rotating_right_2)
+        
+        # transition /container/shoot/hold
+        _container_shoot_hold_0 = Transition(self, self.states["/container/shoot/hold"], [self.states["/container/shoot/shoot"]])
+        _container_shoot_hold_0.setAction(self._container_shoot_hold_0_exec)
+        _container_shoot_hold_0.trigger = Event("shoot-pressed", "input")
+        self.states["/container/shoot/hold"].addTransition(_container_shoot_hold_0)
+        
+        # transition /container/shoot/shoot
+        _container_shoot_shoot_0 = Transition(self, self.states["/container/shoot/shoot"], [self.states["/container/shoot/hold"]])
+        _container_shoot_shoot_0.trigger = Event("shoot-released", "input")
+        self.states["/container/shoot/shoot"].addTransition(_container_shoot_shoot_0)
+        _container_shoot_shoot_1 = Transition(self, self.states["/container/shoot/shoot"], [self.states["/container/shoot/shoot"]])
+        _container_shoot_shoot_1.setAction(self._container_shoot_shoot_1_exec)
+        _container_shoot_shoot_1.trigger = Event("loaded", None)
+        self.states["/container/shoot/shoot"].addTransition(_container_shoot_shoot_1)
+        
+        # transition /container/ammo/loaded
+        _container_ammo_loaded_0 = Transition(self, self.states["/container/ammo/loaded"], [self.states["/container/ammo/unloaded"]])
+        _container_ammo_loaded_0.setAction(self._container_ammo_loaded_0_exec)
+        _container_ammo_loaded_0.trigger = Event("shoot", None)
+        self.states["/container/ammo/loaded"].addTransition(_container_ammo_loaded_0)
+        
+        # transition /container/ammo/unloaded
+        _container_ammo_unloaded_0 = Transition(self, self.states["/container/ammo/unloaded"], [self.states["/container/ammo/loaded"]])
+        _container_ammo_unloaded_0.setAction(self._container_ammo_unloaded_0_exec)
+        _container_ammo_unloaded_0.trigger = Event("_0after")
+        self.states["/container/ammo/unloaded"].addTransition(_container_ammo_unloaded_0)
+    
+    def _container_ammo_unloaded_enter(self):
+        self.addTimer(0, self.reload_time)
+    
+    def _container_ammo_unloaded_exit(self):
+        self.removeTimer(0)
+    
+    def _container_rotating_left_2_exec(self, parameters):
+        self.tank.turnCannonLeft()
+    
+    def _container_rotating_right_2_exec(self, parameters):
+        self.tank.turnCannonRight()
+    
+    def _container_shoot_hold_0_exec(self, parameters):
+        self.raiseInternalEvent(Event("shoot", None, []))
+    
+    def _container_shoot_shoot_1_exec(self, parameters):
+        self.raiseInternalEvent(Event("shoot", None, []))
+    
+    def _container_ammo_loaded_0_exec(self, parameters):
+        self.tank.shoot()
+        self.big_step.outputEvent(Event("reloading", "gui", []))
+    
+    def _container_ammo_unloaded_0_exec(self, parameters):
+        self.raiseInternalEvent(Event("loaded", None, []))
+        self.big_step.outputEvent(Event("loaded", "gui", []))
+    
+    def initializeStatechart(self):
+        # enter default state
+        states = self.states["/container"].getEffectiveTargetStates()
+        self.updateConfiguration(states)
+        for state in states:
+            if state.enter:
+                state.enter()
+
+class Body(RuntimeClassBase):
+    def __init__(self, controller, tank):
+        RuntimeClassBase.__init__(self, controller)
+        
+        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
+        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
+        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
+        self.semantics.priority = StatechartSemantics.SourceParent
+        self.semantics.concurrency = StatechartSemantics.Single
+        
+        # build Statechart structure
+        self.build_statechart_structure()
+        
+        # user defined attributes
+        self.tank = None
+        
+        # call user defined constructor
+        Body.user_defined_constructor(self, tank)
+    
+    def user_defined_constructor(self, tank):
+        self.tank = tank
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /container
+        self.states["/container"] = ParallelState(1, self)
+        
+        # state /container/horizontal
+        self.states["/container/horizontal"] = State(2, self)
+        
+        # state /container/horizontal/none
+        self.states["/container/horizontal/none"] = State(3, self)
+        
+        # state /container/horizontal/left
+        self.states["/container/horizontal/left"] = State(4, self)
+        
+        # state /container/horizontal/both
+        self.states["/container/horizontal/both"] = State(5, self)
+        
+        # state /container/horizontal/right
+        self.states["/container/horizontal/right"] = State(6, self)
+        
+        # state /container/vertical
+        self.states["/container/vertical"] = State(7, self)
+        
+        # state /container/vertical/none
+        self.states["/container/vertical/none"] = State(8, self)
+        
+        # state /container/vertical/down
+        self.states["/container/vertical/down"] = State(9, self)
+        
+        # state /container/vertical/both
+        self.states["/container/vertical/both"] = State(10, self)
+        
+        # state /container/vertical/up
+        self.states["/container/vertical/up"] = State(11, self)
+        
+        # add children
+        self.states[""].addChild(self.states["/container"])
+        self.states["/container"].addChild(self.states["/container/horizontal"])
+        self.states["/container"].addChild(self.states["/container/vertical"])
+        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/none"])
+        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/left"])
+        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/both"])
+        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/right"])
+        self.states["/container/vertical"].addChild(self.states["/container/vertical/none"])
+        self.states["/container/vertical"].addChild(self.states["/container/vertical/down"])
+        self.states["/container/vertical"].addChild(self.states["/container/vertical/both"])
+        self.states["/container/vertical"].addChild(self.states["/container/vertical/up"])
+        self.states[""].fixTree()
+        self.states[""].default_state = self.states["/container"]
+        self.states["/container/horizontal"].default_state = self.states["/container/horizontal/none"]
+        self.states["/container/vertical"].default_state = self.states["/container/vertical/none"]
+        
+        # transition /container/horizontal/none
+        _container_horizontal_none_0 = Transition(self, self.states["/container/horizontal/none"], [self.states["/container/horizontal/left"]])
+        _container_horizontal_none_0.trigger = Event("left-pressed", "input")
+        self.states["/container/horizontal/none"].addTransition(_container_horizontal_none_0)
+        _container_horizontal_none_1 = Transition(self, self.states["/container/horizontal/none"], [self.states["/container/horizontal/right"]])
+        _container_horizontal_none_1.trigger = Event("right-pressed", "input")
+        self.states["/container/horizontal/none"].addTransition(_container_horizontal_none_1)
+        
+        # transition /container/horizontal/left
+        _container_horizontal_left_0 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/none"]])
+        _container_horizontal_left_0.trigger = Event("left-released", "input")
+        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_0)
+        _container_horizontal_left_1 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/both"]])
+        _container_horizontal_left_1.trigger = Event("right-pressed", "input")
+        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_1)
+        _container_horizontal_left_2 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/left"]])
+        _container_horizontal_left_2.setAction(self._container_horizontal_left_2_exec)
+        _container_horizontal_left_2.trigger = Event("update", "engine")
+        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_2)
+        
+        # transition /container/horizontal/both
+        _container_horizontal_both_0 = Transition(self, self.states["/container/horizontal/both"], [self.states["/container/horizontal/right"]])
+        _container_horizontal_both_0.trigger = Event("left-released", "input")
+        self.states["/container/horizontal/both"].addTransition(_container_horizontal_both_0)
+        _container_horizontal_both_1 = Transition(self, self.states["/container/horizontal/both"], [self.states["/container/horizontal/left"]])
+        _container_horizontal_both_1.trigger = Event("right-released", "input")
+        self.states["/container/horizontal/both"].addTransition(_container_horizontal_both_1)
+        
+        # transition /container/horizontal/right
+        _container_horizontal_right_0 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/both"]])
+        _container_horizontal_right_0.trigger = Event("left-pressed", "input")
+        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_0)
+        _container_horizontal_right_1 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/none"]])
+        _container_horizontal_right_1.trigger = Event("right-released", "input")
+        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_1)
+        _container_horizontal_right_2 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/right"]])
+        _container_horizontal_right_2.setAction(self._container_horizontal_right_2_exec)
+        _container_horizontal_right_2.trigger = Event("update", "engine")
+        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_2)
+        
+        # transition /container/vertical/none
+        _container_vertical_none_0 = Transition(self, self.states["/container/vertical/none"], [self.states["/container/vertical/down"]])
+        _container_vertical_none_0.trigger = Event("down-pressed", "input")
+        self.states["/container/vertical/none"].addTransition(_container_vertical_none_0)
+        _container_vertical_none_1 = Transition(self, self.states["/container/vertical/none"], [self.states["/container/vertical/up"]])
+        _container_vertical_none_1.trigger = Event("up-pressed", "input")
+        self.states["/container/vertical/none"].addTransition(_container_vertical_none_1)
+        
+        # transition /container/vertical/down
+        _container_vertical_down_0 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/none"]])
+        _container_vertical_down_0.trigger = Event("down-released", "input")
+        self.states["/container/vertical/down"].addTransition(_container_vertical_down_0)
+        _container_vertical_down_1 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/both"]])
+        _container_vertical_down_1.trigger = Event("up-pressed", "input")
+        self.states["/container/vertical/down"].addTransition(_container_vertical_down_1)
+        _container_vertical_down_2 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/down"]])
+        _container_vertical_down_2.setAction(self._container_vertical_down_2_exec)
+        _container_vertical_down_2.trigger = Event("update", "engine")
+        self.states["/container/vertical/down"].addTransition(_container_vertical_down_2)
+        
+        # transition /container/vertical/both
+        _container_vertical_both_0 = Transition(self, self.states["/container/vertical/both"], [self.states["/container/vertical/up"]])
+        _container_vertical_both_0.trigger = Event("down-released", "input")
+        self.states["/container/vertical/both"].addTransition(_container_vertical_both_0)
+        _container_vertical_both_1 = Transition(self, self.states["/container/vertical/both"], [self.states["/container/vertical/down"]])
+        _container_vertical_both_1.trigger = Event("up-released", "input")
+        self.states["/container/vertical/both"].addTransition(_container_vertical_both_1)
+        
+        # transition /container/vertical/up
+        _container_vertical_up_0 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/both"]])
+        _container_vertical_up_0.trigger = Event("down-pressed", "input")
+        self.states["/container/vertical/up"].addTransition(_container_vertical_up_0)
+        _container_vertical_up_1 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/none"]])
+        _container_vertical_up_1.trigger = Event("up-released", "input")
+        self.states["/container/vertical/up"].addTransition(_container_vertical_up_1)
+        _container_vertical_up_2 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/up"]])
+        _container_vertical_up_2.setAction(self._container_vertical_up_2_exec)
+        _container_vertical_up_2.trigger = Event("update", "engine")
+        self.states["/container/vertical/up"].addTransition(_container_vertical_up_2)
+    
+    def _container_horizontal_left_2_exec(self, parameters):
+        self.tank.turnLeft()
+    
+    def _container_horizontal_right_2_exec(self, parameters):
+        self.tank.turnRight()
+    
+    def _container_vertical_down_2_exec(self, parameters):
+        self.tank.moveDown()
+    
+    def _container_vertical_up_2_exec(self, parameters):
+        self.tank.moveUp()
+    
+    def initializeStatechart(self):
+        # enter default state
+        states = self.states["/container"].getEffectiveTargetStates()
+        self.updateConfiguration(states)
+        for state in states:
+            if state.enter:
+                state.enter()
+
+class ObjectManager(ObjectManagerBase):
+    def __init__(self, controller):
+        ObjectManagerBase.__init__(self, controller)
+    
+    def instantiate(self, class_name, construct_params):
+        if class_name == "Main":
+            instance = Main(self.controller, construct_params[0])
+            instance.associations = {}
+            instance.associations["cannon"] = Association("Cannon", 1, 1)
+            instance.associations["body"] = Association("Body", 1, 1)
+        elif class_name == "Cannon":
+            instance = Cannon(self.controller, construct_params[0])
+            instance.associations = {}
+        elif class_name == "Body":
+            instance = Body(self.controller, construct_params[0])
+            instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
+        return instance
+
+class Controller(EventLoopControllerBase):
+    def __init__(self, tank, event_loop_callbacks, finished_callback = None):
+        if finished_callback == None: finished_callback = None
+        EventLoopControllerBase.__init__(self, ObjectManager(self), event_loop_callbacks, finished_callback)
+        self.addInputPort("engine")
+        self.addInputPort("input")
+        self.addOutputPort("gui")
+        self.object_manager.createInstance("Main", [tank])

+ 2 - 0
examples/tanks/player_controller.xml

@@ -23,6 +23,7 @@
                 <transition target="../state_2">
                     <raise event="create_instance" scope="CD">
                         <parameter expr="'cannon'"/>
+                        <parameter expr="'Cannon'"/>
                         <parameter expr="SELF.tank"/>
                     </raise>
                 </transition>
@@ -34,6 +35,7 @@
                 <transition target="../state_4">
                      <raise event="create_instance" scope="CD">
                         <parameter expr="'body'"/>
+                        <parameter expr="'Body'"/>
                         <parameter expr="SELF.tank"/>
                     </raise>
                 </transition>

+ 10 - 0
examples/timer-parallel/Makefile

@@ -0,0 +1,10 @@
+.PHONY: all
+
+SUB_DIRS = python
+
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+

+ 5 - 4
examples/timer-parallel/python/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
-FLAGS = -l python -p eventloop
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p threads
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_py
-TARGET = $(TARGET_DIR)/sccd.py
+TARGET = $(TARGET_DIR)/target.py
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)
@@ -20,4 +20,5 @@ $(TARGET): $(SOURCE)
 
 $(TARGET_DIR):
 	-mkdir $@
+	touch $@/__init__.py
 

+ 1 - 1
examples/timer-parallel/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p threads -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p threads -l python -o target_py\target.py sccd.xml

+ 3 - 5
examples/timer-parallel/python/runner.py

@@ -5,14 +5,12 @@ Created on 27-jul.-2014
 '''
 
 import Tkinter as tk
-import target_py.sccd as sccd
-from python_runtime.libs.ui import ui
-from python_runtime.statecharts_core import Event
-from python_runtime.tkinter_eventloop import *
+import target_py.target as target
+from sccd.runtime.statecharts_core import Event
 import threading
 
 if __name__ == '__main__':
-    controller = sccd.Controller()
+    controller = target.Controller()
     def raw_inputter():
         while 1:
             controller.addInput(Event(raw_input(), "input", []))

+ 1 - 2
examples/timer-parallel/python/sccd.xml

@@ -3,8 +3,7 @@
     <description>
     </description>
     <top>
-        from python_runtime.libs.ui import ui
-        from python_runtime.accurate_time import time
+        from sccd.runtime.accurate_time import time
     </top>    
     <inport name="input" />
 

+ 0 - 5
examples/timer-parallel/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 0 - 171
examples/timer-parallel/python/target_py/sccd_new.py

@@ -1,171 +0,0 @@
-"""
-Generated by Statechart compiler by Glenn De Jonghe and Joeri Exelmans
-
-Date:   Wed Jul 20 12:52:08 2016
-
-Model author: Simon Van Mierlo
-Model name:   Timer (Threaded Version)
-
-"""
-
-from python_runtime.statecharts_core import *
-from python_runtime.ordered_set import OrderedSet
-from python_runtime.libs.ui import ui
-from python_runtime.accurate_time import time
-
-# package "Timer (Threaded Version)"
-
-class MainApp(RuntimeClassBase):
-    def __init__(self, controller):
-        RuntimeClassBase.__init__(self, controller)
-        
-        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
-        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
-        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
-        self.semantics.priority = StatechartSemantics.SourceChild
-        self.semantics.concurrency = StatechartSemantics.Single
-        
-        # state /running
-        self.states["/running"] = ParallelState(0)
-        
-        # state /running/print_simulated_time
-        self.states["/running/print_simulated_time"] = State(1)
-        self.states["/running"].children.add(self.states["/running/print_simulated_time"])
-        
-        # state /running/print_wct_time
-        self.states["/running/print_wct_time"] = State(2)
-        self.states["/running"].children.add(self.states["/running/print_wct_time"])
-        
-        # state /running/print_simulated_time/print_simulated_time
-        self.states["/running/print_simulated_time/print_simulated_time"] = State(3)
-        self.states["/running/print_simulated_time"].children.add(self.states["/running/print_simulated_time/print_simulated_time"])
-        
-        def running_print_simulated_time_print_simulated_time_enter(self):
-            self.addTimer(0, 1)
-        self.states["/running/print_simulated_time/print_simulated_time"].enter = running_print_simulated_time_print_simulated_time_enter
-        def running_print_simulated_time_print_simulated_time_exit(self):
-            self.removeTimer(0)
-        self.states["/running/print_simulated_time/print_simulated_time"].exit = running_print_simulated_time_print_simulated_time_exit
-        
-        # state /running/print_wct_time/print_wct_time
-        self.states["/running/print_wct_time/print_wct_time"] = State(4)
-        self.states["/running/print_wct_time"].children.add(self.states["/running/print_wct_time/print_wct_time"])
-        
-        def running_print_wct_time_print_wct_time_enter(self):
-            self.addTimer(1, 1)
-        self.states["/running/print_wct_time/print_wct_time"].enter = running_print_wct_time_print_wct_time_enter
-        def running_print_wct_time_print_wct_time_exit(self):
-            self.removeTimer(1)
-        self.states["/running/print_wct_time/print_wct_time"].exit = running_print_wct_time_print_wct_time_exit
-       
-        # state /interrupted
-        self.states["/interrupted"] = State(5)
-        
-        # fix ancestors and descendants
-        self.states["/running"].fixTree()
-        self.states["/interrupted"].fixTree()
-        
-        # defaults
-        self.states["/running/print_simulated_time"].default = self.states["/running/print_simulated_time/print_simulated_time"]
-        self.states["/running/print_wct_time"].default = self.states["/running/print_wct_time/print_wct_time"]
-        
-        # transitions /running        
-        running_0 = Transition(self, self.states["/running"], self.states["/interrupted"])
-        def running_0_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        running_0.executable_content = running_0_exec
-        running_0.trigger = Event("interrupt", "input")
-        self.states["/running"].transitions.add(running_0)
-        
-        # transitions /running/print_simulated_time/print_simulated_time
-        running_print_simulated_time_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], self.states["/running/print_simulated_time/print_simulated_time"])
-        def running_print_simulated_time_print_simulated_time_0_exec(self):
-            self.print_simulated_time()
-        running_print_simulated_time_print_simulated_time_0.executable_content = running_print_simulated_time_print_simulated_time_0_exec
-        running_print_simulated_time_print_simulated_time_0.trigger = Event("_0after")
-        self.states["/running/print_simulated_time/print_simulated_time"].transitions.add(running_print_simulated_time_print_simulated_time_0)
-        
-        running_print_simulated_time_print_simulated_time_1 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], self.states["/running/print_simulated_time/print_simulated_time"])
-        def running_print_simulated_time_print_simulated_time_1_exec(self):
-            print 'going nowhere!'
-        running_print_simulated_time_print_simulated_time_1.executable_content = running_print_simulated_time_print_simulated_time_1_exec
-        running_print_simulated_time_print_simulated_time_1.trigger = Event("interrupt", "input")        
-        self.states["/running/print_simulated_time/print_simulated_time"].transitions.add(running_print_simulated_time_print_simulated_time_1)
-        
-        # transitions /running/print_wct_time/print_wct_time
-        running_print_wct_time_print_wct_time_0 = Transition(self, self.states["/running/print_wct_time/print_wct_time"], self.states["/running/print_wct_time/print_wct_time"])
-        def running_print_wct_time_print_wct_time_0_exec(self):
-            self.print_wct_time()
-        running_print_wct_time_print_wct_time_0.executable_content = running_print_wct_time_print_wct_time_0_exec
-        running_print_wct_time_print_wct_time_0.trigger = Event("_1after")
-        self.states["/running/print_wct_time/print_wct_time"].transitions.add(running_print_wct_time_print_wct_time_0)
-        
-        # transitions /interrupted
-        interrupted_0 = Transition(self, self.states["/interrupted"], self.states["/interrupted"])
-        def interrupted_0_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        interrupted_0.executable_content = interrupted_0_exec
-        interrupted_0.trigger = Event("interrupt", "input")
-        self.states["/interrupted"].transitions.add(interrupted_0)
-        
-        interrupted_1 = Transition(self, self.states["/interrupted"], self.states["/running"])
-        def interrupted_1_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        interrupted_1.executable_content = interrupted_1_exec
-        interrupted_1.trigger = Event("continue", "input")
-        self.states["/interrupted"].transitions.add(interrupted_1)
-        
-        # call user defined constructor
-        MainApp.user_defined_constructor(self)
-    
-    def user_defined_constructor(self):
-        pass
-    
-    def user_defined_destructor(self):
-        pass
-    
-    # user defined method
-    def print_simulated_time(self):
-        print 'SIMTIME = %.3f' % get_simulated_time()
-        
-    def print_wct_time(self):
-        print 'ACTTIME = %.3f' % time()
-    
-    def initializeStatechart(self):        
-        # enter default state
-        states = self.states["/running"].getEffectiveTargetStates()
-        self.configuration.update(states)
-        for state in states:
-            if state.enter:
-                state.enter(self)
-    
-    # generate transition candidates for current small step
-    def generateCandidates(self):
-        enabledEvents = self.getEnabledEvents()
-        enabledTransitions = OrderedSet()
-        for s in self.configuration:
-            if not s in self.combo_step.changed:
-                for t in s.transitions:
-                    if t.isEnabled(enabledEvents):
-                        enabledTransitions.add(t)
-        return enabledTransitions
-
-class ObjectManager(ObjectManagerBase):
-    def __init__(self, controller):
-        ObjectManagerBase.__init__(self, controller)
-    
-    def instantiate(self, class_name, construct_params):
-        if class_name == "MainApp":
-            instance = MainApp(self.controller)
-            instance.associations = {}
-        return instance
-
-class Controller(ThreadsControllerBase):
-    def __init__(self, keep_running = None):
-        if keep_running == None: keep_running = True
-        ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running)
-        self.addInputPort("input")
-        self.object_manager.createInstance("MainApp", [])

+ 26 - 25
examples/timer-parallel/python/target_py/sccd.py

@@ -1,16 +1,15 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Tue Aug 02 14:27:28 2016
+Date:   Thu Aug 04 13:29:23 2016
 
 Model author: Simon Van Mierlo
 Model name:   Timer (Threaded Version)
 
 """
 
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import ui
-from python_runtime.accurate_time import time
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.accurate_time import time
 
 # package "Timer (Threaded Version)"
 
@@ -50,30 +49,30 @@ class MainApp(RuntimeClassBase):
     # builds Statechart structure
     def build_statechart_structure(self):
         
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /running
+        self.states["/running"] = ParallelState(1, self)
+        
+        # state /running/print_simulated_time
+        self.states["/running/print_simulated_time"] = State(2, self)
+        
         # state /running/print_simulated_time/print_simulated_time
-        self.states["/running/print_simulated_time/print_simulated_time"] = State(0, self)
+        self.states["/running/print_simulated_time/print_simulated_time"] = State(3, self)
         self.states["/running/print_simulated_time/print_simulated_time"].setEnter(self._running_print_simulated_time_print_simulated_time_enter)
         self.states["/running/print_simulated_time/print_simulated_time"].setExit(self._running_print_simulated_time_print_simulated_time_exit)
         
+        # state /running/print_wct_time
+        self.states["/running/print_wct_time"] = State(4, self)
+        
         # state /running/print_wct_time/print_wct_time
-        self.states["/running/print_wct_time/print_wct_time"] = State(1, self)
+        self.states["/running/print_wct_time/print_wct_time"] = State(5, self)
         self.states["/running/print_wct_time/print_wct_time"].setEnter(self._running_print_wct_time_print_wct_time_enter)
         self.states["/running/print_wct_time/print_wct_time"].setExit(self._running_print_wct_time_print_wct_time_exit)
         
         # state /interrupted
-        self.states["/interrupted"] = State(2, self)
-        
-        # state <root>
-        self.states[""] = State(3, self)
-        
-        # state /running
-        self.states["/running"] = ParallelState(4, self)
-        
-        # state /running/print_simulated_time
-        self.states["/running/print_simulated_time"] = State(5, self)
-        
-        # state /running/print_wct_time
-        self.states["/running/print_wct_time"] = State(6, self)
+        self.states["/interrupted"] = State(6, self)
         
         # add children
         self.states[""].addChild(self.states["/running"])
@@ -88,35 +87,35 @@ class MainApp(RuntimeClassBase):
         self.states["/running/print_wct_time"].default_state = self.states["/running/print_wct_time/print_wct_time"]
         
         # transition /running/print_simulated_time/print_simulated_time
-        _running_print_simulated_time_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], self.states["/running/print_simulated_time/print_simulated_time"])
+        _running_print_simulated_time_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], [self.states["/running/print_simulated_time/print_simulated_time"]])
         _running_print_simulated_time_print_simulated_time_0.setAction(self._running_print_simulated_time_print_simulated_time_0_exec)
         _running_print_simulated_time_print_simulated_time_0.trigger = Event("_0after")
         self.states["/running/print_simulated_time/print_simulated_time"].addTransition(_running_print_simulated_time_print_simulated_time_0)
         
         # transition /running/print_wct_time/print_wct_time
-        _running_print_wct_time_print_wct_time_0 = Transition(self, self.states["/running/print_wct_time/print_wct_time"], self.states["/running/print_wct_time/print_wct_time"])
+        _running_print_wct_time_print_wct_time_0 = Transition(self, self.states["/running/print_wct_time/print_wct_time"], [self.states["/running/print_wct_time/print_wct_time"]])
         _running_print_wct_time_print_wct_time_0.setAction(self._running_print_wct_time_print_wct_time_0_exec)
         _running_print_wct_time_print_wct_time_0.trigger = Event("_1after")
         self.states["/running/print_wct_time/print_wct_time"].addTransition(_running_print_wct_time_print_wct_time_0)
         
         # transition /interrupted
-        _interrupted_0 = Transition(self, self.states["/interrupted"], self.states["/interrupted"])
+        _interrupted_0 = Transition(self, self.states["/interrupted"], [self.states["/interrupted"]])
         _interrupted_0.setAction(self._interrupted_0_exec)
         _interrupted_0.trigger = Event("interrupt", "input")
         self.states["/interrupted"].addTransition(_interrupted_0)
-        _interrupted_1 = Transition(self, self.states["/interrupted"], self.states["/running"])
+        _interrupted_1 = Transition(self, self.states["/interrupted"], [self.states["/running"]])
         _interrupted_1.setAction(self._interrupted_1_exec)
         _interrupted_1.trigger = Event("continue", "input")
         self.states["/interrupted"].addTransition(_interrupted_1)
         
         # transition /running
-        _running_0 = Transition(self, self.states["/running"], self.states["/interrupted"])
+        _running_0 = Transition(self, self.states["/running"], [self.states["/interrupted"]])
         _running_0.setAction(self._running_0_exec)
         _running_0.trigger = Event("interrupt", "input")
         self.states["/running"].addTransition(_running_0)
         
         # transition /running/print_simulated_time
-        _running_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time"], self.states["/running/print_simulated_time"])
+        _running_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time"], [self.states["/running/print_simulated_time"]])
         _running_print_simulated_time_0.setAction(self._running_print_simulated_time_0_exec)
         _running_print_simulated_time_0.trigger = Event("interrupt", "input")
         self.states["/running/print_simulated_time"].addTransition(_running_print_simulated_time_0)
@@ -170,6 +169,8 @@ class ObjectManager(ObjectManagerBase):
         if class_name == "MainApp":
             instance = MainApp(self.controller)
             instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(ThreadsControllerBase):

+ 10 - 0
examples/timer-threads/Makefile

@@ -0,0 +1,10 @@
+.PHONY: all
+
+SUB_DIRS = python
+
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+

+ 5 - 4
examples/timer-threads/python/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
-FLAGS = -l python -p eventloop
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p threads
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_py
-TARGET = $(TARGET_DIR)/sccd.py
+TARGET = $(TARGET_DIR)/target.py
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)
@@ -20,4 +20,5 @@ $(TARGET): $(SOURCE)
 
 $(TARGET_DIR):
 	-mkdir $@
+	touch $(TARGET_DIR)/__init__.py
 

+ 1 - 1
examples/timer-threads/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p threads -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p threads -l python -o target_py\target.py sccd.xml

+ 3 - 5
examples/timer-threads/python/runner.py

@@ -4,14 +4,12 @@ Created on 27-jul.-2014
 @author: Simon
 '''
 
-import Tkinter as tk
-import target_py.sccd as sccd
-from python_runtime.libs.ui import ui
-from python_runtime.statecharts_core import Event
+import target_py.target as target
+from sccd.runtime.statecharts_core import Event
 import threading
 
 if __name__ == '__main__':
-    controller = sccd.Controller()
+    controller = target.Controller()
     def raw_inputter():
         while 1:
             controller.addInput(Event(raw_input(), "input", []))

+ 1 - 2
examples/timer-threads/python/sccd.xml

@@ -3,8 +3,7 @@
     <description>
     </description>
     <top>
-        from python_runtime.libs.ui import ui
-        from python_runtime.accurate_time import time
+        from sccd.runtime.accurate_time import time
     </top>    
     <inport name="input" />
 

+ 0 - 5
examples/timer-threads/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 14 - 13
examples/timer-threads/python/target_py/sccd.py

@@ -1,16 +1,15 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Tue Aug 02 14:25:10 2016
+Date:   Thu Aug 04 13:29:23 2016
 
 Model author: Simon Van Mierlo
 Model name:   Timer (Threaded Version)
 
 """
 
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import ui
-from python_runtime.accurate_time import time
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.accurate_time import time
 
 # package "Timer (Threaded Version)"
 
@@ -46,16 +45,16 @@ class MainApp(RuntimeClassBase):
     # builds Statechart structure
     def build_statechart_structure(self):
         
+        # state <root>
+        self.states[""] = State(0, self)
+        
         # state /running
-        self.states["/running"] = State(0, self)
+        self.states["/running"] = State(1, self)
         self.states["/running"].setEnter(self._running_enter)
         self.states["/running"].setExit(self._running_exit)
         
         # state /interrupted
-        self.states["/interrupted"] = State(1, self)
-        
-        # state <root>
-        self.states[""] = State(2, self)
+        self.states["/interrupted"] = State(2, self)
         
         # add children
         self.states[""].addChild(self.states["/running"])
@@ -64,21 +63,21 @@ class MainApp(RuntimeClassBase):
         self.states[""].default_state = self.states["/running"]
         
         # transition /running
-        _running_0 = Transition(self, self.states["/running"], self.states["/running"])
+        _running_0 = Transition(self, self.states["/running"], [self.states["/running"]])
         _running_0.setAction(self._running_0_exec)
         _running_0.trigger = Event("_0after")
         self.states["/running"].addTransition(_running_0)
-        _running_1 = Transition(self, self.states["/running"], self.states["/interrupted"])
+        _running_1 = Transition(self, self.states["/running"], [self.states["/interrupted"]])
         _running_1.setAction(self._running_1_exec)
         _running_1.trigger = Event("interrupt", "input")
         self.states["/running"].addTransition(_running_1)
         
         # transition /interrupted
-        _interrupted_0 = Transition(self, self.states["/interrupted"], self.states["/interrupted"])
+        _interrupted_0 = Transition(self, self.states["/interrupted"], [self.states["/interrupted"]])
         _interrupted_0.setAction(self._interrupted_0_exec)
         _interrupted_0.trigger = Event("interrupt", "input")
         self.states["/interrupted"].addTransition(_interrupted_0)
-        _interrupted_1 = Transition(self, self.states["/interrupted"], self.states["/running"])
+        _interrupted_1 = Transition(self, self.states["/interrupted"], [self.states["/running"]])
         _interrupted_1.setAction(self._interrupted_1_exec)
         _interrupted_1.trigger = Event("continue", "input")
         self.states["/interrupted"].addTransition(_interrupted_1)
@@ -117,6 +116,8 @@ class ObjectManager(ObjectManagerBase):
         if class_name == "MainApp":
             instance = MainApp(self.controller)
             instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(ThreadsControllerBase):

+ 10 - 0
examples/timer/Makefile

@@ -0,0 +1,10 @@
+.PHONY: all
+
+SUB_DIRS = js python
+
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+

+ 3 - 3
examples/timer/js/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l javascript -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_js
-TARGET = $(TARGET_DIR)/sccd.js
+TARGET = $(TARGET_DIR)/target.js
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)

+ 5 - 5
examples/timer/js/index.html

@@ -1,9 +1,9 @@
 <div>
-<script src="../../../javascript_runtime/statecharts_core.js"></script>
-<script src="../../../javascript_runtime/libs/utils.js"></script>
-<script src="../../../javascript_runtime/libs/svg.js"></script>
-<script src="../../../javascript_runtime/libs/ui.js"></script>
-<script src="target_js/sccd.js"></script>
+<script src="../../../src/javascript_sccd_runtime/statecharts_core.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/utils.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/svg.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/ui.js"></script>
+<script src="target_js/target.js"></script>
 <script>
 controller = new Timer.Controller(new JsEventLoop());
 controller.start();

+ 1 - 1
examples/timer/js/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l javascript -o target_js\sccd.js sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l javascript -o target_js\target.js sccd.xml

+ 3 - 1
examples/timer/js/target_js/sccd.js

@@ -1,6 +1,6 @@
 /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 16:58:36 2016
+Date:   Thu Aug 04 13:29:23 2016
 
 Model author: Simon Van Mierlo
 Model name:   Timer
@@ -161,6 +161,8 @@ ObjectManager.prototype.instantiate = function(class_name, construct_params) {
     if (class_name === "MainApp") {
         var instance = new MainApp(this.controller);
         instance.associations = new Object();
+    } else  {
+        throw new Error("Cannot instantiate class " + class_name);
     }
     return instance;
 };

+ 4 - 3
examples/timer/python/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l python -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_py
-TARGET = $(TARGET_DIR)/sccd.py
+TARGET = $(TARGET_DIR)/target.py
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)
@@ -20,4 +20,5 @@ $(TARGET): $(SOURCE)
 
 $(TARGET_DIR):
 	-mkdir $@
+	touch $@/__init__.py
 

+ 1 - 1
examples/timer/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l python -o target_py\target.py sccd.xml

+ 5 - 5
examples/timer/python/runner.py

@@ -5,14 +5,14 @@ Created on 27-jul.-2014
 '''
 
 import Tkinter as tk
-import target_py.sccd as sccd
-from python_runtime.libs.ui import ui
-from python_runtime.statecharts_core import Event
-from python_runtime.tkinter_eventloop import *
+import target_py.target as target
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.statecharts_core import Event
+from sccd.runtime.tkinter_eventloop import *
 
 if __name__ == '__main__':
 	ui.window = tk.Tk()
 
-	controller = sccd.Controller(TkEventLoop(ui.window))
+	controller = target.Controller(TkEventLoop(ui.window))
 	controller.start()
 	ui.window.mainloop()

+ 3 - 3
examples/timer/python/sccd.xml

@@ -3,9 +3,9 @@
     <description>
     </description>
     <top>
-        from python_runtime.libs.ui import ui
-        from python_runtime.accurate_time import time
-        from python_runtime.statecharts_core import get_simulated_time
+        from sccd.runtime.libs.ui import ui
+        from sccd.runtime.accurate_time import time
+        from sccd.runtime.statecharts_core import get_simulated_time
     </top>    
     <inport name="ui" />
 

+ 0 - 5
examples/timer/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 16 - 14
examples/timer/python/target_py/sccd.py

@@ -1,17 +1,17 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Tue Aug 02 14:28:12 2016
+Date:   Thu Aug 04 13:29:23 2016
 
 Model author: Simon Van Mierlo
 Model name:   Timer
 
 """
 
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import ui
-from python_runtime.accurate_time import time
-from python_runtime.statecharts_core import get_simulated_time
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.accurate_time import time
+from sccd.runtime.statecharts_core import get_simulated_time
 
 # package "Timer"
 
@@ -53,16 +53,16 @@ class MainApp(RuntimeClassBase):
     # builds Statechart structure
     def build_statechart_structure(self):
         
+        # state <root>
+        self.states[""] = State(0, self)
+        
         # state /running
-        self.states["/running"] = State(0, self)
+        self.states["/running"] = State(1, self)
         self.states["/running"].setEnter(self._running_enter)
         self.states["/running"].setExit(self._running_exit)
         
         # state /interrupted
-        self.states["/interrupted"] = State(1, self)
-        
-        # state <root>
-        self.states[""] = State(2, self)
+        self.states["/interrupted"] = State(2, self)
         
         # add children
         self.states[""].addChild(self.states["/running"])
@@ -71,21 +71,21 @@ class MainApp(RuntimeClassBase):
         self.states[""].default_state = self.states["/running"]
         
         # transition /running
-        _running_0 = Transition(self, self.states["/running"], self.states["/running"])
+        _running_0 = Transition(self, self.states["/running"], [self.states["/running"]])
         _running_0.setAction(self._running_0_exec)
         _running_0.trigger = Event("_0after")
         self.states["/running"].addTransition(_running_0)
-        _running_1 = Transition(self, self.states["/running"], self.states["/interrupted"])
+        _running_1 = Transition(self, self.states["/running"], [self.states["/interrupted"]])
         _running_1.setAction(self._running_1_exec)
         _running_1.trigger = Event("interrupt_clicked", "ui")
         self.states["/running"].addTransition(_running_1)
         
         # transition /interrupted
-        _interrupted_0 = Transition(self, self.states["/interrupted"], self.states["/interrupted"])
+        _interrupted_0 = Transition(self, self.states["/interrupted"], [self.states["/interrupted"]])
         _interrupted_0.setAction(self._interrupted_0_exec)
         _interrupted_0.trigger = Event("interrupt_clicked", "ui")
         self.states["/interrupted"].addTransition(_interrupted_0)
-        _interrupted_1 = Transition(self, self.states["/interrupted"], self.states["/running"])
+        _interrupted_1 = Transition(self, self.states["/interrupted"], [self.states["/running"]])
         _interrupted_1.setAction(self._interrupted_1_exec)
         _interrupted_1.trigger = Event("continue_clicked", "ui")
         self.states["/interrupted"].addTransition(_interrupted_1)
@@ -124,6 +124,8 @@ class ObjectManager(ObjectManagerBase):
         if class_name == "MainApp":
             instance = MainApp(self.controller)
             instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(EventLoopControllerBase):

+ 5 - 1
examples/trafficlights/Makefile

@@ -2,5 +2,9 @@
 
 SUB_DIRS = js python
 
-all %:
+all:
 	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+

+ 3 - 3
examples/trafficlights/js/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l javascript -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_js
-TARGET = $(TARGET_DIR)/sccd.js
+TARGET = $(TARGET_DIR)/target.js
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)

+ 5 - 5
examples/trafficlights/js/index.html

@@ -1,9 +1,9 @@
 <div>
-<script src="../../../javascript_runtime/statecharts_core.js"></script>
-<script src="../../../javascript_runtime/libs/utils.js"></script>
-<script src="../../../javascript_runtime/libs/svg.js"></script>
-<script src="../../../javascript_runtime/libs/ui.js"></script>
-<script src="target_js/sccd.js"></script>
+<script src="../../../src/javascript_sccd_runtime/statecharts_core.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/utils.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/svg.js"></script>
+<script src="../../../src/javascript_sccd_runtime/libs/ui.js"></script>
+<script src="target_js/target.js"></script>
 <script>
 controller = new Traffic_Light_JavaScript_Version.Controller(new JsEventLoop());
 controller.start();

+ 1 - 1
examples/trafficlights/js/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l javascript -o target_js\sccd.js sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l javascript -o target_js\target.js sccd.xml

+ 3 - 1
examples/trafficlights/js/target_js/sccd.js

@@ -1,6 +1,6 @@
 /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 16:57:46 2016
+Date:   Thu Aug 04 13:32:47 2016
 
 Model author: Raphael Mannadiar
 Model name:   Traffic_Light_JavaScript_Version
@@ -363,6 +363,8 @@ ObjectManager.prototype.instantiate = function(class_name, construct_params) {
     } else if (class_name === "TrafficLight") {
         var instance = new TrafficLight(this.controller, construct_params[0]);
         instance.associations = new Object();
+    } else  {
+        throw new Error("Cannot instantiate class " + class_name);
     }
     return instance;
 };

+ 4 - 3
examples/trafficlights/python/Makefile

@@ -1,18 +1,18 @@
 .PHONY: all clean
 
-SCCDC = python ../../../python_sccd_compiler/sccdc.py
+SCCDC = python -m sccd.compiler.sccdc
 FLAGS = -l python -p eventloop
 
 SOURCE = sccd.xml
 
 TARGET_DIR = target_py
-TARGET = $(TARGET_DIR)/sccd.py
+TARGET = $(TARGET_DIR)/target.py
 
 
 all: $(TARGET_DIR) $(TARGET)
 
 clean:
-	-rm -f  $(TARGET)
+	find $(TARGET_DIR) -type f -delete
 	-rmdir $(TARGET_DIR)
 
 $(TARGET): $(SOURCE)
@@ -20,4 +20,5 @@ $(TARGET): $(SOURCE)
 
 $(TARGET_DIR):
 	-mkdir $@
+	touch $(TARGET_DIR)/__init__.py
 

+ 1 - 1
examples/trafficlights/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l python -o target_py\target.py sccd.xml

+ 5 - 5
examples/trafficlights/python/runner.py

@@ -5,14 +5,14 @@ Created on 27-jul.-2014
 '''
 
 import Tkinter as tk
-import target_py.sccd as sccd
-from python_runtime.libs.ui import ui
-from python_runtime.statecharts_core import Event
-from python_runtime.tkinter_eventloop import *
+import target_py.target as target
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.statecharts_core import Event
+from sccd.runtime.tkinter_eventloop import *
 
 if __name__ == '__main__':
 	ui.window = tk.Tk()
 
-	controller = sccd.Controller(TkEventLoop(ui.window))
+	controller = target.Controller(TkEventLoop(ui.window))
 	controller.start()
 	ui.window.mainloop()

+ 1 - 1
examples/trafficlights/python/sccd.xml

@@ -3,7 +3,7 @@
     <description>
     </description>
     <top>
-        from python_runtime.libs.ui import ui
+        from sccd.runtime.libs.ui import ui
     </top>    
     <inport name="ui" />
 

+ 0 - 5
examples/trafficlights/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 0 - 341
examples/trafficlights/python/target_py/sccd.py

@@ -1,341 +0,0 @@
-"""
-Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
-
-Date:   Thu Jul 28 15:43:05 2016
-
-Model author: Raphael Mannadiar
-Model name:   Traffic_Light_Python_Version
-
-"""
-
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import ui
-
-# package "Traffic_Light_Python_Version"
-
-class MainApp(RuntimeClassBase):
-	def __init__(self, controller):
-		RuntimeClassBase.__init__(self, controller)
-		
-		self.semantics.big_step_maximality = StatechartSemantics.TakeMany
-		self.semantics.internal_event_lifeline = StatechartSemantics.Queue
-		self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
-		self.semantics.priority = StatechartSemantics.SourceParent
-		self.semantics.concurrency = StatechartSemantics.Single
-		
-		# build Statechart structure
-		self.build_statechart_structure()
-		
-		# call user defined constructor
-		MainApp.user_defined_constructor(self)
-	
-	def user_defined_constructor(self):
-		self.canvas   = ui.append_canvas(ui.window,100,310,{'background':'#eee'});
-		police_button = ui.append_button(ui.window, 'Police interrupt');
-		quit_button   = ui.append_button(ui.window, 'Quit');
-		ui.bind_event(police_button.element, ui.EVENTS.MOUSE_CLICK, self.controller, 'police_interrupt_clicked');
-		ui.bind_event(quit_button.element,      ui.EVENTS.MOUSE_CLICK, self.controller, 'quit_clicked');
-	
-	def user_defined_destructor(self):
-		pass
-	
-	
-	# builds Statechart structure
-	def build_statechart_structure(self):
-		
-		# state /initializing
-		self.states["/initializing"] = State(0, self)
-		
-		# state /creating
-		self.states["/creating"] = State(1, self)
-		
-		# state /initialized
-		self.states["/initialized"] = State(2, self)
-		
-		# state <root>
-		self.states[""] = State(3, self)
-		
-		# add children
-		self.states[""].children.add(self.states["/initializing"])
-		self.states[""].children.add(self.states["/creating"])
-		self.states[""].children.add(self.states["/initialized"])
-		self.states[""].fixTree()
-		self.states[""].default = self.states["/initializing"]
-		
-		# transition /initializing
-		_initializing_0 = Transition(self, self.states["/initializing"], self.states["/creating"])
-		_initializing_0.executables["action"] = self._initializing_0_exec
-		self.states["/initializing"].transitions.add(_initializing_0)
-		
-		# transition /creating
-		_creating_0 = Transition(self, self.states["/creating"], self.states["/initialized"])
-		_creating_0.executables["action"] = self._creating_0_exec
-		_creating_0.trigger = Event("instance_created", None)
-		self.states["/creating"].transitions.add(_creating_0)
-	
-	def _initializing_0_exec(self, parameters):
-		self.big_step.outputEventOM(Event("create_instance", None, [self, "trafficlight", "TrafficLight", self.canvas]))
-	
-	def _creating_0_exec(self, parameters):
-		association_name = parameters[0]
-		self.big_step.outputEventOM(Event("start_instance", None, [self, association_name]))
-		self.big_step.outputEventOM(Event("narrow_cast", None, [self, association_name, Event("set_association_name", None, [association_name])]))
-	
-	# generate transition candidates for current small step
-	def generateCandidates(self):
-		enabledEvents = self.getEnabledEvents()
-		enabledTransitions = OrderedSet()
-		for s in self.configuration:
-			if not (s in self.combo_step.changed):
-				for t in s.transitions:
-					if t.isEnabled(enabledEvents):
-						enabledTransitions.add(t)
-		return enabledTransitions
-	
-	def initializeStatechart(self):
-		# enter default state
-		states = self.states["/initializing"].getEffectiveTargetStates()
-		self.configuration.update(states)
-		for state in states:
-			if state.executables["enter"]:
-				state.executables["enter"]()
-
-class TrafficLight(RuntimeClassBase):
-	def __init__(self, controller, canvas):
-		RuntimeClassBase.__init__(self, controller)
-		
-		self.semantics.big_step_maximality = StatechartSemantics.TakeMany
-		self.semantics.internal_event_lifeline = StatechartSemantics.Queue
-		self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
-		self.semantics.priority = StatechartSemantics.SourceParent
-		self.semantics.concurrency = StatechartSemantics.Single
-		
-		# build Statechart structure
-		self.build_statechart_structure()
-		
-		# call user defined constructor
-		TrafficLight.user_defined_constructor(self, canvas)
-	
-	def user_defined_constructor(self, canvas):
-		size        = 100;
-		offset      = size+5;
-		self.RED    = 0;
-		self.YELLOW = 1;
-		self.GREEN  = 2;
-		self.colors = ['#f00','#ff0','#0f0']
-		self.lights = [
-		    canvas.add_rectangle(size/2, size/2, size, size, {'fill':'#000'}),
-		    canvas.add_rectangle(size/2, size/2+offset,     size, size, {'fill':'#000'}),
-		    canvas.add_rectangle(size/2, size/2+2*offset, size, size, {'fill':'#000'})];
-		self.my_after = 1
-	
-	def user_defined_destructor(self):
-		pass
-	
-	
-	# user defined method
-	def clear(self):
-		self.lights[self.RED].set_color('#000');
-		self.lights[self.YELLOW].set_color('#000');
-		self.lights[self.GREEN].set_color('#000');
-	
-	
-	# user defined method
-	def setGreen(self):
-		self.clear();
-		self.lights[self.GREEN].set_color(self.colors[self.GREEN]);
-	
-	
-	# user defined method
-	def setYellow(self):
-		self.clear();
-		self.lights[self.YELLOW].set_color(self.colors[self.YELLOW]);
-	
-	
-	# user defined method
-	def setRed(self):
-		self.clear();
-		self.lights[self.RED].set_color(self.colors[self.RED]);
-	
-	
-	# builds Statechart structure
-	def build_statechart_structure(self):
-		
-		# state /on/normal/red
-		self.states["/on/normal/red"] = State(0, self)
-		self.states["/on/normal/red"].executables["enter"] = self._on_normal_red_enter
-		self.states["/on/normal/red"].executables["exit"] = self._on_normal_red_exit
-		
-		# state /on/normal/green
-		self.states["/on/normal/green"] = State(1, self)
-		self.states["/on/normal/green"].executables["enter"] = self._on_normal_green_enter
-		self.states["/on/normal/green"].executables["exit"] = self._on_normal_green_exit
-		
-		# state /on/normal/yellow
-		self.states["/on/normal/yellow"] = State(2, self)
-		self.states["/on/normal/yellow"].executables["enter"] = self._on_normal_yellow_enter
-		self.states["/on/normal/yellow"].executables["exit"] = self._on_normal_yellow_exit
-		
-		# state /on/interrupted/yellow
-		self.states["/on/interrupted/yellow"] = State(3, self)
-		self.states["/on/interrupted/yellow"].executables["enter"] = self._on_interrupted_yellow_enter
-		self.states["/on/interrupted/yellow"].executables["exit"] = self._on_interrupted_yellow_exit
-		
-		# state /on/interrupted/black
-		self.states["/on/interrupted/black"] = State(4, self)
-		self.states["/on/interrupted/black"].executables["enter"] = self._on_interrupted_black_enter
-		self.states["/on/interrupted/black"].executables["exit"] = self._on_interrupted_black_exit
-		
-		# state /off
-		self.states["/off"] = State(5, self)
-		self.states["/off"].executables["enter"] = self._off_enter
-		
-		# state <root>
-		self.states[""] = State(6, self)
-		
-		# state /on
-		self.states["/on"] = State(7, self)
-		
-		# state /on/normal
-		self.states["/on/normal"] = State(8, self)
-		
-		# state /on/interrupted
-		self.states["/on/interrupted"] = State(9, self)
-		
-		# state /on/normal/history
-		self.states["/on/normal/history"] = ShallowHistoryState(10, self)
-		
-		# add children
-		self.states[""].children.add(self.states["/on"])
-		self.states[""].children.add(self.states["/off"])
-		self.states["/on"].children.add(self.states["/on/normal"])
-		self.states["/on"].children.add(self.states["/on/interrupted"])
-		self.states["/on/normal"].children.add(self.states["/on/normal/red"])
-		self.states["/on/normal"].children.add(self.states["/on/normal/green"])
-		self.states["/on/normal"].children.add(self.states["/on/normal/yellow"])
-		self.states["/on/normal"].children.add(self.states["/on/normal/history"])
-		self.states["/on/interrupted"].children.add(self.states["/on/interrupted/yellow"])
-		self.states["/on/interrupted"].children.add(self.states["/on/interrupted/black"])
-		self.states[""].fixTree()
-		self.states[""].default = self.states["/on"]
-		self.states["/on"].default = self.states["/on/normal"]
-		self.states["/on/normal"].default = self.states["/on/normal/red"]
-		self.states["/on/interrupted"].default = self.states["/on/interrupted/yellow"]
-		
-		# transition /on/normal/red
-		_on_normal_red_0 = Transition(self, self.states["/on/normal/red"], self.states["/on/normal/green"])
-		_on_normal_red_0.trigger = Event("_0after")
-		self.states["/on/normal/red"].transitions.add(_on_normal_red_0)
-		
-		# transition /on/normal/green
-		_on_normal_green_0 = Transition(self, self.states["/on/normal/green"], self.states["/on/normal/yellow"])
-		_on_normal_green_0.trigger = Event("_1after")
-		self.states["/on/normal/green"].transitions.add(_on_normal_green_0)
-		
-		# transition /on/normal/yellow
-		_on_normal_yellow_0 = Transition(self, self.states["/on/normal/yellow"], self.states["/on/normal/red"])
-		_on_normal_yellow_0.trigger = Event("_2after")
-		self.states["/on/normal/yellow"].transitions.add(_on_normal_yellow_0)
-		
-		# transition /on/interrupted/yellow
-		_on_interrupted_yellow_0 = Transition(self, self.states["/on/interrupted/yellow"], self.states["/on/interrupted/black"])
-		_on_interrupted_yellow_0.trigger = Event("_3after")
-		self.states["/on/interrupted/yellow"].transitions.add(_on_interrupted_yellow_0)
-		
-		# transition /on/interrupted/black
-		_on_interrupted_black_0 = Transition(self, self.states["/on/interrupted/black"], self.states["/on/interrupted/yellow"])
-		_on_interrupted_black_0.trigger = Event("_4after")
-		self.states["/on/interrupted/black"].transitions.add(_on_interrupted_black_0)
-		
-		# transition /on
-		_on_0 = Transition(self, self.states["/on"], self.states["/off"])
-		_on_0.trigger = Event("quit_clicked", "ui")
-		self.states["/on"].transitions.add(_on_0)
-		
-		# transition /on/normal
-		_on_normal_0 = Transition(self, self.states["/on/normal"], self.states["/on/interrupted"])
-		_on_normal_0.trigger = Event("police_interrupt_clicked", "ui")
-		self.states["/on/normal"].transitions.add(_on_normal_0)
-		
-		# transition /on/interrupted
-		_on_interrupted_0 = Transition(self, self.states["/on/interrupted"], self.states["/on/normal/history"])
-		_on_interrupted_0.trigger = Event("police_interrupt_clicked", "ui")
-		self.states["/on/interrupted"].transitions.add(_on_interrupted_0)
-	
-	def _on_normal_red_enter(self):
-		self.addTimer(0, 3)
-		self.setRed();
-	
-	def _on_normal_red_exit(self):
-		self.removeTimer(0)
-	
-	def _on_normal_green_enter(self):
-		self.addTimer(1, 2)
-		self.setGreen();
-	
-	def _on_normal_green_exit(self):
-		self.removeTimer(1)
-	
-	def _on_normal_yellow_enter(self):
-		self.addTimer(2, self.my_after)
-		self.setYellow();
-	
-	def _on_normal_yellow_exit(self):
-		self.removeTimer(2)
-	
-	def _on_interrupted_yellow_enter(self):
-		self.addTimer(3, .5)
-		self.setYellow();
-	
-	def _on_interrupted_yellow_exit(self):
-		self.removeTimer(3)
-	
-	def _on_interrupted_black_enter(self):
-		self.addTimer(4, .5)
-		self.clear();
-	
-	def _on_interrupted_black_exit(self):
-		self.removeTimer(4)
-	
-	def _off_enter(self):
-		self.clear();
-	
-	# generate transition candidates for current small step
-	def generateCandidates(self):
-		enabledEvents = self.getEnabledEvents()
-		enabledTransitions = OrderedSet()
-		for s in self.configuration:
-			if not (s in self.combo_step.changed):
-				for t in s.transitions:
-					if t.isEnabled(enabledEvents):
-						enabledTransitions.add(t)
-		return enabledTransitions
-	
-	def initializeStatechart(self):
-		# enter default state
-		states = self.states["/on"].getEffectiveTargetStates()
-		self.configuration.update(states)
-		for state in states:
-			if state.executables["enter"]:
-				state.executables["enter"]()
-
-class ObjectManager(ObjectManagerBase):
-	def __init__(self, controller):
-		ObjectManagerBase.__init__(self, controller)
-	
-	def instantiate(self, class_name, construct_params):
-		if class_name == "MainApp":
-			instance = MainApp(self.controller)
-			instance.associations = {}
-			instance.associations["trafficlight"] = Association("TrafficLight", 0, -1)
-		elif class_name == "TrafficLight":
-			instance = TrafficLight(self.controller, construct_params[0])
-			instance.associations = {}
-		return instance
-
-class Controller(EventLoopControllerBase):
-	def __init__(self, event_loop_callbacks, finished_callback = None):
-		if finished_callback == None: finished_callback = None
-		EventLoopControllerBase.__init__(self, ObjectManager(self), event_loop_callbacks, finished_callback)
-		self.addInputPort("ui")
-		self.object_manager.createInstance("MainApp", [])

+ 320 - 0
examples/trafficlights/python/target_py/target.py

@@ -0,0 +1,320 @@
+"""
+Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
+
+Date:   Thu Aug 04 13:29:24 2016
+
+Model author: Raphael Mannadiar
+Model name:   Traffic_Light_Python_Version
+
+"""
+
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.libs.ui import ui
+
+# package "Traffic_Light_Python_Version"
+
+class MainApp(RuntimeClassBase):
+    def __init__(self, controller):
+        RuntimeClassBase.__init__(self, controller)
+        
+        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
+        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
+        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
+        self.semantics.priority = StatechartSemantics.SourceParent
+        self.semantics.concurrency = StatechartSemantics.Single
+        
+        # build Statechart structure
+        self.build_statechart_structure()
+        
+        # call user defined constructor
+        MainApp.user_defined_constructor(self)
+    
+    def user_defined_constructor(self):
+        self.canvas   = ui.append_canvas(ui.window,100,310,{'background':'#eee'});
+        police_button = ui.append_button(ui.window, 'Police interrupt');
+        quit_button   = ui.append_button(ui.window, 'Quit');
+        ui.bind_event(police_button.element, ui.EVENTS.MOUSE_CLICK, self.controller, 'police_interrupt_clicked');
+        ui.bind_event(quit_button.element,      ui.EVENTS.MOUSE_CLICK, self.controller, 'quit_clicked');
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /initializing
+        self.states["/initializing"] = State(1, self)
+        
+        # state /creating
+        self.states["/creating"] = State(2, self)
+        
+        # state /initialized
+        self.states["/initialized"] = State(3, self)
+        
+        # add children
+        self.states[""].addChild(self.states["/initializing"])
+        self.states[""].addChild(self.states["/creating"])
+        self.states[""].addChild(self.states["/initialized"])
+        self.states[""].fixTree()
+        self.states[""].default_state = self.states["/initializing"]
+        
+        # transition /initializing
+        _initializing_0 = Transition(self, self.states["/initializing"], [self.states["/creating"]])
+        _initializing_0.setAction(self._initializing_0_exec)
+        self.states["/initializing"].addTransition(_initializing_0)
+        
+        # transition /creating
+        _creating_0 = Transition(self, self.states["/creating"], [self.states["/initialized"]])
+        _creating_0.setAction(self._creating_0_exec)
+        _creating_0.trigger = Event("instance_created", None)
+        self.states["/creating"].addTransition(_creating_0)
+    
+    def _initializing_0_exec(self, parameters):
+        self.big_step.outputEventOM(Event("create_instance", None, [self, "trafficlight", "TrafficLight", self.canvas]))
+    
+    def _creating_0_exec(self, parameters):
+        association_name = parameters[0]
+        self.big_step.outputEventOM(Event("start_instance", None, [self, association_name]))
+        self.big_step.outputEventOM(Event("narrow_cast", None, [self, association_name, Event("set_association_name", None, [association_name])]))
+    
+    def initializeStatechart(self):
+        # enter default state
+        states = self.states["/initializing"].getEffectiveTargetStates()
+        self.updateConfiguration(states)
+        for state in states:
+            if state.enter:
+                state.enter()
+
+class TrafficLight(RuntimeClassBase):
+    def __init__(self, controller, canvas):
+        RuntimeClassBase.__init__(self, controller)
+        
+        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
+        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
+        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
+        self.semantics.priority = StatechartSemantics.SourceParent
+        self.semantics.concurrency = StatechartSemantics.Single
+        
+        # build Statechart structure
+        self.build_statechart_structure()
+        
+        # call user defined constructor
+        TrafficLight.user_defined_constructor(self, canvas)
+    
+    def user_defined_constructor(self, canvas):
+        size        = 100;
+        offset      = size+5;
+        self.RED    = 0;
+        self.YELLOW = 1;
+        self.GREEN  = 2;
+        self.colors = ['#f00','#ff0','#0f0']
+        self.lights = [
+            canvas.add_rectangle(size/2, size/2, size, size, {'fill':'#000'}),
+            canvas.add_rectangle(size/2, size/2+offset,     size, size, {'fill':'#000'}),
+            canvas.add_rectangle(size/2, size/2+2*offset, size, size, {'fill':'#000'})];
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # user defined method
+    def clear(self):
+        self.lights[self.RED].set_color('#000');
+        self.lights[self.YELLOW].set_color('#000');
+        self.lights[self.GREEN].set_color('#000');
+    
+    
+    # user defined method
+    def setGreen(self):
+        self.clear();
+        self.lights[self.GREEN].set_color(self.colors[self.GREEN]);
+    
+    
+    # user defined method
+    def setYellow(self):
+        self.clear();
+        self.lights[self.YELLOW].set_color(self.colors[self.YELLOW]);
+    
+    
+    # user defined method
+    def setRed(self):
+        self.clear();
+        self.lights[self.RED].set_color(self.colors[self.RED]);
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /on
+        self.states["/on"] = State(1, self)
+        
+        # state /on/normal
+        self.states["/on/normal"] = State(2, self)
+        
+        # state /on/normal/red
+        self.states["/on/normal/red"] = State(3, self)
+        self.states["/on/normal/red"].setEnter(self._on_normal_red_enter)
+        self.states["/on/normal/red"].setExit(self._on_normal_red_exit)
+        
+        # state /on/normal/green
+        self.states["/on/normal/green"] = State(4, self)
+        self.states["/on/normal/green"].setEnter(self._on_normal_green_enter)
+        self.states["/on/normal/green"].setExit(self._on_normal_green_exit)
+        
+        # state /on/normal/yellow
+        self.states["/on/normal/yellow"] = State(5, self)
+        self.states["/on/normal/yellow"].setEnter(self._on_normal_yellow_enter)
+        self.states["/on/normal/yellow"].setExit(self._on_normal_yellow_exit)
+        
+        # state /on/normal/history
+        self.states["/on/normal/history"] = ShallowHistoryState(6, self)
+        
+        # state /on/interrupted
+        self.states["/on/interrupted"] = State(7, self)
+        
+        # state /on/interrupted/yellow
+        self.states["/on/interrupted/yellow"] = State(8, self)
+        self.states["/on/interrupted/yellow"].setEnter(self._on_interrupted_yellow_enter)
+        self.states["/on/interrupted/yellow"].setExit(self._on_interrupted_yellow_exit)
+        
+        # state /on/interrupted/black
+        self.states["/on/interrupted/black"] = State(9, self)
+        self.states["/on/interrupted/black"].setEnter(self._on_interrupted_black_enter)
+        self.states["/on/interrupted/black"].setExit(self._on_interrupted_black_exit)
+        
+        # state /off
+        self.states["/off"] = State(10, self)
+        self.states["/off"].setEnter(self._off_enter)
+        
+        # add children
+        self.states[""].addChild(self.states["/on"])
+        self.states[""].addChild(self.states["/off"])
+        self.states["/on"].addChild(self.states["/on/normal"])
+        self.states["/on"].addChild(self.states["/on/interrupted"])
+        self.states["/on/normal"].addChild(self.states["/on/normal/red"])
+        self.states["/on/normal"].addChild(self.states["/on/normal/green"])
+        self.states["/on/normal"].addChild(self.states["/on/normal/yellow"])
+        self.states["/on/normal"].addChild(self.states["/on/normal/history"])
+        self.states["/on/interrupted"].addChild(self.states["/on/interrupted/yellow"])
+        self.states["/on/interrupted"].addChild(self.states["/on/interrupted/black"])
+        self.states[""].fixTree()
+        self.states[""].default_state = self.states["/on"]
+        self.states["/on"].default_state = self.states["/on/normal"]
+        self.states["/on/normal"].default_state = self.states["/on/normal/red"]
+        self.states["/on/interrupted"].default_state = self.states["/on/interrupted/yellow"]
+        
+        # transition /on/normal/red
+        _on_normal_red_0 = Transition(self, self.states["/on/normal/red"], [self.states["/on/normal/green"]])
+        _on_normal_red_0.trigger = Event("_0after")
+        self.states["/on/normal/red"].addTransition(_on_normal_red_0)
+        
+        # transition /on/normal/green
+        _on_normal_green_0 = Transition(self, self.states["/on/normal/green"], [self.states["/on/normal/yellow"]])
+        _on_normal_green_0.trigger = Event("_1after")
+        self.states["/on/normal/green"].addTransition(_on_normal_green_0)
+        
+        # transition /on/normal/yellow
+        _on_normal_yellow_0 = Transition(self, self.states["/on/normal/yellow"], [self.states["/on/normal/red"]])
+        _on_normal_yellow_0.trigger = Event("_2after")
+        self.states["/on/normal/yellow"].addTransition(_on_normal_yellow_0)
+        
+        # transition /on/interrupted/yellow
+        _on_interrupted_yellow_0 = Transition(self, self.states["/on/interrupted/yellow"], [self.states["/on/interrupted/black"]])
+        _on_interrupted_yellow_0.trigger = Event("_3after")
+        self.states["/on/interrupted/yellow"].addTransition(_on_interrupted_yellow_0)
+        
+        # transition /on/interrupted/black
+        _on_interrupted_black_0 = Transition(self, self.states["/on/interrupted/black"], [self.states["/on/interrupted/yellow"]])
+        _on_interrupted_black_0.trigger = Event("_4after")
+        self.states["/on/interrupted/black"].addTransition(_on_interrupted_black_0)
+        
+        # transition /on
+        _on_0 = Transition(self, self.states["/on"], [self.states["/off"]])
+        _on_0.trigger = Event("quit_clicked", "ui")
+        self.states["/on"].addTransition(_on_0)
+        
+        # transition /on/normal
+        _on_normal_0 = Transition(self, self.states["/on/normal"], [self.states["/on/interrupted"]])
+        _on_normal_0.trigger = Event("police_interrupt_clicked", "ui")
+        self.states["/on/normal"].addTransition(_on_normal_0)
+        
+        # transition /on/interrupted
+        _on_interrupted_0 = Transition(self, self.states["/on/interrupted"], [self.states["/on/normal/history"]])
+        _on_interrupted_0.trigger = Event("police_interrupt_clicked", "ui")
+        self.states["/on/interrupted"].addTransition(_on_interrupted_0)
+    
+    def _on_normal_red_enter(self):
+        self.addTimer(0, 3)
+        self.setRed();
+    
+    def _on_normal_red_exit(self):
+        self.removeTimer(0)
+    
+    def _on_normal_green_enter(self):
+        self.addTimer(1, 2)
+        self.setGreen();
+    
+    def _on_normal_green_exit(self):
+        self.removeTimer(1)
+    
+    def _on_normal_yellow_enter(self):
+        self.addTimer(2, 1)
+        self.setYellow();
+    
+    def _on_normal_yellow_exit(self):
+        self.removeTimer(2)
+    
+    def _on_interrupted_yellow_enter(self):
+        self.addTimer(3, .5)
+        self.setYellow();
+    
+    def _on_interrupted_yellow_exit(self):
+        self.removeTimer(3)
+    
+    def _on_interrupted_black_enter(self):
+        self.addTimer(4, .5)
+        self.clear();
+    
+    def _on_interrupted_black_exit(self):
+        self.removeTimer(4)
+    
+    def _off_enter(self):
+        self.clear();
+    
+    def initializeStatechart(self):
+        # enter default state
+        states = self.states["/on"].getEffectiveTargetStates()
+        self.updateConfiguration(states)
+        for state in states:
+            if state.enter:
+                state.enter()
+
+class ObjectManager(ObjectManagerBase):
+    def __init__(self, controller):
+        ObjectManagerBase.__init__(self, controller)
+    
+    def instantiate(self, class_name, construct_params):
+        if class_name == "MainApp":
+            instance = MainApp(self.controller)
+            instance.associations = {}
+            instance.associations["trafficlight"] = Association("TrafficLight", 0, -1)
+        elif class_name == "TrafficLight":
+            instance = TrafficLight(self.controller, construct_params[0])
+            instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
+        return instance
+
+class Controller(EventLoopControllerBase):
+    def __init__(self, event_loop_callbacks, finished_callback = None):
+        if finished_callback == None: finished_callback = None
+        EventLoopControllerBase.__init__(self, ObjectManager(self), event_loop_callbacks, finished_callback)
+        self.addInputPort("ui")
+        self.object_manager.createInstance("MainApp", [])

+ 10 - 0
examples/train/Makefile

@@ -0,0 +1,10 @@
+.PHONY: all
+
+SUB_DIRS = python
+
+all:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+
+clean:
+	for D in $(SUB_DIRS); do $(MAKE) -C $$D $@ ; done
+

+ 24 - 0
examples/train/python/Makefile

@@ -0,0 +1,24 @@
+.PHONY: all clean
+
+SCCDC = python -m sccd.compiler.sccdc
+FLAGS = -l python -p eventloop
+
+SOURCE = sccd.xml
+
+TARGET_DIR = target_py
+TARGET = $(TARGET_DIR)/target.py
+
+
+all: $(TARGET_DIR) $(TARGET)
+
+clean:
+	find $(TARGET_DIR) -type f -delete
+	-rmdir $(TARGET_DIR)
+
+$(TARGET): $(SOURCE)
+	$(SCCDC) $(FLAGS) -o $@ $<
+
+$(TARGET_DIR):
+	-mkdir $@
+	touch $@/__init__.py
+

+ 1 - 1
examples/train/python/make.bat

@@ -1 +1 @@
-..\..\..\python_sccd_compiler\sccdc.py -p eventloop -l python -o target_py\sccd.py sccd.xml
+python -m sccd.compiler.sccdc -p eventloop -l python -o target_py\target.py sccd.xml

+ 5 - 4
examples/train/python/runner.py

@@ -2,9 +2,10 @@ from Tkinter import *
 import random
 import math
 
-import target_py.sccd as sccd
-from python_runtime.statecharts_core import Event
-from python_runtime.tkinter_eventloop import *
+import target_py.target as target
+from sccd.runtime.libs.ui import ui
+from sccd.runtime.statecharts_core import Event
+from sccd.runtime.tkinter_eventloop import *
 
 width_railway = 20
 marked = {}
@@ -182,7 +183,7 @@ class SimulationGUI(Tk):
 root = SimulationGUI()
 if __name__ == "__main__":
     random.seed(1)
-    controller = sccd.Controller(root, TkEventLoop(root))
+    controller = target.Controller(root, TkEventLoop(root))
     root.controller = controller
     controller.start()
     try:

+ 0 - 5
examples/train/python/target_py/__init__.py

@@ -1,5 +0,0 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''

+ 0 - 171
examples/train/python/target_py/sccd_new.py

@@ -1,171 +0,0 @@
-"""
-Generated by Statechart compiler by Glenn De Jonghe and Joeri Exelmans
-
-Date:   Wed Jul 20 12:52:08 2016
-
-Model author: Simon Van Mierlo
-Model name:   Timer (Threaded Version)
-
-"""
-
-from python_runtime.statecharts_core import *
-from python_runtime.ordered_set import OrderedSet
-from python_runtime.libs.ui import ui
-from python_runtime.accurate_time import time
-
-# package "Timer (Threaded Version)"
-
-class MainApp(RuntimeClassBase):
-    def __init__(self, controller):
-        RuntimeClassBase.__init__(self, controller)
-        
-        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
-        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
-        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
-        self.semantics.priority = StatechartSemantics.SourceChild
-        self.semantics.concurrency = StatechartSemantics.Single
-        
-        # state /running
-        self.states["/running"] = ParallelState(0)
-        
-        # state /running/print_simulated_time
-        self.states["/running/print_simulated_time"] = State(1)
-        self.states["/running"].children.add(self.states["/running/print_simulated_time"])
-        
-        # state /running/print_wct_time
-        self.states["/running/print_wct_time"] = State(2)
-        self.states["/running"].children.add(self.states["/running/print_wct_time"])
-        
-        # state /running/print_simulated_time/print_simulated_time
-        self.states["/running/print_simulated_time/print_simulated_time"] = State(3)
-        self.states["/running/print_simulated_time"].children.add(self.states["/running/print_simulated_time/print_simulated_time"])
-        
-        def running_print_simulated_time_print_simulated_time_enter(self):
-            self.addTimer(0, 1)
-        self.states["/running/print_simulated_time/print_simulated_time"].enter = running_print_simulated_time_print_simulated_time_enter
-        def running_print_simulated_time_print_simulated_time_exit(self):
-            self.removeTimer(0)
-        self.states["/running/print_simulated_time/print_simulated_time"].exit = running_print_simulated_time_print_simulated_time_exit
-        
-        # state /running/print_wct_time/print_wct_time
-        self.states["/running/print_wct_time/print_wct_time"] = State(4)
-        self.states["/running/print_wct_time"].children.add(self.states["/running/print_wct_time/print_wct_time"])
-        
-        def running_print_wct_time_print_wct_time_enter(self):
-            self.addTimer(1, 1)
-        self.states["/running/print_wct_time/print_wct_time"].enter = running_print_wct_time_print_wct_time_enter
-        def running_print_wct_time_print_wct_time_exit(self):
-            self.removeTimer(1)
-        self.states["/running/print_wct_time/print_wct_time"].exit = running_print_wct_time_print_wct_time_exit
-       
-        # state /interrupted
-        self.states["/interrupted"] = State(5)
-        
-        # fix ancestors and descendants
-        self.states["/running"].fixTree()
-        self.states["/interrupted"].fixTree()
-        
-        # defaults
-        self.states["/running/print_simulated_time"].default = self.states["/running/print_simulated_time/print_simulated_time"]
-        self.states["/running/print_wct_time"].default = self.states["/running/print_wct_time/print_wct_time"]
-        
-        # transitions /running        
-        running_0 = Transition(self, self.states["/running"], self.states["/interrupted"])
-        def running_0_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        running_0.executable_content = running_0_exec
-        running_0.trigger = Event("interrupt", "input")
-        self.states["/running"].transitions.add(running_0)
-        
-        # transitions /running/print_simulated_time/print_simulated_time
-        running_print_simulated_time_print_simulated_time_0 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], self.states["/running/print_simulated_time/print_simulated_time"])
-        def running_print_simulated_time_print_simulated_time_0_exec(self):
-            self.print_simulated_time()
-        running_print_simulated_time_print_simulated_time_0.executable_content = running_print_simulated_time_print_simulated_time_0_exec
-        running_print_simulated_time_print_simulated_time_0.trigger = Event("_0after")
-        self.states["/running/print_simulated_time/print_simulated_time"].transitions.add(running_print_simulated_time_print_simulated_time_0)
-        
-        running_print_simulated_time_print_simulated_time_1 = Transition(self, self.states["/running/print_simulated_time/print_simulated_time"], self.states["/running/print_simulated_time/print_simulated_time"])
-        def running_print_simulated_time_print_simulated_time_1_exec(self):
-            print 'going nowhere!'
-        running_print_simulated_time_print_simulated_time_1.executable_content = running_print_simulated_time_print_simulated_time_1_exec
-        running_print_simulated_time_print_simulated_time_1.trigger = Event("interrupt", "input")        
-        self.states["/running/print_simulated_time/print_simulated_time"].transitions.add(running_print_simulated_time_print_simulated_time_1)
-        
-        # transitions /running/print_wct_time/print_wct_time
-        running_print_wct_time_print_wct_time_0 = Transition(self, self.states["/running/print_wct_time/print_wct_time"], self.states["/running/print_wct_time/print_wct_time"])
-        def running_print_wct_time_print_wct_time_0_exec(self):
-            self.print_wct_time()
-        running_print_wct_time_print_wct_time_0.executable_content = running_print_wct_time_print_wct_time_0_exec
-        running_print_wct_time_print_wct_time_0.trigger = Event("_1after")
-        self.states["/running/print_wct_time/print_wct_time"].transitions.add(running_print_wct_time_print_wct_time_0)
-        
-        # transitions /interrupted
-        interrupted_0 = Transition(self, self.states["/interrupted"], self.states["/interrupted"])
-        def interrupted_0_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        interrupted_0.executable_content = interrupted_0_exec
-        interrupted_0.trigger = Event("interrupt", "input")
-        self.states["/interrupted"].transitions.add(interrupted_0)
-        
-        interrupted_1 = Transition(self, self.states["/interrupted"], self.states["/running"])
-        def interrupted_1_exec(self):
-            self.print_simulated_time()
-            self.print_wct_time()
-        interrupted_1.executable_content = interrupted_1_exec
-        interrupted_1.trigger = Event("continue", "input")
-        self.states["/interrupted"].transitions.add(interrupted_1)
-        
-        # call user defined constructor
-        MainApp.user_defined_constructor(self)
-    
-    def user_defined_constructor(self):
-        pass
-    
-    def user_defined_destructor(self):
-        pass
-    
-    # user defined method
-    def print_simulated_time(self):
-        print 'SIMTIME = %.3f' % get_simulated_time()
-        
-    def print_wct_time(self):
-        print 'ACTTIME = %.3f' % time()
-    
-    def initializeStatechart(self):        
-        # enter default state
-        states = self.states["/running"].getEffectiveTargetStates()
-        self.configuration.update(states)
-        for state in states:
-            if state.enter:
-                state.enter(self)
-    
-    # generate transition candidates for current small step
-    def generateCandidates(self):
-        enabledEvents = self.getEnabledEvents()
-        enabledTransitions = OrderedSet()
-        for s in self.configuration:
-            if not s in self.combo_step.changed:
-                for t in s.transitions:
-                    if t.isEnabled(enabledEvents):
-                        enabledTransitions.add(t)
-        return enabledTransitions
-
-class ObjectManager(ObjectManagerBase):
-    def __init__(self, controller):
-        ObjectManagerBase.__init__(self, controller)
-    
-    def instantiate(self, class_name, construct_params):
-        if class_name == "MainApp":
-            instance = MainApp(self.controller)
-            instance.associations = {}
-        return instance
-
-class Controller(ThreadsControllerBase):
-    def __init__(self, keep_running = None):
-        if keep_running == None: keep_running = True
-        ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running)
-        self.addInputPort("input")
-        self.object_manager.createInstance("MainApp", [])

+ 4 - 2
examples/train/python/target_py/sccd.py

@@ -1,11 +1,11 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 03 16:58:55 2016
+Date:   Thu Aug 04 13:29:24 2016
 
 """
 
-from python_runtime.statecharts_core import *
+from sccd.runtime.statecharts_core import *
 
 # package ""
 
@@ -460,6 +460,8 @@ class ObjectManager(ObjectManagerBase):
         if class_name == "Train":
             instance = Train(self.controller, construct_params[0])
             instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
         return instance
 
 class Controller(EventLoopControllerBase):

+ 0 - 41
src/csharp_sccd_compiler/Action.cs

@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Xml.Linq;
-
-
-namespace csharp_sccd_compiler
-{
-    public class Action : Visitable
-    {
-        public List<SubAction> sub_actions { get; private set; }
-
-        public Action(XElement xml)
-        {
-            this.sub_actions = new List<SubAction>();
-            foreach (XElement sub_action_xml in xml.Elements())
-            {
-                SubAction sub_action = null;
-                if (sub_action_xml.Name == "raise")
-                    sub_action = new RaiseEvent(sub_action_xml);
-                else if (sub_action_xml.Name == "script")
-                    sub_action = new Script(sub_action_xml);
-                else if (sub_action_xml.Name == "log")
-                    sub_action = new Log(sub_action_xml);
-                else if (sub_action_xml.Name == "assign")
-                    sub_action = new Assign(sub_action_xml);
-                else if (sub_action_xml.Name != "parameter")      
-                    throw new CompilerException(string.Format("Invalid subaction <{0}>.", sub_action_xml.Name));
-
-                if (sub_action != null)
-                    this.sub_actions.Add(sub_action);
-            }
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            foreach (SubAction sub_action in this.sub_actions)
-                sub_action.accept(visitor);
-        }
-    }
-}
-

+ 0 - 96
src/csharp_sccd_compiler/Association.cs

@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-
-namespace csharp_sccd_compiler
-{
-    public class Association : Visitable
-    {
-        /// <summary>
-        /// Minimum cardinality of the association.
-        /// </summary>
-        public int min { get; private set; }
-        /// <summary>
-        /// Maximum cardinality of the association.
-        /// </summary>
-        /// <value>N is represented as -1.</value>
-        public int max { get; private set; }
-
-        public string to_class { get; private set; } // TODO perhaps try to replace the string by the actual class with a visitor? That's an extra error check.
-
-        public string name { get; private set; }
-
-        public Association(XElement xml)
-        {
-            XAttribute class_name_attribute = xml.Attribute("class");
-            if (class_name_attribute == null)
-                throw new CompilerException("Association missing class attribute.");
-            this.to_class = class_name_attribute.Value.Trim();
-            if (this.to_class == "")
-                throw new CompilerException("Association has empty class attribute.");
-
-            if (Constants.Reserved.Contains(this.to_class))
-                throw new CompilerException(string.Format("Reserved word '{0}' used as class attribute for association.", this.to_class));
-
-            XAttribute min_card_attribute = xml.Attribute("min");
-            if (min_card_attribute == null)
-                this.min = 0; //default value
-            else
-            {
-                try
-                {
-                    this.min = Convert.ToInt32(min_card_attribute.Value);
-                    if(this.min < 0)
-                        throw new FormatException();            
-                }
-                catch(FormatException)
-                {
-                    throw new CompilerException("Faulty minimum cardinality value in association.");
-                }
-                catch(OverflowException)
-                {
-                    throw new CompilerException("Minimum cardinality of association is too large.");
-                }
-            }
-
-            XAttribute max_card_attribute = xml.Attribute("max");
-            if (max_card_attribute == null)
-                this.max = -1; //default value TODO:use maxvalue?
-            else
-            {
-                try
-                {
-                    this.max = Convert.ToInt32(max_card_attribute.Value);
-                    if(this.max < this.min)
-                        throw new FormatException();                 
-                }
-                catch(FormatException)
-                {
-                    throw new CompilerException("Faulty maximum cardinality value in association.");
-                }
-                catch(OverflowException)
-                {
-                    throw new CompilerException("Maximum cardinality of association is too large.");
-                }
-            }
-
-            XAttribute association_name_attribute = xml.Attribute("name");
-            if (association_name_attribute == null)
-                throw new CompilerException("Association missing name attribute.");
-            this.name = association_name_attribute.Value.Trim();
-            if (this.name == "")
-                throw new CompilerException("Associaion has empty name attribute.");
-
-            if (Constants.Reserved.Contains(this.name))
-                throw new CompilerException(string.Format("Reserved word '{0}' used as class attribute for association.", this.name));
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 45
src/csharp_sccd_compiler/Attribute.cs

@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public class Attribute : Visitable
-    {
-        public string name { get; private set; }
-        public string type { get; private set; }
-        public string init_value { get; private set; }
-
-        public Attribute(XElement xml)
-        {
-            XAttribute name_attribute = xml.Attribute("name");
-            if (name_attribute == null)
-                throw new CompilerException("Missing attribute name.");
-            this.name = name_attribute.Value.Trim();
-            if (this.name == "")
-                throw new CompilerException("Empty attribute name.");
-            if (Constants.Reserved.Contains(this.name))
-                throw new CompilerException(string.Format("Reserved word '{0}' used as attribute name.", this.name));
-
-            XAttribute type_attribute = xml.Attribute("type");
-            if (type_attribute == null)
-                throw new CompilerException("Missing attribute type.");
-            this.type = type_attribute.Value.Trim();
-            if (this.type == "")
-                throw new CompilerException("Empty attribute type.");
-
-            XAttribute init_attribute = xml.Attribute("init-value");
-            if (init_attribute == null || init_attribute.Value == "")
-                this.init_value = null;
-            else
-                this.init_value = init_attribute.Value;
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 104
src/csharp_sccd_compiler/Class.cs

@@ -1,104 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public class Class : Visitable
-    {
-        public string name { get; private set; }
-        public bool is_default { get; private set; }
-
-        public List<Constructor> constructors { get; private set; }
-        public List<Destructor> destructors { get; private set; }
-        public List<Method> methods { get; private set; }
-        public List<Attribute> attributes { get; private set; }
-        public List<Association> associations { get; private set; }
-
-        public StateChart statechart { get; private set; }
-        public string super_class { get; private set; }
-
-        public Class(XElement xml)
-        {
-            this.name = xml.Attribute("name").Value;
-            XAttribute default_attribute = xml.Attribute("default");
-            if (default_attribute != null && default_attribute.Value.ToLower() == "true")
-            {
-                this.is_default = true;
-            }
-            else
-            {
-                this.is_default = false;
-            }
-            this.attributes = new List<Attribute>();
-            foreach(XElement attribute_xml in xml.Elements("attribute"))
-            {
-                this.attributes.Add(new Attribute(attribute_xml));
-            }
-
-            this.methods = new List<Method>();
-            this.constructors = new List<Constructor>();
-            this.destructors = new List<Destructor>();
-            foreach(XElement method_xml in xml.Elements("method"))
-            {
-                this.processMethod(method_xml);
-            }
-
-            if (this.destructors.Count > 1)
-                throw new CompilerException("Multiple destructors defined.");
-
-            if (this.constructors.Count == 0)
-                this.constructors.Add(new Constructor(this.name));
-
-
-            var associations = new List<XElement>();
-            var inheritances = new List<XElement>();
-            foreach (XElement relationships_xml in xml.Elements("relationships"))
-            {
-                associations.AddRange(relationships_xml.Elements("association"));
-                inheritances.AddRange(relationships_xml.Elements("inheritance"));
-            }
-
-            this.associations = new List<Association>();
-            foreach( XElement association_xml in associations)
-                this.associations.Add(new Association(association_xml));
-
-            if(inheritances.Count > 1)
-                throw new CompilerException("Multiple inheritance detected which is not supported.");
-            if (inheritances.Count == 1)
-                this.super_class = inheritances[0].Attribute("class").Value;
-            else
-                this.super_class = null;
-
-            XElement[] statecharts = xml.Elements("scxml").ToArray();
-            if (statecharts.Length > 1)
-                throw new CompilerException("Multiple statecharts found.");
-            if (statecharts.Length == 1)
-                this.statechart = new StateChart(statecharts[0]);
-        }
-
-        private void processMethod(XElement method_xml)
-        {
-            XAttribute method_name_attribute = method_xml.Attribute("name");
-            if (method_name_attribute == null)
-                throw new CompilerException("Missing method name.");
-            string method_name = method_name_attribute.Value;
-            if (method_name == "")
-                throw new CompilerException("Empty method name.");
-            if (Constants.Reserved.Contains(method_name))
-                throw new CompilerException(string.Format("Reserved word '{0}' used as method name.", method_name));
-            if (method_name == this.name)
-                this.constructors.Add(new Constructor(method_xml));
-            else if (method_name == string.Concat("~",this.name))
-                this.destructors.Add(new Destructor(method_xml));
-            else
-                this.methods.Add(new Method(method_xml));
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}

+ 0 - 132
src/csharp_sccd_compiler/ClassDiagram.cs

@@ -1,132 +0,0 @@
-using System;
-using System.Linq;
-using System.Xml.Linq;
-using System.Collections.Generic;
-
-namespace csharp_sccd_compiler
-{
-	public class ClassDiagram : Visitable
-	{
-        public string model_name { get; private set; }
-
-        public string model_author { get; private set; }
-
-        public string model_description { get; private set; }
-
-        public List<string> class_names { get; private set; }
-
-        public List<string> inports { get; private set; }
-
-        public List<string> outports { get; private set; }
-
-        public string top_section { get; private set; }
-
-        public List<Class> classes { get; private set; }
-
-        public Class default_class { get; private set; }
-
-		public ClassDiagram (string input_file_path)
-        {
-            XElement root = XDocument.Load(input_file_path).Root;
-            XAttribute name_attribute = root.Attribute("name");
-            if (name_attribute != null && name_attribute.Value.Trim() != "")
-                this.model_name = name_attribute.Value.Trim();
-            XAttribute author_attribute = root.Attribute("author");
-            if (author_attribute != null && author_attribute.Value.Trim() != "")
-                this.model_author = author_attribute.Value.Trim();
-            XElement description_element = root.Element("description");
-            if (description_element != null && description_element.Value.Trim() != "")
-                model_description = description_element.Value;
-
-            this.class_names = new List<string>();
-			foreach (XElement class_xml in root.Elements("class"))
-            {
-                XAttribute class_name_attribute = class_xml.Attribute("name");
-                if (class_name_attribute == null)
-                    throw new CompilerException("Missing class name.");
-                string class_name = class_name_attribute.Value.Trim();
-                if (class_name == "")
-                    throw new CompilerException("Empty class name.");
-                if (this.class_names.Contains(class_name))
-                    throw new CompilerException(string.Format("Found 2 classes with the same name '{0}'.", class_name));
-                this.class_names.Add(class_name);
-            }
-
-            if (this.class_names.Count == 0)
-                throw new CompilerException("Found no classes to compile.");
-
-			this.inports = new List<string> ();
-            foreach (XElement inport_xml in root.Elements("inport"))
-            {
-                XAttribute inport_name_attribute = inport_xml.Attribute("name");
-                if (inport_name_attribute == null)
-                    throw new CompilerException("Missing inport name.");
-                string inport_name = inport_name_attribute.Value.Trim();
-                if (inport_name == "")
-                    throw new CompilerException("Empty inport name.");
-                if (this.inports.Contains(inport_name))
-                    throw new CompilerException(string.Format("Found 2 inports with the same name '{0}'.", inport_name));
-                this.inports.Add(inport_name);
-            }
-
-			this.outports = new List<string> ();
-            foreach (XElement outport_xml in root.Elements("outport"))
-            {
-                XAttribute outport_name_attribute = outport_xml.Attribute("name");
-                if (outport_name_attribute == null)
-                    throw new CompilerException("Missing outport name.");
-                string outport_name = outport_name_attribute.Value.Trim();
-                if (outport_name == "")
-                    throw new CompilerException("Empty outport name.");
-                if (this.outports.Contains(outport_name))
-                    throw new CompilerException(string.Format("Found 2 outports with the same name '{0}'.", outport_name));
-                this.outports.Add(outport_name);
-            }
-
-            List<XElement> top_elements = root.Elements("top").ToList();
-            if (top_elements.Count == 1 && top_elements[0].Value.Trim() != "")
-                this.top_section = top_elements[0].Value;
-            else if (top_elements.Count > 1)
-                throw new CompilerException("Class diagram can only have one <top> element.");
-
-            this.classes = new List<Class>(); 
-            List<Class> default_classes = new List<Class>(); 
-
-            foreach (XElement class_xml in root.Elements("class"))
-            {
-                Class processed_class = null;
-                try
-                {
-                    processed_class = new Class(class_xml);
-                }
-                catch(CompilerException e)
-                {
-                    throw new CompilerException(string.Format("Class <{0}> failed compilation.", class_xml.Attribute("name").Value), e);
-                }
-
-                Logger.displayInfo(string.Format("Class <{0}> has been successfully loaded.", processed_class.name));
-                this.classes.Add(processed_class);
-                if (processed_class.is_default)
-                    default_classes.Add(processed_class);
-            }
-
-            if (default_classes.Count != 1)
-            {
-                if (this.classes.Count == 1)
-                {
-                    Logger.displayInfo(string.Format("Only one class given. Using <{0}> as the default class.", this.classes[0].name));
-                    this.default_class = this.classes[0];
-                }
-                else
-                    throw new CompilerException("Provide one and only one default class to instantiate on start up.");
-            }
-            else
-                this.default_class = default_classes[0];
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-	}
-}

+ 0 - 890
src/csharp_sccd_compiler/Code Generation/CSharpGenerator.cs

@@ -1,890 +0,0 @@
-using System;
-using System.Linq;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace csharp_sccd_compiler
-{
-    public class CSharpGenerator : CodeGenerator
-    {
-
-        public CSharpGenerator() : base( new Platform[]{Platform.THREADS, Platform.GAMELOOP} )
-        {
-        }
-
-        public override void visit(ClassDiagram class_diagram)
-        {
-            this.output_file.write("/*");
-            this.output_file.indent();
-            this.output_file.write("Statecharts + Class Diagram compiler by Glenn De Jonghe");
-            this.output_file.write();
-            this.output_file.write(string.Format("Generated on {0}.", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
-            if  (class_diagram.model_name != null || class_diagram.model_author != null || class_diagram.model_description != null)
-                this.output_file.write();
-
-            if (class_diagram.model_name != null)
-                this.output_file.write("Model name:   " + class_diagram.model_name);
-            if (class_diagram.model_author != null)
-                this.output_file.write("Model author: " + class_diagram.model_author);
-
-            if (class_diagram.model_description != null)
-            {
-                this.output_file.write("Model description:");
-                this.output_file.write();
-                this.output_file.indent();
-                this.writeCorrectIndent(class_diagram.model_description);
-                this.output_file.dedent();
-            }
-            this.output_file.dedent();
-            this.output_file.write("*/");
-            this.output_file.write();
-            
-            //Use runtime libraries
-            this.output_file.write("using System;");
-            this.output_file.write("using System.Collections.Generic;");
-            this.output_file.write("using sccdlib;");
-
-            //Namespace using declarations by the user
-            if (class_diagram.top_section != null)
-                this.writeCorrectIndent(class_diagram.top_section);
-            this.output_file.write();
-            
-            //visit children
-            foreach (Class c in class_diagram.classes)
-                c.accept(this);
-             
-            //writing out ObjectManager
-            this.output_file.write("public class ObjectManager : ObjectManagerBase");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("public ObjectManager(ControllerBase controller): base(controller)");
-            this.output_file.write("{");
-            this.output_file.write("}");
-            this.output_file.write();
-            
-            this.output_file.write("protected override InstanceWrapper instantiate(string class_name, object[] construct_params)");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("RuntimeClassBase instance = null;");
-            this.output_file.write("List<Association> associations = new List<Association>();");
-            for (int index = 0; index < class_diagram.classes.Count; ++index)
-            {
-                if (index == 0)
-                    this.output_file.write();
-                else
-                    this.output_file.write("}else ");
-                this.output_file.extendWrite("if (class_name == \"" + class_diagram.classes[index].name + "\" ){");
-                this.output_file.indent();
-                this.output_file.write("object[] new_parameters = new object[construct_params.Length + 1];");
-                this.output_file.write("new_parameters[0] = this.controller;");
-                this.output_file.write("Array.Copy(construct_params, 0, new_parameters, 1, construct_params.Length);");
-                this.output_file.write("instance = (RuntimeClassBase) Activator.CreateInstance(typeof(" + class_diagram.classes[index].name + "), new_parameters);");
-                foreach (Association association in class_diagram.classes[index].associations)
-                    association.accept(this);
-                this.output_file.dedent();
-                if (index == class_diagram.classes.Count - 1)
-                    this.output_file.write("}");
-            }
-            this.output_file.write("if (instance != null) {");
-            this.output_file.indent();
-            this.output_file.write("return new InstanceWrapper(instance, associations);");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write("return null;");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.dedent();
-            this.output_file.write("}");
-
-            //Write out controller
-            this.output_file.write();
-            string controller_sub_class = "";
-            if (this.current_platform == Platform.THREADS)
-                controller_sub_class = "ThreadsControllerBase";
-            else if (this.current_platform == Platform.GAMELOOP)
-                controller_sub_class = "GameLoopControllerBase";
-            this.output_file.write("public class Controller : " + controller_sub_class);
-            this.output_file.write("{");
-            this.output_file.indent();
-        
-            //Write out constructor(s)
-            if (class_diagram.default_class.constructors != null)
-                foreach (Constructor constructor in class_diagram.default_class.constructors)
-                    this.writeControllerConstructor(class_diagram, constructor.parameters);
-            else
-                this.writeControllerConstructor(class_diagram, new List<FormalParameter>());
-            
-            this.output_file.write("public static void Main()");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("Controller controller = new Controller();");
-            this.output_file.write("controller.start();");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            
-            this.output_file.dedent();
-            this.output_file.write("}");
-        }
-
-        /// <summary>
-        /// Helper method
-        /// </summary>
-        private void writeControllerConstructor(ClassDiagram class_diagram, List<FormalParameter> parameters)
-        {
-            this.output_file.write("public Controller(");
-            this.writeFormalParameters(parameters.Concat(new FormalParameter[]{new FormalParameter("keep_running", "bool", "true")}));
-            this.output_file.extendWrite(") : base(keep_running)");
-            this.output_file.write("{");
-            this.output_file.indent();
-            
-            foreach (string p in class_diagram.inports)
-                this.output_file.write("this.addInputPort(\"" + p + "\");");
-            foreach (string p in class_diagram.outports)
-                this.output_file.write("this.addOutputPort(\"" + p + "\");");
-            this.output_file.write("this.object_manager = new ObjectManager(this);");
-            string[] actual_parameters = (from parameter in parameters select parameter.name).ToArray();
-            this.output_file.write("this.object_manager.createInstance(\"" + class_diagram.default_class.name + "\", new object[]{" + string.Join(", ", actual_parameters) + "});");
-            this.output_file.dedent();
-            this.output_file.write("}");
-        }
-
-        /// <summary>
-        /// Generate code for Class construct
-        /// </summary>
-        public override void visit(Class class_node)
-        {
-            this.output_file.write();
-            this.output_file.write("public class " + class_node.name);
-            // Take care of inheritance
-            if (class_node.super_class != null)
-                this.output_file.extendWrite(" : " + class_node.super_class);
-            else
-                this.output_file.extendWrite(" : " + "RuntimeClassBase");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write();
-            
-            if (class_node.statechart != null)
-            {
-                //assign each node a unique ID
-                this.output_file.write("/// <summary>");
-                this.output_file.write("/// Enum uniquely representing all statechart nodes.");
-                this.output_file.write("/// </summary>");
-                this.output_file.write("public enum Node {");
-                this.output_file.indent();
-                foreach( StateChartNode node in class_node.statechart.composites.Concat(class_node.statechart.basics))
-                    this.output_file.write(node.full_name + ",");
-                this.output_file.dedent();
-                this.output_file.write("};");
-                this.output_file.write();
-                this.output_file.write("Dictionary<Node,List<Node>> current_state = new Dictionary<Node,List<Node>>();");
-                if (class_node.statechart.histories.Count > 0)
-                    this.output_file.write("Dictionary<Node,List<Node>> history_state = new Dictionary<Node,List<Node>>();");
-                this.output_file.write();
-            }
-
-            //User defined attributes
-            if (class_node.attributes.Count > 0)
-            {
-                this.output_file.write("//User defined attributes");
-                foreach (Attribute attribute in class_node.attributes)
-                {
-                    this.output_file.write(attribute.type + " " + attribute.name);
-                    if (attribute.init_value != null)
-                        this.output_file.extendWrite(" = " + attribute.init_value);
-                    this.output_file.extendWrite(";");     
-                }
-                this.output_file.write();
-            }
-
-            if (class_node.statechart != null)
-            {
-                this.output_file.write("/// <summary>");
-                this.output_file.write("/// Constructor part that is common for all constructors.");
-                this.output_file.write("/// </summary>");
-                this.output_file.write("private void commonConstructor(ControllerBase controller = null)");
-                this.output_file.write("{");
-                this.output_file.indent(); 
-                this.output_file.write("this.controller = controller;");
-                this.output_file.write("this.object_manager = controller.getObjectManager();");
-                if (class_node.statechart.nr_of_after_transitions != 0)
-                    this.output_file.write("this.timers = new Dictionary<int,double>();");
-
-                this.output_file.write();
-                this.output_file.write("//Initialize statechart :");
-                this.output_file.write();
-
-                if (class_node.statechart.histories.Count > 0)
-                {
-                    foreach (StateChartNode node in class_node.statechart.combined_history_parents)
-                    {
-                        this.output_file.write("this.history_state[Node." + node.full_name + "] = new List<Node>();");
-                    }
-                    this.output_file.write();
-                }
-
-                foreach (StateChartNode node in class_node.statechart.composites)
-                    this.output_file.write("this.current_state[Node." + node.full_name + "] = new List<Node>();");
-            }
-
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-            
-            this.output_file.write("public override void start()");
-            this.output_file.write("{");
-            
-            this.output_file.indent();
-            this.output_file.write("base.start();");
-            foreach (StateChartNode default_node in class_node.statechart.root.defaults)
-            {
-                if (default_node.is_composite)
-                    this.output_file.write("this.enterDefault_" + default_node.full_name + "();");
-                else if (default_node.is_basic)
-                    this.output_file.write("this.enter_" + default_node.full_name + "();");
-            }
-
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-            
-            //visit children
-            foreach( var i in class_node.constructors)
-                i.accept(this);
-            foreach( var i in class_node.destructors)
-                i.accept(this);
-            foreach( var i in class_node.methods)
-                i.accept(this);
-            if (class_node.statechart != null)
-                class_node.statechart.accept(this);
-              
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-
-        /// <summary>
-        /// Helper method that writes a correct comma separated list of formal parameters.
-        /// </summary>
-        private void writeFormalParameters(IEnumerable<FormalParameter> parameters)
-        {
-            bool first = true;       
-            foreach (FormalParameter param in parameters)
-            {
-                if (first)
-                    first = false;
-                else
-                    this.output_file.extendWrite(", ");
-                param.accept(this);
-            }
-        }
-            
-        public override void visit(FormalParameter formal_parameter)
-        {
-            this.output_file.extendWrite(formal_parameter.type + " " + formal_parameter.name);
-            if (formal_parameter.default_value != null)
-                this.output_file.extendWrite(" = " + formal_parameter.default_value);
-        }
-                        
-        public override void visit(Constructor constructor)
-        {
-            this.output_file.write(constructor.access + " " + constructor.name + "(");
-            this.writeFormalParameters(new FormalParameter[]{new FormalParameter("controller", "ControllerBase", null)}.Concat(constructor.parameters));
-            this.output_file.extendWrite(")");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("this.commonConstructor(controller);");
-            if (constructor.body != null && constructor.body.Trim() != "")
-            {
-                this.output_file.write();
-                this.output_file.write("//constructor body (user-defined)");
-                this.writeCorrectIndent(constructor.body);
-            }
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-            
-        public override void visit(Destructor destructor)
-        {
-            this.output_file.write(destructor.name + "()");
-            this.output_file.write("{");
-            if (destructor.body != null)
-            {
-                this.output_file.indent();
-                this.writeCorrectIndent(destructor.body);
-                this.output_file.dedent();
-            }
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-            
-        public override void visit(Method method)
-        {
-            this.output_file.write(method.access + " " + method.return_type + " " + method.name + "(");
-            this.writeFormalParameters(method.parameters);
-            this.output_file.extendWrite(")");
-            this.output_file.write("{");
-            this.output_file.indent();
-            if (method.body != null)
-            {
-                this.output_file.indent();
-                this.writeCorrectIndent(method.body);
-                this.output_file.dedent();
-            }
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-
-        public override void visit(Association association)
-        {
-            this.output_file.write("associations.Add(new Association(\"" + association.name + "\", \"" + association.to_class + "\", " + association.min.ToString() + ", " + association.max.ToString() + "));");
-        }
-
-        /// <summary>
-        /// Helper method that writes the transitions recursively.
-        /// </summary>
-        public void writeTransitionsRecursively(StateChartNode current_node)
-        {
-            this.output_file.write("private bool transition_" + current_node.full_name + "(Event e)");
-            this.output_file.write("{");
-            this.output_file.indent();
-            
-            List<StateChartNode> valid_children = new List<StateChartNode>();
-            foreach (StateChartNode child in current_node.children)
-            {
-                if (child.is_composite || child.is_basic)
-                    valid_children.Add(child);
-            }
-             
-            this.output_file.write("bool catched = false;");
-            bool do_dedent = false;
-            if (current_node.solves_conflict_outer)
-            {
-                this.writeFromTransitions(current_node);
-                if (current_node.is_parallel || current_node.is_composite)
-                {
-                    this.output_file.write("if (!catched){");
-                    this.output_file.indent();
-                    do_dedent = true;
-                }
-            }
-                
-            if (current_node.is_parallel)
-            {
-                foreach (StateChartNode child in valid_children) 
-                    this.output_file.write("catched = this.transition_" + child.full_name + "(e) || catched;");
-            }
-            else if (current_node.is_composite)
-            {
-                this.output_file.write();
-                for (int i=0; i < valid_children.Count; ++i)
-                {
-                    if (i > 0)
-                        this.output_file.extendWrite(" else ");
-                    this.output_file.extendWrite("if (this.current_state[Node." + current_node.full_name + "][0] == Node." + valid_children[i].full_name + "){");
-                    this.output_file.indent();
-                    this.output_file.write("catched = this.transition_" + valid_children[i].full_name + "(e);");
-                    this.output_file.dedent();
-                    this.output_file.write("}");
-                }
-            }   
-            if (current_node.solves_conflict_outer)
-            {
-                if (do_dedent)
-                {
-                    this.output_file.dedent();
-                    this.output_file.write("}");
-                }
-            }
-            else if (current_node.transitions.Count > 0)
-            {
-                this.output_file.write("if (!catched) {");
-                this.output_file.indent();
-                this.writeFromTransitions(current_node);
-                this.output_file.dedent();
-                this.output_file.write("}");
-            }
-                
-            this.output_file.write("return catched;");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-            
-            foreach (StateChartNode child in valid_children)
-                this.writeTransitionsRecursively(child);
-        }
-                    
-        /// <summary>
-        /// Helper method
-        /// </summary>
-        private void writeFromTransitions(StateChartNode current_node)
-        {
-            if (current_node.transitions.Count == 0)
-                return;
-            
-            this.output_file.write("List<int> enableds = new List<int>();");
-            for (int index=0; index < current_node.transitions.Count; ++index)
-                this.writeTransitionCondition(current_node.transitions[index], index);
-                
-            this.output_file.write("if (enableds.Count > 1){");
-            this.output_file.indent();
-            this.output_file.write("Console.WriteLine(\"Runtime warning : indeterminism detected in a transition from node " +  current_node.full_name + ". Only the first in document order enabled transition is executed.\");");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write("if (enableds.Count > 0){");
-            this.output_file.indent();
-            this.output_file.write("int enabled = enableds[0];");
-            this.output_file.write();
-                  
-            for (int index=0; index < current_node.transitions.Count; ++index)
-                this.writeTransitionAction(current_node.transitions[index], index);
-            
-            this.output_file.write("catched = true;");   
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-            
-        public override void visit( FormalEventParameter formal_event_parameter)
-        {
-            this.output_file.extendWrite(formal_event_parameter.type + " " + formal_event_parameter.name);
-        }
-            
-        /// <summary>
-        /// Helper method
-        /// </summary>
-        private void writeFormalEventParameters(StateChartTransition transition)
-        {
-            if (transition.trigger.parameters.Count > 0)
-            {
-                this.output_file.write("object[] parameters = e.getParameters();");
-                for (int index=0; index < transition.trigger.parameters.Count; ++index)
-                {
-                    this.output_file.write();
-                    transition.trigger.parameters[index].accept(this);
-                    this.output_file.extendWrite(" = (" + transition.trigger.parameters[index].type + ")parameters[" + index.ToString() + "];");
-                }
-            }
-        }
-
-        ///
-        private void writeTransitionAction(StateChartTransition transition, int index)
-        {
-            if (index > 1)
-                this.output_file.extendWrite(" else ");
-            else
-                this.output_file.write();
-            this.output_file.extendWrite("if (enabled == " + index.ToString() + "){");
-            this.output_file.indent();
-
-            //Handle parameters to actually use them             
-            this.writeFormalEventParameters(transition);
-            
-            //Write out exit actions
-            StateChartNode last_exit_node = transition.exit_nodes[transition.exit_nodes.Count - 1];
-            if (!last_exit_node.is_basic)
-                this.output_file.write("this.exit_" + last_exit_node.full_name + "();");
-            else
-            {
-                foreach (StateChartNode node in transition.exit_nodes)
-                {
-                    if (node.is_basic)
-                        this.output_file.write("this.exit_" + node.full_name + "();");
-                }
-            }
-
-            //Write out trigger actions
-            transition.action.accept(this);
-            
-            foreach (Tuple<StateChartNode,bool> enter_node_tuple in transition.enter_nodes)
-            {
-                StateChartNode entering_node = enter_node_tuple.Item1;
-                if (enter_node_tuple.Item2)
-                {
-                    if (entering_node.is_composite)
-                        this.output_file.write("this.enterDefault_" + entering_node.full_name + "();");
-                    else if (entering_node.is_history)
-                    {
-                        if (entering_node.is_history_deep)
-                            this.output_file.write("this.enterHistoryDeep_" + entering_node.parent.full_name + "();");
-                        else
-                            this.output_file.write("this.enterHistoryShallow_" + entering_node.parent.full_name + "();");
-                    }
-                    else
-                        this.output_file.write("this.enter_" + entering_node.full_name + "();");
-                }
-                else
-                {
-                    if (entering_node.is_composite)
-                        this.output_file.write("this.enter_" + entering_node.full_name + "();");
-                }
-            }
-            this.output_file.dedent();
-            this.output_file.write("}");
-        }
-                            
-        private void writeTransitionCondition(StateChartTransition transition, int index)
-        {
-            if (!transition.trigger.is_uc)
-            {
-                this.output_file.write("if (e.getName() == \"" + transition.trigger.event_name + "\" && e.getPort() == \"" + transition.trigger.port + "\"){");
-                this.output_file.indent();   
-            }
-            //Evaluate guard
-            if (transition.guard != null)
-            {
-                //Handle parameters for guard evaluation       
-                this.writeFormalEventParameters(transition);  
-
-                this.output_file.write("if (");
-                transition.guard.accept(this);
-                this.output_file.extendWrite("){");
-                this.output_file.indent();    
-            }
-            this.output_file.write("enableds.Add(" + index.ToString() + ");");
-
-            if (transition.guard != null)
-            {
-                this.output_file.dedent();
-                this.output_file.write("}");
-            }
-            if (!transition.trigger.is_uc)
-            {
-                this.output_file.dedent();
-                this.output_file.write("}");
-            }
-            this.output_file.write();
-        }
-        
-        public override void visit(EnterAction enter_method)
-        {
-            this.output_file.write("private void enter_" + enter_method.parent.full_name + "()");
-            this.output_file.write("{");
-            this.output_file.indent();
-            
-            //Take care of any AFTER events
-            foreach (StateChartTransition transition in enter_method.parent.transitions)
-            {
-                if (transition.trigger.is_after)
-                {
-                    this.output_file.write("this.timers[" + transition.trigger.after_index.ToString() + "] = ");
-                    transition.trigger.after_expression.accept(this);
-                    this.output_file.extendWrite(";");
-                }
-            }
-            if (enter_method.action != null)
-                enter_method.action.accept(this);
-            this.output_file.write("this.current_state[Node." + enter_method.parent.parent.full_name + "].Add(Node." + enter_method.parent.full_name + ");");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-
-        private void writeEnterDefault(StateChartNode entered_node)
-        {
-            this.output_file.write("private void enterDefault_" + entered_node.full_name + "()");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("this.enter_" + entered_node.full_name + "();");
-            if (entered_node.is_composite)
-            {
-                foreach(StateChartNode default_node in entered_node.defaults)
-                {
-                    if (default_node.is_composite)
-                        this.output_file.write("this.enterDefault_" + default_node.full_name + "();");
-                    else if (default_node.is_basic)
-                        this.output_file.write("this.enter_" + default_node.full_name + "();");
-                }
-            }
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-             
-        public override void visit(ExitAction exit_method)
-        {
-            this.output_file.write("private void exit_" + exit_method.parent.full_name + "()");
-            this.output_file.write("{");
-            this.output_file.indent();
-            //If the exited node is composite take care of potential history and the leaving of descendants
-            if (exit_method.parent.is_composite)
-            {
-                //handle history
-                if (exit_method.parent.save_state_on_exit)
-                    this.output_file.write("this.history_state[Node." + exit_method.parent.full_name + "].AddRange(this.current_state[Node." + exit_method.parent.full_name + "]);");
-                
-                //Take care of leaving children
-                if (exit_method.parent.is_parallel)
-                {
-                    foreach(StateChartNode child in exit_method.parent.children)
-                    {
-                        if (!child.is_history)
-                            this.output_file.write("this.exit_" + child.full_name + "();");
-                    }
-                }
-                else
-                {
-                    foreach(StateChartNode child in exit_method.parent.children)
-                    {
-                        if (!child.is_history)
-                        {
-                            this.output_file.write("if (this.current_state[Node." + exit_method.parent.full_name + "].Contains(Node." + child.full_name + ")){");
-                            this.output_file.indent();
-                            this.output_file.write("this.exit_" + child.full_name + "();");
-                            this.output_file.dedent();
-                            this.output_file.write("}");
-                        }
-                    }
-                }
-            }
-
-            //Take care of any AFTER events
-            foreach (StateChartTransition transition in exit_method.parent.transitions)
-            {
-                if (transition.trigger.is_after)
-                    this.output_file.write("this.timers.Remove(" + transition.trigger.after_index.ToString() + ");");
-            } 
-
-            //Execute user-defined exit action if present
-            if (exit_method.action != null)
-                exit_method.action.accept(this);
-                
-            //Adjust state
-            this.output_file.write("this.current_state[Node." + exit_method.parent.parent.full_name + "].Remove(Node." + exit_method.parent.full_name + ");");
-
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-           
-        private void writeEnterHistory(StateChartNode entered_node, bool is_deep)
-        {
-            this.output_file.write("private void enterHistory");
-            if (is_deep)
-                this.output_file.extendWrite("Deep");
-            else
-                this.output_file.extendWrite("Shallow");
-            this.output_file.extendWrite("_" + entered_node.full_name + "()");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("if (this.history_state[Node." + entered_node.full_name + "].Count == 0){");
-            this.output_file.indent();
-
-            foreach (StateChartNode node in entered_node.defaults)
-            {
-                if (node.is_basic)
-                    this.output_file.write("this.enter_" + node.full_name + "();");
-                else if (node.is_composite)
-                    this.output_file.write("this.enterDefault_" + node.full_name + "();");
-            }
-
-            this.output_file.dedent();
-            this.output_file.write("} else {");
-            this.output_file.indent();
-
-            if (entered_node.is_parallel)
-            {
-                foreach (StateChartNode child in entered_node.children)
-                {
-                    if (!child.is_history)
-                    {
-                        this.output_file.write("this.enterHistory");
-                        if (is_deep)
-                            this.output_file.extendWrite("Deep");
-                        else
-                            this.output_file.extendWrite("Shallow");
-                        this.output_file.extendWrite("_" + child.full_name + "();");
-                    }
-                }
-            }
-            else
-            {
-                foreach (StateChartNode child in entered_node.children)
-                {
-                    if (!child.is_history)
-                    {
-                        this.output_file.write("if (this.history_state[Node." + entered_node.full_name + "].Contains(Node." + child.full_name + ")){");
-                        this.output_file.indent();
-                        if (child.is_composite)
-                        {
-                            if (is_deep)
-                            {
-                                this.output_file.write("this.enter_" + child.full_name + "();");
-                                this.output_file.write("this.enterHistoryDeep_" + child.full_name + "();");
-                            }
-                            else
-                                this.output_file.write("this.enterDefault_" + child.full_name + "();");
-                        }
-                        else
-                            this.output_file.write("this.enter_" + child.full_name + "();");
-                        this.output_file.dedent();
-                        this.output_file.write("}");
-                    }
-                }
-            }
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-
-        public override void visit(StateChart statechart)
-        {
-            this.output_file.write("//Statechart enter/exit action method(s) :");
-            this.output_file.write();
-            
-            //Visit enter and exit actions of children
-            foreach (StateChartNode node in statechart.composites.Concat(statechart.basics))
-            {
-                if (!object.ReferenceEquals(node, statechart.root))
-                {
-                    node.enter_action.accept(this);
-                    node.exit_action.accept(this);
-                }
-            }
-            //Write out statecharts methods for enter/exit state
-            if (statechart.composites.Count > 1)
-            {
-                this.output_file.write("//Statechart enter/exit default method(s) :");
-                this.output_file.write();
-                foreach (StateChartNode node in statechart.composites)
-                {
-                    if (!object.ReferenceEquals(node, statechart.root))
-                        this.writeEnterDefault(node);
-                }
-            }
-
-            //Write out statecharts methods for enter/exit history
-            if (statechart.histories.Count > 0)
-            {
-                this.output_file.write("//Statechart enter/exit history method(s) :");
-                this.output_file.write();
-                foreach (StateChartNode node in statechart.shallow_history_parents)
-                    this.writeEnterHistory(node, false);
-                foreach (StateChartNode node in statechart.deep_history_parents)
-                    this.writeEnterHistory(node, true);   
-            }
-            this.output_file.write("//Statechart transitions :");
-            this.output_file.write();
-            this.writeTransitionsRecursively(statechart.root);           
-                    
-            //Write out transition function
-            this.output_file.write("protected override void transition (Event e = null)");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("if (e == null) {");
-            this.output_file.indent();
-            this.output_file.write("e = new Event();");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write("this.state_changed = this.transition_" + statechart.root.full_name + "(e);");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-
-            //Write out inState function
-            this.output_file.write("public bool inState(List<Node> nodes)");
-            this.output_file.write("{");
-            this.output_file.indent();
-            this.output_file.write("foreach(List<Node> actives in current_state.Values){");
-            this.output_file.indent();
-            this.output_file.write("foreach(Node node in actives)");
-            this.output_file.indent();
-            this.output_file.write("nodes.Remove (node);");
-            this.output_file.dedent();
-            this.output_file.write("if (nodes.Count == 0){");
-            this.output_file.indent();
-            this.output_file.write("return true;");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write("return false;");
-            this.output_file.dedent();
-            this.output_file.write("}");
-            this.output_file.write();
-        }
-
-        public override void visit(ExpressionPartString expression_part_string)
-        {
-            this.output_file.extendWrite(expression_part_string.value);
-        }
-            
-        public override void visit(SelfReference self_reference)
-        {
-            this.output_file.extendWrite("this");
-        }
-            
-        public override void visit(StateReference state_ref)
-        {
-            this.output_file.extendWrite("new List<Node>() {");
-            this.output_file.extendWrite(string.Join(", ", (from node in state_ref.target_nodes select "Node." + node.full_name)));
-            this.output_file.extendWrite("}");
-        }
-            
-        public override void visit(InStateCall in_state_call)
-        {
-            this.output_file.extendWrite("this.inState(");
-            in_state_call.state_reference.accept(this);
-            this.output_file.extendWrite(")");
-        }
-            
-        public override void visit(RaiseEvent raise_event)
-        {
-            if (raise_event.scope == RaiseEvent.Scope.NARROW_SCOPE || raise_event.scope == RaiseEvent.Scope.BROAD_SCOPE)
-                this.output_file.write("Event send_event = new Event(\"" + raise_event.event_name + "\", \"\", new object[] {");
-            else if (raise_event.scope == RaiseEvent.Scope.LOCAL_SCOPE)
-                this.output_file.write("this.addEvent( new Event(\"" + raise_event.event_name + "\", \"\", new object[] {");
-            else if (raise_event.scope == RaiseEvent.Scope.OUTPUT_SCOPE)
-                this.output_file.write("this.controller.outputEvent(new Event(\"" + raise_event.event_name + "\", \"" + raise_event.port + "\", new object[] {");
-            else if (raise_event.scope == RaiseEvent.Scope.CD_SCOPE)
-                this.output_file.write("this.object_manager.addEvent(new Event(\"" + raise_event.event_name + "\", \"\", new object[] { this, ");
-
-            bool first_param = true;
-            foreach (Expression param in raise_event.parameters)
-            {
-                if (first_param)
-                    first_param = false;
-                else
-                    this.output_file.extendWrite(",");
-                param.accept(this);
-            }
-
-            if (raise_event.scope == RaiseEvent.Scope.NARROW_SCOPE)
-            {
-                this.output_file.extendWrite("});");
-                this.output_file.write("this.object_manager.addEvent(new Event(\"narrow_cast\", \"\", new object[] {this, \"" + raise_event.target + "\" ,send_event}));");
-            }
-            else if (raise_event.scope == RaiseEvent.Scope.BROAD_SCOPE)
-            {
-                this.output_file.extendWrite("});");
-                this.output_file.write("this.object_manager.addEvent(new Event(\"broad_cast\", \"\", new object[] {send_event}));");
-            }
-            else
-                this.output_file.extendWrite("}));");
-        }
-                
-        public override void visit(Script script)
-        {
-            this.writeCorrectIndent(script.code);
-        }
-            
-        public override void visit(Log log)
-        {
-            this.output_file.write("Console.WriteLine(\"" + log.message + "\");");
-        }
-            
-        public override void visit(Assign assign)
-        {
-            this.output_file.write();
-            assign.lvalue.accept(this);
-            this.output_file.extendWrite(" = ");
-            assign.expression.accept(this);
-            this.output_file.extendWrite(";");
-        }
-    }
-}
-

+ 0 - 89
src/csharp_sccd_compiler/Code Generation/CodeGenerator.cs

@@ -1,89 +0,0 @@
-using System;
-using System.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public abstract class CodeGenerator : Visitor
-    {
-        protected Platform current_platform;
-        protected Platform[] supported_platforms;
-        protected FileOutputer output_file;
-
-        public enum Platform {
-            THREADS,
-            GAMELOOP
-        };
-
-        private enum IndentType {
-            NOT_SET,
-            SPACES,
-            TABS
-        }
-
-        public CodeGenerator(Platform[] supported_platforms)
-        {
-            this.supported_platforms = supported_platforms;
-        }
-
-        public bool generate(ClassDiagram class_diagram, string output_file_path, Platform current_platform)
-        {
-            this.current_platform = current_platform;
-            if (! this.supported_platforms.Contains(this.current_platform))
-            {
-                Logger.displayError("Unsupported platform.");
-                return false;
-            }
-            try
-            {
-                this.output_file = new FileOutputer(output_file_path);
-                class_diagram.accept(this);
-            }
-            finally
-            {
-                this.output_file.close();
-            }
-            return true;
-        }
-
-        protected void writeCorrectIndent(string code)
-        {
-            string[] lines = code.Split('\n');
-
-            int begin_index = 0;
-            while (begin_index < lines.Length && lines[begin_index].Trim() == "")
-                begin_index += 1;
-
-            if (begin_index >= lines.Length)
-                return;
-
-            int end_index = lines.Length - 1;
-            while (end_index > begin_index && lines[end_index].Trim() == "")
-            {
-                end_index -= 1;
-            }
-
-            //first index where valid code is present
-            int to_strip_length = lines[begin_index].TrimEnd().Length - lines[begin_index].Trim().Length;
-            IndentType indent_type = IndentType.NOT_SET;
-
-            for(int index = begin_index; index <= end_index; ++index)
-            {
-				string strip_part = lines[index].Substring (0, to_strip_length);
-
-				if ((strip_part.Contains ('\t') && strip_part.Contains (' ')) ||
-					(indent_type == IndentType.SPACES && strip_part.Contains ('\t')) ||
-					(indent_type == IndentType.TABS && strip_part.Contains (' '))   
-                )
-					throw new CodeBlockException ("Mixed tab and space indentation!");
-
-				if (indent_type == IndentType.NOT_SET) {
-					if (strip_part.Contains (' '))
-						indent_type = IndentType.SPACES;
-					else if (strip_part.Contains ('\t'))
-						indent_type = IndentType.TABS;
-				}
-				this.output_file.write (lines[index].Substring (to_strip_length));
-            }
-        }
-    }
-}

+ 0 - 55
src/csharp_sccd_compiler/Code Generation/FileOutputer.cs

@@ -1,55 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public class FileOutputer
-    {
-        int             indent_level = 0;
-        int             nr_of_indent_chars = 4;
-        char            indent_char = ' ';
-        bool            first_write = true;
-        StreamWriter    output_file;
-
-        public FileOutputer(string output_file_path)
-        {
-            this.output_file = new StreamWriter(output_file_path, false);
-        }
-
-        public void write(string text = "")
-        {
-            if (this.first_write)
-            {
-                this.first_write = false;
-                this.output_file.Write(new String(this.indent_char, this.indent_level * this.nr_of_indent_chars) + text);
-            }
-            else
-            {
-                this.output_file.WriteLine();
-                this.output_file.Write(new String(this.indent_char, this.indent_level * this.nr_of_indent_chars) + text);
-            }
-        }
-
-        public void extendWrite(string text = "")
-        {
-            this.output_file.Write(text);            
-        }
-
-        public void indent()
-        {
-            this.indent_level += 1;
-        }
-
-        public void dedent()
-        {
-            this.indent_level -= 1;
-        }
-
-        public void close()
-        {
-            this.output_file.Close();
-        }
-    }
-}
-

+ 0 - 29
src/csharp_sccd_compiler/Compiler.cs

@@ -1,29 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class Compiler
-    {
-
-        public static void generate(string input_file, string output_file, CodeGenerator.Platform platform)
-        {
-            ClassDiagram class_diagram = createAST(input_file);
-            generateFromAST(class_diagram, output_file, platform);
-        }
-              
-        public static ClassDiagram createAST(string input_file)
-        {
-            ClassDiagram cd = new ClassDiagram(input_file); //create AST
-            (new StateLinker()).visit(cd); //visitor fixing state references
-            (new PathCalculator()).visit(cd); //visitor calculating paths
-            return cd;
-        }
-            
-        public static void generateFromAST(ClassDiagram class_diagram, string output_file, CodeGenerator.Platform platform)
-        {
-            if ((new CSharpGenerator()).generate(class_diagram, output_file, platform))
-                Logger.displayInfo("The following classes <" + string.Join(", ", class_diagram.class_names) + "> have been exported to the following file: " + output_file);
-        }
-    }
-}
-

+ 0 - 17
src/csharp_sccd_compiler/Constants.cs

@@ -1,17 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class Constants
-    {
-        /// <summary>
-        /// Reserved keywords.
-        /// </summary>
-        public static string[] Reserved = new string[]{};
-
-        public static string INSTATE_SEQ = "INSTATE";
-
-        public static string SELF_REFERENCE_SEQ = "SELF";
-    }
-}
-

+ 0 - 28
src/csharp_sccd_compiler/Constructor.cs

@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-
-namespace csharp_sccd_compiler
-{
-    public class Constructor : Method
-    {
-        public Constructor(XElement xml) : base(xml)
-        {
-        }
-
-        public Constructor(string class_name)
-        {
-            this.name = class_name;
-            this.access = "public";
-            this.parameters = new List<FormalParameter>();
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 21
src/csharp_sccd_compiler/Destructor.cs

@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-
-namespace csharp_sccd_compiler
-{
-    public class Destructor : Method
-    {
-        public Destructor(XElement xml) : base(xml)
-        {
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 51
src/csharp_sccd_compiler/EnterExitAction.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Xml.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public abstract class EnterExitAction : Visitable
-    {
-        public StateChartNode parent { get; private set; }
-
-        public Action action { get; private set; }
-
-        public EnterExitAction(StateChartNode parent, XElement xml = null)
-        {
-            this.parent = parent;
-            if (xml != null)
-                this.action = new Action(xml);
-            else
-                this.action = null;
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-
-    public class EnterAction : EnterExitAction
-    {
-        public EnterAction(StateChartNode parent, XElement xml = null) : base(parent,xml)
-        {
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-
-    public class ExitAction : EnterExitAction
-    {
-        public ExitAction(StateChartNode parent, XElement xml = null) : base(parent,xml)
-        {
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/ActionException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class ActionException : CompilerException
-    {
-        public ActionException ()
-        {
-        }
-
-        public ActionException(string message)
-            : base(message)
-        {
-        }
-
-        public ActionException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/CodeBlockException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class CodeBlockException : CompilerException
-    {
-        public CodeBlockException ()
-        {
-        }
-
-        public CodeBlockException(string message)
-            : base(message)
-        {
-        }
-
-        public CodeBlockException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/CompilerException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class CompilerException : Exception
-    {
-        public CompilerException ()
-        {
-        }
-
-        public CompilerException(string message)
-            : base(message)
-        {
-        }
-
-        public CompilerException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 24
src/csharp_sccd_compiler/Exceptions/LexerException.cs

@@ -1,24 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class LexerException : CompilerException
-    {
-        public LexerException ()
-        {
-        }
-
-        public LexerException(string message)
-            : base(message)
-        {
-        }
-
-        public LexerException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-
-
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/StateReferenceException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class StateReferenceException : CompilerException
-    {
-        public StateReferenceException ()
-        {
-        }
-
-        public StateReferenceException(string message)
-            : base(message)
-        {
-        }
-
-        public StateReferenceException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/TransitionException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class TransitionException : CompilerException
-    {
-        public TransitionException ()
-        {
-        }
-
-        public TransitionException(string message)
-            : base(message)
-        {
-        }
-
-        public TransitionException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 22
src/csharp_sccd_compiler/Exceptions/UnprocessedException.cs

@@ -1,22 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class UnprocessedException : CompilerException
-    {
-		public UnprocessedException ()
-        {
-        }
-
-		public UnprocessedException(string message)
-            : base(message)
-        {
-        }
-
-		public UnprocessedException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-}
-

+ 0 - 87
src/csharp_sccd_compiler/Expression/Expression.cs

@@ -1,87 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-namespace csharp_sccd_compiler
-{
-    public class Expression : Visitable
-    {
-        private static Lexer lexer = new Lexer(false, true);
-
-        public List<ExpressionPart> expression_parts { get; private set; }
-
-        public Expression(string input_string)
-        {
-            if (input_string == "")
-                throw new CompilerException("Empty Expression.");
-            this.parse(input_string);
-        }
-
-        protected void parse(string input_string, string[] dont_parse = null)
-        {
-            this.expression_parts = new List<ExpressionPart>();
-            Expression.lexer.setInput(input_string);
-            string processed_bare_expression = "";
-            if (dont_parse == null)
-                dont_parse = new string[] { };
-
-            foreach (Token token in Expression.lexer.iterateTokens())
-            {
-                ExpressionPart created_part = null;
-
-                if (token.type == Token.Type.WORD)
-                {
-                    if (dont_parse.Contains(token.val))
-                        throw new CompilerException(string.Format("Macro \"{0}\" not allowed here.",token.val));
-                    else if (token.val == Constants.SELF_REFERENCE_SEQ)
-                        created_part = new SelfReference();
-                    else if (token.val == Constants.INSTATE_SEQ)
-                    {
-                        created_part = this.parseInStateCall();
-                        if (created_part == null)
-                            throw new CompilerException(string.Format("Illegal use of \"{0}\" macro.", Constants.INSTATE_SEQ));
-                    }
-                }
-
-                if (created_part == null)
-                    processed_bare_expression += token.val;
-                else
-                {
-                    if (processed_bare_expression != "")
-                    {
-                        this.expression_parts.Add( new ExpressionPartString(processed_bare_expression));
-                        processed_bare_expression = "";
-                    }
-                    this.expression_parts.Add(created_part);
-                }
-            }
-
-            //Process part of input after the last created macro object
-            if (processed_bare_expression != "")
-                this.expression_parts.Add( new ExpressionPartString(processed_bare_expression));
-        }
-
-        private InStateCall parseInStateCall()
-        {
-            Token token = Expression.lexer.nextToken();
-            if (token == null || token.type != Token.Type.LBRACKET)
-                return null;
-            token = Expression.lexer.nextToken();
-            if (token == null || token.type != Token.Type.QUOTED)
-                return null;
-            InStateCall result = new InStateCall(token.val.Substring(1, token.val.Length - 2));
-            token = Expression.lexer.nextToken();
-            if (token == null || token.type != Token.Type.RBRACKET)
-                return null;
-            return result;
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            foreach (ExpressionPart expression_part in this.expression_parts)
-                expression_part.accept(visitor);
-        }
-    }
-}
-

+ 0 - 12
src/csharp_sccd_compiler/Expression/ExpressionPart.cs

@@ -1,12 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public abstract class ExpressionPart : Visitable
-    {
-        public ExpressionPart()
-        {
-        }
-    }
-}
-

+ 0 - 20
src/csharp_sccd_compiler/Expression/ExpressionPartString.cs

@@ -1,20 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class ExpressionPartString : ExpressionPart
-    {
-        public string value { get; private set; }
-
-        public ExpressionPartString(string value)
-        {
-            this.value = value;
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 20
src/csharp_sccd_compiler/Expression/InStateCall.cs

@@ -1,20 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-	public class InStateCall : ExpressionPart
-    {
-        public StateReference state_reference { get; private set; }
-
-        public InStateCall(string state_reference_string)
-        {
-            this.state_reference = new StateReference(state_reference_string);
-        }
-
-        public override void accept(Visitor visitor)
-        {
-            visitor.visit (this);
-        }
-    }
-}
-

+ 0 - 12
src/csharp_sccd_compiler/Expression/LValue.cs

@@ -1,12 +0,0 @@
-using System;
-
-namespace csharp_sccd_compiler
-{
-    public class LValue : Expression
-    {
-        public LValue(string input_string) : base(input_string)
-        {
-        }
-    }
-}
-

+ 0 - 0
src/csharp_sccd_compiler/Expression/SelfReference.cs


Some files were not shown because too many files changed in this diff