فهرست منبع

deprecated hutn notation for fsa_simulator

Cláudio Gomes 9 سال پیش
والد
کامیت
45bcc60d26

fsa_cbd_composition/fsasimulator/fsasimulator.sccd → fsa_cbd_composition/fsasimulator/DEPRECATED_fsasimulator.sccd


fsa_cbd_composition/fsasimulator/fsasimulator_hierarchical.sccd → fsa_cbd_composition/fsasimulator/DEPRECATED_fsasimulator_hierarchical.sccd


fsa_cbd_composition/fsasimulator/fsasimulator_normal.sccd → fsa_cbd_composition/fsasimulator/DEPRECATED_fsasimulator_normal.sccd


+ 6 - 0
fsa_cbd_composition/fsasimulator/DEPRECATED_generateSCCD.bat

@@ -0,0 +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\fsasimulator\DEPRECATED_fsasimulator_hierarchical.sccd" -o "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\fsasimulator\fsasimulator.py"
+endlocal
+pause

+ 124 - 70
fsa_cbd_composition/fsasimulator/fsasimulator.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)
 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:55:10 2016
+Date:   Tue Oct 11 13:15:37 2016
 
 
 Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
 Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
 Model name:   FSASimulator
 Model name:   FSASimulator
@@ -31,6 +31,7 @@ class FSASimulator(RuntimeClassBase):
         
         
         # user defined attributes
         # user defined attributes
         self.elapsed = None
         self.elapsed = None
+        self.super_step_completed = None
         self.model = None
         self.model = None
         self.logicalTime = None
         self.logicalTime = None
         self.timestep = None
         self.timestep = None
@@ -68,95 +69,148 @@ class FSASimulator(RuntimeClassBase):
         # state <root>
         # state <root>
         self.states[""] = State(0, self)
         self.states[""] = State(0, self)
         
         
-        # state /End
-        self.states["/End"] = State(1, self)
+        # state /CheckTermination
+        self.states["/CheckTermination"] = State(1, self)
+        
+        # state /CheckTermination/MacroStepProcessed
+        self.states["/CheckTermination/MacroStepProcessed"] = State(2, self)
+        
+        # state /DoSimulation
+        self.states["/DoSimulation"] = State(3, self)
+        
+        # state /DoSimulation/MicroStepPrepared
+        self.states["/DoSimulation/MicroStepPrepared"] = State(4, self)
         
         
-        # state /Processing
-        self.states["/Processing"] = State(2, self)
+        # state /DoSimulation/MicroStepProcessed
+        self.states["/DoSimulation/MicroStepProcessed"] = State(5, self)
         
         
-        # state /Check
-        self.states["/Check"] = State(3, self)
-        self.states["/Check"].setEnter(self._Check_enter)
+        # state /DoSimulation/MacroStepPrepared
+        self.states["/DoSimulation/MacroStepPrepared"] = State(6, self)
         
         
-        # state /Start
-        self.states["/Start"] = State(4, self)
+        # state /Initialized
+        self.states["/Initialized"] = State(7, self)
+        
+        # state /Started
+        self.states["/Started"] = State(8, self)
+        
+        # state /End
+        self.states["/End"] = State(9, self)
         
         
         # add children
         # add children
+        self.states[""].addChild(self.states["/CheckTermination"])
+        self.states[""].addChild(self.states["/DoSimulation"])
+        self.states[""].addChild(self.states["/Initialized"])
+        self.states[""].addChild(self.states["/Started"])
         self.states[""].addChild(self.states["/End"])
         self.states[""].addChild(self.states["/End"])
-        self.states[""].addChild(self.states["/Processing"])
-        self.states[""].addChild(self.states["/Check"])
-        self.states[""].addChild(self.states["/Start"])
+        self.states["/CheckTermination"].addChild(self.states["/CheckTermination/MacroStepProcessed"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MicroStepPrepared"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MicroStepProcessed"])
+        self.states["/DoSimulation"].addChild(self.states["/DoSimulation/MacroStepPrepared"])
         self.states[""].fixTree()
         self.states[""].fixTree()
-        self.states[""].default_state = self.states["/Start"]
-        
-        # transition /Processing
-        _Processing_0 = Transition(self, self.states["/Processing"], [self.states["/Check"]])
-        _Processing_0.setAction(self._Processing_0_exec)
-        _Processing_0.setTrigger(None)
-        _Processing_0.setGuard(self._Processing_0_guard)
-        self.states["/Processing"].addTransition(_Processing_0)
-        _Processing_1 = Transition(self, self.states["/Processing"], [self.states["/Check"]])
-        _Processing_1.setAction(self._Processing_1_exec)
-        _Processing_1.setTrigger(None)
-        _Processing_1.setGuard(self._Processing_1_guard)
-        self.states["/Processing"].addTransition(_Processing_1)
-        
-        # transition /Check
-        _Check_0 = Transition(self, self.states["/Check"], [self.states["/End"]])
-        _Check_0.setAction(self._Check_0_exec)
-        _Check_0.setTrigger(None)
-        _Check_0.setGuard(self._Check_0_guard)
-        self.states["/Check"].addTransition(_Check_0)
-        _Check_1 = Transition(self, self.states["/Check"], [self.states["/Processing"]])
-        _Check_1.setAction(self._Check_1_exec)
-        _Check_1.setTrigger(None)
-        _Check_1.setGuard(self._Check_1_guard)
-        self.states["/Check"].addTransition(_Check_1)
-        
-        # transition /Start
-        _Start_0 = Transition(self, self.states["/Start"], [self.states["/Check"]])
-        _Start_0.setAction(self._Start_0_exec)
-        _Start_0.setTrigger(None)
-        self.states["/Start"].addTransition(_Start_0)
-    
-    def _Check_enter(self):
+        self.states[""].default_state = self.states["/Started"]
+        self.states["/CheckTermination"].default_state = self.states["/CheckTermination/MacroStepProcessed"]
+        self.states["/DoSimulation"].default_state = self.states["/DoSimulation/MacroStepPrepared"]
+        
+        # transition /CheckTermination/MacroStepProcessed
+        _CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/CheckTermination/MacroStepProcessed"], [self.states["/End"]])
+        _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["/DoSimulation"]])
+        _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 /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["/DoSimulation/MicroStepPrepared"]])
+        _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["/CheckTermination"]])
+        _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 /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 /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)
+        
+        # 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)
+    
+    def _CheckTermination_MacroStepProcessed_0_exec(self, parameters):
+        print('Going to End... ')
+    
+    def _CheckTermination_MacroStepProcessed_0_guard(self, parameters):
+        return self.currentState.final
+    
+    def _CheckTermination_MacroStepProcessed_1_exec(self, parameters):
+        print('Going to DoSimulation and reading events... ')
         self.currentEvent = self.getInputEventAt(self.logicalTime)
         self.currentEvent = self.getInputEventAt(self.logicalTime)
         self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
         self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
+        print(self.currentEvent)
+        print(self.selectedTransition)
     
     
-    def _Processing_0_exec(self, parameters):
-        self.logicalTime = self.logicalTime + self.timestep
-        self.elapsed = self.elapsed + self.timestep
-        print(self.logicalTime)
-        print(self.elapsed)
+    def _CheckTermination_MacroStepProcessed_1_guard(self, parameters):
+        return not self.currentState.final
     
     
-    def _Processing_0_guard(self, parameters):
-        return self.selectedTransition == None
-    
-    def _Processing_1_exec(self, parameters):
+    def _DoSimulation_MicroStepPrepared_0_exec(self, parameters):
+        print('Going to MicroStepProcessed, taking transition and reading events... ')
+        print('Transition to be taken: ' + str(self.selectedTransition))
         self.currentState = self.selectedTransition.target
         self.currentState = self.selectedTransition.target
         self.elapsed = 0
         self.elapsed = 0
         self.processEvent(self.currentEvent)
         self.processEvent(self.currentEvent)
-        print('changing to state: ')
-        print(self.currentState.getName())
-        print(self.logicalTime)
-        print(self.elapsed)
+        print('New state: ' + str(self.currentState))
+        self.currentEvent = self.getInputEventAt(self.logicalTime)
+        self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
+        print(self.currentEvent)
+        print(self.selectedTransition)
     
     
-    def _Processing_1_guard(self, parameters):
+    def _DoSimulation_MicroStepProcessed_0_exec(self, parameters):
+        print('Going to MicroStepPrepared... ')
+    
+    def _DoSimulation_MicroStepProcessed_0_guard(self, parameters):
         return self.selectedTransition != None
         return self.selectedTransition != None
     
     
-    def _Check_0_exec(self, parameters):
-        print('going to end... ')
+    def _DoSimulation_MicroStepProcessed_1_exec(self, parameters):
+        print('Going to CheckTermination and advancing time... ')
+        self.logicalTime = self.logicalTime + self.timestep
+        self.elapsed = self.elapsed + self.timestep
+        print(self.logicalTime)
+        print(self.elapsed)
     
     
-    def _Check_0_guard(self, parameters):
-        return self.currentState.final == True
+    def _DoSimulation_MicroStepProcessed_1_guard(self, parameters):
+        return self.selectedTransition == None
     
     
-    def _Check_1_exec(self, parameters):
-        print('going to process... ')
+    def _DoSimulation_MacroStepPrepared_0_exec(self, parameters):
+        print('Going to MicroStepProcessed... ')
     
     
-    def _Check_1_guard(self, parameters):
-        return self.currentState.final == False
+    def _Initialized_0_exec(self, parameters):
+        print('Going to MacroStepProcessed... ')
     
     
-    def _Start_0_exec(self, parameters):
+    def _Started_0_exec(self, parameters):
+        print('Going to Initialized... ')
         self.logicalTime = 0
         self.logicalTime = 0
         self.elapsed = 0
         self.elapsed = 0
         self.timestep = 1.0
         self.timestep = 1.0
@@ -164,7 +218,7 @@ class FSASimulator(RuntimeClassBase):
     
     
     def initializeStatechart(self):
     def initializeStatechart(self):
         # enter default state
         # enter default state
-        self.default_targets = self.states["/Start"].getEffectiveTargetStates()
+        self.default_targets = self.states["/Started"].getEffectiveTargetStates()
         RuntimeClassBase.initializeStatechart(self)
         RuntimeClassBase.initializeStatechart(self)
 
 
 class ObjectManager(ObjectManagerBase):
 class ObjectManager(ObjectManagerBase):

+ 0 - 114
fsa_cbd_composition/fsasimulator/fsasimulator.py.xml

@@ -1,114 +0,0 @@
-<?xml version="1.0" ?>
-<diagram name="FSASimulator" author="Sadaf Mustafiz and Bruno Barroca and Claudio Gomes">
-	<description>
-		An FSA simulator written in SCCD. It supports after and events.
-	</description>
-	<top>
-		from sccd.runtime.libs.ui import *
-		from sccd.runtime.libs.utils import *
-		import fsaclasses
-	</top>
-	<class name="FSASimulator" default="True">
-		<attribute name="elapsed"/>
-		<attribute name="model"/>
-		<attribute name="logicalTime"/>
-		<attribute name="timestep"/>
-		<attribute name="currentEvent"/>
-		<attribute name="selectedTransition"/>
-		<attribute name="eventList"/>
-		<attribute name="currentState"/>
-		<method name="FSASimulator">
-			<parameter name="amodel"/>
-			<parameter name="events"/>
-			<body>
-			<![CDATA[
-				self.model = amodel
-				self.eventList = events
-			]]>
-			</body>
-		</method>
-		<method name="processEvent">
-			<parameter name="event"/>
-			<body>
-			<![CDATA[
-				if (event != None):
-					self.eventList.popEvent(event)
-					event.processed = True
-			]]>
-			</body>
-		</method>
-		<method name="getInputEventAt">
-			<parameter name="time"/>
-			<body>
-			<![CDATA[
-				return self.eventList.getInputAt(time)
-			]]>
-			</body>
-		</method>
-		<scxml  initial="Start" final="End">
-			<state id="End">
-			</state>
-			<state id="Processing">
-				<transition target="../Check" cond="self.selectedTransition == None">
-					<script>
-						<![CDATA[
-							self.logicalTime = self.logicalTime + self.timestep
-							self.elapsed = self.elapsed + self.timestep
-							print(self.logicalTime)
-							print(self.elapsed)
-						]]>
-					</script>
-				</transition>
-				<transition target="../Check" cond="self.selectedTransition != None">
-					<script>
-						<![CDATA[
-							self.currentState = self.selectedTransition.target
-							self.elapsed = 0
-							self.processEvent(self.currentEvent)
-							print('changing to state: ')
-							print(self.currentState.getName())
-							print(self.logicalTime)
-							print(self.elapsed)
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="Check">
-				<onentry>
-					<script>
-					<![CDATA[
-						self.currentEvent = self.getInputEventAt(self.logicalTime)
-						self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
-					]]>
-					</script>
-				</onentry>
-				<transition target="../End" cond="self.currentState.final == True">
-					<script>
-						<![CDATA[
-							print('going to end... ')
-						]]>
-					</script>
-				</transition>
-				<transition target="../Processing" cond="self.currentState.final == False">
-					<script>
-						<![CDATA[
-							print('going to process... ')
-						]]>
-					</script>
-				</transition>
-			</state>
-			<state id="Start">
-				<transition target="../Check">
-					<script>
-						<![CDATA[
-							self.logicalTime = 0
-							self.elapsed = 0
-							self.timestep = 1.0
-							self.currentState = self.model.initialState
-						]]>
-					</script>
-				</transition>
-			</state>
-		</scxml>
-	</class>
-</diagram>

+ 147 - 0
fsa_cbd_composition/fsasimulator/fsasimulator_hierarchical.xml

@@ -0,0 +1,147 @@
+<?xml version="1.0" ?>
+<diagram name="FSASimulator" author="Sadaf Mustafiz and Bruno Barroca and Claudio Gomes">
+	<description>
+		An FSA simulator written in SCCD. It supports after and events.
+	</description>
+	<top>
+		from sccd.runtime.libs.ui import *
+		from sccd.runtime.libs.utils import *
+		import fsaclasses
+	</top>
+	<class name="FSASimulator" default="True">
+		<attribute name="elapsed"/>
+		<attribute name="super_step_completed"/>
+		<attribute name="model"/>
+		<attribute name="logicalTime"/>
+		<attribute name="timestep"/>
+		<attribute name="currentEvent"/>
+		<attribute name="selectedTransition"/>
+		<attribute name="eventList"/>
+		<attribute name="currentState"/>
+		<method name="FSASimulator">
+			<parameter name="amodel"/>
+			<parameter name="events"/>
+			<body>
+			<![CDATA[
+				self.model = amodel
+				self.eventList = events
+			]]>
+			</body>
+		</method>
+		<method name="processEvent">
+			<parameter name="event"/>
+			<body>
+			<![CDATA[
+				if (event != None):
+					self.eventList.popEvent(event)
+					event.processed = True
+			]]>
+			</body>
+		</method>
+		<method name="getInputEventAt">
+			<parameter name="time"/>
+			<body>
+			<![CDATA[
+				return self.eventList.getInputAt(time)
+			]]>
+			</body>
+		</method>
+		<scxml  initial="Started" final="End">
+			<state id="CheckTermination" initial="MacroStepProcessed">
+				<state id="MacroStepProcessed">
+					<transition target="../../End" cond="self.currentState.final">
+						<script>
+							<![CDATA[
+								print('Going to End... ')
+							]]>
+						</script>
+					</transition>
+					<transition target="../../DoSimulation" cond="not self.currentState.final">
+						<script>
+							<![CDATA[
+								print('Going to DoSimulation and reading events... ')
+								self.currentEvent = self.getInputEventAt(self.logicalTime)
+								self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
+								print(self.currentEvent)
+								print(self.selectedTransition)
+							]]>
+						</script>
+					</transition>
+				</state>
+			</state>
+			<state id="DoSimulation" initial="MacroStepPrepared">
+				<state id="MicroStepPrepared">
+					<transition target="../MicroStepProcessed">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepProcessed, taking transition and reading events... ')
+								print('Transition to be taken: ' + str(self.selectedTransition))
+								self.currentState = self.selectedTransition.target
+								self.elapsed = 0
+								self.processEvent(self.currentEvent)
+								print('New state: ' + str(self.currentState))
+								self.currentEvent = self.getInputEventAt(self.logicalTime)
+								self.selectedTransition = self.model.getTransitionFrom(self.currentState, self.currentEvent, self.elapsed)
+								print(self.currentEvent)
+								print(self.selectedTransition)
+							]]>
+						</script>
+					</transition>
+				</state>
+				<state id="MicroStepProcessed">
+					<transition target="../MicroStepPrepared" cond="self.selectedTransition != None">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepPrepared... ')
+							]]>
+						</script>
+					</transition>
+					<transition target="../../CheckTermination" cond="self.selectedTransition == None">
+						<script>
+							<![CDATA[
+								print('Going to CheckTermination and advancing time... ')
+								self.logicalTime = self.logicalTime + self.timestep
+								self.elapsed = self.elapsed + self.timestep
+								print(self.logicalTime)
+								print(self.elapsed)
+							]]>
+						</script>
+					</transition>
+				</state>
+				<state id="MacroStepPrepared">
+					<transition target="../MicroStepProcessed">
+						<script>
+							<![CDATA[
+								print('Going to MicroStepProcessed... ')
+							]]>
+						</script>
+					</transition>
+				</state>
+			</state>
+			<state id="Initialized">
+				<transition target="../CheckTermination">
+					<script>
+						<![CDATA[
+							print('Going to MacroStepProcessed... ')
+						]]>
+					</script>
+				</transition>
+			</state>
+			<state id="Started">
+				<transition target="../Initialized">
+					<script>
+						<![CDATA[
+							print('Going to Initialized... ')
+							self.logicalTime = 0
+							self.elapsed = 0
+							self.timestep = 1.0
+							self.currentState = self.model.initialState
+						]]>
+					</script>
+				</transition>
+			</state>
+			<state id="End">
+			</state>
+		</scxml>
+	</class>
+</diagram>

+ 2 - 2
fsa_cbd_composition/fsasimulator/generateSCCD.bat

@@ -1,6 +1,6 @@
 @ECHO OFF
 @ECHO OFF
 setlocal
 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\fsasimulator\fsasimulator_hierarchical.sccd" -o "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\fsasimulator\fsasimulator.py"
+set PYTHONPATH=C:\Users\clagms\Source Control\Git_SCCD\src\build\lib
+python -m sccd.compiler.sccdc -p threads -l python -o fsasimulator.py fsasimulator_hierarchical.xml
 endlocal
 endlocal
 pause
 pause