فهرست منبع

ported to new version of sccd, and a file name change

Simon Van Mierlo 9 سال پیش
والد
کامیت
8ff1099d1e

+ 198 - 0
debugging_fsa_cbd_composition/.keepme

@@ -0,0 +1,198 @@
+# ---> Python
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# ---> TeX
+## Core latex/pdflatex auxiliary files:
+*.aux
+*.lof
+*.log
+*.lot
+*.fls
+*.out
+*.toc
+
+## Intermediate documents:
+*.dvi
+*-converted-to.*
+# these rules might exclude image files for figures etc.
+# *.ps
+# *.eps
+# *.pdf
+
+## Bibliography auxiliary files (bibtex/biblatex/biber):
+*.bbl
+*.bcf
+*.blg
+*-blx.aux
+*-blx.bib
+*.brf
+*.run.xml
+
+## Build tool auxiliary files:
+*.fdb_latexmk
+*.synctex
+*.synctex.gz
+*.synctex.gz(busy)
+*.pdfsync
+
+## Auxiliary and intermediate files from other packages:
+
+
+# algorithms
+*.alg
+*.loa
+
+# achemso
+acs-*.bib
+
+# amsthm
+*.thm
+
+# beamer
+*.nav
+*.snm
+*.vrb
+
+#(e)ledmac/(e)ledpar
+*.end
+*.[1-9]
+*.[1-9][0-9]
+*.[1-9][0-9][0-9]
+*.[1-9]R
+*.[1-9][0-9]R
+*.[1-9][0-9][0-9]R
+*.eledsec[1-9]
+*.eledsec[1-9]R
+*.eledsec[1-9][0-9]
+*.eledsec[1-9][0-9]R
+*.eledsec[1-9][0-9][0-9]
+*.eledsec[1-9][0-9][0-9]R
+
+# glossaries
+*.acn
+*.acr
+*.glg
+*.glo
+*.gls
+
+# gnuplottex
+*-gnuplottex-*
+
+# hyperref
+*.brf
+
+# knitr
+*-concordance.tex
+*.tikz
+*-tikzDictionary
+
+# listings
+*.lol
+
+# makeidx
+*.idx
+*.ilg
+*.ind
+*.ist
+
+# minitoc
+*.maf
+*.mtc
+*.mtc[0-9]
+*.mtc[1-9][0-9]
+
+# minted
+_minted*
+*.pyg
+
+# morewrites
+*.mw
+
+# mylatexformat
+*.fmt
+
+# nomencl
+*.nlo
+
+# sagetex
+*.sagetex.sage
+*.sagetex.py
+*.sagetex.scmd
+
+# sympy
+*.sout
+*.sympy
+sympy-plots-for-*.tex/
+
+# TikZ & PGF
+*.dpth
+*.md5
+*.auxlock
+
+# todonotes
+*.tdo
+
+# xindy
+*.xdy
+
+# WinEdt
+*.bak
+*.sav
+

+ 0 - 0
debugging_fsa_cbd_coomposition/Add debugging related sccds here.txt


+ 234 - 368
fsa_cbd_composition/cbdsimulator/cbdsim.py

@@ -1,7 +1,7 @@
 """
 """
-Generated by Statechart compiler by Glenn De Jonghe and Joeri Exelmans
+Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Fri Oct 07 12:07:43 2016
+Date:   Mon Oct 10 11:30:03 2016
 
 
 Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
 Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
 Model name:   CBDSimulator
 Model name:   CBDSimulator
@@ -9,379 +9,245 @@ Model description:
 SCCD HUTN model of a CBD simulator
 SCCD HUTN model of a CBD simulator
 """
 """
 
 
-from python_runtime.statecharts_core import *
-from python_runtime.libs.ui import *
-from python_runtime.libs.utils import *
+from sccd.runtime.statecharts_core import *
+from sccd.runtime.libs.ui import *
+from sccd.runtime.libs.utils import *
 from CBD_Controller import CBDController
 from CBD_Controller import CBDController
 import Options
 import Options
 
 
 # package "CBDSimulator"
 # package "CBDSimulator"
 
 
 class CBDSimulator(RuntimeClassBase):
 class CBDSimulator(RuntimeClassBase):
-	def __init__(self, controller, options, model):
-		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
-		
-		# User defined attributes
-		self.delta = None
-		self.strongComponentList = None
-		self.currentCompIdx = None
-		self.iteration = None
-		self.depGraph = None
-		self.cbdController = None
-		self.clock = None
-		self.model = None
-		
-		# Call user defined constructor
-		CBDSimulator.user_defined_constructor(self, options, model)
-	
-	def user_defined_constructor(self, options, model):
-		self.options = options
-		self.delta = self.options.getDeltaT()
-		self.model = model
-	
-	def user_defined_destructor(self):
-		pass
-	
-	
-	# User defined method
-	def currentComponentIsCycle(self):
-		return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
-	
-	
-	# User defined method
-	def advanceTime(self):
-		self.iteration = self.iteration + 1
-		self.clock = self.clock + self.delta
-		self.cbdController.advanceTimeStep()
-	
-	
-	# User defined method
-	def hasNextStrongComponent(self):
-		return (self.currentCompIdx) < len(self.strongComponentList)
-	
-	
-	# User defined method
-	def maxIterationsReached(self):
-		return self.iteration >= self.options.getMaxIterations()
-	
-	
-	# 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)
-	
-	def initializeStatechart(self):
-		self.current_state[self.Root] = []
-		self.current_state[self.Root_DoSimulation] = []
-		self.current_state[self.Root_CheckTermination] = []
-		
-		# Enter default state
-		self.enter_Root_Started()
-	
-	# Unique IDs for all statechart nodes
-	Root = 0
-	Root_DoSimulation = 1
-	Root_CheckTermination = 2
-	Root_Started = 3
-	Root_DoSimulation_MacroStepPrepared = 4
-	Root_DoSimulation_MicroStepPrepared = 5
-	Root_DoSimulation_MicroStepProcessed = 6
-	Root_CheckTermination_MacroStepProcessed = 7
-	Root_Initialized = 8
-	Root_End = 9
-	
-	# Statechart enter/exit action method(s)
-	
-	def enter_Root_DoSimulation(self):
-		self.current_state[self.Root].append(self.Root_DoSimulation)
-	
-	def exit_Root_DoSimulation(self):
-		if self.Root_DoSimulation_MacroStepPrepared in self.current_state[self.Root_DoSimulation]:
-			self.exit_Root_DoSimulation_MacroStepPrepared()
-		if self.Root_DoSimulation_MicroStepPrepared in self.current_state[self.Root_DoSimulation]:
-			self.exit_Root_DoSimulation_MicroStepPrepared()
-		if self.Root_DoSimulation_MicroStepProcessed in self.current_state[self.Root_DoSimulation]:
-			self.exit_Root_DoSimulation_MicroStepProcessed()
-		self.current_state[self.Root] = []
-	
-	def enter_Root_CheckTermination(self):
-		self.current_state[self.Root].append(self.Root_CheckTermination)
-	
-	def exit_Root_CheckTermination(self):
-		if self.Root_CheckTermination_MacroStepProcessed in self.current_state[self.Root_CheckTermination]:
-			self.exit_Root_CheckTermination_MacroStepProcessed()
-		self.current_state[self.Root] = []
-	
-	def enter_Root_Started(self):
-		self.current_state[self.Root].append(self.Root_Started)
-	
-	def exit_Root_Started(self):
-		self.current_state[self.Root] = []
-	
-	def enter_Root_DoSimulation_MacroStepPrepared(self):
-		self.current_state[self.Root_DoSimulation].append(self.Root_DoSimulation_MacroStepPrepared)
-	
-	def exit_Root_DoSimulation_MacroStepPrepared(self):
-		self.current_state[self.Root_DoSimulation] = []
-	
-	def enter_Root_DoSimulation_MicroStepPrepared(self):
-		self.current_state[self.Root_DoSimulation].append(self.Root_DoSimulation_MicroStepPrepared)
-	
-	def exit_Root_DoSimulation_MicroStepPrepared(self):
-		self.current_state[self.Root_DoSimulation] = []
-	
-	def enter_Root_DoSimulation_MicroStepProcessed(self):
-		self.current_state[self.Root_DoSimulation].append(self.Root_DoSimulation_MicroStepProcessed)
-	
-	def exit_Root_DoSimulation_MicroStepProcessed(self):
-		self.current_state[self.Root_DoSimulation] = []
-	
-	def enter_Root_CheckTermination_MacroStepProcessed(self):
-		self.current_state[self.Root_CheckTermination].append(self.Root_CheckTermination_MacroStepProcessed)
-	
-	def exit_Root_CheckTermination_MacroStepProcessed(self):
-		self.current_state[self.Root_CheckTermination] = []
-	
-	def enter_Root_Initialized(self):
-		self.current_state[self.Root].append(self.Root_Initialized)
-	
-	def exit_Root_Initialized(self):
-		self.current_state[self.Root] = []
-	
-	def enter_Root_End(self):
-		self.current_state[self.Root].append(self.Root_End)
-	
-	def exit_Root_End(self):
-		self.current_state[self.Root] = []
-	
-	# Statechart enter/exit default method(s)
-	
-	def enterDefault_Root_DoSimulation(self):
-		self.enter_Root_DoSimulation()
-		self.enter_Root_DoSimulation_MacroStepPrepared()
-	
-	def enterDefault_Root_CheckTermination(self):
-		self.enter_Root_CheckTermination()
-		self.enter_Root_CheckTermination_MacroStepProcessed()
-	
-	# Statechart transitions
-	
-	def generateCandidatesChildren_Root(self):
-		if self.current_state[self.Root][0] == self.Root_Started:
-			return self.generateCandidates_Root_Started()
-		elif self.current_state[self.Root][0] == self.Root_DoSimulation:
-			return self.generateCandidates_Root_DoSimulation()
-		elif self.current_state[self.Root][0] == self.Root_CheckTermination:
-			return self.generateCandidates_Root_CheckTermination()
-		elif self.current_state[self.Root][0] == self.Root_Initialized:
-			return self.generateCandidates_Root_Initialized()
-		elif self.current_state[self.Root][0] == self.Root_End:
-			return self.generateCandidates_Root_End()
-		return False
-	
-	def generateCandidates_Root(self):
-		if not self.combo_step.isArenaChanged(self.Root):
-			return self.generateCandidatesChildren_Root()
-		else:
-			return True
-	
-	def generateCandidatesCurrent_Root_Started(self):
-		enabled_events = self.getEnabledEvents()
-		self.small_step.addCandidate(self.transition_Root_Started_1, [])
-		return True
-		return False
-	
-	def generateCandidates_Root_Started(self):
-		if not self.combo_step.isArenaChanged(self.Root_Started):
-			return self.generateCandidatesCurrent_Root_Started()
-		else:
-			return True
-	
-	def transition_Root_Started_1(self, parameters):
-		self.exit_Root_Started()
-		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')
-		self.combo_step.setArenaChanged(self.Root)
-		self.enter_Root_Initialized()
-	
-	def generateCandidatesChildren_Root_DoSimulation(self):
-		if self.current_state[self.Root_DoSimulation][0] == self.Root_DoSimulation_MacroStepPrepared:
-			return self.generateCandidates_Root_DoSimulation_MacroStepPrepared()
-		elif self.current_state[self.Root_DoSimulation][0] == self.Root_DoSimulation_MicroStepPrepared:
-			return self.generateCandidates_Root_DoSimulation_MicroStepPrepared()
-		elif self.current_state[self.Root_DoSimulation][0] == self.Root_DoSimulation_MicroStepProcessed:
-			return self.generateCandidates_Root_DoSimulation_MicroStepProcessed()
-		return False
-	
-	def generateCandidates_Root_DoSimulation(self):
-		if not self.combo_step.isArenaChanged(self.Root_DoSimulation):
-			return self.generateCandidatesChildren_Root_DoSimulation()
-		else:
-			return True
-	
-	def generateCandidatesCurrent_Root_DoSimulation_MacroStepPrepared(self):
-		enabled_events = self.getEnabledEvents()
-		self.small_step.addCandidate(self.transition_Root_DoSimulation_MacroStepPrepared_1, [])
-		return True
-		return False
-	
-	def generateCandidates_Root_DoSimulation_MacroStepPrepared(self):
-		if not self.combo_step.isArenaChanged(self.Root_DoSimulation_MacroStepPrepared):
-			return self.generateCandidatesCurrent_Root_DoSimulation_MacroStepPrepared()
-		else:
-			return True
-	
-	def transition_Root_DoSimulation_MacroStepPrepared_1(self, parameters):
-		self.exit_Root_DoSimulation_MacroStepPrepared()
-		print('Going to MicroStepProcessed... ')
-		self.combo_step.setArenaChanged(self.Root_DoSimulation)
-		self.enter_Root_DoSimulation_MicroStepProcessed()
-	
-	def generateCandidatesCurrent_Root_DoSimulation_MicroStepPrepared(self):
-		enabled_events = self.getEnabledEvents()
-		self.small_step.addCandidate(self.transition_Root_DoSimulation_MicroStepPrepared_1, [])
-		return True
-		return False
-	
-	def generateCandidates_Root_DoSimulation_MicroStepPrepared(self):
-		if not self.combo_step.isArenaChanged(self.Root_DoSimulation_MicroStepPrepared):
-			return self.generateCandidatesCurrent_Root_DoSimulation_MicroStepPrepared()
-		else:
-			return True
-	
-	def transition_Root_DoSimulation_MicroStepPrepared_1(self, parameters):
-		self.exit_Root_DoSimulation_MicroStepPrepared()
-		print('Going to MicroStepProcessed...')
-		self.computeBlock()
-		self.currentCompIdx = self.currentCompIdx + 1
-		self.combo_step.setArenaChanged(self.Root_DoSimulation)
-		self.enter_Root_DoSimulation_MicroStepProcessed()
-	
-	def generateCandidatesCurrent_Root_DoSimulation_MicroStepProcessed(self):
-		enabled_events = self.getEnabledEvents()
-		if not self.hasNextStrongComponent():
-			self.small_step.addCandidate(self.transition_Root_DoSimulation_MicroStepProcessed_1, [])
-			return True
-		enabled_events = self.getEnabledEvents()
-		if self.hasNextStrongComponent():
-			self.small_step.addCandidate(self.transition_Root_DoSimulation_MicroStepProcessed_2, [])
-			return True
-		return False
-	
-	def generateCandidates_Root_DoSimulation_MicroStepProcessed(self):
-		if not self.combo_step.isArenaChanged(self.Root_DoSimulation_MicroStepProcessed):
-			return self.generateCandidatesCurrent_Root_DoSimulation_MicroStepProcessed()
-		else:
-			return True
-	
-	def transition_Root_DoSimulation_MicroStepProcessed_1(self, parameters):
-		self.exit_Root_DoSimulation()
-		print('Going to CheckTermination and advancing time... ')
-		self.advanceTime()
-		print(self.clock)
-		print(self.iteration)
-		self.combo_step.setArenaChanged(self.Root)
-		self.enterDefault_Root_CheckTermination()
-	
-	def transition_Root_DoSimulation_MicroStepProcessed_2(self, parameters):
-		self.exit_Root_DoSimulation_MicroStepProcessed()
-		print('Going to MicroStepPrepared')
-		self.combo_step.setArenaChanged(self.Root_DoSimulation)
-		self.enter_Root_DoSimulation_MicroStepPrepared()
-	
-	def generateCandidatesChildren_Root_CheckTermination(self):
-		if self.current_state[self.Root_CheckTermination][0] == self.Root_CheckTermination_MacroStepProcessed:
-			return self.generateCandidates_Root_CheckTermination_MacroStepProcessed()
-		return False
-	
-	def generateCandidates_Root_CheckTermination(self):
-		if not self.combo_step.isArenaChanged(self.Root_CheckTermination):
-			return self.generateCandidatesChildren_Root_CheckTermination()
-		else:
-			return True
-	
-	def generateCandidatesCurrent_Root_CheckTermination_MacroStepProcessed(self):
-		enabled_events = self.getEnabledEvents()
-		if not self.maxIterationsReached():
-			self.small_step.addCandidate(self.transition_Root_CheckTermination_MacroStepProcessed_1, [])
-			return True
-		enabled_events = self.getEnabledEvents()
-		if self.maxIterationsReached():
-			self.small_step.addCandidate(self.transition_Root_CheckTermination_MacroStepProcessed_2, [])
-			return True
-		return False
-	
-	def generateCandidates_Root_CheckTermination_MacroStepProcessed(self):
-		if not self.combo_step.isArenaChanged(self.Root_CheckTermination_MacroStepProcessed):
-			return self.generateCandidatesCurrent_Root_CheckTermination_MacroStepProcessed()
-		else:
-			return True
-	
-	def transition_Root_CheckTermination_MacroStepProcessed_1(self, parameters):
-		self.exit_Root_CheckTermination()
-		print('Going to DoSimulation... ')
-		self.currentCompIdx = 0
-		self.depGraph = self.cbdController.createDepGraph(self.iteration)
-		self.strongComponentList = self.cbdController.createStrongComponents(self.depGraph, self.iteration)
-		self.combo_step.setArenaChanged(self.Root)
-		self.enterDefault_Root_DoSimulation()
-	
-	def transition_Root_CheckTermination_MacroStepProcessed_2(self, parameters):
-		self.exit_Root_CheckTermination()
-		print('Going to End... ')
-		self.combo_step.setArenaChanged(self.Root)
-		self.enter_Root_End()
-	
-	def generateCandidatesCurrent_Root_Initialized(self):
-		enabled_events = self.getEnabledEvents()
-		self.small_step.addCandidate(self.transition_Root_Initialized_1, [])
-		return True
-		return False
-	
-	def generateCandidates_Root_Initialized(self):
-		if not self.combo_step.isArenaChanged(self.Root_Initialized):
-			return self.generateCandidatesCurrent_Root_Initialized()
-		else:
-			return True
-	
-	def transition_Root_Initialized_1(self, parameters):
-		self.exit_Root_Initialized()
-		print('Going to CheckTermination... ')
-		self.combo_step.setArenaChanged(self.Root)
-		self.enterDefault_Root_CheckTermination()
-	
-	def generateCandidates_Root_End(self):
-		return False
-	
-	# Generate transition candidates for current small step
-	def generateCandidates(self):
-		self.generateCandidates_Root()
+    def __init__(self, controller, options, model):
+        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.delta = None
+        self.strongComponentList = None
+        self.currentCompIdx = None
+        self.iteration = None
+        self.depGraph = None
+        self.cbdController = None
+        self.clock = None
+        self.model = None
+        
+        # call user defined constructor
+        CBDSimulator.user_defined_constructor(self, options, model)
+    
+    def user_defined_constructor(self, options, model):
+        self.options = options
+        self.delta = self.options.getDeltaT()
+        self.model = model
+    
+    def user_defined_destructor(self):
+        pass
+    
+    
+    # user defined method
+    def currentComponentIsCycle(self):
+        return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
+    
+    
+    # user defined method
+    def advanceTime(self):
+        self.iteration = self.iteration + 1
+        self.clock = self.clock + self.delta
+        self.cbdController.advanceTimeStep()
+    
+    
+    # user defined method
+    def hasNextStrongComponent(self):
+        return (self.currentCompIdx) < len(self.strongComponentList)
+    
+    
+    # user defined method
+    def maxIterationsReached(self):
+        return self.iteration >= self.options.getMaxIterations()
+    
+    
+    # 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)
+    
+    
+    # builds Statechart structure
+    def build_statechart_structure(self):
+        
+        # state <root>
+        self.states[""] = State(0, self)
+        
+        # state /Started
+        self.states["/Started"] = State(1, self)
+        
+        # state /DoSimulation
+        self.states["/DoSimulation"] = State(2, self)
+        
+        # state /DoSimulation/MacroStepPrepared
+        self.states["/DoSimulation/MacroStepPrepared"] = State(3, self)
+        
+        # state /DoSimulation/MicroStepPrepared
+        self.states["/DoSimulation/MicroStepPrepared"] = State(4, self)
+        
+        # state /DoSimulation/MicroStepProcessed
+        self.states["/DoSimulation/MicroStepProcessed"] = State(5, self)
+        
+        # state /CheckTermination
+        self.states["/CheckTermination"] = State(6, self)
+        
+        # state /CheckTermination/MacroStepProcessed
+        self.states["/CheckTermination/MacroStepProcessed"] = State(7, self)
+        
+        # state /Initialized
+        self.states["/Initialized"] = State(8, self)
+        
+        # state /End
+        self.states["/End"] = State(9, self)
+        
+        # add children
+        self.states[""].addChild(self.states["/Started"])
+        self.states[""].addChild(self.states["/DoSimulation"])
+        self.states[""].addChild(self.states["/CheckTermination"])
+        self.states[""].addChild(self.states["/Initialized"])
+        self.states[""].addChild(self.states["/End"])
+        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["/Started"]
+        self.states["/DoSimulation"].default_state = self.states["/DoSimulation/MacroStepPrepared"]
+        self.states["/CheckTermination"].default_state = self.states["/CheckTermination/MacroStepProcessed"]
+        
+        # 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 /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 /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 _Started_0_exec(self, parameters):
+        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')
+    
+    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 _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 _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)
+    
+    def _CheckTermination_MacroStepProcessed_0_guard(self, parameters):
+        return not self.maxIterationsReached()
+    
+    def _CheckTermination_MacroStepProcessed_1_exec(self, parameters):
+        print('Going to End... ')
+    
+    def _CheckTermination_MacroStepProcessed_1_guard(self, parameters):
+        return self.maxIterationsReached()
+    
+    def _Initialized_0_exec(self, parameters):
+        print('Going to CheckTermination... ')
+    
+    def initializeStatechart(self):
+        # enter default state
+        self.default_targets = self.states["/Started"].getEffectiveTargetStates()
+        RuntimeClassBase.initializeStatechart(self)
 
 
 class ObjectManager(ObjectManagerBase):
 class ObjectManager(ObjectManagerBase):
-	def __init__(self, controller):
-		ObjectManagerBase.__init__(self, controller)
-	
-	def instantiate(self, class_name, construct_params):
-		if class_name == "CBDSimulator":
-			instance = CBDSimulator(self.controller, construct_params[0], construct_params[1])
-			instance.associations = {}
-		return instance
+    def __init__(self, controller):
+        ObjectManagerBase.__init__(self, controller)
+    
+    def instantiate(self, class_name, construct_params):
+        if class_name == "CBDSimulator":
+            instance = CBDSimulator(self.controller, construct_params[0], construct_params[1])
+            instance.associations = {}
+        else:
+            raise Exception("Cannot instantiate class " + class_name)
+        return instance
 
 
 class Controller(ThreadsControllerBase):
 class Controller(ThreadsControllerBase):
-	def __init__(self, options, model, keep_running = None):
-		if keep_running == None: keep_running = True
-		ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running)
-		self.object_manager.createInstance("CBDSimulator", [options, model])
+    def __init__(self, options, model, keep_running = None, behind_schedule_callback = None):
+        if keep_running == None: keep_running = True
+        if behind_schedule_callback == None: behind_schedule_callback = None
+        ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running, behind_schedule_callback)
+        self.object_manager.createInstance("CBDSimulator", [options, model])

+ 0 - 1
fsa_cbd_composition/cbdsimulator/run_cbd_sim.py

@@ -16,7 +16,6 @@ cbdModel = CircleCBDDerivative("CircleCBDDerivative",options.getDeltaT())
 # Use keep_running false for as fast as possible simulation.
 # Use keep_running false for as fast as possible simulation.
 cbdSimController = Controller(options, cbdModel, keep_running=False)
 cbdSimController = Controller(options, cbdModel, keep_running=False)
 cbdSimController.start()
 cbdSimController.start()
-cbdSimController.join()
 
 
 times = []
 times = []
 values = []
 values = []