"""
Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)

Date:   Wed Nov 09 17:04:31 2016

Model author: Sadaf Mustafiz and Claudio Gomes and Simon Van Mierlo
Model name:   CBDSimulator
Model description:
A debuggeable CBD simulator.
"""

from sccd.runtime.statecharts_core import *
from sccd.runtime.libs.ui import *
from sccd.runtime.libs.utils import *
from CBD_Controller import CBDController
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

# package "CBDSimulator"

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
        
        # build Statechart structure
        self.build_statechart_structure()
        
        # user defined attributes
        self.iteration = None
        self.delta = None
        self.clock = None
        self.state = None
        self.model = None
        self.depGraph = None
        self.strongComponentList = None
        self.currentCompIdx = None
        self.cbdController = None
        self.options = 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() * 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
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initializeSimulation(self):
        self.iteration = 0
        self.clock = 0
        self.time_next = self.delta
        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
    
    
    # user defined method
    def initializeBigStep(self):
        self.currentCompIdx = 0
        self.depGraph = self.cbdController.createDepGraph(self.iteration)
        self.strongComponentList = self.cbdController.createStrongComponents(self.depGraph, self.iteration)
    
    
    # user defined method
    def initializeSmallStep(self):
        self.small_step_executed = False
    
    
    # user defined method
    def simulationInitialized(self):
        return self.simulation_initialized
    
    
    # user defined method
    def bigStepInitialized(self):
        return self.big_step_initialized
    
    
    # user defined method
    def smallStepInitialized(self):
        return self.small_step_initialized
    
    
    # user defined method
    def finalizeSimulation(self):
        from bokeh.plotting import figure, output_file, show    
        times = []
        values = []
        for timeValuePair in self.model.getSignal("neg"):
            times.append(timeValuePair.time)
            values.append(timeValuePair.value)
        
        output_file("./plot.html", title="Plot")
        p = figure(title="Something vs Otherthing", x_axis_label="Time", y_axis_label="Values")
        p.line(times, values, legend="Something", line_width=1, line_color="red")
        show(p)
        print 'Simulation finalized.'
    
    
    # user defined method
    def finalizeBigStep(self):
        self.advanceTime()
    
    
    # user defined method
    def finalizeSmallStep(self):
        self.currentCompIdx = self.currentCompIdx + 1
    
    
    # user defined method
    def endConditionSimulation(self):
        return self.simulation_initialized and self.iteration >= self.options.getMaxIterations()
    
    
    # user defined method
    def endConditionBigStep(self):
        return self.currentCompIdx >= len(self.strongComponentList)
    
    
    # user defined method
    def endConditionSmallStep(self):
        return self.small_step_executed
    
    
    # user defined method
    def advanceTime(self):
        self.iteration = self.iteration + 1
        self.clock = self.time_next
        self.cbdController.advanceTimeStep()
        self.time_next = self.clock + self.delta
    
    
    # user defined method
    def currentComponentIsCycle(self):
        return self.cbdController.componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
    
    
    # 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)
        self.state = {b.getBlockName(): b.getSignal() for b in self.model.getBlocks()}
    
    
    # user defined method
    def initializeSimulationDebugger(self):
        self.breakpoints = []
        self.triggered_bp = None
    
    
    # user defined method
    def initializeBigStepDebugger(self):
        pass
    
    
    # user defined method
    def initializeSmallStepDebugger(self):
        pass
    
    
    # user defined method
    def waitTime(self):
        # 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)
    
    
    # user defined method
    def syncSimulatedTime(self):
        diff = accurate_time.time() - self.realtime_start_time
        self.clock = diff * self.realtime_scale
    
    
    # user defined method
    def addBreakpoint(self, name, function, enabled = None, disable_on_trigger = None):
        if enabled == None: enabled = true
        if disable_on_trigger == None: disable_on_trigger = true
        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
    
    
    # user defined method
    def delBreakpoint(self, name):
        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
    
    
    # user defined method
    def toggleBreakpoint(self, name):
        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
    
    
    # user defined method
    def breakpointTriggers(self, is_realtime_simulation):
        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
    
    
    # user defined method
    def godEvent(self, block_name, new_val):
        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
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /Main
        self.states["/Main"] = ParallelState(1, "/Main", self)
        
        # state /Main/SimulationCoordinator
        self.states["/Main/SimulationCoordinator"] = ParallelState(2, "/Main/SimulationCoordinator", self)
        
        # state /Main/SimulationCoordinator/ModeSelector
        self.states["/Main/SimulationCoordinator/ModeSelector"] = State(3, "/Main/SimulationCoordinator/ModeSelector", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Paused
        self.states["/Main/SimulationCoordinator/ModeSelector/Paused"] = State(4, "/Main/SimulationCoordinator/ModeSelector/Paused", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Running
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"] = State(5, "/Main/SimulationCoordinator/ModeSelector/Running", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Running/Continuous
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"] = State(6, "/Main/SimulationCoordinator/ModeSelector/Running/Continuous", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Running/Realtime
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"] = State(7, "/Main/SimulationCoordinator/ModeSelector/Running/Realtime", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Running/BigStep
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"] = State(8, "/Main/SimulationCoordinator/ModeSelector/Running/BigStep", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/Running/SmallStep
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"] = State(9, "/Main/SimulationCoordinator/ModeSelector/Running/SmallStep", self)
        
        # state /Main/SimulationCoordinator/ModeSelector/WaitingForPaused
        self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"] = State(10, "/Main/SimulationCoordinator/ModeSelector/WaitingForPaused", self)
        
        # state /Main/SimulationCoordinator/SmallStepState
        self.states["/Main/SimulationCoordinator/SmallStepState"] = State(11, "/Main/SimulationCoordinator/SmallStepState", self)
        
        # state /Main/SimulationCoordinator/SmallStepState/Uninitialized
        self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"] = State(12, "/Main/SimulationCoordinator/SmallStepState/Uninitialized", self)
        
        # state /Main/SimulationCoordinator/SmallStepState/Initialized
        self.states["/Main/SimulationCoordinator/SmallStepState/Initialized"] = State(13, "/Main/SimulationCoordinator/SmallStepState/Initialized", self)
        
        # state /Main/SimulationCoordinator/BigStepState
        self.states["/Main/SimulationCoordinator/BigStepState"] = State(14, "/Main/SimulationCoordinator/BigStepState", self)
        
        # state /Main/SimulationCoordinator/BigStepState/Uninitialized
        self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"] = State(15, "/Main/SimulationCoordinator/BigStepState/Uninitialized", self)
        
        # state /Main/SimulationCoordinator/BigStepState/Initialized
        self.states["/Main/SimulationCoordinator/BigStepState/Initialized"] = State(16, "/Main/SimulationCoordinator/BigStepState/Initialized", self)
        
        # state /Main/SimulationCoordinator/SimulationState
        self.states["/Main/SimulationCoordinator/SimulationState"] = State(17, "/Main/SimulationCoordinator/SimulationState", self)
        
        # state /Main/SimulationCoordinator/SimulationState/Uninitialized
        self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"] = State(18, "/Main/SimulationCoordinator/SimulationState/Uninitialized", self)
        
        # state /Main/SimulationCoordinator/SimulationState/Initialized
        self.states["/Main/SimulationCoordinator/SimulationState/Initialized"] = State(19, "/Main/SimulationCoordinator/SimulationState/Initialized", self)
        
        # state /Main/SimulationCoordinator/Initializer
        self.states["/Main/SimulationCoordinator/Initializer"] = State(20, "/Main/SimulationCoordinator/Initializer", self)
        
        # state /Main/SimulationCoordinator/Initializer/Waiting
        self.states["/Main/SimulationCoordinator/Initializer/Waiting"] = State(21, "/Main/SimulationCoordinator/Initializer/Waiting", self)
        
        # state /Main/SimulationCoordinator/Initializer/InitializingSimulation
        self.states["/Main/SimulationCoordinator/Initializer/InitializingSimulation"] = State(22, "/Main/SimulationCoordinator/Initializer/InitializingSimulation", self)
        
        # state /Main/SimulationCoordinator/Initializer/InitializingBigStep
        self.states["/Main/SimulationCoordinator/Initializer/InitializingBigStep"] = State(23, "/Main/SimulationCoordinator/Initializer/InitializingBigStep", self)
        
        # state /Main/SimulationCoordinator/Initializer/InitializingSmallStep
        self.states["/Main/SimulationCoordinator/Initializer/InitializingSmallStep"] = State(24, "/Main/SimulationCoordinator/Initializer/InitializingSmallStep", self)
        
        # state /Main/SimulationCoordinator/SimulationFlow
        self.states["/Main/SimulationCoordinator/SimulationFlow"] = State(25, "/Main/SimulationCoordinator/SimulationFlow", self)
        
        # state /Main/SimulationCoordinator/SimulationFlow/PrePaused
        self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"] = State(26, "/Main/SimulationCoordinator/SimulationFlow/PrePaused", self)
        self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"].setEnter(self._Main_SimulationCoordinator_SimulationFlow_PrePaused_enter)
        self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"].setExit(self._Main_SimulationCoordinator_SimulationFlow_PrePaused_exit)
        
        # state /Main/SimulationCoordinator/SimulationFlow/Paused
        self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"] = State(27, "/Main/SimulationCoordinator/SimulationFlow/Paused", self)
        
        # state /Main/SimulationCoordinator/SimulationFlow/Executing
        self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"] = State(28, "/Main/SimulationCoordinator/SimulationFlow/Executing", self)
        
        # state /Main/SimulationCoordinator/GodEventManager
        self.states["/Main/SimulationCoordinator/GodEventManager"] = State(29, "/Main/SimulationCoordinator/GodEventManager", self)
        
        # state /Main/SimulationCoordinator/GodEventManager/Listening
        self.states["/Main/SimulationCoordinator/GodEventManager/Listening"] = State(30, "/Main/SimulationCoordinator/GodEventManager/Listening", self)
        
        # state /Main/SimulationCoordinator/BreakpointManager
        self.states["/Main/SimulationCoordinator/BreakpointManager"] = State(31, "/Main/SimulationCoordinator/BreakpointManager", self)
        
        # state /Main/SimulationCoordinator/BreakpointManager/Listening
        self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"] = State(32, "/Main/SimulationCoordinator/BreakpointManager/Listening", self)
        
        # state /Main/ExecuteSimulation
        self.states["/Main/ExecuteSimulation"] = ParallelState(33, "/Main/ExecuteSimulation", self)
        
        # state /Main/ExecuteSimulation/SimulationState
        self.states["/Main/ExecuteSimulation/SimulationState"] = State(34, "/Main/ExecuteSimulation/SimulationState", self)
        
        # state /Main/ExecuteSimulation/SimulationState/Paused
        self.states["/Main/ExecuteSimulation/SimulationState/Paused"] = State(35, "/Main/ExecuteSimulation/SimulationState/Paused", self)
        
        # state /Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered
        self.states["/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered"] = State(36, "/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered", self)
        
        # state /Main/ExecuteSimulation/SimulationState/Continuous
        self.states["/Main/ExecuteSimulation/SimulationState/Continuous"] = State(37, "/Main/ExecuteSimulation/SimulationState/Continuous", self)
        
        # state /Main/ExecuteSimulation/SimulationState/Realtime
        self.states["/Main/ExecuteSimulation/SimulationState/Realtime"] = State(38, "/Main/ExecuteSimulation/SimulationState/Realtime", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow
        self.states["/Main/ExecuteSimulation/SimulationFlow"] = State(39, "/Main/ExecuteSimulation/SimulationFlow", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/Stopped
        self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"] = State(40, "/Main/ExecuteSimulation/SimulationFlow/Stopped", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/Started
        self.states["/Main/ExecuteSimulation/SimulationFlow/Started"] = State(41, "/Main/ExecuteSimulation/SimulationFlow/Started", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/Initialized
        self.states["/Main/ExecuteSimulation/SimulationFlow/Initialized"] = State(42, "/Main/ExecuteSimulation/SimulationFlow/Initialized", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/InitializeDebugger
        self.states["/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger"] = State(43, "/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/Waiting
        self.states["/Main/ExecuteSimulation/SimulationFlow/Waiting"] = State(44, "/Main/ExecuteSimulation/SimulationFlow/Waiting", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"] = State(45, "/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/ExecuteSimulation/SimulationFlow/CheckTermination
        self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"] = State(46, "/Main/ExecuteSimulation/SimulationFlow/CheckTermination", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/WaitingRealtime
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"] = State(47, "/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime", self)
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"].setEnter(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_enter)
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"].setExit(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_exit)
        
        # state /Main/ExecuteSimulation/SimulationFlow/InitializingBigStep
        self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"] = State(48, "/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep", self)
        
        # state /Main/ExecuteSimulation/SimulationFlow/Executing
        self.states["/Main/ExecuteSimulation/SimulationFlow/Executing"] = State(49, "/Main/ExecuteSimulation/SimulationFlow/Executing", self)
        
        # state /Main/ExecuteBigStep
        self.states["/Main/ExecuteBigStep"] = State(50, "/Main/ExecuteBigStep", self)
        
        # state /Main/ExecuteBigStep/Stopped
        self.states["/Main/ExecuteBigStep/Stopped"] = State(51, "/Main/ExecuteBigStep/Stopped", self)
        
        # state /Main/ExecuteBigStep/Started
        self.states["/Main/ExecuteBigStep/Started"] = State(52, "/Main/ExecuteBigStep/Started", self)
        
        # state /Main/ExecuteBigStep/Initialized
        self.states["/Main/ExecuteBigStep/Initialized"] = State(53, "/Main/ExecuteBigStep/Initialized", self)
        
        # state /Main/ExecuteBigStep/InitializeDebugger
        self.states["/Main/ExecuteBigStep/InitializeDebugger"] = State(54, "/Main/ExecuteBigStep/InitializeDebugger", self)
        
        # state /Main/ExecuteBigStep/Waiting
        self.states["/Main/ExecuteBigStep/Waiting"] = State(55, "/Main/ExecuteBigStep/Waiting", self)
        
        # state /Main/ExecuteBigStep/SettleBeforeCheckTermination
        self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"] = State(56, "/Main/ExecuteBigStep/SettleBeforeCheckTermination", self)
        self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"].setEnter(self._Main_ExecuteBigStep_SettleBeforeCheckTermination_enter)
        self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"].setExit(self._Main_ExecuteBigStep_SettleBeforeCheckTermination_exit)
        
        # state /Main/ExecuteBigStep/CheckTermination
        self.states["/Main/ExecuteBigStep/CheckTermination"] = State(57, "/Main/ExecuteBigStep/CheckTermination", self)
        
        # state /Main/ExecuteBigStep/InitializingSmallStep
        self.states["/Main/ExecuteBigStep/InitializingSmallStep"] = State(58, "/Main/ExecuteBigStep/InitializingSmallStep", self)
        
        # state /Main/ExecuteBigStep/Executing
        self.states["/Main/ExecuteBigStep/Executing"] = State(59, "/Main/ExecuteBigStep/Executing", self)
        
        # state /Main/ExecuteSmallStep
        self.states["/Main/ExecuteSmallStep"] = State(60, "/Main/ExecuteSmallStep", self)
        
        # state /Main/ExecuteSmallStep/Stopped
        self.states["/Main/ExecuteSmallStep/Stopped"] = State(61, "/Main/ExecuteSmallStep/Stopped", self)
        
        # state /Main/ExecuteSmallStep/Started
        self.states["/Main/ExecuteSmallStep/Started"] = State(62, "/Main/ExecuteSmallStep/Started", self)
        
        # state /Main/ExecuteSmallStep/Initialized
        self.states["/Main/ExecuteSmallStep/Initialized"] = State(63, "/Main/ExecuteSmallStep/Initialized", self)
        
        # state /Main/ExecuteSmallStep/InitializeDebugger
        self.states["/Main/ExecuteSmallStep/InitializeDebugger"] = State(64, "/Main/ExecuteSmallStep/InitializeDebugger", self)
        
        # state /Main/ExecuteSmallStep/Waiting
        self.states["/Main/ExecuteSmallStep/Waiting"] = State(65, "/Main/ExecuteSmallStep/Waiting", self)
        
        # state /Main/ExecuteSmallStep/SettleBeforeCheckTermination
        self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"] = State(66, "/Main/ExecuteSmallStep/SettleBeforeCheckTermination", self)
        self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"].setEnter(self._Main_ExecuteSmallStep_SettleBeforeCheckTermination_enter)
        self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"].setExit(self._Main_ExecuteSmallStep_SettleBeforeCheckTermination_exit)
        
        # state /Main/ExecuteSmallStep/CheckTermination
        self.states["/Main/ExecuteSmallStep/CheckTermination"] = State(67, "/Main/ExecuteSmallStep/CheckTermination", self)
        
        # state /Main/ExecuteSmallStep/Executing
        self.states["/Main/ExecuteSmallStep/Executing"] = State(68, "/Main/ExecuteSmallStep/Executing", self)
        self.states["/Main/ExecuteSmallStep/Executing"].setEnter(self._Main_ExecuteSmallStep_Executing_enter)
        
        # state /Main/ExecuteBlock
        self.states["/Main/ExecuteBlock"] = State(69, "/Main/ExecuteBlock", self)
        
        # state /Main/ExecuteBlock/Waiting
        self.states["/Main/ExecuteBlock/Waiting"] = State(70, "/Main/ExecuteBlock/Waiting", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states["/Main"].addChild(self.states["/Main/SimulationCoordinator"])
        self.states["/Main"].addChild(self.states["/Main/ExecuteSimulation"])
        self.states["/Main"].addChild(self.states["/Main/ExecuteBigStep"])
        self.states["/Main"].addChild(self.states["/Main/ExecuteSmallStep"])
        self.states["/Main"].addChild(self.states["/Main/ExecuteBlock"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/SmallStepState"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/BigStepState"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/SimulationState"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/Initializer"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/SimulationFlow"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/GodEventManager"])
        self.states["/Main/SimulationCoordinator"].addChild(self.states["/Main/SimulationCoordinator/BreakpointManager"])
        self.states["/Main/SimulationCoordinator/ModeSelector"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Paused"])
        self.states["/Main/SimulationCoordinator/ModeSelector"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Running"])
        self.states["/Main/SimulationCoordinator/ModeSelector"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"])
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"])
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"])
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"])
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addChild(self.states["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"])
        self.states["/Main/SimulationCoordinator/SmallStepState"].addChild(self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"])
        self.states["/Main/SimulationCoordinator/SmallStepState"].addChild(self.states["/Main/SimulationCoordinator/SmallStepState/Initialized"])
        self.states["/Main/SimulationCoordinator/BigStepState"].addChild(self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"])
        self.states["/Main/SimulationCoordinator/BigStepState"].addChild(self.states["/Main/SimulationCoordinator/BigStepState/Initialized"])
        self.states["/Main/SimulationCoordinator/SimulationState"].addChild(self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"])
        self.states["/Main/SimulationCoordinator/SimulationState"].addChild(self.states["/Main/SimulationCoordinator/SimulationState/Initialized"])
        self.states["/Main/SimulationCoordinator/Initializer"].addChild(self.states["/Main/SimulationCoordinator/Initializer/Waiting"])
        self.states["/Main/SimulationCoordinator/Initializer"].addChild(self.states["/Main/SimulationCoordinator/Initializer/InitializingSimulation"])
        self.states["/Main/SimulationCoordinator/Initializer"].addChild(self.states["/Main/SimulationCoordinator/Initializer/InitializingBigStep"])
        self.states["/Main/SimulationCoordinator/Initializer"].addChild(self.states["/Main/SimulationCoordinator/Initializer/InitializingSmallStep"])
        self.states["/Main/SimulationCoordinator/SimulationFlow"].addChild(self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"])
        self.states["/Main/SimulationCoordinator/SimulationFlow"].addChild(self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"])
        self.states["/Main/SimulationCoordinator/SimulationFlow"].addChild(self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"])
        self.states["/Main/SimulationCoordinator/GodEventManager"].addChild(self.states["/Main/SimulationCoordinator/GodEventManager/Listening"])
        self.states["/Main/SimulationCoordinator/BreakpointManager"].addChild(self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"])
        self.states["/Main/ExecuteSimulation"].addChild(self.states["/Main/ExecuteSimulation/SimulationState"])
        self.states["/Main/ExecuteSimulation"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow"])
        self.states["/Main/ExecuteSimulation/SimulationState"].addChild(self.states["/Main/ExecuteSimulation/SimulationState/Paused"])
        self.states["/Main/ExecuteSimulation/SimulationState"].addChild(self.states["/Main/ExecuteSimulation/SimulationState/Continuous"])
        self.states["/Main/ExecuteSimulation/SimulationState"].addChild(self.states["/Main/ExecuteSimulation/SimulationState/Realtime"])
        self.states["/Main/ExecuteSimulation/SimulationState/Paused"].addChild(self.states["/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/Started"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/Initialized"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/Waiting"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"])
        self.states["/Main/ExecuteSimulation/SimulationFlow"].addChild(self.states["/Main/ExecuteSimulation/SimulationFlow/Executing"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/Stopped"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/Started"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/Initialized"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/InitializeDebugger"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/Waiting"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/CheckTermination"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/InitializingSmallStep"])
        self.states["/Main/ExecuteBigStep"].addChild(self.states["/Main/ExecuteBigStep/Executing"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/Stopped"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/Started"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/Initialized"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/InitializeDebugger"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/Waiting"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/CheckTermination"])
        self.states["/Main/ExecuteSmallStep"].addChild(self.states["/Main/ExecuteSmallStep/Executing"])
        self.states["/Main/ExecuteBlock"].addChild(self.states["/Main/ExecuteBlock/Waiting"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/SimulationCoordinator/ModeSelector"].default_state = self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].default_state = self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"]
        self.states["/Main/SimulationCoordinator/SmallStepState"].default_state = self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"]
        self.states["/Main/SimulationCoordinator/BigStepState"].default_state = self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"]
        self.states["/Main/SimulationCoordinator/SimulationState"].default_state = self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"]
        self.states["/Main/SimulationCoordinator/Initializer"].default_state = self.states["/Main/SimulationCoordinator/Initializer/Waiting"]
        self.states["/Main/SimulationCoordinator/SimulationFlow"].default_state = self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"]
        self.states["/Main/SimulationCoordinator/GodEventManager"].default_state = self.states["/Main/SimulationCoordinator/GodEventManager/Listening"]
        self.states["/Main/SimulationCoordinator/BreakpointManager"].default_state = self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"]
        self.states["/Main/ExecuteSimulation/SimulationState"].default_state = self.states["/Main/ExecuteSimulation/SimulationState/Paused"]
        self.states["/Main/ExecuteSimulation/SimulationState/Paused"].default_state = self.states["/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered"]
        self.states["/Main/ExecuteSimulation/SimulationFlow"].default_state = self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"]
        self.states["/Main/ExecuteBigStep"].default_state = self.states["/Main/ExecuteBigStep/Stopped"]
        self.states["/Main/ExecuteSmallStep"].default_state = self.states["/Main/ExecuteSmallStep/Stopped"]
        self.states["/Main/ExecuteBlock"].default_state = self.states["/Main/ExecuteBlock/Waiting"]
        
        # transition /Main/SimulationCoordinator/ModeSelector/Paused
        _Main_SimulationCoordinator_ModeSelector_Paused_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Paused"], [self.states["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"]])
        _Main_SimulationCoordinator_ModeSelector_Paused_0.setTrigger(Event("small_step", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Paused"].addTransition(_Main_SimulationCoordinator_ModeSelector_Paused_0)
        _Main_SimulationCoordinator_ModeSelector_Paused_1 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Paused"], [self.states["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"]])
        _Main_SimulationCoordinator_ModeSelector_Paused_1.setTrigger(Event("big_step", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Paused"].addTransition(_Main_SimulationCoordinator_ModeSelector_Paused_1)
        _Main_SimulationCoordinator_ModeSelector_Paused_2 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Paused"], [self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"]])
        _Main_SimulationCoordinator_ModeSelector_Paused_2.setTrigger(Event("continuous", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Paused"].addTransition(_Main_SimulationCoordinator_ModeSelector_Paused_2)
        _Main_SimulationCoordinator_ModeSelector_Paused_3 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Paused"], [self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"]])
        _Main_SimulationCoordinator_ModeSelector_Paused_3.setAction(self._Main_SimulationCoordinator_ModeSelector_Paused_3_exec)
        _Main_SimulationCoordinator_ModeSelector_Paused_3.setTrigger(Event("realtime", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Paused"].addTransition(_Main_SimulationCoordinator_ModeSelector_Paused_3)
        
        # transition /Main/SimulationCoordinator/ModeSelector/Running/Continuous
        _Main_SimulationCoordinator_ModeSelector_Running_Continuous_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"], [self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_Continuous_0.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_Continuous_0_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_Continuous_0.setTrigger(Event("pause", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_Continuous_0)
        
        # transition /Main/SimulationCoordinator/ModeSelector/Running/Realtime
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"], [self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_0.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_Realtime_0_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_0.setTrigger(Event("pause", "user_input"))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_Realtime_0)
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_1 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"], [self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"]])
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_1.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_Realtime_1_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_Realtime_1.setTrigger(Event("BigStep.Finished", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_Realtime_1)
        
        # transition /Main/SimulationCoordinator/ModeSelector/Running/BigStep
        _Main_SimulationCoordinator_ModeSelector_Running_BigStep_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"], [self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_BigStep_0.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_BigStep_0_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_BigStep_0.setTrigger(Event("BigStep.Finished", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_BigStep_0)
        
        # transition /Main/SimulationCoordinator/ModeSelector/Running/SmallStep
        _Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"], [self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0.setTrigger(Event("SmallStep.Finished", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/SimulationCoordinator/ModeSelector/WaitingForPaused
        _Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"], [self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]])
        _Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0.setAction(self._Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0_exec)
        _Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0.setTrigger(Event("Simulation.Paused", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/WaitingForPaused"].addTransition(_Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0)
        
        # transition /Main/SimulationCoordinator/SmallStepState/Uninitialized
        _Main_SimulationCoordinator_SmallStepState_Uninitialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"], [self.states["/Main/SimulationCoordinator/SmallStepState/Initialized"]])
        _Main_SimulationCoordinator_SmallStepState_Uninitialized_0.setTrigger(Event("SmallStep.Initialized", None))
        self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"].addTransition(_Main_SimulationCoordinator_SmallStepState_Uninitialized_0)
        
        # transition /Main/SimulationCoordinator/SmallStepState/Initialized
        _Main_SimulationCoordinator_SmallStepState_Initialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/SmallStepState/Initialized"], [self.states["/Main/SimulationCoordinator/SmallStepState/Uninitialized"]])
        _Main_SimulationCoordinator_SmallStepState_Initialized_0.setTrigger(Event("SmallStep.Finished", None))
        self.states["/Main/SimulationCoordinator/SmallStepState/Initialized"].addTransition(_Main_SimulationCoordinator_SmallStepState_Initialized_0)
        
        # transition /Main/SimulationCoordinator/BigStepState/Uninitialized
        _Main_SimulationCoordinator_BigStepState_Uninitialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"], [self.states["/Main/SimulationCoordinator/BigStepState/Initialized"]])
        _Main_SimulationCoordinator_BigStepState_Uninitialized_0.setTrigger(Event("BigStep.Initialized", None))
        self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"].addTransition(_Main_SimulationCoordinator_BigStepState_Uninitialized_0)
        
        # transition /Main/SimulationCoordinator/BigStepState/Initialized
        _Main_SimulationCoordinator_BigStepState_Initialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/BigStepState/Initialized"], [self.states["/Main/SimulationCoordinator/BigStepState/Uninitialized"]])
        _Main_SimulationCoordinator_BigStepState_Initialized_0.setTrigger(Event("BigStep.Finished", None))
        self.states["/Main/SimulationCoordinator/BigStepState/Initialized"].addTransition(_Main_SimulationCoordinator_BigStepState_Initialized_0)
        
        # transition /Main/SimulationCoordinator/SimulationState/Uninitialized
        _Main_SimulationCoordinator_SimulationState_Uninitialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"], [self.states["/Main/SimulationCoordinator/SimulationState/Initialized"]])
        _Main_SimulationCoordinator_SimulationState_Uninitialized_0.setTrigger(Event("Simulation.Initialized", None))
        self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"].addTransition(_Main_SimulationCoordinator_SimulationState_Uninitialized_0)
        
        # transition /Main/SimulationCoordinator/SimulationState/Initialized
        _Main_SimulationCoordinator_SimulationState_Initialized_0 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationState/Initialized"], [self.states["/Main/SimulationCoordinator/SimulationState/Uninitialized"]])
        _Main_SimulationCoordinator_SimulationState_Initialized_0.setTrigger(Event("Simulation.Finished", None))
        self.states["/Main/SimulationCoordinator/SimulationState/Initialized"].addTransition(_Main_SimulationCoordinator_SimulationState_Initialized_0)
        
        # transition /Main/SimulationCoordinator/Initializer/Waiting
        _Main_SimulationCoordinator_Initializer_Waiting_0 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/Waiting"], [self.states["/Main/SimulationCoordinator/Initializer/InitializingSimulation"]])
        _Main_SimulationCoordinator_Initializer_Waiting_0.setAction(self._Main_SimulationCoordinator_Initializer_Waiting_0_exec)
        _Main_SimulationCoordinator_Initializer_Waiting_0.setTrigger(None)
        _Main_SimulationCoordinator_Initializer_Waiting_0.setGuard(self._Main_SimulationCoordinator_Initializer_Waiting_0_guard)
        self.states["/Main/SimulationCoordinator/Initializer/Waiting"].addTransition(_Main_SimulationCoordinator_Initializer_Waiting_0)
        _Main_SimulationCoordinator_Initializer_Waiting_1 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/Waiting"], [self.states["/Main/SimulationCoordinator/Initializer/InitializingBigStep"]])
        _Main_SimulationCoordinator_Initializer_Waiting_1.setAction(self._Main_SimulationCoordinator_Initializer_Waiting_1_exec)
        _Main_SimulationCoordinator_Initializer_Waiting_1.setTrigger(None)
        _Main_SimulationCoordinator_Initializer_Waiting_1.setGuard(self._Main_SimulationCoordinator_Initializer_Waiting_1_guard)
        self.states["/Main/SimulationCoordinator/Initializer/Waiting"].addTransition(_Main_SimulationCoordinator_Initializer_Waiting_1)
        _Main_SimulationCoordinator_Initializer_Waiting_2 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/Waiting"], [self.states["/Main/SimulationCoordinator/Initializer/InitializingSmallStep"]])
        _Main_SimulationCoordinator_Initializer_Waiting_2.setAction(self._Main_SimulationCoordinator_Initializer_Waiting_2_exec)
        _Main_SimulationCoordinator_Initializer_Waiting_2.setTrigger(None)
        _Main_SimulationCoordinator_Initializer_Waiting_2.setGuard(self._Main_SimulationCoordinator_Initializer_Waiting_2_guard)
        self.states["/Main/SimulationCoordinator/Initializer/Waiting"].addTransition(_Main_SimulationCoordinator_Initializer_Waiting_2)
        
        # transition /Main/SimulationCoordinator/Initializer/InitializingSimulation
        _Main_SimulationCoordinator_Initializer_InitializingSimulation_0 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/InitializingSimulation"], [self.states["/Main/SimulationCoordinator/Initializer/Waiting"]])
        _Main_SimulationCoordinator_Initializer_InitializingSimulation_0.setTrigger(Event("Simulation.Initialized", None))
        self.states["/Main/SimulationCoordinator/Initializer/InitializingSimulation"].addTransition(_Main_SimulationCoordinator_Initializer_InitializingSimulation_0)
        
        # transition /Main/SimulationCoordinator/Initializer/InitializingBigStep
        _Main_SimulationCoordinator_Initializer_InitializingBigStep_0 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/InitializingBigStep"], [self.states["/Main/SimulationCoordinator/Initializer/Waiting"]])
        _Main_SimulationCoordinator_Initializer_InitializingBigStep_0.setTrigger(Event("BigStep.Initialized", None))
        self.states["/Main/SimulationCoordinator/Initializer/InitializingBigStep"].addTransition(_Main_SimulationCoordinator_Initializer_InitializingBigStep_0)
        
        # transition /Main/SimulationCoordinator/Initializer/InitializingSmallStep
        _Main_SimulationCoordinator_Initializer_InitializingSmallStep_0 = Transition(self, self.states["/Main/SimulationCoordinator/Initializer/InitializingSmallStep"], [self.states["/Main/SimulationCoordinator/Initializer/Waiting"]])
        _Main_SimulationCoordinator_Initializer_InitializingSmallStep_0.setTrigger(Event("SmallStep.Initialized", None))
        self.states["/Main/SimulationCoordinator/Initializer/InitializingSmallStep"].addTransition(_Main_SimulationCoordinator_Initializer_InitializingSmallStep_0)
        
        # transition /Main/SimulationCoordinator/SimulationFlow/PrePaused
        _Main_SimulationCoordinator_SimulationFlow_PrePaused_0 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"]])
        _Main_SimulationCoordinator_SimulationFlow_PrePaused_0.setTrigger(Event("_0after"))
        self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"].addTransition(_Main_SimulationCoordinator_SimulationFlow_PrePaused_0)
        
        # transition /Main/SimulationCoordinator/SimulationFlow/Paused
        _Main_SimulationCoordinator_SimulationFlow_Paused_0 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"]])
        _Main_SimulationCoordinator_SimulationFlow_Paused_0.setAction(self._Main_SimulationCoordinator_SimulationFlow_Paused_0_exec)
        _Main_SimulationCoordinator_SimulationFlow_Paused_0.setTrigger(None)
        _Main_SimulationCoordinator_SimulationFlow_Paused_0.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Paused_0_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Paused_0)
        _Main_SimulationCoordinator_SimulationFlow_Paused_1 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"]])
        _Main_SimulationCoordinator_SimulationFlow_Paused_1.setAction(self._Main_SimulationCoordinator_SimulationFlow_Paused_1_exec)
        _Main_SimulationCoordinator_SimulationFlow_Paused_1.setTrigger(None)
        _Main_SimulationCoordinator_SimulationFlow_Paused_1.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Paused_1_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Paused_1)
        _Main_SimulationCoordinator_SimulationFlow_Paused_2 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"]])
        _Main_SimulationCoordinator_SimulationFlow_Paused_2.setAction(self._Main_SimulationCoordinator_SimulationFlow_Paused_2_exec)
        _Main_SimulationCoordinator_SimulationFlow_Paused_2.setTrigger(None)
        _Main_SimulationCoordinator_SimulationFlow_Paused_2.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Paused_2_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Paused_2)
        _Main_SimulationCoordinator_SimulationFlow_Paused_3 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"]])
        _Main_SimulationCoordinator_SimulationFlow_Paused_3.setAction(self._Main_SimulationCoordinator_SimulationFlow_Paused_3_exec)
        _Main_SimulationCoordinator_SimulationFlow_Paused_3.setTrigger(None)
        _Main_SimulationCoordinator_SimulationFlow_Paused_3.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Paused_3_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Paused_3)
        
        # transition /Main/SimulationCoordinator/SimulationFlow/Executing
        _Main_SimulationCoordinator_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"], [self.states["/Main/SimulationCoordinator/SimulationFlow/Paused"]])
        _Main_SimulationCoordinator_SimulationFlow_Executing_0.setTrigger(None)
        _Main_SimulationCoordinator_SimulationFlow_Executing_0.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Executing_0_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Executing_0)
        _Main_SimulationCoordinator_SimulationFlow_Executing_1 = Transition(self, self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"], [self.states["/Main/SimulationCoordinator/SimulationFlow/PrePaused"]])
        _Main_SimulationCoordinator_SimulationFlow_Executing_1.setTrigger(Event("Simulation.Finished", None))
        _Main_SimulationCoordinator_SimulationFlow_Executing_1.setGuard(self._Main_SimulationCoordinator_SimulationFlow_Executing_1_guard)
        self.states["/Main/SimulationCoordinator/SimulationFlow/Executing"].addTransition(_Main_SimulationCoordinator_SimulationFlow_Executing_1)
        
        # transition /Main/SimulationCoordinator/GodEventManager/Listening
        _Main_SimulationCoordinator_GodEventManager_Listening_0 = Transition(self, self.states["/Main/SimulationCoordinator/GodEventManager/Listening"], [self.states["/Main/SimulationCoordinator/GodEventManager/Listening"]])
        _Main_SimulationCoordinator_GodEventManager_Listening_0.setAction(self._Main_SimulationCoordinator_GodEventManager_Listening_0_exec)
        _Main_SimulationCoordinator_GodEventManager_Listening_0.setTrigger(Event("god_event", "user_input"))
        _Main_SimulationCoordinator_GodEventManager_Listening_0.setGuard(self._Main_SimulationCoordinator_GodEventManager_Listening_0_guard)
        self.states["/Main/SimulationCoordinator/GodEventManager/Listening"].addTransition(_Main_SimulationCoordinator_GodEventManager_Listening_0)
        
        # transition /Main/SimulationCoordinator/BreakpointManager/Listening
        _Main_SimulationCoordinator_BreakpointManager_Listening_0 = Transition(self, self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"], [self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"]])
        _Main_SimulationCoordinator_BreakpointManager_Listening_0.setAction(self._Main_SimulationCoordinator_BreakpointManager_Listening_0_exec)
        _Main_SimulationCoordinator_BreakpointManager_Listening_0.setTrigger(Event("add_breakpoint", "user_input"))
        self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"].addTransition(_Main_SimulationCoordinator_BreakpointManager_Listening_0)
        _Main_SimulationCoordinator_BreakpointManager_Listening_1 = Transition(self, self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"], [self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"]])
        _Main_SimulationCoordinator_BreakpointManager_Listening_1.setAction(self._Main_SimulationCoordinator_BreakpointManager_Listening_1_exec)
        _Main_SimulationCoordinator_BreakpointManager_Listening_1.setTrigger(Event("del_breakpoint", "user_input"))
        self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"].addTransition(_Main_SimulationCoordinator_BreakpointManager_Listening_1)
        _Main_SimulationCoordinator_BreakpointManager_Listening_2 = Transition(self, self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"], [self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"]])
        _Main_SimulationCoordinator_BreakpointManager_Listening_2.setAction(self._Main_SimulationCoordinator_BreakpointManager_Listening_2_exec)
        _Main_SimulationCoordinator_BreakpointManager_Listening_2.setTrigger(Event("toggle_breakpoint", "user_input"))
        self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"].addTransition(_Main_SimulationCoordinator_BreakpointManager_Listening_2)
        _Main_SimulationCoordinator_BreakpointManager_Listening_3 = Transition(self, self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"], [self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"]])
        _Main_SimulationCoordinator_BreakpointManager_Listening_3.setAction(self._Main_SimulationCoordinator_BreakpointManager_Listening_3_exec)
        _Main_SimulationCoordinator_BreakpointManager_Listening_3.setTrigger(Event("list_breakpoints", "user_input"))
        self.states["/Main/SimulationCoordinator/BreakpointManager/Listening"].addTransition(_Main_SimulationCoordinator_BreakpointManager_Listening_3)
        
        # transition /Main/ExecuteSimulation/SimulationState/Continuous
        _Main_ExecuteSimulation_SimulationState_Continuous_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Continuous"], [self.states["/Main/ExecuteSimulation/SimulationState/Paused"]])
        _Main_ExecuteSimulation_SimulationState_Continuous_0.setTrigger(Event("Simulation.Pause", None))
        self.states["/Main/ExecuteSimulation/SimulationState/Continuous"].addTransition(_Main_ExecuteSimulation_SimulationState_Continuous_0)
        _Main_ExecuteSimulation_SimulationState_Continuous_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Continuous"], [self.states["/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered"]])
        _Main_ExecuteSimulation_SimulationState_Continuous_1.setAction(self._Main_ExecuteSimulation_SimulationState_Continuous_1_exec)
        _Main_ExecuteSimulation_SimulationState_Continuous_1.setTrigger(None)
        _Main_ExecuteSimulation_SimulationState_Continuous_1.setGuard(self._Main_ExecuteSimulation_SimulationState_Continuous_1_guard)
        self.states["/Main/ExecuteSimulation/SimulationState/Continuous"].addTransition(_Main_ExecuteSimulation_SimulationState_Continuous_1)
        
        # transition /Main/ExecuteSimulation/SimulationState/Realtime
        _Main_ExecuteSimulation_SimulationState_Realtime_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Realtime"], [self.states["/Main/ExecuteSimulation/SimulationState/Paused"]])
        _Main_ExecuteSimulation_SimulationState_Realtime_0.setTrigger(Event("Simulation.Pause", None))
        self.states["/Main/ExecuteSimulation/SimulationState/Realtime"].addTransition(_Main_ExecuteSimulation_SimulationState_Realtime_0)
        _Main_ExecuteSimulation_SimulationState_Realtime_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Realtime"], [self.states["/Main/ExecuteSimulation/SimulationState/Paused/BreakpointTriggered"]])
        _Main_ExecuteSimulation_SimulationState_Realtime_1.setAction(self._Main_ExecuteSimulation_SimulationState_Realtime_1_exec)
        _Main_ExecuteSimulation_SimulationState_Realtime_1.setTrigger(None)
        _Main_ExecuteSimulation_SimulationState_Realtime_1.setGuard(self._Main_ExecuteSimulation_SimulationState_Realtime_1_guard)
        self.states["/Main/ExecuteSimulation/SimulationState/Realtime"].addTransition(_Main_ExecuteSimulation_SimulationState_Realtime_1)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/Stopped
        _Main_ExecuteSimulation_SimulationFlow_Stopped_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"], [self.states["/Main/ExecuteSimulation/SimulationFlow/Started"]])
        _Main_ExecuteSimulation_SimulationFlow_Stopped_0.setTrigger(Event("Simulation.Reset", None))
        self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"].addTransition(_Main_ExecuteSimulation_SimulationFlow_Stopped_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/Started
        _Main_ExecuteSimulation_SimulationFlow_Started_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/Started"], [self.states["/Main/ExecuteSimulation/SimulationFlow/Initialized"]])
        _Main_ExecuteSimulation_SimulationFlow_Started_0.setAction(self._Main_ExecuteSimulation_SimulationFlow_Started_0_exec)
        _Main_ExecuteSimulation_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/ExecuteSimulation/SimulationFlow/Started"].addTransition(_Main_ExecuteSimulation_SimulationFlow_Started_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/Initialized
        _Main_ExecuteSimulation_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/Initialized"], [self.states["/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger"]])
        _Main_ExecuteSimulation_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/ExecuteSimulation/SimulationFlow/Initialized"].addTransition(_Main_ExecuteSimulation_SimulationFlow_Initialized_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/InitializeDebugger
        _Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger"], [self.states["/Main/ExecuteSimulation/SimulationFlow/Waiting"]])
        _Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0.setAction(self._Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0_exec)
        _Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/ExecuteSimulation/SimulationFlow/InitializeDebugger"].addTransition(_Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/Waiting
        _Main_ExecuteSimulation_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/Waiting"], [self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_Waiting_0.setTrigger(None)
        self.states["/Main/ExecuteSimulation/SimulationFlow/Waiting"].addTransition(_Main_ExecuteSimulation_SimulationFlow_Waiting_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_0)
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1.setAction(self._Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1_exec)
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1.setGuard(self._Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/CheckTermination
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"], [self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"]])
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0.setAction(self._Main_ExecuteSimulation_SimulationFlow_CheckTermination_0_exec)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0.setGuard(self._Main_ExecuteSimulation_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"].addTransition(_Main_ExecuteSimulation_SimulationFlow_CheckTermination_0)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"], [self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"]])
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_1.setGuard(self._Main_ExecuteSimulation_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"].addTransition(_Main_ExecuteSimulation_SimulationFlow_CheckTermination_1)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"], [self.states["/Main/ExecuteSimulation/SimulationFlow/Stopped"]])
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2.setAction(self._Main_ExecuteSimulation_SimulationFlow_CheckTermination_2_exec)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2.setGuard(self._Main_ExecuteSimulation_SimulationFlow_CheckTermination_2_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"].addTransition(_Main_ExecuteSimulation_SimulationFlow_CheckTermination_2)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/WaitingRealtime
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"], [self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0.setAction(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0_exec)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0.setTrigger(Event("_2after"))
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"].addTransition(_Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"], [self.states["/Main/ExecuteSimulation/SimulationFlow/CheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1.setAction(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1_exec)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1.setGuard(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"].addTransition(_Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"], [self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"]])
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2.setAction(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2_exec)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2.setTrigger(None)
        _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2.setGuard(self._Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2_guard)
        self.states["/Main/ExecuteSimulation/SimulationFlow/WaitingRealtime"].addTransition(_Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/InitializingBigStep
        _Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"], [self.states["/Main/ExecuteSimulation/SimulationFlow/Executing"]])
        _Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0.setAction(self._Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0_exec)
        _Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0.setTrigger(Event("BigStep.Initialized", None))
        self.states["/Main/ExecuteSimulation/SimulationFlow/InitializingBigStep"].addTransition(_Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0)
        
        # transition /Main/ExecuteSimulation/SimulationFlow/Executing
        _Main_ExecuteSimulation_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationFlow/Executing"], [self.states["/Main/ExecuteSimulation/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_ExecuteSimulation_SimulationFlow_Executing_0.setTrigger(Event("BigStep.Finished", None))
        self.states["/Main/ExecuteSimulation/SimulationFlow/Executing"].addTransition(_Main_ExecuteSimulation_SimulationFlow_Executing_0)
        
        # transition /Main/ExecuteBigStep/Stopped
        _Main_ExecuteBigStep_Stopped_0 = Transition(self, self.states["/Main/ExecuteBigStep/Stopped"], [self.states["/Main/ExecuteBigStep/Started"]])
        _Main_ExecuteBigStep_Stopped_0.setTrigger(Event("BigStep.Reset", None))
        self.states["/Main/ExecuteBigStep/Stopped"].addTransition(_Main_ExecuteBigStep_Stopped_0)
        
        # transition /Main/ExecuteBigStep/Started
        _Main_ExecuteBigStep_Started_0 = Transition(self, self.states["/Main/ExecuteBigStep/Started"], [self.states["/Main/ExecuteBigStep/Initialized"]])
        _Main_ExecuteBigStep_Started_0.setAction(self._Main_ExecuteBigStep_Started_0_exec)
        _Main_ExecuteBigStep_Started_0.setTrigger(None)
        self.states["/Main/ExecuteBigStep/Started"].addTransition(_Main_ExecuteBigStep_Started_0)
        
        # transition /Main/ExecuteBigStep/Initialized
        _Main_ExecuteBigStep_Initialized_0 = Transition(self, self.states["/Main/ExecuteBigStep/Initialized"], [self.states["/Main/ExecuteBigStep/InitializeDebugger"]])
        _Main_ExecuteBigStep_Initialized_0.setTrigger(None)
        self.states["/Main/ExecuteBigStep/Initialized"].addTransition(_Main_ExecuteBigStep_Initialized_0)
        
        # transition /Main/ExecuteBigStep/InitializeDebugger
        _Main_ExecuteBigStep_InitializeDebugger_0 = Transition(self, self.states["/Main/ExecuteBigStep/InitializeDebugger"], [self.states["/Main/ExecuteBigStep/Waiting"]])
        _Main_ExecuteBigStep_InitializeDebugger_0.setAction(self._Main_ExecuteBigStep_InitializeDebugger_0_exec)
        _Main_ExecuteBigStep_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/ExecuteBigStep/InitializeDebugger"].addTransition(_Main_ExecuteBigStep_InitializeDebugger_0)
        
        # transition /Main/ExecuteBigStep/Waiting
        _Main_ExecuteBigStep_Waiting_0 = Transition(self, self.states["/Main/ExecuteBigStep/Waiting"], [self.states["/Main/ExecuteBigStep/CheckTermination"]])
        _Main_ExecuteBigStep_Waiting_0.setTrigger(Event("BigStep.Execute", None))
        self.states["/Main/ExecuteBigStep/Waiting"].addTransition(_Main_ExecuteBigStep_Waiting_0)
        _Main_ExecuteBigStep_Waiting_1 = Transition(self, self.states["/Main/ExecuteBigStep/Waiting"], [self.states["/Main/ExecuteBigStep/Stopped"]])
        _Main_ExecuteBigStep_Waiting_1.setAction(self._Main_ExecuteBigStep_Waiting_1_exec)
        _Main_ExecuteBigStep_Waiting_1.setTrigger(None)
        _Main_ExecuteBigStep_Waiting_1.setGuard(self._Main_ExecuteBigStep_Waiting_1_guard)
        self.states["/Main/ExecuteBigStep/Waiting"].addTransition(_Main_ExecuteBigStep_Waiting_1)
        
        # transition /Main/ExecuteBigStep/SettleBeforeCheckTermination
        _Main_ExecuteBigStep_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"], [self.states["/Main/ExecuteBigStep/CheckTermination"]])
        _Main_ExecuteBigStep_SettleBeforeCheckTermination_0.setTrigger(Event("_3after"))
        self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"].addTransition(_Main_ExecuteBigStep_SettleBeforeCheckTermination_0)
        
        # transition /Main/ExecuteBigStep/CheckTermination
        _Main_ExecuteBigStep_CheckTermination_0 = Transition(self, self.states["/Main/ExecuteBigStep/CheckTermination"], [self.states["/Main/ExecuteBigStep/InitializingSmallStep"]])
        _Main_ExecuteBigStep_CheckTermination_0.setAction(self._Main_ExecuteBigStep_CheckTermination_0_exec)
        _Main_ExecuteBigStep_CheckTermination_0.setTrigger(None)
        _Main_ExecuteBigStep_CheckTermination_0.setGuard(self._Main_ExecuteBigStep_CheckTermination_0_guard)
        self.states["/Main/ExecuteBigStep/CheckTermination"].addTransition(_Main_ExecuteBigStep_CheckTermination_0)
        _Main_ExecuteBigStep_CheckTermination_1 = Transition(self, self.states["/Main/ExecuteBigStep/CheckTermination"], [self.states["/Main/ExecuteBigStep/Stopped"]])
        _Main_ExecuteBigStep_CheckTermination_1.setAction(self._Main_ExecuteBigStep_CheckTermination_1_exec)
        _Main_ExecuteBigStep_CheckTermination_1.setTrigger(None)
        _Main_ExecuteBigStep_CheckTermination_1.setGuard(self._Main_ExecuteBigStep_CheckTermination_1_guard)
        self.states["/Main/ExecuteBigStep/CheckTermination"].addTransition(_Main_ExecuteBigStep_CheckTermination_1)
        
        # transition /Main/ExecuteBigStep/InitializingSmallStep
        _Main_ExecuteBigStep_InitializingSmallStep_0 = Transition(self, self.states["/Main/ExecuteBigStep/InitializingSmallStep"], [self.states["/Main/ExecuteBigStep/Executing"]])
        _Main_ExecuteBigStep_InitializingSmallStep_0.setAction(self._Main_ExecuteBigStep_InitializingSmallStep_0_exec)
        _Main_ExecuteBigStep_InitializingSmallStep_0.setTrigger(Event("SmallStep.Initialized", None))
        self.states["/Main/ExecuteBigStep/InitializingSmallStep"].addTransition(_Main_ExecuteBigStep_InitializingSmallStep_0)
        
        # transition /Main/ExecuteBigStep/Executing
        _Main_ExecuteBigStep_Executing_0 = Transition(self, self.states["/Main/ExecuteBigStep/Executing"], [self.states["/Main/ExecuteBigStep/SettleBeforeCheckTermination"]])
        _Main_ExecuteBigStep_Executing_0.setTrigger(Event("SmallStep.Finished", None))
        self.states["/Main/ExecuteBigStep/Executing"].addTransition(_Main_ExecuteBigStep_Executing_0)
        
        # transition /Main/ExecuteSmallStep/Stopped
        _Main_ExecuteSmallStep_Stopped_0 = Transition(self, self.states["/Main/ExecuteSmallStep/Stopped"], [self.states["/Main/ExecuteSmallStep/Started"]])
        _Main_ExecuteSmallStep_Stopped_0.setTrigger(Event("SmallStep.Reset", None))
        self.states["/Main/ExecuteSmallStep/Stopped"].addTransition(_Main_ExecuteSmallStep_Stopped_0)
        
        # transition /Main/ExecuteSmallStep/Started
        _Main_ExecuteSmallStep_Started_0 = Transition(self, self.states["/Main/ExecuteSmallStep/Started"], [self.states["/Main/ExecuteSmallStep/Initialized"]])
        _Main_ExecuteSmallStep_Started_0.setAction(self._Main_ExecuteSmallStep_Started_0_exec)
        _Main_ExecuteSmallStep_Started_0.setTrigger(None)
        self.states["/Main/ExecuteSmallStep/Started"].addTransition(_Main_ExecuteSmallStep_Started_0)
        
        # transition /Main/ExecuteSmallStep/Initialized
        _Main_ExecuteSmallStep_Initialized_0 = Transition(self, self.states["/Main/ExecuteSmallStep/Initialized"], [self.states["/Main/ExecuteSmallStep/InitializeDebugger"]])
        _Main_ExecuteSmallStep_Initialized_0.setTrigger(None)
        self.states["/Main/ExecuteSmallStep/Initialized"].addTransition(_Main_ExecuteSmallStep_Initialized_0)
        
        # transition /Main/ExecuteSmallStep/InitializeDebugger
        _Main_ExecuteSmallStep_InitializeDebugger_0 = Transition(self, self.states["/Main/ExecuteSmallStep/InitializeDebugger"], [self.states["/Main/ExecuteSmallStep/Waiting"]])
        _Main_ExecuteSmallStep_InitializeDebugger_0.setAction(self._Main_ExecuteSmallStep_InitializeDebugger_0_exec)
        _Main_ExecuteSmallStep_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/ExecuteSmallStep/InitializeDebugger"].addTransition(_Main_ExecuteSmallStep_InitializeDebugger_0)
        
        # transition /Main/ExecuteSmallStep/Waiting
        _Main_ExecuteSmallStep_Waiting_0 = Transition(self, self.states["/Main/ExecuteSmallStep/Waiting"], [self.states["/Main/ExecuteSmallStep/CheckTermination"]])
        _Main_ExecuteSmallStep_Waiting_0.setTrigger(Event("SmallStep.Execute", None))
        self.states["/Main/ExecuteSmallStep/Waiting"].addTransition(_Main_ExecuteSmallStep_Waiting_0)
        
        # transition /Main/ExecuteSmallStep/SettleBeforeCheckTermination
        _Main_ExecuteSmallStep_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"], [self.states["/Main/ExecuteSmallStep/CheckTermination"]])
        _Main_ExecuteSmallStep_SettleBeforeCheckTermination_0.setTrigger(Event("_4after"))
        self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"].addTransition(_Main_ExecuteSmallStep_SettleBeforeCheckTermination_0)
        
        # transition /Main/ExecuteSmallStep/CheckTermination
        _Main_ExecuteSmallStep_CheckTermination_0 = Transition(self, self.states["/Main/ExecuteSmallStep/CheckTermination"], [self.states["/Main/ExecuteSmallStep/Executing"]])
        _Main_ExecuteSmallStep_CheckTermination_0.setTrigger(None)
        _Main_ExecuteSmallStep_CheckTermination_0.setGuard(self._Main_ExecuteSmallStep_CheckTermination_0_guard)
        self.states["/Main/ExecuteSmallStep/CheckTermination"].addTransition(_Main_ExecuteSmallStep_CheckTermination_0)
        _Main_ExecuteSmallStep_CheckTermination_1 = Transition(self, self.states["/Main/ExecuteSmallStep/CheckTermination"], [self.states["/Main/ExecuteSmallStep/Stopped"]])
        _Main_ExecuteSmallStep_CheckTermination_1.setAction(self._Main_ExecuteSmallStep_CheckTermination_1_exec)
        _Main_ExecuteSmallStep_CheckTermination_1.setTrigger(None)
        _Main_ExecuteSmallStep_CheckTermination_1.setGuard(self._Main_ExecuteSmallStep_CheckTermination_1_guard)
        self.states["/Main/ExecuteSmallStep/CheckTermination"].addTransition(_Main_ExecuteSmallStep_CheckTermination_1)
        
        # transition /Main/ExecuteSmallStep/Executing
        _Main_ExecuteSmallStep_Executing_0 = Transition(self, self.states["/Main/ExecuteSmallStep/Executing"], [self.states["/Main/ExecuteSmallStep/SettleBeforeCheckTermination"]])
        _Main_ExecuteSmallStep_Executing_0.setAction(self._Main_ExecuteSmallStep_Executing_0_exec)
        _Main_ExecuteSmallStep_Executing_0.setTrigger(Event("Block.Finished", None))
        self.states["/Main/ExecuteSmallStep/Executing"].addTransition(_Main_ExecuteSmallStep_Executing_0)
        
        # transition /Main/ExecuteBlock/Waiting
        _Main_ExecuteBlock_Waiting_0 = Transition(self, self.states["/Main/ExecuteBlock/Waiting"], [self.states["/Main/ExecuteBlock/Waiting"]])
        _Main_ExecuteBlock_Waiting_0.setAction(self._Main_ExecuteBlock_Waiting_0_exec)
        _Main_ExecuteBlock_Waiting_0.setTrigger(Event("Block.Execute", None))
        self.states["/Main/ExecuteBlock/Waiting"].addTransition(_Main_ExecuteBlock_Waiting_0)
        
        # transition /Main/SimulationCoordinator/ModeSelector/Running
        _Main_SimulationCoordinator_ModeSelector_Running_0 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running"], [self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_0.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_0_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_0.setTrigger(Event("Simulation.Finished", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_0)
        _Main_SimulationCoordinator_ModeSelector_Running_1 = Transition(self, self.states["/Main/SimulationCoordinator/ModeSelector/Running"], [self.states["/Main/SimulationCoordinator/ModeSelector/Paused"]])
        _Main_SimulationCoordinator_ModeSelector_Running_1.setAction(self._Main_SimulationCoordinator_ModeSelector_Running_1_exec)
        _Main_SimulationCoordinator_ModeSelector_Running_1.setTrigger(Event("Breakpoint.Triggered", None))
        self.states["/Main/SimulationCoordinator/ModeSelector/Running"].addTransition(_Main_SimulationCoordinator_ModeSelector_Running_1)
        
        # transition /Main/ExecuteSimulation/SimulationState/Paused
        _Main_ExecuteSimulation_SimulationState_Paused_0 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Paused"], [self.states["/Main/ExecuteSimulation/SimulationState/Continuous"]])
        _Main_ExecuteSimulation_SimulationState_Paused_0.setTrigger(Event("Simulation.Execute", None))
        self.states["/Main/ExecuteSimulation/SimulationState/Paused"].addTransition(_Main_ExecuteSimulation_SimulationState_Paused_0)
        _Main_ExecuteSimulation_SimulationState_Paused_1 = Transition(self, self.states["/Main/ExecuteSimulation/SimulationState/Paused"], [self.states["/Main/ExecuteSimulation/SimulationState/Realtime"]])
        _Main_ExecuteSimulation_SimulationState_Paused_1.setAction(self._Main_ExecuteSimulation_SimulationState_Paused_1_exec)
        _Main_ExecuteSimulation_SimulationState_Paused_1.setTrigger(Event("Simulation.ExecuteRealtime", None))
        self.states["/Main/ExecuteSimulation/SimulationState/Paused"].addTransition(_Main_ExecuteSimulation_SimulationState_Paused_1)
    
    def _Main_SimulationCoordinator_SimulationFlow_PrePaused_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_SimulationCoordinator_SimulationFlow_PrePaused_exit(self):
        self.removeTimer(0)
    
    def _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_enter(self):
        self.addTimer(2, self.sccd_yield())
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_exit(self):
        self.removeTimer(2)
    
    def _Main_ExecuteBigStep_SettleBeforeCheckTermination_enter(self):
        self.addTimer(3, self.sccd_yield())
    
    def _Main_ExecuteBigStep_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(3)
    
    def _Main_ExecuteSmallStep_SettleBeforeCheckTermination_enter(self):
        self.addTimer(4, self.sccd_yield())
    
    def _Main_ExecuteSmallStep_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(4)
    
    def _Main_ExecuteSmallStep_Executing_enter(self):
        self.raiseInternalEvent(Event("Block.Execute", None, []))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_0_exec(self, parameters):
        self.big_step.outputEvent(Event("Simulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_1_exec(self, parameters):
        self.big_step.outputEvent(Event("Breakpoint.Triggered", "user_output", [self.triggered_bp]))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_ExecuteSimulation_SimulationState_Paused_1_exec(self, parameters):
        realtime_scale = parameters[0]
        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)
    
    def _Main_SimulationCoordinator_ModeSelector_Paused_3_exec(self, parameters):
        realtime_scale = parameters[0]
        self.realtime_scale = realtime_scale
    
    def _Main_SimulationCoordinator_ModeSelector_Running_Continuous_0_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Pause", None, []))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_Realtime_0_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Pause", None, []))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_Realtime_1_exec(self, parameters):
        self.big_step.outputEvent(Event("BigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_BigStep_0_exec(self, parameters):
        self.big_step.outputEvent(Event("BigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_SimulationCoordinator_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        self.big_step.outputEvent(Event("SmallStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_SimulationCoordinator_ModeSelector_WaitingForPaused_0_exec(self, parameters):
        self.big_step.outputEvent(Event("Simulation.Paused", "user_output", []))
        self.big_step.outputEvent(Event("State", "user_output", [self.clock / 1000.0]))
    
    def _Main_SimulationCoordinator_Initializer_Waiting_0_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Reset", None, []))
    
    def _Main_SimulationCoordinator_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/SimulationState/Uninitialized"])
    
    def _Main_SimulationCoordinator_Initializer_Waiting_1_exec(self, parameters):
        self.raiseInternalEvent(Event("BigStep.Reset", None, []))
    
    def _Main_SimulationCoordinator_Initializer_Waiting_1_guard(self, parameters):
        return (self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"]) or self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"])) and self.inState(["/Main/SimulationCoordinator/SimulationState/Initialized"]) and self.inState(["/Main/SimulationCoordinator/BigStepState/Uninitialized"])
    
    def _Main_SimulationCoordinator_Initializer_Waiting_2_exec(self, parameters):
        self.raiseInternalEvent(Event("SmallStep.Reset", None, []))
    
    def _Main_SimulationCoordinator_Initializer_Waiting_2_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"]) and self.inState(["/Main/SimulationCoordinator/BigStepState/Initialized"]) and self.inState(["/Main/SimulationCoordinator/SmallStepState/Uninitialized"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_0_exec(self, parameters):
        self.raiseInternalEvent(Event("SmallStep.Execute", None, []))
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_0_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/SmallStep"]) and self.inState(["/Main/SimulationCoordinator/SmallStepState/Initialized"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_1_exec(self, parameters):
        self.raiseInternalEvent(Event("BigStep.Execute", None, []))
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_1_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/BigStep"]) and self.inState(["/Main/SimulationCoordinator/BigStepState/Initialized"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_2_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Execute", None, []))
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_2_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"]) and self.inState(["/Main/SimulationCoordinator/SimulationState/Initialized"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_3_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.ExecuteRealtime", None, [self.realtime_scale]))
    
    def _Main_SimulationCoordinator_SimulationFlow_Paused_3_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"]) and self.inState(["/Main/SimulationCoordinator/SimulationState/Initialized"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Executing_0_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Paused"])
    
    def _Main_SimulationCoordinator_SimulationFlow_Executing_1_guard(self, parameters):
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/Continuous"]) or self.inState(["/Main/SimulationCoordinator/ModeSelector/Running/Realtime"])
    
    def _Main_SimulationCoordinator_GodEventManager_Listening_0_exec(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        result = self.godEvent(block_name, new_val)
        self.big_step.outputEvent(Event("god_event_result", "user_output", [result]))
    
    def _Main_SimulationCoordinator_GodEventManager_Listening_0_guard(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        return self.inState(["/Main/SimulationCoordinator/ModeSelector/Paused"])
    
    def _Main_SimulationCoordinator_BreakpointManager_Listening_0_exec(self, parameters):
        name = parameters[0]
        function = parameters[1]
        enabled = parameters[2]
        disable_on_trigger = parameters[3]
        result = self.addBreakpoint(name, function, bool(enabled), bool(disable_on_trigger))
        self.big_step.outputEvent(Event("add_breakpoint_result", "user_output", [result]))
    
    def _Main_SimulationCoordinator_BreakpointManager_Listening_1_exec(self, parameters):
        name = parameters[0]
        result = self.delBreakpoint(name)
        self.big_step.outputEvent(Event("del_breakpoint_result", "user_output", [result]))
    
    def _Main_SimulationCoordinator_BreakpointManager_Listening_2_exec(self, parameters):
        name = parameters[0]
        result = self.toggleBreakpoint(name)
        self.big_step.outputEvent(Event("toggle_breakpoint_result", "user_output", [result]))
    
    def _Main_SimulationCoordinator_BreakpointManager_Listening_3_exec(self, parameters):
        self.big_step.outputEvent(Event("list_breakpoints_result", "user_output", [[bp.name for bp in self.breakpoints]]))
    
    def _Main_ExecuteSimulation_SimulationState_Continuous_1_exec(self, parameters):
        self.raiseInternalEvent(Event("Breakpoint.Triggered", None, []))
    
    def _Main_ExecuteSimulation_SimulationState_Continuous_1_guard(self, parameters):
        return self.breakpointTriggers(False)
    
    def _Main_ExecuteSimulation_SimulationState_Realtime_1_exec(self, parameters):
        self.raiseInternalEvent(Event("Breakpoint.Triggered", None, []))
    
    def _Main_ExecuteSimulation_SimulationState_Realtime_1_guard(self, parameters):
        return self.breakpointTriggers(True)
    
    def _Main_ExecuteSimulation_SimulationFlow_Started_0_exec(self, parameters):
        self.initializeSimulation()
    
    def _Main_ExecuteSimulation_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeSimulationDebugger()
        self.raiseInternalEvent(Event("Simulation.Initialized", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Paused", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_SettleBeforeCheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ExecuteSimulation/SimulationState/Paused"])
    
    def _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.raiseInternalEvent(Event("BigStep.Reset", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return self.inState(["/Main/ExecuteSimulation/SimulationState/Continuous"]) and not self.endConditionSimulation()
    
    def _Main_ExecuteSimulation_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ExecuteSimulation/SimulationState/Realtime"]) and not self.endConditionSimulation()
    
    def _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2_exec(self, parameters):
        print 'simulation executed'
        self.finalizeSimulation()
        self.raiseInternalEvent(Event("Simulation.Finished", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_CheckTermination_2_guard(self, parameters):
        return self.endConditionSimulation()
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_0_exec(self, parameters):
        self.syncSimulatedTime()
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1_exec(self, parameters):
        self.raiseInternalEvent(Event("Simulation.Paused", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_1_guard(self, parameters):
        return self.inState(["/Main/ExecuteSimulation/SimulationState/Paused"])
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2_exec(self, parameters):
        self.raiseInternalEvent(Event("BigStep.Reset", None, []))
    
    def _Main_ExecuteSimulation_SimulationFlow_WaitingRealtime_2_guard(self, parameters):
        return self.waitTime() / 1000.0 <= self.sccd_yield()
    
    def _Main_ExecuteSimulation_SimulationFlow_InitializingBigStep_0_exec(self, parameters):
        self.raiseInternalEvent(Event("BigStep.Execute", None, []))
    
    def _Main_ExecuteBigStep_Started_0_exec(self, parameters):
        self.initializeBigStep()
    
    def _Main_ExecuteBigStep_InitializeDebugger_0_exec(self, parameters):
        self.initializeBigStepDebugger()
        self.raiseInternalEvent(Event("BigStep.Initialized", None, []))
    
    def _Main_ExecuteBigStep_Waiting_1_exec(self, parameters):
        print 'big step executed'
        self.finalizeBigStep()
        self.raiseInternalEvent(Event("BigStep.Finished", None, []))
    
    def _Main_ExecuteBigStep_Waiting_1_guard(self, parameters):
        return self.endConditionBigStep()
    
    def _Main_ExecuteBigStep_CheckTermination_0_exec(self, parameters):
        self.raiseInternalEvent(Event("SmallStep.Reset", None, []))
    
    def _Main_ExecuteBigStep_CheckTermination_0_guard(self, parameters):
        return not self.endConditionBigStep()
    
    def _Main_ExecuteBigStep_CheckTermination_1_exec(self, parameters):
        print 'big step executed'
        self.finalizeBigStep()
        self.raiseInternalEvent(Event("BigStep.Finished", None, []))
    
    def _Main_ExecuteBigStep_CheckTermination_1_guard(self, parameters):
        return self.endConditionBigStep()
    
    def _Main_ExecuteBigStep_InitializingSmallStep_0_exec(self, parameters):
        self.raiseInternalEvent(Event("SmallStep.Execute", None, []))
    
    def _Main_ExecuteSmallStep_Started_0_exec(self, parameters):
        self.initializeSmallStep()
    
    def _Main_ExecuteSmallStep_InitializeDebugger_0_exec(self, parameters):
        self.initializeSmallStepDebugger()
        self.raiseInternalEvent(Event("SmallStep.Initialized", None, []))
    
    def _Main_ExecuteSmallStep_CheckTermination_0_guard(self, parameters):
        return not self.endConditionSmallStep()
    
    def _Main_ExecuteSmallStep_CheckTermination_1_exec(self, parameters):
        print 'small step executed'
        self.finalizeSmallStep()
        self.raiseInternalEvent(Event("SmallStep.Finished", None, []))
    
    def _Main_ExecuteSmallStep_CheckTermination_1_guard(self, parameters):
        return self.endConditionSmallStep()
    
    def _Main_ExecuteSmallStep_Executing_0_exec(self, parameters):
        self.small_step_executed = True
    
    def _Main_ExecuteBlock_Waiting_0_exec(self, parameters):
        self.computeBlock()
        self.raiseInternalEvent(Event("Block.Finished", None, []))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

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 = {}
        else:
            raise Exception("Cannot instantiate class " + class_name)
        return instance

class Controller(ThreadsControllerBase):
    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.addInputPort("user_input")
        self.addInputPort("user_output")
        self.object_manager.createInstance("CBDSimulator", [options, model])