瀏覽代碼

created gen for normal sccd

Cláudio Gomes 9 年之前
父節點
當前提交
44694f6c0e

+ 1 - 1
fsa_cbd_composition/cbdsimulator/DEPRECATED_generateSCCD.bat

@@ -1,6 +1,6 @@
 @ECHO OFF
 setlocal
 set PYTHONPATH=C:\Users\clagms\Source Control\Git_SCCD\src\build\lib;C:\Users\clagms\Source Control\SVN_MvK
-python "C:\Users\clagms\Source Control\Git_SCCD\textualnotations\sccdtnc.py" "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\cbdsim_hierarchical.sccd" -o "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\cbdsim.py"
+python "C:\Users\clagms\Source Control\Git_SCCD\textualnotations\sccdtnc.py" "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\DEPRECATED_cbdsim_hierarchical.sccd" -o "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\cbdsim.py"
 endlocal
 pause

+ 131 - 155
fsa_cbd_composition/cbdsimulator/cbdsim.py

@@ -1,9 +1,9 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Tue Oct 11 09:44:07 2016
+Date:   Tue Oct 11 13:05:26 2016
 
-Model author: Sadaf Mustafiz and Claudio Gomes
+Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
 Model name:   CBDSimulator
 Model description:
 SCCD HUTN model of a CBD simulator
@@ -33,12 +33,12 @@ class CBDSimulator(RuntimeClassBase):
         # user defined attributes
         self.iteration = None
         self.cbdController = None
-        self.delta = None
+        self.currentCompIdx = None
         self.clock = None
         self.model = None
         self.depGraph = None
         self.strongComponentList = None
-        self.currentCompIdx = None
+        self.delta = None
         
         # call user defined constructor
         CBDSimulator.user_defined_constructor(self, options, model)
@@ -62,6 +62,19 @@ class CBDSimulator(RuntimeClassBase):
         return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
     
     
+    # user defined method
+    def hasNextStrongComponent(self):
+        return (self.currentCompIdx) < len(self.strongComponentList)
+    
+    
+    # user defined method
+    def computeBlock(self):
+        if self.currentComponentIsCycle():
+        	self.cbdController.computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
+        else:
+        	self.cbdController.computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
+    
+    
     # user defined method
     def advanceTime(self):
         self.iteration = self.iteration + 1
@@ -69,119 +82,127 @@ class CBDSimulator(RuntimeClassBase):
         self.cbdController.advanceTimeStep()
     
     
-    # user defined method
-    def hasNextStrongComponent(self):
-        return (self.currentCompIdx + 1) < len(self.strongComponentList)
-    
-    
     # builds Statechart structure
     def build_statechart_structure(self):
         
         # state <root>
         self.states[""] = State(0, self)
         
-        # state /SimulationComplete
-        self.states["/SimulationComplete"] = State(1, self)
+        # state /DoSimulation
+        self.states["/DoSimulation"] = State(1, self)
         
-        # state /CreateDependencyGraph
-        self.states["/CreateDependencyGraph"] = State(2, self)
-        self.states["/CreateDependencyGraph"].setEnter(self._CreateDependencyGraph_enter)
+        # state /DoSimulation/MacroStepPrepared
+        self.states["/DoSimulation/MacroStepPrepared"] = State(2, self)
         
-        # state /Initialize
-        self.states["/Initialize"] = State(3, self)
-        self.states["/Initialize"].setEnter(self._Initialize_enter)
+        # state /DoSimulation/MicroStepPrepared
+        self.states["/DoSimulation/MicroStepPrepared"] = State(3, self)
         
-        # state /CheckTerminationCondition
-        self.states["/CheckTerminationCondition"] = State(4, self)
+        # state /DoSimulation/MicroStepProcessed
+        self.states["/DoSimulation/MicroStepProcessed"] = State(4, self)
         
-        # state /IsolateStrongComponents
-        self.states["/IsolateStrongComponents"] = State(5, self)
-        self.states["/IsolateStrongComponents"].setEnter(self._IsolateStrongComponents_enter)
+        # state /Started
+        self.states["/Started"] = State(5, self)
         
-        # state /ExecuteSimulationStep
-        self.states["/ExecuteSimulationStep"] = State(6, self)
+        # state /CheckTermination
+        self.states["/CheckTermination"] = State(6, self)
         
-        # state /ExecuteSimulationStep/CheckNextComponent
-        self.states["/ExecuteSimulationStep/CheckNextComponent"] = State(7, self)
-        self.states["/ExecuteSimulationStep/CheckNextComponent"].setEnter(self._ExecuteSimulationStep_CheckNextComponent_enter)
+        # state /CheckTermination/MacroStepProcessed
+        self.states["/CheckTermination/MacroStepProcessed"] = State(7, self)
         
-        # state /ExecuteSimulationStep/CheckCycle
-        self.states["/ExecuteSimulationStep/CheckCycle"] = State(8, self)
-        self.states["/ExecuteSimulationStep/CheckCycle"].setEnter(self._ExecuteSimulationStep_CheckCycle_enter)
+        # state /End
+        self.states["/End"] = State(8, self)
+        
+        # state /Initialized
+        self.states["/Initialized"] = State(9, self)
         
         # add children
-        self.states[""].addChild(self.states["/SimulationComplete"])
-        self.states[""].addChild(self.states["/CreateDependencyGraph"])
-        self.states[""].addChild(self.states["/Initialize"])
-        self.states[""].addChild(self.states["/CheckTerminationCondition"])
-        self.states[""].addChild(self.states["/IsolateStrongComponents"])
-        self.states[""].addChild(self.states["/ExecuteSimulationStep"])
-        self.states["/ExecuteSimulationStep"].addChild(self.states["/ExecuteSimulationStep/CheckNextComponent"])
-        self.states["/ExecuteSimulationStep"].addChild(self.states["/ExecuteSimulationStep/CheckCycle"])
+        self.states[""].addChild(self.states["/DoSimulation"])
+        self.states[""].addChild(self.states["/Started"])
+        self.states[""].addChild(self.states["/CheckTermination"])
+        self.states[""].addChild(self.states["/End"])
+        self.states[""].addChild(self.states["/Initialized"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MacroStepPrepared"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MicroStepPrepared"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MicroStepProcessed"])
+        self.states["/CheckTermination"].addChild(self.states["/CheckTermination/MacroStepProcessed"])
         self.states[""].fixTree()
-        self.states[""].default_state = self.states["/Initialize"]
-        self.states["/ExecuteSimulationStep"].default_state = self.states["/ExecuteSimulationStep/CheckNextComponent"]
-        
-        # transition /CreateDependencyGraph
-        _CreateDependencyGraph_0 = Transition(self, self.states["/CreateDependencyGraph"], [self.states["/IsolateStrongComponents"]])
-        _CreateDependencyGraph_0.setAction(self._CreateDependencyGraph_0_exec)
-        _CreateDependencyGraph_0.setTrigger(None)
-        self.states["/CreateDependencyGraph"].addTransition(_CreateDependencyGraph_0)
-        
-        # transition /Initialize
-        _Initialize_0 = Transition(self, self.states["/Initialize"], [self.states["/CheckTerminationCondition"]])
-        _Initialize_0.setAction(self._Initialize_0_exec)
-        _Initialize_0.setTrigger(None)
-        self.states["/Initialize"].addTransition(_Initialize_0)
-        
-        # transition /CheckTerminationCondition
-        _CheckTerminationCondition_0 = Transition(self, self.states["/CheckTerminationCondition"], [self.states["/CreateDependencyGraph"]])
-        _CheckTerminationCondition_0.setAction(self._CheckTerminationCondition_0_exec)
-        _CheckTerminationCondition_0.setTrigger(None)
-        _CheckTerminationCondition_0.setGuard(self._CheckTerminationCondition_0_guard)
-        self.states["/CheckTerminationCondition"].addTransition(_CheckTerminationCondition_0)
-        _CheckTerminationCondition_1 = Transition(self, self.states["/CheckTerminationCondition"], [self.states["/SimulationComplete"]])
-        _CheckTerminationCondition_1.setAction(self._CheckTerminationCondition_1_exec)
-        _CheckTerminationCondition_1.setTrigger(None)
-        _CheckTerminationCondition_1.setGuard(self._CheckTerminationCondition_1_guard)
-        self.states["/CheckTerminationCondition"].addTransition(_CheckTerminationCondition_1)
-        
-        # transition /IsolateStrongComponents
-        _IsolateStrongComponents_0 = Transition(self, self.states["/IsolateStrongComponents"], [self.states["/ExecuteSimulationStep"]])
-        _IsolateStrongComponents_0.setAction(self._IsolateStrongComponents_0_exec)
-        _IsolateStrongComponents_0.setTrigger(None)
-        self.states["/IsolateStrongComponents"].addTransition(_IsolateStrongComponents_0)
-        
-        # transition /ExecuteSimulationStep/CheckNextComponent
-        _ExecuteSimulationStep_CheckNextComponent_0 = Transition(self, self.states["/ExecuteSimulationStep/CheckNextComponent"], [self.states["/ExecuteSimulationStep/CheckCycle"]])
-        _ExecuteSimulationStep_CheckNextComponent_0.setAction(self._ExecuteSimulationStep_CheckNextComponent_0_exec)
-        _ExecuteSimulationStep_CheckNextComponent_0.setTrigger(None)
-        _ExecuteSimulationStep_CheckNextComponent_0.setGuard(self._ExecuteSimulationStep_CheckNextComponent_0_guard)
-        self.states["/ExecuteSimulationStep/CheckNextComponent"].addTransition(_ExecuteSimulationStep_CheckNextComponent_0)
-        _ExecuteSimulationStep_CheckNextComponent_1 = Transition(self, self.states["/ExecuteSimulationStep/CheckNextComponent"], [self.states["/CheckTerminationCondition"]])
-        _ExecuteSimulationStep_CheckNextComponent_1.setAction(self._ExecuteSimulationStep_CheckNextComponent_1_exec)
-        _ExecuteSimulationStep_CheckNextComponent_1.setTrigger(None)
-        _ExecuteSimulationStep_CheckNextComponent_1.setGuard(self._ExecuteSimulationStep_CheckNextComponent_1_guard)
-        self.states["/ExecuteSimulationStep/CheckNextComponent"].addTransition(_ExecuteSimulationStep_CheckNextComponent_1)
-        
-        # transition /ExecuteSimulationStep/CheckCycle
-        _ExecuteSimulationStep_CheckCycle_0 = Transition(self, self.states["/ExecuteSimulationStep/CheckCycle"], [self.states["/ExecuteSimulationStep/CheckNextComponent"]])
-        _ExecuteSimulationStep_CheckCycle_0.setAction(self._ExecuteSimulationStep_CheckCycle_0_exec)
-        _ExecuteSimulationStep_CheckCycle_0.setTrigger(None)
-        _ExecuteSimulationStep_CheckCycle_0.setGuard(self._ExecuteSimulationStep_CheckCycle_0_guard)
-        self.states["/ExecuteSimulationStep/CheckCycle"].addTransition(_ExecuteSimulationStep_CheckCycle_0)
-        _ExecuteSimulationStep_CheckCycle_1 = Transition(self, self.states["/ExecuteSimulationStep/CheckCycle"], [self.states["/ExecuteSimulationStep/CheckNextComponent"]])
-        _ExecuteSimulationStep_CheckCycle_1.setAction(self._ExecuteSimulationStep_CheckCycle_1_exec)
-        _ExecuteSimulationStep_CheckCycle_1.setTrigger(None)
-        _ExecuteSimulationStep_CheckCycle_1.setGuard(self._ExecuteSimulationStep_CheckCycle_1_guard)
-        self.states["/ExecuteSimulationStep/CheckCycle"].addTransition(_ExecuteSimulationStep_CheckCycle_1)
+        self.states[""].default_state = self.states["/Started"]
+        self.states["/DoSimulation"].default_state = self.states["/DoSimulation/MacroStepPrepared"]
+        self.states["/CheckTermination"].default_state = self.states["/CheckTermination/MacroStepProcessed"]
+        
+        # transition /DoSimulation/MacroStepPrepared
+        _DoSimulation_MacroStepPrepared_0 = Transition(self, self.states["/DoSimulation/MacroStepPrepared"], [self.states["/DoSimulation/MicroStepProcessed"]])
+        _DoSimulation_MacroStepPrepared_0.setAction(self._DoSimulation_MacroStepPrepared_0_exec)
+        _DoSimulation_MacroStepPrepared_0.setTrigger(None)
+        self.states["/DoSimulation/MacroStepPrepared"].addTransition(_DoSimulation_MacroStepPrepared_0)
+        
+        # transition /DoSimulation/MicroStepPrepared
+        _DoSimulation_MicroStepPrepared_0 = Transition(self, self.states["/DoSimulation/MicroStepPrepared"], [self.states["/DoSimulation/MicroStepProcessed"]])
+        _DoSimulation_MicroStepPrepared_0.setAction(self._DoSimulation_MicroStepPrepared_0_exec)
+        _DoSimulation_MicroStepPrepared_0.setTrigger(None)
+        self.states["/DoSimulation/MicroStepPrepared"].addTransition(_DoSimulation_MicroStepPrepared_0)
+        
+        # transition /DoSimulation/MicroStepProcessed
+        _DoSimulation_MicroStepProcessed_0 = Transition(self, self.states["/DoSimulation/MicroStepProcessed"], [self.states["/CheckTermination"]])
+        _DoSimulation_MicroStepProcessed_0.setAction(self._DoSimulation_MicroStepProcessed_0_exec)
+        _DoSimulation_MicroStepProcessed_0.setTrigger(None)
+        _DoSimulation_MicroStepProcessed_0.setGuard(self._DoSimulation_MicroStepProcessed_0_guard)
+        self.states["/DoSimulation/MicroStepProcessed"].addTransition(_DoSimulation_MicroStepProcessed_0)
+        _DoSimulation_MicroStepProcessed_1 = Transition(self, self.states["/DoSimulation/MicroStepProcessed"], [self.states["/DoSimulation/MicroStepPrepared"]])
+        _DoSimulation_MicroStepProcessed_1.setAction(self._DoSimulation_MicroStepProcessed_1_exec)
+        _DoSimulation_MicroStepProcessed_1.setTrigger(None)
+        _DoSimulation_MicroStepProcessed_1.setGuard(self._DoSimulation_MicroStepProcessed_1_guard)
+        self.states["/DoSimulation/MicroStepProcessed"].addTransition(_DoSimulation_MicroStepProcessed_1)
+        
+        # transition /Started
+        _Started_0 = Transition(self, self.states["/Started"], [self.states["/Initialized"]])
+        _Started_0.setAction(self._Started_0_exec)
+        _Started_0.setTrigger(None)
+        self.states["/Started"].addTransition(_Started_0)
+        
+        # transition /CheckTermination/MacroStepProcessed
+        _CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/CheckTermination/MacroStepProcessed"], [self.states["/DoSimulation"]])
+        _CheckTermination_MacroStepProcessed_0.setAction(self._CheckTermination_MacroStepProcessed_0_exec)
+        _CheckTermination_MacroStepProcessed_0.setTrigger(None)
+        _CheckTermination_MacroStepProcessed_0.setGuard(self._CheckTermination_MacroStepProcessed_0_guard)
+        self.states["/CheckTermination/MacroStepProcessed"].addTransition(_CheckTermination_MacroStepProcessed_0)
+        _CheckTermination_MacroStepProcessed_1 = Transition(self, self.states["/CheckTermination/MacroStepProcessed"], [self.states["/End"]])
+        _CheckTermination_MacroStepProcessed_1.setAction(self._CheckTermination_MacroStepProcessed_1_exec)
+        _CheckTermination_MacroStepProcessed_1.setTrigger(None)
+        _CheckTermination_MacroStepProcessed_1.setGuard(self._CheckTermination_MacroStepProcessed_1_guard)
+        self.states["/CheckTermination/MacroStepProcessed"].addTransition(_CheckTermination_MacroStepProcessed_1)
+        
+        # transition /Initialized
+        _Initialized_0 = Transition(self, self.states["/Initialized"], [self.states["/CheckTermination"]])
+        _Initialized_0.setAction(self._Initialized_0_exec)
+        _Initialized_0.setTrigger(None)
+        self.states["/Initialized"].addTransition(_Initialized_0)
+    
+    def _DoSimulation_MacroStepPrepared_0_exec(self, parameters):
+        print('Going to MicroStepProcessed... ')
+    
+    def _DoSimulation_MicroStepPrepared_0_exec(self, parameters):
+        print('Going to MicroStepProcessed...')
+        self.computeBlock()
+        self.currentCompIdx = self.currentCompIdx + 1
     
-    def _CreateDependencyGraph_enter(self):
-        print('Performing dependency graph creation...')
-        self.depGraph = self.cbdController.createDepGraph(self.iteration)
-        print('Performing dependency graph creation... DONE')
+    def _DoSimulation_MicroStepProcessed_0_exec(self, parameters):
+        print('Going to CheckTermination and advancing time... ')
+        self.advanceTime()
+        print(self.clock)
+        print(self.iteration)
+    
+    def _DoSimulation_MicroStepProcessed_0_guard(self, parameters):
+        return not self.hasNextStrongComponent()
+    
+    def _DoSimulation_MicroStepProcessed_1_exec(self, parameters):
+        print('Going to MicroStepPrepared')
+    
+    def _DoSimulation_MicroStepProcessed_1_guard(self, parameters):
+        return self.hasNextStrongComponent()
     
-    def _Initialize_enter(self):
+    def _Started_0_exec(self, parameters):
+        print('Going to Initialized... ')
         print('Performing initialization...')
         self.iteration = 0
         self.clock = 0
@@ -189,72 +210,27 @@ class CBDSimulator(RuntimeClassBase):
         self.cbdController.initSimulation()
         print('Performing initialization... DONE')
     
-    def _IsolateStrongComponents_enter(self):
-        print('Performing strong components isolation...')
+    def _CheckTermination_MacroStepProcessed_0_exec(self, parameters):
+        print('Going to DoSimulation... ')
+        self.currentCompIdx = 0
+        self.depGraph = self.cbdController.createDepGraph(self.iteration)
         self.strongComponentList = self.cbdController.createStrongComponents(self.depGraph, self.iteration)
-        print('Performing strong components isolation... DONE')
-    
-    def _ExecuteSimulationStep_CheckNextComponent_enter(self):
-        print('Performing CheckNextComponent...')
-        print('Performing CheckNextComponent... DONE')
-    
-    def _ExecuteSimulationStep_CheckCycle_enter(self):
-        print('Performing CheckCycle...')
-        print('Performing CheckCycle... DONE')
-    
-    def _CreateDependencyGraph_0_exec(self, parameters):
-        print('Transition to IsolateStrongComponents')
-    
-    def _Initialize_0_exec(self, parameters):
-        print('Transition to CheckTerminationCondition')
-    
-    def _CheckTerminationCondition_0_exec(self, parameters):
-        print('Transition to CreateDependencyGraph')
     
-    def _CheckTerminationCondition_0_guard(self, parameters):
+    def _CheckTermination_MacroStepProcessed_0_guard(self, parameters):
         return not self.maxIterationsReached()
     
-    def _CheckTerminationCondition_1_exec(self, parameters):
-        print('Transition to SimulationComplete')
+    def _CheckTermination_MacroStepProcessed_1_exec(self, parameters):
+        print('Going to End... ')
     
-    def _CheckTerminationCondition_1_guard(self, parameters):
+    def _CheckTermination_MacroStepProcessed_1_guard(self, parameters):
         return self.maxIterationsReached()
     
-    def _IsolateStrongComponents_0_exec(self, parameters):
-        print('Transition to ExecuteSimulationStep')
-        self.currentCompIdx = -1
-    
-    def _ExecuteSimulationStep_CheckNextComponent_0_exec(self, parameters):
-        print('Transition to CheckCycle')
-        self.currentCompIdx = self.currentCompIdx + 1
-    
-    def _ExecuteSimulationStep_CheckNextComponent_0_guard(self, parameters):
-        return self.hasNextStrongComponent()
-    
-    def _ExecuteSimulationStep_CheckNextComponent_1_exec(self, parameters):
-        print('Transition to CheckTerminationCondition')
-        self.advanceTime()
-    
-    def _ExecuteSimulationStep_CheckNextComponent_1_guard(self, parameters):
-        return not self.hasNextStrongComponent()
-    
-    def _ExecuteSimulationStep_CheckCycle_0_exec(self, parameters):
-        print('Transition to CheckNextComponent')
-        self.cbdController.computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
-    
-    def _ExecuteSimulationStep_CheckCycle_0_guard(self, parameters):
-        return not self.currentComponentIsCycle()
-    
-    def _ExecuteSimulationStep_CheckCycle_1_exec(self, parameters):
-        print('Transition to CheckNextComponent')
-        self.cbdController.computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
-    
-    def _ExecuteSimulationStep_CheckCycle_1_guard(self, parameters):
-        return self.currentComponentIsCycle()
+    def _Initialized_0_exec(self, parameters):
+        print('Going to CheckTermination... ')
     
     def initializeStatechart(self):
         # enter default state
-        self.default_targets = self.states["/Initialize"].getEffectiveTargetStates()
+        self.default_targets = self.states["/Started"].getEffectiveTargetStates()
         RuntimeClassBase.initializeStatechart(self)
 
 class ObjectManager(ObjectManagerBase):

+ 0 - 195
fsa_cbd_composition/cbdsimulator/cbdsim.py.xml

@@ -1,195 +0,0 @@
-<?xml version="1.0" ?>
-<diagram name="CBDSimulator" author="Sadaf Mustafiz and Claudio Gomes">
-	<description>
-		SCCD HUTN model of a CBD simulator
-	</description>
-	<top>
-		from sccd.runtime.libs.ui import *
-		from sccd.runtime.libs.utils import *
-		from CBD_Controller import CBDController
-		import Options
-	</top>
-	<class name="CBDSimulator" default="True">
-		<attribute name="iteration"/>
-		<attribute name="cbdController"/>
-		<attribute name="delta"/>
-		<attribute name="clock"/>
-		<attribute name="model"/>
-		<attribute name="depGraph"/>
-		<attribute name="strongComponentList"/>
-		<attribute name="currentCompIdx"/>
-		<method name="CBDSimulator">
-			<parameter name="options"/>
-			<parameter name="model"/>
-			<body>
-			<![CDATA[
-				self.options = options
-				self.delta = self.options.getDeltaT()
-				self.model = model
-			]]>
-			</body>
-		</method>
-		<method name="maxIterationsReached">
-			<body>
-			<![CDATA[
-				return self.iteration >= self.options.getMaxIterations()
-			]]>
-			</body>
-		</method>
-		<method name="currentComponentIsCycle">
-			<body>
-			<![CDATA[
-				return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
-			]]>
-			</body>
-		</method>
-		<method name="advanceTime">
-			<body>
-			<![CDATA[
-				self.iteration = self.iteration + 1
-				self.clock = self.clock + self.delta
-				self.cbdController.advanceTimeStep()
-			]]>
-			</body>
-		</method>
-		<method name="hasNextStrongComponent">
-			<body>
-			<![CDATA[
-				return (self.currentCompIdx + 1) < len(self.strongComponentList)
-			]]>
-			</body>
-		</method>
-		<scxml initial="Initialize">
-			<state id="SimulationComplete">
-			</state>
-			<state id="CreateDependencyGraph">
-				<onentry>
-					<script>
-					<![CDATA[
-						print('Performing dependency graph creation...')
-						self.depGraph = self.cbdController.createDepGraph(self.iteration)
-						print('Performing dependency graph creation... DONE')
-					]]>
-					</script>
-				</onentry>
-				<transition target="../IsolateStrongComponents">
-					<script>
-						<![CDATA[
-							print('Transition to IsolateStrongComponents')
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="Initialize">
-				<onentry>
-					<script>
-					<![CDATA[
-						print('Performing initialization...')
-						self.iteration = 0
-						self.clock = 0
-						self.cbdController = CBDController(self.model, self.delta)
-						self.cbdController.initSimulation()
-						print('Performing initialization... DONE')
-					]]>
-					</script>
-				</onentry>
-				<transition target="../CheckTerminationCondition">
-					<script>
-						<![CDATA[
-							print('Transition to CheckTerminationCondition')
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="CheckTerminationCondition">
-				<transition target="../CreateDependencyGraph" cond="not self.maxIterationsReached()">
-					<script>
-						<![CDATA[
-							print('Transition to CreateDependencyGraph')
-						]]>
-					</script>
-				</transition>
-				<transition target="../SimulationComplete" cond="self.maxIterationsReached()">
-					<script>
-						<![CDATA[
-							print('Transition to SimulationComplete')
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="IsolateStrongComponents">
-				<onentry>
-					<script>
-					<![CDATA[
-						print('Performing strong components isolation...')
-						self.strongComponentList = self.cbdController.createStrongComponents(self.depGraph, self.iteration)
-						print('Performing strong components isolation... DONE')
-					]]>
-					</script>
-				</onentry>
-				<transition target="../ExecuteSimulationStep">
-					<script>
-						<![CDATA[
-							print('Transition to ExecuteSimulationStep')
-							self.currentCompIdx = -1
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="ExecuteSimulationStep" initial="CheckNextComponent">
-				<state id="CheckNextComponent">
-					<onentry>
-						<script>
-						<![CDATA[
-							print('Performing CheckNextComponent...')
-							print('Performing CheckNextComponent... DONE')
-						]]>
-						</script>
-					</onentry>
-					<transition target="../CheckCycle" cond="self.hasNextStrongComponent()">
-						<script>
-							<![CDATA[
-								print('Transition to CheckCycle')
-								self.currentCompIdx = self.currentCompIdx + 1
-							]]>
-						</script>
-					</transition>
-					<transition target="../../CheckTerminationCondition" cond="not self.hasNextStrongComponent()">
-						<script>
-							<![CDATA[
-								print('Transition to CheckTerminationCondition')
-								self.advanceTime()
-							]]>
-						</script>
-					</transition>
-				</state>
-				<state id="CheckCycle">
-					<onentry>
-						<script>
-						<![CDATA[
-							print('Performing CheckCycle...')
-							print('Performing CheckCycle... DONE')
-						]]>
-						</script>
-					</onentry>
-					<transition target="../CheckNextComponent" cond="not self.currentComponentIsCycle()">
-						<script>
-							<![CDATA[
-								print('Transition to CheckNextComponent')
-								self.cbdController.computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
-							]]>
-						</script>
-					</transition>
-					<transition target="../CheckNextComponent" cond="self.currentComponentIsCycle()">
-						<script>
-							<![CDATA[
-								print('Transition to CheckNextComponent')
-								self.cbdController.computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
-							]]>
-						</script>
-					</transition>
-				</state>
-			</state>
-		</scxml>
-	</class>
-</diagram>

+ 163 - 0
fsa_cbd_composition/cbdsimulator/cbdsim_hierarchical.xml

@@ -0,0 +1,163 @@
+<?xml version="1.0" ?>
+<diagram name="CBDSimulator" author="Sadaf Mustafiz and Bruno Barroca and Claudio Gomes">
+	<description>
+		SCCD HUTN model of a CBD simulator
+	</description>
+	<top>
+		from sccd.runtime.libs.ui import *
+		from sccd.runtime.libs.utils import *
+		from CBD_Controller import CBDController
+		import Options
+	</top>
+	<class name="CBDSimulator" default="True">
+		<attribute name="iteration"/>
+		<attribute name="cbdController"/>
+		<attribute name="currentCompIdx"/>
+		<attribute name="clock"/>
+		<attribute name="model"/>
+		<attribute name="depGraph"/>
+		<attribute name="strongComponentList"/>
+		<attribute name="delta"/>
+		<method name="CBDSimulator">
+			<parameter name="options"/>
+			<parameter name="model"/>
+			<body>
+			<![CDATA[
+				self.options = options
+				self.delta = self.options.getDeltaT()
+				self.model = model
+			]]>
+			</body>
+		</method>
+		<method name="maxIterationsReached">
+			<body>
+			<![CDATA[
+				return self.iteration >= self.options.getMaxIterations()
+			]]>
+			</body>
+		</method>
+		<method name="currentComponentIsCycle">
+			<body>
+			<![CDATA[
+				return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
+			]]>
+			</body>
+		</method>
+		<method name="hasNextStrongComponent">
+			<body>
+			<![CDATA[
+				return (self.currentCompIdx) < len(self.strongComponentList)
+			]]>
+			</body>
+		</method>
+		<method name="computeBlock">
+			<body>
+			<![CDATA[
+				if self.currentComponentIsCycle():
+					self.cbdController.computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
+				else:
+					self.cbdController.computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
+			]]>
+			</body>
+		</method>
+		<method name="advanceTime">
+			<body>
+			<![CDATA[
+				self.iteration = self.iteration + 1
+				self.clock = self.clock + self.delta
+				self.cbdController.advanceTimeStep()
+			]]>
+			</body>
+		</method>
+		<scxml  initial="Started" final="End">
+			<state id="DoSimulation" initial="MacroStepPrepared">
+				<state id="MacroStepPrepared">
+					<transition target="../MicroStepProcessed">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepProcessed... ')
+							]]>
+						</script>
+					</transition>
+				</state>
+				<state id="MicroStepPrepared">
+					<transition target="../MicroStepProcessed">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepProcessed...')
+								self.computeBlock()
+								self.currentCompIdx = self.currentCompIdx + 1
+							]]>
+						</script>
+					</transition>
+				</state>
+				<state id="MicroStepProcessed">
+					<transition target="../../CheckTermination" cond="not self.hasNextStrongComponent()">
+						<script>
+							<![CDATA[
+								print('Going to CheckTermination and advancing time... ')
+								self.advanceTime()
+								print(self.clock)
+								print(self.iteration)
+							]]>
+						</script>
+					</transition>
+					<transition target="../MicroStepPrepared" cond="self.hasNextStrongComponent()">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepPrepared')
+							]]>
+						</script>
+					</transition>
+				</state>
+			</state>
+			<state id="Started">
+				<transition target="../Initialized">
+					<script>
+						<![CDATA[
+							print('Going to Initialized... ')
+							print('Performing initialization...')
+							self.iteration = 0
+							self.clock = 0
+							self.cbdController = CBDController(self.model, self.delta)
+							self.cbdController.initSimulation()
+							print('Performing initialization... DONE')
+						]]>
+					</script>
+				</transition>
+			</state>
+			<state id="CheckTermination" initial="MacroStepProcessed">
+				<state id="MacroStepProcessed">
+					<transition target="../../DoSimulation" cond="not self.maxIterationsReached()">
+						<script>
+							<![CDATA[
+								print('Going to DoSimulation... ')
+								self.currentCompIdx = 0
+								self.depGraph = self.cbdController.createDepGraph(self.iteration)
+								self.strongComponentList = self.cbdController.createStrongComponents(self.depGraph, self.iteration)
+							]]>
+						</script>
+					</transition>
+					<transition target="../../End" cond="self.maxIterationsReached()">
+						<script>
+							<![CDATA[
+								print('Going to End... ')
+							]]>
+						</script>
+					</transition>
+				</state>
+			</state>
+			<state id="End">
+			</state>
+			<state id="Initialized">
+				<transition target="../CheckTermination">
+					<script>
+						<![CDATA[
+							print('Going to CheckTermination... ')
+						]]>
+					</script>
+				</transition>
+			</state>
+		</scxml>
+	</class>
+</diagram>

+ 6 - 0
fsa_cbd_composition/cbdsimulator/generateSCCD.bat

@@ -0,0 +1,6 @@
+@ECHO OFF
+setlocal
+set PYTHONPATH=C:\Users\clagms\Source Control\Git_SCCD\src\build\lib
+python -m sccd.compiler.sccdc -p threads -l python -o cbdsim.py cbdsim_hierarchical.xml
+endlocal
+pause