|
|
@@ -1,7 +1,7 @@
|
|
|
<?xml version="1.0" ?>
|
|
|
<diagram name="CBDSimulator" author="Sadaf Mustafiz and Claudio Gomes and Simon Van Mierlo">
|
|
|
<description>
|
|
|
- A debuggeable CBD simulator.
|
|
|
+ A CBD simulator.
|
|
|
</description>
|
|
|
|
|
|
<inport name="user_input" />
|
|
|
@@ -14,12 +14,6 @@
|
|
|
import Options
|
|
|
import sccd.runtime.accurate_time as accurate_time
|
|
|
|
|
|
- class Breakpoint:
|
|
|
- def __init__(self, name, function, enabled, disable_on_trigger):
|
|
|
- self.name = name
|
|
|
- self.function = function
|
|
|
- self.enabled = enabled
|
|
|
- self.disable_on_trigger = disable_on_trigger
|
|
|
</top>
|
|
|
|
|
|
<class name="CBDSimulator" default="True">
|
|
|
@@ -41,9 +35,6 @@
|
|
|
self.options = options
|
|
|
self.delta = self.options.getDeltaT() * 1000.0 # in miliseconds for real-time simulation
|
|
|
self.model = model
|
|
|
- self.simulation_initialized = False
|
|
|
- self.big_step_initialized = False
|
|
|
- self.small_step_initialized = False
|
|
|
]]>
|
|
|
</body>
|
|
|
</method>
|
|
|
@@ -56,7 +47,6 @@
|
|
|
self.cbdController = CBDController(self.model, self.delta / 1000.0)
|
|
|
self.cbdController.initSimulation()
|
|
|
self.state = {b.getBlockName(): b.getSignal() for b in self.model.getBlocks()}
|
|
|
- self.simulation_initialized = True
|
|
|
]]>
|
|
|
</body>
|
|
|
</method>
|
|
|
@@ -76,27 +66,6 @@
|
|
|
]]>
|
|
|
</body>
|
|
|
</method>
|
|
|
- <method name="simulationInitialized">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- return self.simulation_initialized
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="bigStepInitialized">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- return self.big_step_initialized
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="smallStepInitialized">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- return self.small_step_initialized
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
<method name="finalizeSimulation">
|
|
|
<body>
|
|
|
<![CDATA[
|
|
|
@@ -132,7 +101,7 @@
|
|
|
<method name="endConditionSimulation">
|
|
|
<body>
|
|
|
<![CDATA[
|
|
|
- return self.simulation_initialized and self.iteration >= self.options.getMaxIterations()
|
|
|
+ return self.iteration >= self.options.getMaxIterations()
|
|
|
]]>
|
|
|
</body>
|
|
|
</method>
|
|
|
@@ -178,445 +147,49 @@
|
|
|
]]>
|
|
|
</body>
|
|
|
</method>
|
|
|
- <method name="initializeSimulationDebugger">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- self.breakpoints = []
|
|
|
- self.triggered_bp = None
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="initializeBigStepDebugger">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- pass
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="initializeSmallStepDebugger">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- pass
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="waitTime">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- # First, we convert from wall-clock time to simulated time.
|
|
|
- # This means the elapsed time in wall-clock time needs to be scaled according to the realtime scale (for example, if the realtime scale is 2, an elapsed time of 1 second in wall-clock time is equal to an elapsed time of 2 seconds in simulated time).
|
|
|
- simulated_diff = (accurate_time.time() - self.realtime_start_time) * self.realtime_scale
|
|
|
- # time_next and simulated_diff are both in simulated time: so now scale back to wall-clock time by dividing.
|
|
|
- # This function returns an amount of miliseconds.
|
|
|
- return ((self.time_next - simulated_diff) / self.realtime_scale)
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="syncSimulatedTime">
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- diff = accurate_time.time() - self.realtime_start_time
|
|
|
- self.clock = diff * self.realtime_scale
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="addBreakpoint">
|
|
|
- <parameter name="name" />
|
|
|
- <parameter name="function" />
|
|
|
- <parameter name="enabled" default="true" />
|
|
|
- <parameter name="disable_on_trigger" default="true" />
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- if len([bp for bp in self.breakpoints if bp.name == name]) > 0:
|
|
|
- return -1
|
|
|
- self.breakpoints.append(Breakpoint(name, function, enabled, disable_on_trigger))
|
|
|
- return 0
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="delBreakpoint">
|
|
|
- <parameter name="name" />
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- if len([bp for bp in self.breakpoints if bp.name == name]) == 0:
|
|
|
- return -1
|
|
|
- self.breakpoints = [bp for bp in self.breakpoints if bp.name != name]
|
|
|
- return 0
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="toggleBreakpoint">
|
|
|
- <parameter name="name" />
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- if len([bp for bp in self.breakpoints if bp.name == name]) == 0:
|
|
|
- return -1
|
|
|
- for bp in self.breakpoints:
|
|
|
- if bp.name == name:
|
|
|
- bp.enabled = enabled
|
|
|
- break
|
|
|
- return 0
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="breakpointTriggers">
|
|
|
- <parameter name="is_realtime_simulation" />
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- self.triggered_bp = None
|
|
|
- for bp in self.breakpoints:
|
|
|
- if not bp.enabled:
|
|
|
- continue
|
|
|
- # include the function in the scope...
|
|
|
- exec(bp.function)
|
|
|
- # ... and execute it, note that the breakpoint thus has to start with "def breakpoint("
|
|
|
- # note that we pass self.time_next instead of self.simulated_time in the case of as-fast-as-possible simulation (or stepping)
|
|
|
- # this is to make sure that the simulation is stopped BEFORE the specified time is reached, and not AFTER (because we don't necessarily implement 'step back')
|
|
|
- # in case of realtime simulation, we do pass the current simulated time, since we can stop at (more or less) exactly the right time
|
|
|
- if breakpoint({'clock': (self.clock if is_realtime_simulation else self.time_next) / 1000.0, 'state': self.state}):
|
|
|
- # triggered!
|
|
|
- self.triggered_bp = bp.name
|
|
|
- if bp.disable_on_trigger:
|
|
|
- bp.enabled = False
|
|
|
- return True
|
|
|
- else:
|
|
|
- # not triggered, so continue
|
|
|
- continue
|
|
|
- return False
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
- <method name="godEvent">
|
|
|
- <parameter name="block_name" />
|
|
|
- <parameter name="new_val" />
|
|
|
- <body>
|
|
|
- <![CDATA[
|
|
|
- if not self.simulationInitialized():
|
|
|
- return -1
|
|
|
- if block_name not in self.state:
|
|
|
- return -1
|
|
|
- for b in self.model.getBlocks():
|
|
|
- if b.getBlockName() == block_name:
|
|
|
- b.setSignal(new_val)
|
|
|
- self.state = {b.getBlockName(): b.getSignal() for b in self.model.getBlocks()}
|
|
|
- return 0
|
|
|
- ]]>
|
|
|
- </body>
|
|
|
- </method>
|
|
|
<scxml initial="Main" final="SimulationComplete">
|
|
|
<parallel id="Main">
|
|
|
- <parallel id="SimulationCoordinator">
|
|
|
- <state id="ModeSelector" initial="Paused">
|
|
|
- <state id="Paused">
|
|
|
- <transition target="../Running/SmallStep" event="small_step" port="user_input" />
|
|
|
- <transition target="../Running/BigStep" event="big_step" port="user_input" />
|
|
|
- <transition target="../Running/Continuous" event="continuous" port="user_input" />
|
|
|
- <transition target="../Running/Realtime" event="realtime" port="user_input">
|
|
|
- <parameter name="realtime_scale" default="1.0" />
|
|
|
- <script>
|
|
|
- self.realtime_scale = realtime_scale
|
|
|
- </script>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Running" initial="Continuous">
|
|
|
- <state id="Continuous">
|
|
|
- <transition target="../../WaitingForPaused" event="pause" port="user_input">
|
|
|
- <raise event="Simulation.Pause" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Realtime">
|
|
|
- <transition target="../../WaitingForPaused" event="pause" port="user_input">
|
|
|
- <raise event="Simulation.Pause" />
|
|
|
- </transition>
|
|
|
- <transition target="." event="BigStep.Finished">
|
|
|
- <raise event="BigStep.Finished" port="user_output" />
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="BigStep">
|
|
|
- <transition target="../../Paused" event="BigStep.Finished">
|
|
|
- <raise event="BigStep.Finished" port="user_output" />
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="SmallStep">
|
|
|
- <transition target="../../Paused" event="SmallStep.Finished">
|
|
|
- <raise event="SmallStep.Finished" port="user_output" />
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <transition target="../Paused" event="Simulation.Finished">
|
|
|
- <raise event="Simulation.Finished" port="user_output"/>
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- <transition target="../Paused" event="Breakpoint.Triggered">
|
|
|
- <raise event="Breakpoint.Triggered" port="user_output">
|
|
|
- <parameter expr="self.triggered_bp" />
|
|
|
- </raise>
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="WaitingForPaused">
|
|
|
- <transition target="../Paused" event="Simulation.Paused">
|
|
|
- <raise event="Simulation.Paused" port="user_output" />
|
|
|
- <raise event="State" port="user_output">
|
|
|
- <parameter expr="self.clock / 1000.0" />
|
|
|
- <!--parameter expr="self.state" /-->
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- </state>
|
|
|
- <state id="SmallStepState" initial="Uninitialized">
|
|
|
- <state id="Uninitialized">
|
|
|
- <transition event="SmallStep.Initialized" target="../Initialized" />
|
|
|
- </state>
|
|
|
- <state id="Initialized">
|
|
|
- <transition target="../Uninitialized" event="SmallStep.Finished" />
|
|
|
- </state>
|
|
|
- </state>
|
|
|
- <state id="BigStepState" initial="Uninitialized">
|
|
|
- <state id="Uninitialized">
|
|
|
- <transition event="BigStep.Initialized" target="../Initialized" />
|
|
|
- </state>
|
|
|
- <state id="Initialized">
|
|
|
- <transition target="../Uninitialized" event="BigStep.Finished" />
|
|
|
- </state>
|
|
|
- </state>
|
|
|
- <state id="SimulationState" initial="Uninitialized">
|
|
|
- <state id="Uninitialized">
|
|
|
- <transition event="Simulation.Initialized" target="../Initialized" />
|
|
|
- </state>
|
|
|
- <state id="Initialized">
|
|
|
- <transition target="../Uninitialized" event="Simulation.Finished" />
|
|
|
- </state>
|
|
|
- </state>
|
|
|
- <state id="Initializer" initial="Waiting">
|
|
|
- <state id="Waiting">
|
|
|
- <!-- always initialize an uninitialized simulation -->
|
|
|
- <transition target="../InitializingSimulation" cond="INSTATE('../../SimulationState/Uninitialized')">
|
|
|
- <raise event="Simulation.Reset" />
|
|
|
- </transition>
|
|
|
- <transition target="../InitializingBigStep" cond="(INSTATE('../../ModeSelector/Running/SmallStep') or INSTATE('../../ModeSelector/Running/BigStep')) and INSTATE('../../SimulationState/Initialized') and INSTATE('../../BigStepState/Uninitialized')">
|
|
|
- <raise event="BigStep.Reset" />
|
|
|
- </transition>
|
|
|
- <transition target="../InitializingSmallStep" cond="INSTATE('../../ModeSelector/Running/SmallStep') and INSTATE('../../BigStepState/Initialized') and INSTATE('../../SmallStepState/Uninitialized')">
|
|
|
- <raise event="SmallStep.Reset" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="InitializingSimulation">
|
|
|
- <transition target="../Waiting" event="Simulation.Initialized" />
|
|
|
- </state>
|
|
|
- <state id="InitializingBigStep">
|
|
|
- <transition target="../Waiting" event="BigStep.Initialized" />
|
|
|
- </state>
|
|
|
- <state id="InitializingSmallStep">
|
|
|
- <transition target="../Waiting" event="SmallStep.Initialized" />
|
|
|
- </state>
|
|
|
- </state>
|
|
|
- <state id="SimulationFlow" initial="Paused">
|
|
|
- <state id="PrePaused">
|
|
|
- <transition target="../Paused" after="self.sccd_yield()" />
|
|
|
- </state>
|
|
|
- <state id="Paused">
|
|
|
- <transition target="../Executing" cond="INSTATE('../../ModeSelector/Running/SmallStep') and INSTATE('../../SmallStepState/Initialized')">
|
|
|
- <raise event="SmallStep.Execute" />
|
|
|
- </transition>
|
|
|
- <transition target="../Executing" cond="INSTATE('../../ModeSelector/Running/BigStep') and INSTATE('../../BigStepState/Initialized')">
|
|
|
- <raise event="BigStep.Execute" />
|
|
|
- </transition>
|
|
|
- <transition target="../Executing" cond="INSTATE('../../ModeSelector/Running/Continuous') and INSTATE('../../SimulationState/Initialized')">
|
|
|
- <raise event="Simulation.Execute" />
|
|
|
- </transition>
|
|
|
- <transition target="../Executing" cond="INSTATE('../../ModeSelector/Running/Realtime') and INSTATE('../../SimulationState/Initialized')">
|
|
|
- <raise event="Simulation.ExecuteRealtime">
|
|
|
- <parameter expr="self.realtime_scale" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Executing">
|
|
|
- <transition target="../Paused" cond="INSTATE('../../ModeSelector/Paused')" />
|
|
|
- <transition target="../PrePaused" event="Simulation.Finished" cond="INSTATE('../../ModeSelector/Running/Continuous') or INSTATE('../../ModeSelector/Running/Realtime')" />
|
|
|
- </state>
|
|
|
+ <state id="ExecuteSimulation" initial="Started">
|
|
|
+ <state id="Stopped"/>
|
|
|
+ <state id="Started">
|
|
|
+ <transition target="../Initialized">
|
|
|
+ <script>
|
|
|
+ <![CDATA[
|
|
|
+ self.initializeSimulation()
|
|
|
+ ]]>
|
|
|
+ </script>
|
|
|
+ </transition>
|
|
|
</state>
|
|
|
- <state id="GodEventManager" initial="Listening">
|
|
|
- <state id="Listening">
|
|
|
- <transition target="." event="god_event" port="user_input" cond="INSTATE('../../ModeSelector/Paused')">
|
|
|
- <parameter name="block_name" />
|
|
|
- <parameter name="new_val" />
|
|
|
- <script>
|
|
|
- result = self.godEvent(block_name, new_val)
|
|
|
- </script>
|
|
|
- <raise event="god_event_result" port="user_output">
|
|
|
- <parameter expr="result" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
+ <state id="Initialized">
|
|
|
+ <transition target="../CheckTermination" />
|
|
|
</state>
|
|
|
- <state id="BreakpointManager" initial="Listening">
|
|
|
- <state id="Listening">
|
|
|
- <transition target="." event="add_breakpoint" port="user_input">
|
|
|
- <parameter name="name"/>
|
|
|
- <parameter name="function"/>
|
|
|
- <parameter name="enabled"/>
|
|
|
- <parameter name="disable_on_trigger"/>
|
|
|
- <script>
|
|
|
- result = self.addBreakpoint(name, function, bool(enabled), bool(disable_on_trigger))
|
|
|
- </script>
|
|
|
- <raise event="add_breakpoint_result" port="user_output">
|
|
|
- <parameter expr="result" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- <transition target="." event="del_breakpoint" port="user_input">
|
|
|
- <parameter name="name"/>
|
|
|
- <script>
|
|
|
- result = self.delBreakpoint(name)
|
|
|
- </script>
|
|
|
- <raise event="del_breakpoint_result" port="user_output">
|
|
|
- <parameter expr="result" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- <transition target="." event="toggle_breakpoint" port="user_input">
|
|
|
- <parameter name="name"/>
|
|
|
- <script>
|
|
|
- result = self.toggleBreakpoint(name)
|
|
|
- </script>
|
|
|
- <raise event="toggle_breakpoint_result" port="user_output">
|
|
|
- <parameter expr="result" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- <transition target="." event="list_breakpoints" port="user_input">
|
|
|
- <raise event="list_breakpoints_result" port="user_output">
|
|
|
- <parameter expr="[bp.name for bp in self.breakpoints]" />
|
|
|
- </raise>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
+ <state id="CheckTermination">
|
|
|
+ <transition target="../InitializingChild" cond="not self.endConditionSimulation()">
|
|
|
+ <raise event="BigStep.Reset" />
|
|
|
+ </transition>
|
|
|
+ <transition target="../Stopped" cond="self.endConditionSimulation()">
|
|
|
+ <script>
|
|
|
+ print 'Simulation finished'
|
|
|
+ self.finalizeSimulation()
|
|
|
+ </script>
|
|
|
+ </transition>
|
|
|
</state>
|
|
|
- </parallel>
|
|
|
- <parallel id="ExecuteSimulation">
|
|
|
- <state id="SimulationState" initial="Paused">
|
|
|
- <state id="Paused">
|
|
|
- <transition target="../Continuous" event="Simulation.Execute" />
|
|
|
- <transition target="../Realtime" event="Simulation.ExecuteRealtime">
|
|
|
- <parameter name="realtime_scale" default="1.0" />
|
|
|
- <script>
|
|
|
- self.realtime_scale = float(realtime_scale)
|
|
|
- # If the simulation was paused, we need to reset the start time of the simulation.
|
|
|
- # The start time of the simulation is equal to the point in wall-clock time where simulated time is 0.
|
|
|
- # If the simulation was paused, we have to recompute this point in time: it is the difference of the wall-clock time and the simulated time.
|
|
|
- # If the scale was changed after the pause, this point of course moves backwards (for scales smaller than 1) or forwards (for scales larger than 1)
|
|
|
- self.realtime_start_time = accurate_time.time() - (self.clock / self.realtime_scale)
|
|
|
- </script>
|
|
|
- </transition>
|
|
|
- <state id="BreakpointTriggered" />
|
|
|
- </state>
|
|
|
- <state id="Continuous">
|
|
|
- <transition target="../Paused" event="Simulation.Pause" />
|
|
|
- <transition target="../Paused/BreakpointTriggered" cond="self.breakpointTriggers(False)">
|
|
|
- <raise event="Breakpoint.Triggered" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Realtime">
|
|
|
- <transition target="../Paused" event="Simulation.Pause" />
|
|
|
- <transition target="../Paused/BreakpointTriggered" cond="self.breakpointTriggers(True)">
|
|
|
- <raise event="Breakpoint.Triggered" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
+ <state id="InitializingChild">
|
|
|
+ <transition target="../Executing" event="BigStep.Initialized">
|
|
|
+ <raise event="BigStep.Execute" />
|
|
|
+ </transition>
|
|
|
</state>
|
|
|
- <state id="SimulationFlow" initial="Stopped">
|
|
|
- <state id="Stopped">
|
|
|
- <transition target="../Started" event="Simulation.Reset" />
|
|
|
- </state>
|
|
|
- <state id="Started">
|
|
|
- <transition target="../Initialized">
|
|
|
- <script>
|
|
|
- <![CDATA[
|
|
|
- self.initializeSimulation()
|
|
|
- ]]>
|
|
|
- </script>
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Initialized">
|
|
|
- <transition target="../InitializeDebugger" />
|
|
|
- </state>
|
|
|
- <state id="InitializeDebugger">
|
|
|
- <transition target="../Waiting">
|
|
|
- <script>
|
|
|
- <![CDATA[
|
|
|
- self.initializeSimulationDebugger()
|
|
|
- ]]>
|
|
|
- </script>
|
|
|
- <raise event="Simulation.Initialized" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Waiting">
|
|
|
- <transition target="../CheckTermination" />
|
|
|
- </state>
|
|
|
- <state id="SettleBeforeCheckTermination">
|
|
|
- <transition target="../CheckTermination" after="self.sccd_yield()" />
|
|
|
- <transition target="../CheckTermination" cond="INSTATE('../../SimulationState/Paused')">
|
|
|
- <raise event="Simulation.Paused" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="CheckTermination">
|
|
|
- <transition target="../InitializingBigStep" cond="INSTATE('../../SimulationState/Continuous') and not self.endConditionSimulation()">
|
|
|
- <raise event="BigStep.Reset" />
|
|
|
- </transition>
|
|
|
- <transition target="../WaitingRealtime" cond="INSTATE('../../SimulationState/Realtime') and not self.endConditionSimulation()" />
|
|
|
- <transition target="../Stopped" cond="self.endConditionSimulation()">
|
|
|
- <script>
|
|
|
- print 'simulation executed'
|
|
|
- self.finalizeSimulation()
|
|
|
- </script>
|
|
|
- <raise event="Simulation.Finished" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="WaitingRealtime">
|
|
|
- <!-- We schedule to go back to the check_termination state after the smallest possible delay (to accomodate for pauses). -->
|
|
|
- <transition target="../CheckTermination" after="self.sccd_yield()">
|
|
|
- <!-- We set the simulation time to the correct value. -->
|
|
|
- <script>
|
|
|
- self.syncSimulatedTime()
|
|
|
- </script>
|
|
|
- </transition>
|
|
|
- <transition target="../CheckTermination" cond="INSTATE('../../SimulationState/Paused')">
|
|
|
- <raise event="Simulation.Paused" />
|
|
|
- </transition>
|
|
|
- <!-- We execute a step when the wait time is smaller than the smallest possible delay. -->
|
|
|
- <transition target="../InitializingBigStep" cond="self.waitTime() / 1000.0 <= self.sccd_yield()">
|
|
|
- <raise event="BigStep.Reset" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="InitializingBigStep">
|
|
|
- <transition target="../Executing" event="BigStep.Initialized">
|
|
|
- <raise event="BigStep.Execute" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Executing">
|
|
|
- <transition target="../SettleBeforeCheckTermination" event="BigStep.Finished" />
|
|
|
- </state>
|
|
|
+ <state id="Executing">
|
|
|
+ <transition target="../CheckTermination" event="BigStep.Finished" />
|
|
|
</state>
|
|
|
- </parallel>
|
|
|
- <state id="ExecuteBigStep" initial="Stopped">
|
|
|
+ </state>
|
|
|
+ <state id="ExecuteBigStep" initial="Stopped">
|
|
|
<state id="Stopped">
|
|
|
<transition target="../Started" event="BigStep.Reset" />
|
|
|
</state>
|
|
|
<state id="Started">
|
|
|
<transition target="../Initialized">
|
|
|
+ <raise event="BigStep.Initialized" />
|
|
|
<script>
|
|
|
<![CDATA[
|
|
|
self.initializeBigStep()
|
|
|
@@ -625,51 +198,28 @@
|
|
|
</transition>
|
|
|
</state>
|
|
|
<state id="Initialized">
|
|
|
- <transition target="../InitializeDebugger" />
|
|
|
- </state>
|
|
|
- <state id="InitializeDebugger">
|
|
|
- <transition target="../Waiting">
|
|
|
- <script>
|
|
|
- <![CDATA[
|
|
|
- self.initializeBigStepDebugger()
|
|
|
- ]]>
|
|
|
- </script>
|
|
|
- <raise event="BigStep.Initialized" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Waiting">
|
|
|
<transition target="../CheckTermination" event="BigStep.Execute" />
|
|
|
- <!-- in case a small step triggers the end condition of a big step -->
|
|
|
- <transition target="../Stopped" cond="self.endConditionBigStep()">
|
|
|
- <script>
|
|
|
- print 'big step executed'
|
|
|
- self.finalizeBigStep()
|
|
|
- </script>
|
|
|
- <raise event="BigStep.Finished" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="SettleBeforeCheckTermination">
|
|
|
- <transition target="../CheckTermination" after="self.sccd_yield()" />
|
|
|
</state>
|
|
|
<state id="CheckTermination">
|
|
|
- <transition target="../InitializingSmallStep" cond="not self.endConditionBigStep()">
|
|
|
+ <transition target="../InitializingChild" cond="not self.endConditionBigStep()">
|
|
|
<raise event="SmallStep.Reset" />
|
|
|
</transition>
|
|
|
<transition target="../Stopped" cond="self.endConditionBigStep()">
|
|
|
<script>
|
|
|
print 'big step executed'
|
|
|
self.finalizeBigStep()
|
|
|
+ print 'Iteration: ' + str(self.iteration)
|
|
|
</script>
|
|
|
<raise event="BigStep.Finished" />
|
|
|
</transition>
|
|
|
</state>
|
|
|
- <state id="InitializingSmallStep">
|
|
|
+ <state id="InitializingChild">
|
|
|
<transition target="../Executing" event="SmallStep.Initialized">
|
|
|
<raise event="SmallStep.Execute" />
|
|
|
</transition>
|
|
|
</state>
|
|
|
<state id="Executing">
|
|
|
- <transition target="../SettleBeforeCheckTermination" event="SmallStep.Finished" />
|
|
|
+ <transition target="../CheckTermination" event="SmallStep.Finished" />
|
|
|
</state>
|
|
|
</state>
|
|
|
<state id="ExecuteSmallStep" initial="Stopped">
|
|
|
@@ -678,6 +228,7 @@
|
|
|
</state>
|
|
|
<state id="Started">
|
|
|
<transition target="../Initialized">
|
|
|
+ <raise event="SmallStep.Initialized" />
|
|
|
<script>
|
|
|
<![CDATA[
|
|
|
self.initializeSmallStep()
|
|
|
@@ -686,26 +237,12 @@
|
|
|
</transition>
|
|
|
</state>
|
|
|
<state id="Initialized">
|
|
|
- <transition target="../InitializeDebugger" />
|
|
|
- </state>
|
|
|
- <state id="InitializeDebugger">
|
|
|
- <transition target="../Waiting">
|
|
|
- <script>
|
|
|
- <![CDATA[
|
|
|
- self.initializeSmallStepDebugger()
|
|
|
- ]]>
|
|
|
- </script>
|
|
|
- <raise event="SmallStep.Initialized" />
|
|
|
- </transition>
|
|
|
- </state>
|
|
|
- <state id="Waiting">
|
|
|
- <transition target="../CheckTermination" event="SmallStep.Execute" />
|
|
|
- </state>
|
|
|
- <state id="SettleBeforeCheckTermination">
|
|
|
- <transition target="../CheckTermination" after="self.sccd_yield()" />
|
|
|
+ <transition target="../CheckTermination" event="SmallStep.Execute"/>
|
|
|
</state>
|
|
|
<state id="CheckTermination">
|
|
|
- <transition target="../Executing" cond="not self.endConditionSmallStep()" />
|
|
|
+ <transition target="../InitializingChild" cond="not self.endConditionSmallStep()">
|
|
|
+ <raise event="Block.Reset" />
|
|
|
+ </transition>
|
|
|
<transition target="../Stopped" cond="self.endConditionSmallStep()">
|
|
|
<script>
|
|
|
print 'small step executed'
|
|
|
@@ -714,21 +251,34 @@
|
|
|
<raise event="SmallStep.Finished" />
|
|
|
</transition>
|
|
|
</state>
|
|
|
- <state id="Executing">
|
|
|
- <onentry>
|
|
|
+ <state id="InitializingChild">
|
|
|
+ <transition target="../Executing" event="Block.Initialized">
|
|
|
<raise event="Block.Execute" />
|
|
|
- </onentry>
|
|
|
- <transition target="../SettleBeforeCheckTermination" event="Block.Finished">
|
|
|
+ </transition>
|
|
|
+ </state>
|
|
|
+ <state id="Executing">
|
|
|
+ <transition target="../CheckTermination" event="Block.Finished">
|
|
|
<script>
|
|
|
self.small_step_executed = True
|
|
|
</script>
|
|
|
</transition>
|
|
|
</state>
|
|
|
</state>
|
|
|
- <state id="ExecuteBlock" initial="Waiting">
|
|
|
- <state id="Waiting">
|
|
|
- <transition target="." event="Block.Execute">
|
|
|
- <script>
|
|
|
+ <state id="ExecuteBlock" initial="Stopped">
|
|
|
+ <state id="Stopped">
|
|
|
+ <transition target="../Started" event="Block.Reset" />
|
|
|
+ </state>
|
|
|
+ <state id="Started">
|
|
|
+ <transition target="../Initialized">
|
|
|
+ <raise event="Block.Initialized" />
|
|
|
+ </transition>
|
|
|
+ </state>
|
|
|
+ <state id="Initialized">
|
|
|
+ <transition target="../Executing" event="Block.Execute" />
|
|
|
+ </state>
|
|
|
+ <state id="Executing">
|
|
|
+ <transition target="../Stopped">
|
|
|
+ <script>
|
|
|
self.computeBlock()
|
|
|
</script>
|
|
|
<raise event="Block.Finished" />
|