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

Date:   Wed Nov 30 17:39:12 2016

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

from sccd.runtime.statecharts_core import *
from sccd.runtime.libs.ui import *
from sccd.runtime.libs.utils import *
import copy
from CBD_Controller import CBDController
import Options
from fsa_cbd_woven_classes import CBDState
from woven_cbd_fsa_lib import FSACBDLib

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 "FSASimulator_Coordinator"

class WovenSimulator_Coordinator(RuntimeClassBase):
    def __init__(self, controller, woven_model, fsa_events, cbd_options):
        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()
        
        # call user defined constructor
        WovenSimulator_Coordinator.user_defined_constructor(self, woven_model, fsa_events, cbd_options)
    
    def user_defined_constructor(self, woven_model, fsa_events, cbd_options):
        self.woven_model = woven_model
        self.fsa_events = fsa_events
        self.fsa_delta = 1.0 * 1000
        self.cbd_options = cbd_options
    
    def user_defined_destructor(self):
        pass
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/WaitingForStepIntoSuccess
        self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"] = State(4, "/Main/ModeSelector/WaitingForStepIntoSuccess", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(5, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(6, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ModeSelector/Running/Realtime
        self.states["/Main/ModeSelector/Running/Realtime"] = State(7, "/Main/ModeSelector/Running/Realtime", self)
        
        # state /Main/ModeSelector/Running/BigStep
        self.states["/Main/ModeSelector/Running/BigStep"] = State(8, "/Main/ModeSelector/Running/BigStep", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(9, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ModeSelector/Running/StepInto
        self.states["/Main/ModeSelector/Running/StepInto"] = State(10, "/Main/ModeSelector/Running/StepInto", self)
        
        # state /Main/ModeSelector/Running/StepInto/Paused
        self.states["/Main/ModeSelector/Running/StepInto/Paused"] = State(11, "/Main/ModeSelector/Running/StepInto/Paused", self)
        
        # state /Main/ModeSelector/Running/StepInto/BigStep
        self.states["/Main/ModeSelector/Running/StepInto/BigStep"] = State(12, "/Main/ModeSelector/Running/StepInto/BigStep", self)
        
        # state /Main/ModeSelector/Running/StepInto/SmallStep
        self.states["/Main/ModeSelector/Running/StepInto/SmallStep"] = State(13, "/Main/ModeSelector/Running/StepInto/SmallStep", self)
        
        # state /Main/ModeSelector/WaitingForPaused
        self.states["/Main/ModeSelector/WaitingForPaused"] = State(14, "/Main/ModeSelector/WaitingForPaused", self)
        
        # state /Main/ModeSelector/Stopped
        self.states["/Main/ModeSelector/Stopped"] = State(15, "/Main/ModeSelector/Stopped", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(16, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(17, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(18, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(19, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(20, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(21, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(22, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(23, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/PrePaused
        self.states["/Main/SimulationFlow/PrePaused"] = State(24, "/Main/SimulationFlow/PrePaused", self)
        self.states["/Main/SimulationFlow/PrePaused"].setEnter(self._Main_SimulationFlow_PrePaused_enter)
        self.states["/Main/SimulationFlow/PrePaused"].setExit(self._Main_SimulationFlow_PrePaused_exit)
        
        # state /Main/SimulationFlow/Paused
        self.states["/Main/SimulationFlow/Paused"] = State(25, "/Main/SimulationFlow/Paused", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(26, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/GodEventManager
        self.states["/Main/GodEventManager"] = State(27, "/Main/GodEventManager", self)
        
        # state /Main/GodEventManager/Listening
        self.states["/Main/GodEventManager/Listening"] = State(28, "/Main/GodEventManager/Listening", self)
        
        # state /Main/GodEventManager/Waiting
        self.states["/Main/GodEventManager/Waiting"] = State(29, "/Main/GodEventManager/Waiting", self)
        
        # state /Main/BreakpointManager
        self.states["/Main/BreakpointManager"] = State(30, "/Main/BreakpointManager", self)
        
        # state /Main/BreakpointManager/Listening
        self.states["/Main/BreakpointManager/Listening"] = State(31, "/Main/BreakpointManager/Listening", self)
        
        # state /Main/BreakpointManager/Waiting
        self.states["/Main/BreakpointManager/Waiting"] = State(32, "/Main/BreakpointManager/Waiting", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main"].addChild(self.states["/Main/GodEventManager"])
        self.states["/Main"].addChild(self.states["/Main/BreakpointManager"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/WaitingForPaused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Stopped"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Realtime"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/BigStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/StepInto"])
        self.states["/Main/ModeSelector/Running/StepInto"].addChild(self.states["/Main/ModeSelector/Running/StepInto/Paused"])
        self.states["/Main/ModeSelector/Running/StepInto"].addChild(self.states["/Main/ModeSelector/Running/StepInto/BigStep"])
        self.states["/Main/ModeSelector/Running/StepInto"].addChild(self.states["/Main/ModeSelector/Running/StepInto/SmallStep"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/PrePaused"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Paused"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/GodEventManager"].addChild(self.states["/Main/GodEventManager/Listening"])
        self.states["/Main/GodEventManager"].addChild(self.states["/Main/GodEventManager/Waiting"])
        self.states["/Main/BreakpointManager"].addChild(self.states["/Main/BreakpointManager/Listening"])
        self.states["/Main/BreakpointManager"].addChild(self.states["/Main/BreakpointManager/Waiting"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ModeSelector/Running/StepInto"].default_state = self.states["/Main/ModeSelector/Running/StepInto/Paused"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Paused"]
        self.states["/Main/GodEventManager"].default_state = self.states["/Main/GodEventManager/Listening"]
        self.states["/Main/BreakpointManager"].default_state = self.states["/Main/BreakpointManager/Listening"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setTrigger(Event("small_step", "user_input"))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/BigStep"]])
        _Main_ModeSelector_Paused_1.setTrigger(Event("big_step", "user_input"))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        _Main_ModeSelector_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_2.setTrigger(Event("continuous", "user_input"))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_2)
        _Main_ModeSelector_Paused_3 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"]])
        _Main_ModeSelector_Paused_3.setAction(self._Main_ModeSelector_Paused_3_exec)
        _Main_ModeSelector_Paused_3.setTrigger(Event("step_into", "user_input"))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_3)
        _Main_ModeSelector_Paused_4 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Realtime"]])
        _Main_ModeSelector_Paused_4.setAction(self._Main_ModeSelector_Paused_4_exec)
        _Main_ModeSelector_Paused_4.setTrigger(Event("realtime", "user_input"))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_4)
        _Main_ModeSelector_Paused_5 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_5.setAction(self._Main_ModeSelector_Paused_5_exec)
        _Main_ModeSelector_Paused_5.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_5)
        _Main_ModeSelector_Paused_6 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_6.setAction(self._Main_ModeSelector_Paused_6_exec)
        _Main_ModeSelector_Paused_6.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_6)
        _Main_ModeSelector_Paused_7 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_7.setAction(self._Main_ModeSelector_Paused_7_exec)
        _Main_ModeSelector_Paused_7.setTrigger(Event("Breakpoint.Triggered", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_7)
        
        # transition /Main/ModeSelector/WaitingForStepIntoSuccess
        _Main_ModeSelector_WaitingForStepIntoSuccess_0 = Transition(self, self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"], [self.states["/Main/ModeSelector/Running/StepInto"]])
        _Main_ModeSelector_WaitingForStepIntoSuccess_0.setAction(self._Main_ModeSelector_WaitingForStepIntoSuccess_0_exec)
        _Main_ModeSelector_WaitingForStepIntoSuccess_0.setTrigger(Event("StepInto.Success", None))
        self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"].addTransition(_Main_ModeSelector_WaitingForStepIntoSuccess_0)
        _Main_ModeSelector_WaitingForStepIntoSuccess_1 = Transition(self, self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_WaitingForStepIntoSuccess_1.setAction(self._Main_ModeSelector_WaitingForStepIntoSuccess_1_exec)
        _Main_ModeSelector_WaitingForStepIntoSuccess_1.setTrigger(Event("StepInto.Failure", None))
        self.states["/Main/ModeSelector/WaitingForStepIntoSuccess"].addTransition(_Main_ModeSelector_WaitingForStepIntoSuccess_1)
        
        # transition /Main/ModeSelector/Running/Continuous
        _Main_ModeSelector_Running_Continuous_0 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous"], [self.states["/Main/ModeSelector/WaitingForPaused"]])
        _Main_ModeSelector_Running_Continuous_0.setAction(self._Main_ModeSelector_Running_Continuous_0_exec)
        _Main_ModeSelector_Running_Continuous_0.setTrigger(Event("pause", "user_input"))
        self.states["/Main/ModeSelector/Running/Continuous"].addTransition(_Main_ModeSelector_Running_Continuous_0)
        _Main_ModeSelector_Running_Continuous_1 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_Continuous_1.setAction(self._Main_ModeSelector_Running_Continuous_1_exec)
        _Main_ModeSelector_Running_Continuous_1.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running/Continuous"].addTransition(_Main_ModeSelector_Running_Continuous_1)
        
        # transition /Main/ModeSelector/Running/Realtime
        _Main_ModeSelector_Running_Realtime_0 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime"], [self.states["/Main/ModeSelector/WaitingForPaused"]])
        _Main_ModeSelector_Running_Realtime_0.setAction(self._Main_ModeSelector_Running_Realtime_0_exec)
        _Main_ModeSelector_Running_Realtime_0.setTrigger(Event("pause", "user_input"))
        self.states["/Main/ModeSelector/Running/Realtime"].addTransition(_Main_ModeSelector_Running_Realtime_0)
        _Main_ModeSelector_Running_Realtime_1 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_Realtime_1.setAction(self._Main_ModeSelector_Running_Realtime_1_exec)
        _Main_ModeSelector_Running_Realtime_1.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running/Realtime"].addTransition(_Main_ModeSelector_Running_Realtime_1)
        _Main_ModeSelector_Running_Realtime_2 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime"], [self.states["/Main/ModeSelector/Running/Realtime"]])
        _Main_ModeSelector_Running_Realtime_2.setAction(self._Main_ModeSelector_Running_Realtime_2_exec)
        _Main_ModeSelector_Running_Realtime_2.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/Realtime"].addTransition(_Main_ModeSelector_Running_Realtime_2)
        
        # transition /Main/ModeSelector/Running/BigStep
        _Main_ModeSelector_Running_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/BigStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_BigStep_0.setAction(self._Main_ModeSelector_Running_BigStep_0_exec)
        _Main_ModeSelector_Running_BigStep_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/BigStep"].addTransition(_Main_ModeSelector_Running_BigStep_0)
        _Main_ModeSelector_Running_BigStep_1 = Transition(self, self.states["/Main/ModeSelector/Running/BigStep"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_BigStep_1.setAction(self._Main_ModeSelector_Running_BigStep_1_exec)
        _Main_ModeSelector_Running_BigStep_1.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running/BigStep"].addTransition(_Main_ModeSelector_Running_BigStep_1)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        _Main_ModeSelector_Running_SmallStep_1 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_1.setAction(self._Main_ModeSelector_Running_SmallStep_1_exec)
        _Main_ModeSelector_Running_SmallStep_1.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_1)
        _Main_ModeSelector_Running_SmallStep_2 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_SmallStep_2.setAction(self._Main_ModeSelector_Running_SmallStep_2_exec)
        _Main_ModeSelector_Running_SmallStep_2.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_2)
        
        # transition /Main/ModeSelector/Running/StepInto/Paused
        _Main_ModeSelector_Running_StepInto_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Running/StepInto/Paused"], [self.states["/Main/ModeSelector/Running/StepInto/BigStep"]])
        _Main_ModeSelector_Running_StepInto_Paused_0.setTrigger(Event("big_step", "user_input"))
        self.states["/Main/ModeSelector/Running/StepInto/Paused"].addTransition(_Main_ModeSelector_Running_StepInto_Paused_0)
        _Main_ModeSelector_Running_StepInto_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Running/StepInto/Paused"], [self.states["/Main/ModeSelector/Running/StepInto/SmallStep"]])
        _Main_ModeSelector_Running_StepInto_Paused_1.setTrigger(Event("small_step", "user_input"))
        self.states["/Main/ModeSelector/Running/StepInto/Paused"].addTransition(_Main_ModeSelector_Running_StepInto_Paused_1)
        _Main_ModeSelector_Running_StepInto_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Running/StepInto/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_StepInto_Paused_2.setAction(self._Main_ModeSelector_Running_StepInto_Paused_2_exec)
        _Main_ModeSelector_Running_StepInto_Paused_2.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/StepInto/Paused"].addTransition(_Main_ModeSelector_Running_StepInto_Paused_2)
        
        # transition /Main/ModeSelector/Running/StepInto/BigStep
        _Main_ModeSelector_Running_StepInto_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/StepInto/BigStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_StepInto_BigStep_0.setAction(self._Main_ModeSelector_Running_StepInto_BigStep_0_exec)
        _Main_ModeSelector_Running_StepInto_BigStep_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/StepInto/BigStep"].addTransition(_Main_ModeSelector_Running_StepInto_BigStep_0)
        
        # transition /Main/ModeSelector/Running/StepInto/SmallStep
        _Main_ModeSelector_Running_StepInto_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/StepInto/SmallStep"], [self.states["/Main/ModeSelector/Running/StepInto/Paused"]])
        _Main_ModeSelector_Running_StepInto_SmallStep_0.setAction(self._Main_ModeSelector_Running_StepInto_SmallStep_0_exec)
        _Main_ModeSelector_Running_StepInto_SmallStep_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/StepInto/SmallStep"].addTransition(_Main_ModeSelector_Running_StepInto_SmallStep_0)
        
        # transition /Main/ModeSelector/WaitingForPaused
        _Main_ModeSelector_WaitingForPaused_0 = Transition(self, self.states["/Main/ModeSelector/WaitingForPaused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_WaitingForPaused_0.setAction(self._Main_ModeSelector_WaitingForPaused_0_exec)
        _Main_ModeSelector_WaitingForPaused_0.setTrigger(Event("WovenSimulation.Paused", None))
        self.states["/Main/ModeSelector/WaitingForPaused"].addTransition(_Main_ModeSelector_WaitingForPaused_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("WovenSimulation.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("WovenSimulation.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/SimulationFlow/PrePaused
        _Main_SimulationFlow_PrePaused_0 = Transition(self, self.states["/Main/SimulationFlow/PrePaused"], [self.states["/Main/SimulationFlow/Paused"]])
        _Main_SimulationFlow_PrePaused_0.setTrigger(Event("_0after"))
        self.states["/Main/SimulationFlow/PrePaused"].addTransition(_Main_SimulationFlow_PrePaused_0)
        
        # transition /Main/SimulationFlow/Paused
        _Main_SimulationFlow_Paused_0 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_0.setAction(self._Main_SimulationFlow_Paused_0_exec)
        _Main_SimulationFlow_Paused_0.setTrigger(None)
        _Main_SimulationFlow_Paused_0.setGuard(self._Main_SimulationFlow_Paused_0_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_0)
        _Main_SimulationFlow_Paused_1 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_1.setAction(self._Main_SimulationFlow_Paused_1_exec)
        _Main_SimulationFlow_Paused_1.setTrigger(None)
        _Main_SimulationFlow_Paused_1.setGuard(self._Main_SimulationFlow_Paused_1_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_1)
        _Main_SimulationFlow_Paused_2 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_2.setAction(self._Main_SimulationFlow_Paused_2_exec)
        _Main_SimulationFlow_Paused_2.setTrigger(None)
        _Main_SimulationFlow_Paused_2.setGuard(self._Main_SimulationFlow_Paused_2_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_2)
        _Main_SimulationFlow_Paused_3 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_3.setAction(self._Main_SimulationFlow_Paused_3_exec)
        _Main_SimulationFlow_Paused_3.setTrigger(None)
        _Main_SimulationFlow_Paused_3.setGuard(self._Main_SimulationFlow_Paused_3_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_3)
        _Main_SimulationFlow_Paused_4 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_4.setAction(self._Main_SimulationFlow_Paused_4_exec)
        _Main_SimulationFlow_Paused_4.setTrigger(None)
        _Main_SimulationFlow_Paused_4.setGuard(self._Main_SimulationFlow_Paused_4_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_4)
        _Main_SimulationFlow_Paused_5 = Transition(self, self.states["/Main/SimulationFlow/Paused"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_Paused_5.setAction(self._Main_SimulationFlow_Paused_5_exec)
        _Main_SimulationFlow_Paused_5.setTrigger(None)
        _Main_SimulationFlow_Paused_5.setGuard(self._Main_SimulationFlow_Paused_5_guard)
        self.states["/Main/SimulationFlow/Paused"].addTransition(_Main_SimulationFlow_Paused_5)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/Paused"]])
        _Main_SimulationFlow_Executing_0.setTrigger(None)
        _Main_SimulationFlow_Executing_0.setGuard(self._Main_SimulationFlow_Executing_0_guard)
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        _Main_SimulationFlow_Executing_1 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/PrePaused"]])
        _Main_SimulationFlow_Executing_1.setTrigger(Event("WovenSimulation.Finished", None))
        _Main_SimulationFlow_Executing_1.setGuard(self._Main_SimulationFlow_Executing_1_guard)
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_1)
        
        # transition /Main/GodEventManager/Listening
        _Main_GodEventManager_Listening_0 = Transition(self, self.states["/Main/GodEventManager/Listening"], [self.states["/Main/GodEventManager/Waiting"]])
        _Main_GodEventManager_Listening_0.setAction(self._Main_GodEventManager_Listening_0_exec)
        _Main_GodEventManager_Listening_0.setTrigger(Event("god_event", "user_input"))
        _Main_GodEventManager_Listening_0.setGuard(self._Main_GodEventManager_Listening_0_guard)
        self.states["/Main/GodEventManager/Listening"].addTransition(_Main_GodEventManager_Listening_0)
        
        # transition /Main/GodEventManager/Waiting
        _Main_GodEventManager_Waiting_0 = Transition(self, self.states["/Main/GodEventManager/Waiting"], [self.states["/Main/GodEventManager/Listening"]])
        _Main_GodEventManager_Waiting_0.setAction(self._Main_GodEventManager_Waiting_0_exec)
        _Main_GodEventManager_Waiting_0.setTrigger(Event("WovenSimulation.GodEventResult", None))
        self.states["/Main/GodEventManager/Waiting"].addTransition(_Main_GodEventManager_Waiting_0)
        
        # transition /Main/BreakpointManager/Listening
        _Main_BreakpointManager_Listening_0 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Waiting"]])
        _Main_BreakpointManager_Listening_0.setAction(self._Main_BreakpointManager_Listening_0_exec)
        _Main_BreakpointManager_Listening_0.setTrigger(Event("add_breakpoint", "user_input"))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_0)
        _Main_BreakpointManager_Listening_1 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Waiting"]])
        _Main_BreakpointManager_Listening_1.setAction(self._Main_BreakpointManager_Listening_1_exec)
        _Main_BreakpointManager_Listening_1.setTrigger(Event("del_breakpoint", "user_input"))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_1)
        _Main_BreakpointManager_Listening_2 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Waiting"]])
        _Main_BreakpointManager_Listening_2.setAction(self._Main_BreakpointManager_Listening_2_exec)
        _Main_BreakpointManager_Listening_2.setTrigger(Event("toggle_breakpoint", "user_input"))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_2)
        _Main_BreakpointManager_Listening_3 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Waiting"]])
        _Main_BreakpointManager_Listening_3.setAction(self._Main_BreakpointManager_Listening_3_exec)
        _Main_BreakpointManager_Listening_3.setTrigger(Event("list_breakpoints", "user_input"))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_3)
        
        # transition /Main/BreakpointManager/Waiting
        _Main_BreakpointManager_Waiting_0 = Transition(self, self.states["/Main/BreakpointManager/Waiting"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Waiting_0.setAction(self._Main_BreakpointManager_Waiting_0_exec)
        _Main_BreakpointManager_Waiting_0.setTrigger(Event("Breakpoint.AddResult", None))
        self.states["/Main/BreakpointManager/Waiting"].addTransition(_Main_BreakpointManager_Waiting_0)
        _Main_BreakpointManager_Waiting_1 = Transition(self, self.states["/Main/BreakpointManager/Waiting"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Waiting_1.setAction(self._Main_BreakpointManager_Waiting_1_exec)
        _Main_BreakpointManager_Waiting_1.setTrigger(Event("Breakpoint.DelResult", None))
        self.states["/Main/BreakpointManager/Waiting"].addTransition(_Main_BreakpointManager_Waiting_1)
        _Main_BreakpointManager_Waiting_2 = Transition(self, self.states["/Main/BreakpointManager/Waiting"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Waiting_2.setAction(self._Main_BreakpointManager_Waiting_2_exec)
        _Main_BreakpointManager_Waiting_2.setTrigger(Event("Breakpoint.ToggleResult", None))
        self.states["/Main/BreakpointManager/Waiting"].addTransition(_Main_BreakpointManager_Waiting_2)
        _Main_BreakpointManager_Waiting_3 = Transition(self, self.states["/Main/BreakpointManager/Waiting"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Waiting_3.setAction(self._Main_BreakpointManager_Waiting_3_exec)
        _Main_BreakpointManager_Waiting_3.setTrigger(Event("Breakpoint.ListResult", None))
        self.states["/Main/BreakpointManager/Waiting"].addTransition(_Main_BreakpointManager_Waiting_3)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setAction(self._Main_ModeSelector_Running_0_exec)
        _Main_ModeSelector_Running_0.setTrigger(Event("WovenSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
        _Main_ModeSelector_Running_1 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_1.setAction(self._Main_ModeSelector_Running_1_exec)
        _Main_ModeSelector_Running_1.setTrigger(Event("Breakpoint.Triggered", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_1)
    
    def _Main_SimulationFlow_PrePaused_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_SimulationFlow_PrePaused_exit(self):
        self.removeTimer(0)
    
    def _Main_ModeSelector_Running_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_1_exec(self, parameters):
        triggered_bp = parameters[0]
        clock = parameters[1]
        state = parameters[2]
        self.big_step.outputEvent(Event("Breakpoint.Triggered", "user_output", [triggered_bp, clock / 1000.0, state]))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Paused_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.StepInto", None, [])]))
    
    def _Main_ModeSelector_Paused_4_exec(self, parameters):
        realtime_scale = parameters[0]
        self.realtime_scale = float(realtime_scale)
    
    def _Main_ModeSelector_Paused_5_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        fsa_events = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEvent(Event("FSABigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("FSABigStep.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Paused_6_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Paused_7_exec(self, parameters):
        triggered_bp = parameters[0]
        clock = parameters[1]
        state = parameters[2]
        self.big_step.outputEvent(Event("Breakpoint.Triggered", "user_output", [triggered_bp, clock / 1000.0, state]))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_WaitingForStepIntoSuccess_0_exec(self, parameters):
        self.big_step.outputEvent(Event("StepInto.Success", "user_output", []))
    
    def _Main_ModeSelector_WaitingForStepIntoSuccess_1_exec(self, parameters):
        self.big_step.outputEvent(Event("StepInto.Failure", "user_output", []))
    
    def _Main_ModeSelector_Running_Continuous_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.Pause", None, [])]))
    
    def _Main_ModeSelector_Running_Continuous_1_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_Realtime_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.Pause", None, [])]))
    
    def _Main_ModeSelector_Running_Realtime_1_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_Realtime_2_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        fsa_events = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEvent(Event("FSABigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("FSABigStep.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_BigStep_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        fsa_events = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEvent(Event("FSABigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("FSABigStep.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_BigStep_1_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        fsa_events = parameters[3]
        selected_transition = parameters[4]
        self.big_step.outputEvent(Event("FSASmallStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("FSASmallStep.State", "user_output", [clock / 1000.0, state, elapsed, fsa_events, selected_transition]))
    
    def _Main_ModeSelector_Running_SmallStep_1_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        fsa_events = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEvent(Event("FSABigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("FSABigStep.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_SmallStep_2_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Finished", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ModeSelector_Running_StepInto_Paused_2_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEvent(Event("CBDBigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("CBDBigStep.State", "user_output", [clock, iteration, time_next]))
    
    def _Main_ModeSelector_Running_StepInto_BigStep_0_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEvent(Event("CBDBigStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("CBDBigStep.State", "user_output", [clock, iteration, time_next]))
    
    def _Main_ModeSelector_Running_StepInto_SmallStep_0_exec(self, parameters):
        new_current_component_idx = parameters[0]
        new_state = parameters[1]
        self.big_step.outputEvent(Event("CBDSmallStep.Finished", "user_output", []))
        self.big_step.outputEvent(Event("CBDSmallStep.State", "user_output", [new_current_component_idx]))
    
    def _Main_ModeSelector_WaitingForPaused_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        self.big_step.outputEvent(Event("WovenSimulation.Paused", "user_output", []))
        self.big_step.outputEvent(Event("WovenSimulation.State", "user_output", [clock / 1000.0, state]))
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'WovenSimulator_Simulation', copy.deepcopy(self.woven_model), copy.deepcopy(self.fsa_events), self.fsa_delta, copy.deepcopy(self.cbd_options)]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ChildState/Uninitialized"])
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Paused_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.Execute", None, [])]))
    
    def _Main_SimulationFlow_Paused_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Continuous"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Paused_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.ExecuteRealtime", None, [self.realtime_scale])]))
    
    def _Main_SimulationFlow_Paused_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Realtime"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Paused_2_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSABigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_Paused_2_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/BigStep"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Paused_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSASmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_Paused_3_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/SmallStep"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Paused_4_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_Paused_4_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/StepInto/SmallStep"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Paused_5_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_Paused_5_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/StepInto/BigStep"]) and self.inState(["/Main/ChildState/Initialized"])
    
    def _Main_SimulationFlow_Executing_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Paused"]) or self.inState(["/Main/ModeSelector/Running/StepInto/Paused"])
    
    def _Main_SimulationFlow_Executing_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Continuous"]) or self.inState(["/Main/ModeSelector/Running/Realtime"])
    
    def _Main_GodEventManager_Listening_0_exec(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("WovenSimulation.GodEvent", None, [block_name, new_val])]))
    
    def _Main_GodEventManager_Listening_0_guard(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        return self.inState(["/Main/ModeSelector/Paused"])
    
    def _Main_GodEventManager_Waiting_0_exec(self, parameters):
        result = parameters[0]
        self.big_step.outputEvent(Event("GodEventResult", "user_output", [result]))
    
    def _Main_BreakpointManager_Listening_0_exec(self, parameters):
        name = parameters[0]
        function = parameters[1]
        enabled = parameters[2]
        disable_on_trigger = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("Breakpoint.Add", None, [name, function, enabled, disable_on_trigger])]))
    
    def _Main_BreakpointManager_Listening_1_exec(self, parameters):
        name = parameters[0]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("Breakpoint.Del", None, [name])]))
    
    def _Main_BreakpointManager_Listening_2_exec(self, parameters):
        name = parameters[0]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("Breakpoint.Toggle", None, [name])]))
    
    def _Main_BreakpointManager_Listening_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("Breakpoint.List", None, [])]))
    
    def _Main_BreakpointManager_Waiting_0_exec(self, parameters):
        result = parameters[0]
        self.big_step.outputEvent(Event("Breakpoint.AddResult", "user_output", [result]))
    
    def _Main_BreakpointManager_Waiting_1_exec(self, parameters):
        result = parameters[0]
        self.big_step.outputEvent(Event("Breakpoint.DelResult", "user_output", [result]))
    
    def _Main_BreakpointManager_Waiting_2_exec(self, parameters):
        result = parameters[0]
        self.big_step.outputEvent(Event("Breakpoint.ToggleResult", "user_output", [result]))
    
    def _Main_BreakpointManager_Waiting_3_exec(self, parameters):
        result = parameters[0]
        self.big_step.outputEvent(Event("Breakpoint.ListResult", "user_output", [result]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class WovenSimulator_Simulation(RuntimeClassBase):
    def __init__(self, controller, woven_model, fsa_events, fsa_delta, cbd_options):
        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()
        
        # call user defined constructor
        WovenSimulator_Simulation.user_defined_constructor(self, woven_model, fsa_events, fsa_delta, cbd_options)
    
    def user_defined_constructor(self, woven_model, fsa_events, fsa_delta, cbd_options):
        self.cbd_options = cbd_options
        self.fsa_events = fsa_events
        self.woven_delta = min(fsa_delta, self.cbd_options.getDeltaT() * 1000.0)
        self.woven_model = woven_model
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.woven_lib = FSACBDLib()
        self.woven_global_state = dict()
        self.woven_previous_global_state = dict()
        self.woven_triggered_when_transition = None
    
    
    # user defined method
    def endCondition(self):
        return False # This depends on the child simulators (if one of them completes, the simulation completes.)
    
    
    # user defined method
    def finalize(self):
        print '(Woven) Simulation finalized.'
    
    
    # user defined method
    def initializeDebugger(self):
        self.breakpoints = []
        self.triggered_bp = None
        self.breakpoint_triggers = False
    
    
    # user defined method
    def wovenUpdateCBDState(self):
        self.woven_lib.updateCBDState(self.woven_global_state, self.fsa_state.cbd)
    
    
    # user defined method
    def wovenUpdateGlobalState(self):
        self.woven_previous_global_state = copy.deepcopy(self.woven_global_state)
        self.woven_lib.updateGlobalState(self.woven_global_state, self.fsa_state.cbd, self.cbd_clock / 1000.0)
    
    
    # user defined method
    def wovenGetTriggeredWhenTransition(self):
        return self.woven_lib.getTriggeredWhenTransition(self.woven_model, self.fsa_state, self.woven_global_state, self.woven_previous_global_state)
    
    
    # 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.fsa_time_next - simulated_diff) / self.realtime_scale)
    
    
    # user defined method
    def syncSimulatedTime(self):
        diff = accurate_time.time() - self.realtime_start_time
        self.fsa_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 = not bp.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
            try:
                if breakpoint({'fsa_clock': (self.fsa_clock if is_realtime_simulation else self.fsa_time_next) / 1000.0,
                               'fsa_state': self.fsa_state,
                               'fsa_elapsed': self.fsa_elapsed,
                               'fsa_time_next': self.fsa_time_next,
                               'cbd_clock': (self.cbd_clock if is_realtime_simulation else self.cbd_time_next) / 1000.0,
                               'cbd_state': self.cbd_state,
                               'cbd_iteration': self.cbd_iteration,
                               'cbd_time_next': self.cbd_time_next}):
                    # triggered!
                    print 'triggered'
                    self.triggered_bp = bp.name
                    if bp.disable_on_trigger:
                        bp.enabled = False
                    return True
                else:
                    # not triggered, so continue
                    continue
            except AttributeError: 
                pass # this means state/clock has not been set yet, so we are at the start of simulation... no breakpoint can trigger
        return False
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/ExecutingRealtimeIfInitialized
        self.states["/Main/ModeSelector/ExecutingRealtimeIfInitialized"] = State(4, "/Main/ModeSelector/ExecutingRealtimeIfInitialized", self)
        
        # state /Main/ModeSelector/WaitingForBigStepToEndPause
        self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"] = State(5, "/Main/ModeSelector/WaitingForBigStepToEndPause", self)
        
        # state /Main/ModeSelector/CheckIfBreakpointTriggers
        self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"] = State(6, "/Main/ModeSelector/CheckIfBreakpointTriggers", self)
        self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"].setEnter(self._Main_ModeSelector_CheckIfBreakpointTriggers_enter)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(7, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(8, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers
        self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"] = State(9, "/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers", self)
        self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"].setEnter(self._Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_enter)
        
        # state /Main/ModeSelector/Running/Continuous/Running
        self.states["/Main/ModeSelector/Running/Continuous/Running"] = State(10, "/Main/ModeSelector/Running/Continuous/Running", self)
        
        # state /Main/ModeSelector/Running/Realtime
        self.states["/Main/ModeSelector/Running/Realtime"] = State(11, "/Main/ModeSelector/Running/Realtime", self)
        
        # state /Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers
        self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"] = State(12, "/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers", self)
        self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"].setEnter(self._Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_enter)
        
        # state /Main/ModeSelector/Running/Realtime/Running
        self.states["/Main/ModeSelector/Running/Realtime/Running"] = State(13, "/Main/ModeSelector/Running/Realtime/Running", self)
        
        # state /Main/ModeSelector/Running/BigStep
        self.states["/Main/ModeSelector/Running/BigStep"] = State(14, "/Main/ModeSelector/Running/BigStep", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(15, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ModeSelector/Running/ChildStep
        self.states["/Main/ModeSelector/Running/ChildStep"] = State(16, "/Main/ModeSelector/Running/ChildStep", self)
        
        # state /Main/ModeSelector/Running/ChildStep/Paused
        self.states["/Main/ModeSelector/Running/ChildStep/Paused"] = State(17, "/Main/ModeSelector/Running/ChildStep/Paused", self)
        
        # state /Main/ModeSelector/Running/ChildStep/BigStep
        self.states["/Main/ModeSelector/Running/ChildStep/BigStep"] = State(18, "/Main/ModeSelector/Running/ChildStep/BigStep", self)
        
        # state /Main/ModeSelector/Running/ChildStep/SmallStep
        self.states["/Main/ModeSelector/Running/ChildStep/SmallStep"] = State(19, "/Main/ModeSelector/Running/ChildStep/SmallStep", self)
        
        # state /Main/ModeSelector/Stopped
        self.states["/Main/ModeSelector/Stopped"] = State(20, "/Main/ModeSelector/Stopped", self)
        self.states["/Main/ModeSelector/Stopped"].setEnter(self._Main_ModeSelector_Stopped_enter)
        
        # state /Main/FSAChildState
        self.states["/Main/FSAChildState"] = State(21, "/Main/FSAChildState", self)
        
        # state /Main/FSAChildState/Uninitialized
        self.states["/Main/FSAChildState/Uninitialized"] = State(22, "/Main/FSAChildState/Uninitialized", self)
        
        # state /Main/FSAChildState/Initialized
        self.states["/Main/FSAChildState/Initialized"] = State(23, "/Main/FSAChildState/Initialized", self)
        
        # state /Main/CBDChildState
        self.states["/Main/CBDChildState"] = State(24, "/Main/CBDChildState", self)
        
        # state /Main/CBDChildState/Uninitialized
        self.states["/Main/CBDChildState/Uninitialized"] = State(25, "/Main/CBDChildState/Uninitialized", self)
        
        # state /Main/CBDChildState/Initialized
        self.states["/Main/CBDChildState/Initialized"] = State(26, "/Main/CBDChildState/Initialized", self)
        
        # state /Main/FSAInitializer
        self.states["/Main/FSAInitializer"] = State(27, "/Main/FSAInitializer", self)
        
        # state /Main/FSAInitializer/Waiting
        self.states["/Main/FSAInitializer/Waiting"] = State(28, "/Main/FSAInitializer/Waiting", self)
        
        # state /Main/FSAInitializer/CreatingChildSimulator
        self.states["/Main/FSAInitializer/CreatingChildSimulator"] = State(29, "/Main/FSAInitializer/CreatingChildSimulator", self)
        
        # state /Main/FSAInitializer/StartingChildSimulator
        self.states["/Main/FSAInitializer/StartingChildSimulator"] = State(30, "/Main/FSAInitializer/StartingChildSimulator", self)
        
        # state /Main/FSAInitializer/Running
        self.states["/Main/FSAInitializer/Running"] = State(31, "/Main/FSAInitializer/Running", self)
        
        # state /Main/FSAInitializer/SettleBeforeWaiting
        self.states["/Main/FSAInitializer/SettleBeforeWaiting"] = State(32, "/Main/FSAInitializer/SettleBeforeWaiting", self)
        self.states["/Main/FSAInitializer/SettleBeforeWaiting"].setEnter(self._Main_FSAInitializer_SettleBeforeWaiting_enter)
        self.states["/Main/FSAInitializer/SettleBeforeWaiting"].setExit(self._Main_FSAInitializer_SettleBeforeWaiting_exit)
        
        # state /Main/CBDInitializer
        self.states["/Main/CBDInitializer"] = State(33, "/Main/CBDInitializer", self)
        
        # state /Main/CBDInitializer/Waiting
        self.states["/Main/CBDInitializer/Waiting"] = State(34, "/Main/CBDInitializer/Waiting", self)
        
        # state /Main/CBDInitializer/CreatingChildSimulator
        self.states["/Main/CBDInitializer/CreatingChildSimulator"] = State(35, "/Main/CBDInitializer/CreatingChildSimulator", self)
        
        # state /Main/CBDInitializer/StartingChildSimulator
        self.states["/Main/CBDInitializer/StartingChildSimulator"] = State(36, "/Main/CBDInitializer/StartingChildSimulator", self)
        
        # state /Main/CBDInitializer/Running
        self.states["/Main/CBDInitializer/Running"] = State(37, "/Main/CBDInitializer/Running", self)
        
        # state /Main/CBDInitializer/SettleBeforeWaiting
        self.states["/Main/CBDInitializer/SettleBeforeWaiting"] = State(38, "/Main/CBDInitializer/SettleBeforeWaiting", self)
        self.states["/Main/CBDInitializer/SettleBeforeWaiting"].setEnter(self._Main_CBDInitializer_SettleBeforeWaiting_enter)
        self.states["/Main/CBDInitializer/SettleBeforeWaiting"].setExit(self._Main_CBDInitializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(39, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(40, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(41, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(42, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/DebuggerInitialized
        self.states["/Main/SimulationFlow/DebuggerInitialized"] = State(43, "/Main/SimulationFlow/DebuggerInitialized", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(44, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(45, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(46, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/WaitingRealtime
        self.states["/Main/SimulationFlow/WaitingRealtime"] = State(47, "/Main/SimulationFlow/WaitingRealtime", self)
        self.states["/Main/SimulationFlow/WaitingRealtime"].setEnter(self._Main_SimulationFlow_WaitingRealtime_enter)
        self.states["/Main/SimulationFlow/WaitingRealtime"].setExit(self._Main_SimulationFlow_WaitingRealtime_exit)
        
        # state /Main/SimulationFlow/SteppedInto
        self.states["/Main/SimulationFlow/SteppedInto"] = State(48, "/Main/SimulationFlow/SteppedInto", self)
        
        # state /Main/SimulationFlow/SteppedInto/Waiting
        self.states["/Main/SimulationFlow/SteppedInto/Waiting"] = State(49, "/Main/SimulationFlow/SteppedInto/Waiting", self)
        
        # state /Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep
        self.states["/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep"] = State(50, "/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep", self)
        
        # state /Main/SimulationFlow/SteppedInto/SettleBeforeWaiting
        self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"] = State(51, "/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting", self)
        self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"].setEnter(self._Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_enter)
        self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"].setExit(self._Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow/ExecutingCBD
        self.states["/Main/SimulationFlow/ExecutingCBD"] = State(52, "/Main/SimulationFlow/ExecutingCBD", self)
        
        # state /Main/SimulationFlow/CheckingForStateEvent
        self.states["/Main/SimulationFlow/CheckingForStateEvent"] = State(53, "/Main/SimulationFlow/CheckingForStateEvent", self)
        
        # state /Main/SimulationFlow/SendingGodEvent
        self.states["/Main/SimulationFlow/SendingGodEvent"] = State(54, "/Main/SimulationFlow/SendingGodEvent", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(55, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(56, "/Main/SimulationFlow/Stopped", self)
        
        # state /Main/BreakpointManager
        self.states["/Main/BreakpointManager"] = State(57, "/Main/BreakpointManager", self)
        
        # state /Main/BreakpointManager/Listening
        self.states["/Main/BreakpointManager/Listening"] = State(58, "/Main/BreakpointManager/Listening", self)
        
        # state /Main/ParentCommunicator
        self.states["/Main/ParentCommunicator"] = State(59, "/Main/ParentCommunicator", self)
        
        # state /Main/ParentCommunicator/Forwarding
        self.states["/Main/ParentCommunicator/Forwarding"] = State(60, "/Main/ParentCommunicator/Forwarding", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(61, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/FSAChildState"])
        self.states["/Main"].addChild(self.states["/Main/CBDChildState"])
        self.states["/Main"].addChild(self.states["/Main/FSAInitializer"])
        self.states["/Main"].addChild(self.states["/Main/CBDInitializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main"].addChild(self.states["/Main/BreakpointManager"])
        self.states["/Main"].addChild(self.states["/Main/ParentCommunicator"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/ExecutingRealtimeIfInitialized"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Stopped"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Realtime"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/BigStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/ChildStep"])
        self.states["/Main/ModeSelector/Running/Continuous"].addChild(self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"])
        self.states["/Main/ModeSelector/Running/Continuous"].addChild(self.states["/Main/ModeSelector/Running/Continuous/Running"])
        self.states["/Main/ModeSelector/Running/Realtime"].addChild(self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"])
        self.states["/Main/ModeSelector/Running/Realtime"].addChild(self.states["/Main/ModeSelector/Running/Realtime/Running"])
        self.states["/Main/ModeSelector/Running/ChildStep"].addChild(self.states["/Main/ModeSelector/Running/ChildStep/Paused"])
        self.states["/Main/ModeSelector/Running/ChildStep"].addChild(self.states["/Main/ModeSelector/Running/ChildStep/BigStep"])
        self.states["/Main/ModeSelector/Running/ChildStep"].addChild(self.states["/Main/ModeSelector/Running/ChildStep/SmallStep"])
        self.states["/Main/FSAChildState"].addChild(self.states["/Main/FSAChildState/Uninitialized"])
        self.states["/Main/FSAChildState"].addChild(self.states["/Main/FSAChildState/Initialized"])
        self.states["/Main/CBDChildState"].addChild(self.states["/Main/CBDChildState/Uninitialized"])
        self.states["/Main/CBDChildState"].addChild(self.states["/Main/CBDChildState/Initialized"])
        self.states["/Main/FSAInitializer"].addChild(self.states["/Main/FSAInitializer/Waiting"])
        self.states["/Main/FSAInitializer"].addChild(self.states["/Main/FSAInitializer/CreatingChildSimulator"])
        self.states["/Main/FSAInitializer"].addChild(self.states["/Main/FSAInitializer/StartingChildSimulator"])
        self.states["/Main/FSAInitializer"].addChild(self.states["/Main/FSAInitializer/Running"])
        self.states["/Main/FSAInitializer"].addChild(self.states["/Main/FSAInitializer/SettleBeforeWaiting"])
        self.states["/Main/CBDInitializer"].addChild(self.states["/Main/CBDInitializer/Waiting"])
        self.states["/Main/CBDInitializer"].addChild(self.states["/Main/CBDInitializer/CreatingChildSimulator"])
        self.states["/Main/CBDInitializer"].addChild(self.states["/Main/CBDInitializer/StartingChildSimulator"])
        self.states["/Main/CBDInitializer"].addChild(self.states["/Main/CBDInitializer/Running"])
        self.states["/Main/CBDInitializer"].addChild(self.states["/Main/CBDInitializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/DebuggerInitialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/WaitingRealtime"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SteppedInto"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/ExecutingCBD"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckingForStateEvent"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SendingGodEvent"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states["/Main/SimulationFlow/SteppedInto"].addChild(self.states["/Main/SimulationFlow/SteppedInto/Waiting"])
        self.states["/Main/SimulationFlow/SteppedInto"].addChild(self.states["/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep"])
        self.states["/Main/SimulationFlow/SteppedInto"].addChild(self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"])
        self.states["/Main/BreakpointManager"].addChild(self.states["/Main/BreakpointManager/Listening"])
        self.states["/Main/ParentCommunicator"].addChild(self.states["/Main/ParentCommunicator/Forwarding"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ModeSelector/Running/Continuous"].default_state = self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"]
        self.states["/Main/ModeSelector/Running/Realtime"].default_state = self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"]
        self.states["/Main/ModeSelector/Running/ChildStep"].default_state = self.states["/Main/ModeSelector/Running/ChildStep/Paused"]
        self.states["/Main/FSAChildState"].default_state = self.states["/Main/FSAChildState/Uninitialized"]
        self.states["/Main/CBDChildState"].default_state = self.states["/Main/CBDChildState/Uninitialized"]
        self.states["/Main/FSAInitializer"].default_state = self.states["/Main/FSAInitializer/Waiting"]
        self.states["/Main/CBDInitializer"].default_state = self.states["/Main/CBDInitializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        self.states["/Main/SimulationFlow/SteppedInto"].default_state = self.states["/Main/SimulationFlow/SteppedInto/Waiting"]
        self.states["/Main/BreakpointManager"].default_state = self.states["/Main/BreakpointManager/Listening"]
        self.states["/Main/ParentCommunicator"].default_state = self.states["/Main/ParentCommunicator/Forwarding"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setTrigger(Event("FSASmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/BigStep"]])
        _Main_ModeSelector_Paused_1.setTrigger(Event("FSABigStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        _Main_ModeSelector_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_2.setTrigger(Event("WovenSimulation.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_2)
        _Main_ModeSelector_Paused_3 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/ExecutingRealtimeIfInitialized"]])
        _Main_ModeSelector_Paused_3.setAction(self._Main_ModeSelector_Paused_3_exec)
        _Main_ModeSelector_Paused_3.setTrigger(Event("WovenSimulation.ExecuteRealtime", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_3)
        _Main_ModeSelector_Paused_4 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/ChildStep"]])
        _Main_ModeSelector_Paused_4.setAction(self._Main_ModeSelector_Paused_4_exec)
        _Main_ModeSelector_Paused_4.setTrigger(Event("WovenSimulation.StepInto", None))
        _Main_ModeSelector_Paused_4.setGuard(self._Main_ModeSelector_Paused_4_guard)
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_4)
        _Main_ModeSelector_Paused_5 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_5.setAction(self._Main_ModeSelector_Paused_5_exec)
        _Main_ModeSelector_Paused_5.setTrigger(Event("WovenSimulation.StepInto", None))
        _Main_ModeSelector_Paused_5.setGuard(self._Main_ModeSelector_Paused_5_guard)
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_5)
        _Main_ModeSelector_Paused_6 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"]])
        _Main_ModeSelector_Paused_6.setAction(self._Main_ModeSelector_Paused_6_exec)
        _Main_ModeSelector_Paused_6.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_6)
        _Main_ModeSelector_Paused_7 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Paused_7.setTrigger(Event("FSASimulation.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_7)
        _Main_ModeSelector_Paused_8 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Paused_8.setTrigger(Event("CBDSimulation.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_8)
        
        # transition /Main/ModeSelector/ExecutingRealtimeIfInitialized
        _Main_ModeSelector_ExecutingRealtimeIfInitialized_0 = Transition(self, self.states["/Main/ModeSelector/ExecutingRealtimeIfInitialized"], [self.states["/Main/ModeSelector/Running/Realtime"]])
        _Main_ModeSelector_ExecutingRealtimeIfInitialized_0.setAction(self._Main_ModeSelector_ExecutingRealtimeIfInitialized_0_exec)
        _Main_ModeSelector_ExecutingRealtimeIfInitialized_0.setTrigger(None)
        _Main_ModeSelector_ExecutingRealtimeIfInitialized_0.setGuard(self._Main_ModeSelector_ExecutingRealtimeIfInitialized_0_guard)
        self.states["/Main/ModeSelector/ExecutingRealtimeIfInitialized"].addTransition(_Main_ModeSelector_ExecutingRealtimeIfInitialized_0)
        
        # transition /Main/ModeSelector/WaitingForBigStepToEndPause
        _Main_ModeSelector_WaitingForBigStepToEndPause_0 = Transition(self, self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_WaitingForBigStepToEndPause_0.setAction(self._Main_ModeSelector_WaitingForBigStepToEndPause_0_exec)
        _Main_ModeSelector_WaitingForBigStepToEndPause_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"].addTransition(_Main_ModeSelector_WaitingForBigStepToEndPause_0)
        
        # transition /Main/ModeSelector/CheckIfBreakpointTriggers
        _Main_ModeSelector_CheckIfBreakpointTriggers_0 = Transition(self, self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_CheckIfBreakpointTriggers_0.setAction(self._Main_ModeSelector_CheckIfBreakpointTriggers_0_exec)
        _Main_ModeSelector_CheckIfBreakpointTriggers_0.setTrigger(None)
        _Main_ModeSelector_CheckIfBreakpointTriggers_0.setGuard(self._Main_ModeSelector_CheckIfBreakpointTriggers_0_guard)
        self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_CheckIfBreakpointTriggers_0)
        _Main_ModeSelector_CheckIfBreakpointTriggers_1 = Transition(self, self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_CheckIfBreakpointTriggers_1.setTrigger(None)
        _Main_ModeSelector_CheckIfBreakpointTriggers_1.setGuard(self._Main_ModeSelector_CheckIfBreakpointTriggers_1_guard)
        self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_CheckIfBreakpointTriggers_1)
        
        # transition /Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0.setAction(self._Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0_exec)
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0.setTrigger(None)
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0.setGuard(self._Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0_guard)
        self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0)
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Running/Continuous/Running"]])
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1.setTrigger(None)
        _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1.setGuard(self._Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1_guard)
        self.states["/Main/ModeSelector/Running/Continuous/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1)
        
        # transition /Main/ModeSelector/Running/Continuous/Running
        _Main_ModeSelector_Running_Continuous_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous/Running"], [self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"]])
        _Main_ModeSelector_Running_Continuous_Running_0.setTrigger(Event("WovenSimulation.Pause", None))
        self.states["/Main/ModeSelector/Running/Continuous/Running"].addTransition(_Main_ModeSelector_Running_Continuous_Running_0)
        _Main_ModeSelector_Running_Continuous_Running_1 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Continuous_Running_1.setAction(self._Main_ModeSelector_Running_Continuous_Running_1_exec)
        _Main_ModeSelector_Running_Continuous_Running_1.setTrigger(None)
        _Main_ModeSelector_Running_Continuous_Running_1.setGuard(self._Main_ModeSelector_Running_Continuous_Running_1_guard)
        self.states["/Main/ModeSelector/Running/Continuous/Running"].addTransition(_Main_ModeSelector_Running_Continuous_Running_1)
        _Main_ModeSelector_Running_Continuous_Running_2 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous/Running"], [self.states["/Main/ModeSelector/Running/Continuous/Running"]])
        _Main_ModeSelector_Running_Continuous_Running_2.setAction(self._Main_ModeSelector_Running_Continuous_Running_2_exec)
        _Main_ModeSelector_Running_Continuous_Running_2.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/Continuous/Running"].addTransition(_Main_ModeSelector_Running_Continuous_Running_2)
        
        # transition /Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0.setAction(self._Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0_exec)
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0.setTrigger(None)
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0.setGuard(self._Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0_guard)
        self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0)
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"], [self.states["/Main/ModeSelector/Running/Realtime/Running"]])
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1.setTrigger(None)
        _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1.setGuard(self._Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1_guard)
        self.states["/Main/ModeSelector/Running/Realtime/CheckIfBreakpointTriggers"].addTransition(_Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1)
        
        # transition /Main/ModeSelector/Running/Realtime/Running
        _Main_ModeSelector_Running_Realtime_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime/Running"], [self.states["/Main/ModeSelector/WaitingForBigStepToEndPause"]])
        _Main_ModeSelector_Running_Realtime_Running_0.setTrigger(Event("WovenSimulation.Pause", None))
        self.states["/Main/ModeSelector/Running/Realtime/Running"].addTransition(_Main_ModeSelector_Running_Realtime_Running_0)
        _Main_ModeSelector_Running_Realtime_Running_1 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Realtime_Running_1.setAction(self._Main_ModeSelector_Running_Realtime_Running_1_exec)
        _Main_ModeSelector_Running_Realtime_Running_1.setTrigger(None)
        _Main_ModeSelector_Running_Realtime_Running_1.setGuard(self._Main_ModeSelector_Running_Realtime_Running_1_guard)
        self.states["/Main/ModeSelector/Running/Realtime/Running"].addTransition(_Main_ModeSelector_Running_Realtime_Running_1)
        _Main_ModeSelector_Running_Realtime_Running_2 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime/Running"], [self.states["/Main/ModeSelector/Running/Realtime/Running"]])
        _Main_ModeSelector_Running_Realtime_Running_2.setAction(self._Main_ModeSelector_Running_Realtime_Running_2_exec)
        _Main_ModeSelector_Running_Realtime_Running_2.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/Realtime/Running"].addTransition(_Main_ModeSelector_Running_Realtime_Running_2)
        
        # transition /Main/ModeSelector/Running/BigStep
        _Main_ModeSelector_Running_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/BigStep"], [self.states["/Main/ModeSelector/CheckIfBreakpointTriggers"]])
        _Main_ModeSelector_Running_BigStep_0.setAction(self._Main_ModeSelector_Running_BigStep_0_exec)
        _Main_ModeSelector_Running_BigStep_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/BigStep"].addTransition(_Main_ModeSelector_Running_BigStep_0)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/ModeSelector/Running/ChildStep/Paused
        _Main_ModeSelector_Running_ChildStep_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Running/ChildStep/Paused"], [self.states["/Main/ModeSelector/Running/ChildStep/BigStep"]])
        _Main_ModeSelector_Running_ChildStep_Paused_0.setTrigger(Event("CBDBigStep.Execute", None))
        self.states["/Main/ModeSelector/Running/ChildStep/Paused"].addTransition(_Main_ModeSelector_Running_ChildStep_Paused_0)
        _Main_ModeSelector_Running_ChildStep_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Running/ChildStep/Paused"], [self.states["/Main/ModeSelector/Running/ChildStep/SmallStep"]])
        _Main_ModeSelector_Running_ChildStep_Paused_1.setTrigger(Event("CBDSmallStep.Execute", None))
        self.states["/Main/ModeSelector/Running/ChildStep/Paused"].addTransition(_Main_ModeSelector_Running_ChildStep_Paused_1)
        _Main_ModeSelector_Running_ChildStep_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Running/ChildStep/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_ChildStep_Paused_2.setAction(self._Main_ModeSelector_Running_ChildStep_Paused_2_exec)
        _Main_ModeSelector_Running_ChildStep_Paused_2.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/ChildStep/Paused"].addTransition(_Main_ModeSelector_Running_ChildStep_Paused_2)
        
        # transition /Main/ModeSelector/Running/ChildStep/BigStep
        _Main_ModeSelector_Running_ChildStep_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/ChildStep/BigStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_ChildStep_BigStep_0.setAction(self._Main_ModeSelector_Running_ChildStep_BigStep_0_exec)
        _Main_ModeSelector_Running_ChildStep_BigStep_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/ChildStep/BigStep"].addTransition(_Main_ModeSelector_Running_ChildStep_BigStep_0)
        
        # transition /Main/ModeSelector/Running/ChildStep/SmallStep
        _Main_ModeSelector_Running_ChildStep_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/ChildStep/SmallStep"], [self.states["/Main/ModeSelector/Running/ChildStep/Paused"]])
        _Main_ModeSelector_Running_ChildStep_SmallStep_0.setAction(self._Main_ModeSelector_Running_ChildStep_SmallStep_0_exec)
        _Main_ModeSelector_Running_ChildStep_SmallStep_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/ChildStep/SmallStep"].addTransition(_Main_ModeSelector_Running_ChildStep_SmallStep_0)
        
        # transition /Main/FSAChildState/Uninitialized
        _Main_FSAChildState_Uninitialized_0 = Transition(self, self.states["/Main/FSAChildState/Uninitialized"], [self.states["/Main/FSAChildState/Initialized"]])
        _Main_FSAChildState_Uninitialized_0.setAction(self._Main_FSAChildState_Uninitialized_0_exec)
        _Main_FSAChildState_Uninitialized_0.setTrigger(Event("FSASimulation.Initialized", None))
        self.states["/Main/FSAChildState/Uninitialized"].addTransition(_Main_FSAChildState_Uninitialized_0)
        
        # transition /Main/FSAChildState/Initialized
        _Main_FSAChildState_Initialized_0 = Transition(self, self.states["/Main/FSAChildState/Initialized"], [self.states["/Main/FSAChildState/Uninitialized"]])
        _Main_FSAChildState_Initialized_0.setAction(self._Main_FSAChildState_Initialized_0_exec)
        _Main_FSAChildState_Initialized_0.setTrigger(Event("FSASimulation.Finished", None))
        self.states["/Main/FSAChildState/Initialized"].addTransition(_Main_FSAChildState_Initialized_0)
        
        # transition /Main/CBDChildState/Uninitialized
        _Main_CBDChildState_Uninitialized_0 = Transition(self, self.states["/Main/CBDChildState/Uninitialized"], [self.states["/Main/CBDChildState/Initialized"]])
        _Main_CBDChildState_Uninitialized_0.setAction(self._Main_CBDChildState_Uninitialized_0_exec)
        _Main_CBDChildState_Uninitialized_0.setTrigger(Event("CBDSimulation.Initialized", None))
        self.states["/Main/CBDChildState/Uninitialized"].addTransition(_Main_CBDChildState_Uninitialized_0)
        
        # transition /Main/CBDChildState/Initialized
        _Main_CBDChildState_Initialized_0 = Transition(self, self.states["/Main/CBDChildState/Initialized"], [self.states["/Main/CBDChildState/Uninitialized"]])
        _Main_CBDChildState_Initialized_0.setAction(self._Main_CBDChildState_Initialized_0_exec)
        _Main_CBDChildState_Initialized_0.setTrigger(Event("FSASmallStep.Finished", None))
        _Main_CBDChildState_Initialized_0.setGuard(self._Main_CBDChildState_Initialized_0_guard)
        self.states["/Main/CBDChildState/Initialized"].addTransition(_Main_CBDChildState_Initialized_0)
        
        # transition /Main/FSAInitializer/Waiting
        _Main_FSAInitializer_Waiting_0 = Transition(self, self.states["/Main/FSAInitializer/Waiting"], [self.states["/Main/FSAInitializer/CreatingChildSimulator"]])
        _Main_FSAInitializer_Waiting_0.setAction(self._Main_FSAInitializer_Waiting_0_exec)
        _Main_FSAInitializer_Waiting_0.setTrigger(None)
        _Main_FSAInitializer_Waiting_0.setGuard(self._Main_FSAInitializer_Waiting_0_guard)
        self.states["/Main/FSAInitializer/Waiting"].addTransition(_Main_FSAInitializer_Waiting_0)
        
        # transition /Main/FSAInitializer/CreatingChildSimulator
        _Main_FSAInitializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/FSAInitializer/CreatingChildSimulator"], [self.states["/Main/FSAInitializer/StartingChildSimulator"]])
        _Main_FSAInitializer_CreatingChildSimulator_0.setAction(self._Main_FSAInitializer_CreatingChildSimulator_0_exec)
        _Main_FSAInitializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/FSAInitializer/CreatingChildSimulator"].addTransition(_Main_FSAInitializer_CreatingChildSimulator_0)
        
        # transition /Main/FSAInitializer/StartingChildSimulator
        _Main_FSAInitializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/FSAInitializer/StartingChildSimulator"], [self.states["/Main/FSAInitializer/Running"]])
        _Main_FSAInitializer_StartingChildSimulator_0.setTrigger(Event("FSASimulation.Initialized", None))
        self.states["/Main/FSAInitializer/StartingChildSimulator"].addTransition(_Main_FSAInitializer_StartingChildSimulator_0)
        
        # transition /Main/FSAInitializer/Running
        _Main_FSAInitializer_Running_0 = Transition(self, self.states["/Main/FSAInitializer/Running"], [self.states["/Main/FSAInitializer/SettleBeforeWaiting"]])
        _Main_FSAInitializer_Running_0.setTrigger(Event("FSASimulation.Finished", None))
        self.states["/Main/FSAInitializer/Running"].addTransition(_Main_FSAInitializer_Running_0)
        
        # transition /Main/FSAInitializer/SettleBeforeWaiting
        _Main_FSAInitializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/FSAInitializer/SettleBeforeWaiting"], [self.states["/Main/FSAInitializer/Waiting"]])
        _Main_FSAInitializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/FSAInitializer/SettleBeforeWaiting"].addTransition(_Main_FSAInitializer_SettleBeforeWaiting_0)
        
        # transition /Main/CBDInitializer/Waiting
        _Main_CBDInitializer_Waiting_0 = Transition(self, self.states["/Main/CBDInitializer/Waiting"], [self.states["/Main/CBDInitializer/CreatingChildSimulator"]])
        _Main_CBDInitializer_Waiting_0.setAction(self._Main_CBDInitializer_Waiting_0_exec)
        _Main_CBDInitializer_Waiting_0.setTrigger(None)
        _Main_CBDInitializer_Waiting_0.setGuard(self._Main_CBDInitializer_Waiting_0_guard)
        self.states["/Main/CBDInitializer/Waiting"].addTransition(_Main_CBDInitializer_Waiting_0)
        
        # transition /Main/CBDInitializer/CreatingChildSimulator
        _Main_CBDInitializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/CBDInitializer/CreatingChildSimulator"], [self.states["/Main/CBDInitializer/StartingChildSimulator"]])
        _Main_CBDInitializer_CreatingChildSimulator_0.setAction(self._Main_CBDInitializer_CreatingChildSimulator_0_exec)
        _Main_CBDInitializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/CBDInitializer/CreatingChildSimulator"].addTransition(_Main_CBDInitializer_CreatingChildSimulator_0)
        
        # transition /Main/CBDInitializer/StartingChildSimulator
        _Main_CBDInitializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/CBDInitializer/StartingChildSimulator"], [self.states["/Main/CBDInitializer/Running"]])
        _Main_CBDInitializer_StartingChildSimulator_0.setTrigger(Event("CBDSimulation.Initialized", None))
        self.states["/Main/CBDInitializer/StartingChildSimulator"].addTransition(_Main_CBDInitializer_StartingChildSimulator_0)
        
        # transition /Main/CBDInitializer/Running
        _Main_CBDInitializer_Running_0 = Transition(self, self.states["/Main/CBDInitializer/Running"], [self.states["/Main/CBDInitializer/SettleBeforeWaiting"]])
        _Main_CBDInitializer_Running_0.setTrigger(Event("FSASmallStep.Finished", None))
        _Main_CBDInitializer_Running_0.setGuard(self._Main_CBDInitializer_Running_0_guard)
        self.states["/Main/CBDInitializer/Running"].addTransition(_Main_CBDInitializer_Running_0)
        
        # transition /Main/CBDInitializer/SettleBeforeWaiting
        _Main_CBDInitializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/CBDInitializer/SettleBeforeWaiting"], [self.states["/Main/CBDInitializer/Waiting"]])
        _Main_CBDInitializer_SettleBeforeWaiting_0.setTrigger(Event("_1after"))
        self.states["/Main/CBDInitializer/SettleBeforeWaiting"].addTransition(_Main_CBDInitializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/DebuggerInitialized"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/DebuggerInitialized
        _Main_SimulationFlow_DebuggerInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/DebuggerInitialized"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_DebuggerInitialized_0.setAction(self._Main_SimulationFlow_DebuggerInitialized_0_exec)
        _Main_SimulationFlow_DebuggerInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/DebuggerInitialized"].addTransition(_Main_SimulationFlow_DebuggerInitialized_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_2after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/ExecutingCBD"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        _Main_SimulationFlow_CheckTermination_2 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/SteppedInto"]])
        _Main_SimulationFlow_CheckTermination_2.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_2.setGuard(self._Main_SimulationFlow_CheckTermination_2_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_2)
        _Main_SimulationFlow_CheckTermination_3 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/WaitingRealtime"]])
        _Main_SimulationFlow_CheckTermination_3.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_3.setGuard(self._Main_SimulationFlow_CheckTermination_3_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_3)
        _Main_SimulationFlow_CheckTermination_4 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_4.setAction(self._Main_SimulationFlow_CheckTermination_4_exec)
        _Main_SimulationFlow_CheckTermination_4.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_4.setGuard(self._Main_SimulationFlow_CheckTermination_4_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_4)
        
        # transition /Main/SimulationFlow/WaitingRealtime
        _Main_SimulationFlow_WaitingRealtime_0 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_WaitingRealtime_0.setAction(self._Main_SimulationFlow_WaitingRealtime_0_exec)
        _Main_SimulationFlow_WaitingRealtime_0.setTrigger(Event("_3after"))
        _Main_SimulationFlow_WaitingRealtime_0.setGuard(self._Main_SimulationFlow_WaitingRealtime_0_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_0)
        _Main_SimulationFlow_WaitingRealtime_1 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_WaitingRealtime_1.setAction(self._Main_SimulationFlow_WaitingRealtime_1_exec)
        _Main_SimulationFlow_WaitingRealtime_1.setTrigger(None)
        _Main_SimulationFlow_WaitingRealtime_1.setGuard(self._Main_SimulationFlow_WaitingRealtime_1_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_1)
        _Main_SimulationFlow_WaitingRealtime_2 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_WaitingRealtime_2.setAction(self._Main_SimulationFlow_WaitingRealtime_2_exec)
        _Main_SimulationFlow_WaitingRealtime_2.setTrigger(None)
        _Main_SimulationFlow_WaitingRealtime_2.setGuard(self._Main_SimulationFlow_WaitingRealtime_2_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_2)
        _Main_SimulationFlow_WaitingRealtime_3 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/ExecutingCBD"]])
        _Main_SimulationFlow_WaitingRealtime_3.setAction(self._Main_SimulationFlow_WaitingRealtime_3_exec)
        _Main_SimulationFlow_WaitingRealtime_3.setTrigger(None)
        _Main_SimulationFlow_WaitingRealtime_3.setGuard(self._Main_SimulationFlow_WaitingRealtime_3_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_3)
        
        # transition /Main/SimulationFlow/SteppedInto/Waiting
        _Main_SimulationFlow_SteppedInto_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/SteppedInto/Waiting"], [self.states["/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep"]])
        _Main_SimulationFlow_SteppedInto_Waiting_0.setAction(self._Main_SimulationFlow_SteppedInto_Waiting_0_exec)
        _Main_SimulationFlow_SteppedInto_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_SteppedInto_Waiting_0.setGuard(self._Main_SimulationFlow_SteppedInto_Waiting_0_guard)
        self.states["/Main/SimulationFlow/SteppedInto/Waiting"].addTransition(_Main_SimulationFlow_SteppedInto_Waiting_0)
        _Main_SimulationFlow_SteppedInto_Waiting_1 = Transition(self, self.states["/Main/SimulationFlow/SteppedInto/Waiting"], [self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"]])
        _Main_SimulationFlow_SteppedInto_Waiting_1.setAction(self._Main_SimulationFlow_SteppedInto_Waiting_1_exec)
        _Main_SimulationFlow_SteppedInto_Waiting_1.setTrigger(None)
        _Main_SimulationFlow_SteppedInto_Waiting_1.setGuard(self._Main_SimulationFlow_SteppedInto_Waiting_1_guard)
        self.states["/Main/SimulationFlow/SteppedInto/Waiting"].addTransition(_Main_SimulationFlow_SteppedInto_Waiting_1)
        
        # transition /Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep
        _Main_SimulationFlow_SteppedInto_ExecutingCBDSmallStep_0 = Transition(self, self.states["/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep"], [self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"]])
        _Main_SimulationFlow_SteppedInto_ExecutingCBDSmallStep_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/SimulationFlow/SteppedInto/ExecutingCBDSmallStep"].addTransition(_Main_SimulationFlow_SteppedInto_ExecutingCBDSmallStep_0)
        
        # transition /Main/SimulationFlow/SteppedInto/SettleBeforeWaiting
        _Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"], [self.states["/Main/SimulationFlow/SteppedInto/Waiting"]])
        _Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_0.setTrigger(Event("_4after"))
        self.states["/Main/SimulationFlow/SteppedInto/SettleBeforeWaiting"].addTransition(_Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/ExecutingCBD
        _Main_SimulationFlow_ExecutingCBD_0 = Transition(self, self.states["/Main/SimulationFlow/ExecutingCBD"], [self.states["/Main/SimulationFlow/CheckingForStateEvent"]])
        _Main_SimulationFlow_ExecutingCBD_0.setAction(self._Main_SimulationFlow_ExecutingCBD_0_exec)
        _Main_SimulationFlow_ExecutingCBD_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/SimulationFlow/ExecutingCBD"].addTransition(_Main_SimulationFlow_ExecutingCBD_0)
        
        # transition /Main/SimulationFlow/CheckingForStateEvent
        _Main_SimulationFlow_CheckingForStateEvent_0 = Transition(self, self.states["/Main/SimulationFlow/CheckingForStateEvent"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckingForStateEvent_0.setAction(self._Main_SimulationFlow_CheckingForStateEvent_0_exec)
        _Main_SimulationFlow_CheckingForStateEvent_0.setTrigger(None)
        _Main_SimulationFlow_CheckingForStateEvent_0.setGuard(self._Main_SimulationFlow_CheckingForStateEvent_0_guard)
        self.states["/Main/SimulationFlow/CheckingForStateEvent"].addTransition(_Main_SimulationFlow_CheckingForStateEvent_0)
        _Main_SimulationFlow_CheckingForStateEvent_1 = Transition(self, self.states["/Main/SimulationFlow/CheckingForStateEvent"], [self.states["/Main/SimulationFlow/SendingGodEvent"]])
        _Main_SimulationFlow_CheckingForStateEvent_1.setAction(self._Main_SimulationFlow_CheckingForStateEvent_1_exec)
        _Main_SimulationFlow_CheckingForStateEvent_1.setTrigger(None)
        _Main_SimulationFlow_CheckingForStateEvent_1.setGuard(self._Main_SimulationFlow_CheckingForStateEvent_1_guard)
        self.states["/Main/SimulationFlow/CheckingForStateEvent"].addTransition(_Main_SimulationFlow_CheckingForStateEvent_1)
        
        # transition /Main/SimulationFlow/SendingGodEvent
        _Main_SimulationFlow_SendingGodEvent_0 = Transition(self, self.states["/Main/SimulationFlow/SendingGodEvent"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_SendingGodEvent_0.setAction(self._Main_SimulationFlow_SendingGodEvent_0_exec)
        _Main_SimulationFlow_SendingGodEvent_0.setTrigger(Event("FSASimulation.GodEventResult", None))
        self.states["/Main/SimulationFlow/SendingGodEvent"].addTransition(_Main_SimulationFlow_SendingGodEvent_0)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/BreakpointManager/Listening
        _Main_BreakpointManager_Listening_0 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_0.setAction(self._Main_BreakpointManager_Listening_0_exec)
        _Main_BreakpointManager_Listening_0.setTrigger(Event("Breakpoint.Add", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_0)
        _Main_BreakpointManager_Listening_1 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_1.setAction(self._Main_BreakpointManager_Listening_1_exec)
        _Main_BreakpointManager_Listening_1.setTrigger(Event("Breakpoint.Del", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_1)
        _Main_BreakpointManager_Listening_2 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_2.setAction(self._Main_BreakpointManager_Listening_2_exec)
        _Main_BreakpointManager_Listening_2.setTrigger(Event("Breakpoint.Toggle", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_2)
        _Main_BreakpointManager_Listening_3 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_3.setAction(self._Main_BreakpointManager_Listening_3_exec)
        _Main_BreakpointManager_Listening_3.setTrigger(Event("Breakpoint.List", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_3)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("FSASimulation.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
        _Main_ModeSelector_Running_1 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_1.setTrigger(Event("CBDSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_1)
        
        # transition /Main/SimulationFlow/SteppedInto
        _Main_SimulationFlow_SteppedInto_0 = Transition(self, self.states["/Main/SimulationFlow/SteppedInto"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_SteppedInto_0.setAction(self._Main_SimulationFlow_SteppedInto_0_exec)
        _Main_SimulationFlow_SteppedInto_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/SimulationFlow/SteppedInto"].addTransition(_Main_SimulationFlow_SteppedInto_0)
    
    def _Main_ModeSelector_CheckIfBreakpointTriggers_enter(self):
        self.breakpoint_triggers = self.breakpointTriggers(False)
    
    def _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_enter(self):
        self.breakpoint_triggers = self.breakpointTriggers(False)
    
    def _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_enter(self):
        self.breakpoint_triggers = self.breakpointTriggers(False)
    
    def _Main_ModeSelector_Stopped_enter(self):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("WovenSimulation.Finished", None, [self.fsa_clock, self.fsa_state])]))
    
    def _Main_FSAInitializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_FSAInitializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_CBDInitializer_SettleBeforeWaiting_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_CBDInitializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(1)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(2, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(2)
    
    def _Main_SimulationFlow_WaitingRealtime_enter(self):
        self.addTimer(3, self.sccd_yield())
    
    def _Main_SimulationFlow_WaitingRealtime_exit(self):
        self.removeTimer(3)
    
    def _Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_enter(self):
        self.addTimer(4, self.sccd_yield())
    
    def _Main_SimulationFlow_SteppedInto_SettleBeforeWaiting_exit(self):
        self.removeTimer(4)
    
    def _Main_SimulationFlow_SteppedInto_0_exec(self, parameters):
        cbd_clock = parameters[0]
        cbd_iteration = parameters[1]
        cbd_time_next = parameters[2]
        cbd_state = parameters[3]
        self.wovenUpdateGlobalState()
        self.woven_lib.dumpGlobalState(self.woven_model, self.woven_global_state, self.fsa_clock / 1000.0, self.fsa_state)
        self.cbd_clock = cbd_clock
        self.cbd_state = cbd_state
        self.cbd_iteration = cbd_iteration
        self.cbd_time_next = cbd_time_next
        self.woven_triggered_when_transition = self.wovenGetTriggeredWhenTransition()
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASmallStep.Execute", None, [self.woven_triggered_when_transition])]))
        # print 'Executing a FSA small step... (after CBD big step)'
    
    def _Main_ModeSelector_Paused_3_exec(self, parameters):
        realtime_scale = parameters[0]
        self.realtime_scale = float(realtime_scale)
    
    def _Main_ModeSelector_Paused_4_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("StepInto.Success", None, [])]))
    
    def _Main_ModeSelector_Paused_4_guard(self, parameters):
        return isinstance(self.fsa_state, CBDState)
    
    def _Main_ModeSelector_Paused_5_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("StepInto.Failure", None, [])]))
    
    def _Main_ModeSelector_Paused_5_guard(self, parameters):
        return not isinstance(self.fsa_state, CBDState)
    
    def _Main_ModeSelector_Paused_6_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        fsa_event_list = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [fsa_clock, fsa_state, fsa_elapsed, fsa_time_next, fsa_event_list, fsa_executed_transition])]))
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
        self.fsa_event_list = fsa_event_list
    
    def _Main_ModeSelector_ExecutingRealtimeIfInitialized_0_exec(self, parameters):
        # If the simulation was paused, we need to reset the start time of the WovenSimulation.
        # The start time of the simulation is equal to the point in wall-fsa_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-fsa_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.fsa_clock / self.realtime_scale)
    
    def _Main_ModeSelector_ExecutingRealtimeIfInitialized_0_guard(self, parameters):
        return self.inState(["/Main/FSAChildState/Initialized"])
    
    def _Main_ModeSelector_WaitingForBigStepToEndPause_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        fsa_event_list = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [fsa_clock, fsa_state, fsa_elapsed, fsa_time_next, fsa_event_list, fsa_executed_transition])]))
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
        self.fsa_event_list = fsa_event_list
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("WovenSimulation.Paused", None, [self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_CheckIfBreakpointTriggers_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_CheckIfBreakpointTriggers_0_guard(self, parameters):
        return self.breakpoint_triggers
    
    def _Main_ModeSelector_CheckIfBreakpointTriggers_1_guard(self, parameters):
        return not self.breakpoint_triggers
    
    def _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_0_guard(self, parameters):
        return self.breakpoint_triggers
    
    def _Main_ModeSelector_Running_Continuous_CheckIfBreakpointTriggers_1_guard(self, parameters):
        return not self.breakpoint_triggers
    
    def _Main_ModeSelector_Running_Continuous_Running_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_Running_Continuous_Running_1_guard(self, parameters):
        return self.breakpointTriggers(False)
    
    def _Main_ModeSelector_Running_Continuous_Running_2_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        fsa_event_list = parameters[4]
        fsa_executed_transition = parameters[5]
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
        self.fsa_event_list = fsa_event_list
    
    def _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_0_guard(self, parameters):
        return self.breakpoint_triggers
    
    def _Main_ModeSelector_Running_Realtime_CheckIfBreakpointTriggers_1_guard(self, parameters):
        return not self.breakpoint_triggers
    
    def _Main_ModeSelector_Running_Realtime_Running_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.fsa_clock, self.fsa_state])]))
    
    def _Main_ModeSelector_Running_Realtime_Running_1_guard(self, parameters):
        return self.breakpointTriggers(True)
    
    def _Main_ModeSelector_Running_Realtime_Running_2_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        fsa_event_list = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [fsa_clock, fsa_state, fsa_elapsed, fsa_time_next, fsa_event_list, fsa_executed_transition])]))
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
        self.fsa_event_list = fsa_event_list
    
    def _Main_ModeSelector_Running_BigStep_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        fsa_event_list = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [fsa_clock, fsa_state, fsa_elapsed, fsa_time_next, fsa_event_list, fsa_executed_transition])]))
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
        self.fsa_event_list = fsa_event_list
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_event_list = parameters[3]
        fsa_current_event = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASmallStep.Finished", None, [fsa_clock, fsa_state, fsa_elapsed, fsa_event_list, fsa_current_event, fsa_executed_transition])]))
    
    def _Main_ModeSelector_Running_ChildStep_Paused_2_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [clock, iteration, time_next, state])]))
    
    def _Main_ModeSelector_Running_ChildStep_BigStep_0_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [clock, iteration, time_next, state])]))
    
    def _Main_ModeSelector_Running_ChildStep_SmallStep_0_exec(self, parameters):
        new_current_component_idx = parameters[0]
        new_state = parameters[1]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSmallStep.Finished", None, [new_current_component_idx, new_state])]))
    
    def _Main_FSAChildState_Uninitialized_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_time_next = parameters[3]
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_time_next = fsa_time_next
    
    def _Main_FSAChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_fsa_simulator']))
    
    def _Main_CBDChildState_Uninitialized_0_exec(self, parameters):
        cbd_clock = parameters[0]
        cbd_state = parameters[1]
        cbd_iteration = parameters[2]
        cbd_time_next = parameters[3]
        self.cbd_clock = cbd_clock
        self.cbd_state = cbd_state
        self.cbd_iteration = cbd_iteration
        self.cbd_time_next = cbd_time_next
    
    def _Main_CBDChildState_Initialized_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_event_list = parameters[3]
        fsa_current_event = parameters[4]
        fsa_executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_cbd_simulator']))
    
    def _Main_CBDChildState_Initialized_0_guard(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_event_list = parameters[3]
        fsa_current_event = parameters[4]
        fsa_executed_transition = parameters[5]
        return fsa_executed_transition
    
    def _Main_FSAInitializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_fsa_simulator', 'FSASimulator_Simulation', self.woven_model, self.fsa_events, self.woven_delta]))
    
    def _Main_FSAInitializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) or self.inState(["/Main/ModeSelector/ExecutingRealtimeIfInitialized"]) and self.inState(["/Main/FSAChildState/Uninitialized"])
    
    def _Main_FSAInitializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_fsa_simulator']))
    
    def _Main_CBDInitializer_Waiting_0_exec(self, parameters):
        self.wovenUpdateCBDState()
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_cbd_simulator', 'CBDSimulator_Simulation', self.cbd_options, self.fsa_state.cbd, self.woven_delta]))
    
    def _Main_CBDInitializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/CBDChildState/Uninitialized"]) and self.inState(["/Main/FSAChildState/Initialized"]) and isinstance(self.fsa_state, CBDState)
    
    def _Main_CBDInitializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_cbd_simulator']))
    
    def _Main_CBDInitializer_Running_0_guard(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_event_list = parameters[3]
        fsa_current_event = parameters[4]
        fsa_executed_transition = parameters[5]
        return fsa_executed_transition
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
    
    def _Main_SimulationFlow_DebuggerInitialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("WovenSimulation.Initialized", None, [self.woven_global_state])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASmallStep.Execute", None, [None])]))
        # print 'Executing a FSA small step... (no CBD state)'
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return (self.inState(["/Main/ModeSelector/Running/Continuous/Running"]) or self.inState(["/Main/ModeSelector/Running/BigStep"]) or self.inState(["/Main/ModeSelector/Running/SmallStep"])) and self.inState(["/Main/FSAChildState/Initialized"]) and not isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_cbd_simulator', Event("CBDBigStep.Execute", None, [])]))
        # print 'Executing a CBD big step... (CBD state)'
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return (self.inState(["/Main/ModeSelector/Running/Continuous/Running"]) or self.inState(["/Main/ModeSelector/Running/BigStep"]) or self.inState(["/Main/ModeSelector/Running/SmallStep"])) and self.inState(["/Main/CBDChildState/Initialized"]) and isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_CheckTermination_2_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/ChildStep/SmallStep"]) or self.inState(["/Main/ModeSelector/Running/ChildStep/BigStep"])
    
    def _Main_SimulationFlow_CheckTermination_3_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Realtime/Running"]) and self.inState(["/Main/FSAChildState/Initialized"])
    
    def _Main_SimulationFlow_CheckTermination_4_exec(self, parameters):
        # print '>>> (WOVEN) simulation executed <<<'
        self.finalize()
    
    def _Main_SimulationFlow_CheckTermination_4_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Stopped"])
    
    def _Main_SimulationFlow_WaitingRealtime_0_exec(self, parameters):
        self.syncSimulatedTime()
    
    def _Main_SimulationFlow_WaitingRealtime_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_WaitingRealtime_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("WovenSimulation.Paused", None, [self.fsa_clock, self.fsa_state])]))
    
    def _Main_SimulationFlow_WaitingRealtime_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Paused"]) and (not ((self.waitTime() / 1000.0) <= self.sccd_yield()))
    
    def _Main_SimulationFlow_WaitingRealtime_2_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASmallStep.Execute", None, [None])]))
        # print 'Executing a FSA small step... (no CBD state - RT)'
    
    def _Main_SimulationFlow_WaitingRealtime_2_guard(self, parameters):
        return self.waitTime() / 1000.0 <= self.sccd_yield() and not isinstance(self.fsa_state, CBDState) and self.inState(["/Main/FSAChildState/Initialized"])
    
    def _Main_SimulationFlow_WaitingRealtime_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_cbd_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_WaitingRealtime_3_guard(self, parameters):
        return self.waitTime() / 1000.0 <= self.sccd_yield() and isinstance(self.fsa_state, CBDState) and self.inState(["/Main/CBDChildState/Initialized"])
    
    def _Main_SimulationFlow_SteppedInto_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_cbd_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_SteppedInto_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/ChildStep/SmallStep"]) and self.inState(["/Main/CBDChildState/Initialized"])
    
    def _Main_SimulationFlow_SteppedInto_Waiting_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_cbd_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_SteppedInto_Waiting_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/ChildStep/BigStep"]) and self.inState(["/Main/CBDChildState/Initialized"])
    
    def _Main_SimulationFlow_ExecutingCBD_0_exec(self, parameters):
        cbd_clock = parameters[0]
        cbd_iteration = parameters[1]
        cbd_time_next = parameters[2]
        cbd_state = parameters[3]
        self.wovenUpdateGlobalState()
        self.woven_lib.dumpGlobalState(self.woven_model, self.woven_global_state, self.fsa_clock / 1000.0, self.fsa_state)
        self.cbd_clock = cbd_clock
        self.cbd_state = cbd_state
        self.cbd_iteration = cbd_iteration
        self.cbd_time_next = cbd_time_next
        self.woven_triggered_when_transition = self.wovenGetTriggeredWhenTransition()
    
    def _Main_SimulationFlow_CheckingForStateEvent_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASmallStep.Execute", None, [])]))
        # print 'Executing a FSA small step... (after CBD big step)'
    
    def _Main_SimulationFlow_CheckingForStateEvent_0_guard(self, parameters):
        return self.woven_triggered_when_transition == None
    
    def _Main_SimulationFlow_CheckingForStateEvent_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASimulation.GodEvent", None, [self.woven_triggered_when_transition])]))
    
    def _Main_SimulationFlow_CheckingForStateEvent_1_guard(self, parameters):
        return not (self.woven_triggered_when_transition == None)
    
    def _Main_SimulationFlow_SendingGodEvent_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_fsa_simulator', Event("FSASmallStep.Execute", None, [])]))
        # print 'Executing a FSA small step... (after CBD big step -- state event detected)'
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        fsa_clock = parameters[0]
        fsa_state = parameters[1]
        fsa_elapsed = parameters[2]
        fsa_event_list = parameters[3]
        fsa_current_event = parameters[4]
        fsa_executed_transition = parameters[5]
        self.woven_lib.dumpDiscreteEvent(self.woven_model, self.fsa_clock / 1000.0, self.fsa_state, fsa_executed_transition)
        self.fsa_clock = fsa_clock
        self.fsa_state = fsa_state
        self.fsa_elapsed = fsa_elapsed
        self.fsa_event_list = fsa_event_list
        self.woven_triggered_when_transition = None
    
    def _Main_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.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.AddResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_1_exec(self, parameters):
        name = parameters[0]
        result = self.delBreakpoint(name)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.DelResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_2_exec(self, parameters):
        name = parameters[0]
        result = self.toggleBreakpoint(name)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.ToggleResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.ListResult", None, [[bp.name for bp in self.breakpoints]])]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class FSASimulator_Simulation(RuntimeClassBase):
    def __init__(self, controller, model, events, delta):
        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()
        
        # call user defined constructor
        FSASimulator_Simulation.user_defined_constructor(self, model, events, delta)
    
    def user_defined_constructor(self, model, events, delta):
        self.model = model
        self.event_list = events
        self.delta = delta
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.clock = 0
        self.elapsed = 0
        self.time_next = self.delta
        self.state = self.model.initialState
        self.selected_transition = None
    
    
    # user defined method
    def endCondition(self):
        return self.state and self.state.final
    
    
    # user defined method
    def finalize(self):
        print '(FSA) Simulation finalized.'
    
    
    # user defined method
    def initializeDebugger(self):
        pass
    
    
    # user defined method
    def godEvent(self, selected_transition):
        self.selected_transition = selected_transition
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/BigStep
        self.states["/Main/ModeSelector/Running/BigStep"] = State(5, "/Main/ModeSelector/Running/BigStep", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(6, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ModeSelector/Stopped
        self.states["/Main/ModeSelector/Stopped"] = State(7, "/Main/ModeSelector/Stopped", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(8, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(9, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(10, "/Main/ChildState/Initialized", self)
        
        # state /Main/ChildInitializer
        self.states["/Main/ChildInitializer"] = State(11, "/Main/ChildInitializer", self)
        
        # state /Main/ChildInitializer/Waiting
        self.states["/Main/ChildInitializer/Waiting"] = State(12, "/Main/ChildInitializer/Waiting", self)
        
        # state /Main/ChildInitializer/CreatingChildSimulator
        self.states["/Main/ChildInitializer/CreatingChildSimulator"] = State(13, "/Main/ChildInitializer/CreatingChildSimulator", self)
        
        # state /Main/ChildInitializer/StartingChildSimulator
        self.states["/Main/ChildInitializer/StartingChildSimulator"] = State(14, "/Main/ChildInitializer/StartingChildSimulator", self)
        
        # state /Main/ChildInitializer/Running
        self.states["/Main/ChildInitializer/Running"] = State(15, "/Main/ChildInitializer/Running", self)
        
        # state /Main/ChildInitializer/SettleBeforeWaiting
        self.states["/Main/ChildInitializer/SettleBeforeWaiting"] = State(16, "/Main/ChildInitializer/SettleBeforeWaiting", self)
        self.states["/Main/ChildInitializer/SettleBeforeWaiting"].setEnter(self._Main_ChildInitializer_SettleBeforeWaiting_enter)
        self.states["/Main/ChildInitializer/SettleBeforeWaiting"].setExit(self._Main_ChildInitializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(17, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(18, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(19, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(20, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/DebuggerInitialized
        self.states["/Main/SimulationFlow/DebuggerInitialized"] = State(21, "/Main/SimulationFlow/DebuggerInitialized", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(22, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(23, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(24, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/ExecutingBigStep
        self.states["/Main/SimulationFlow/ExecutingBigStep"] = State(25, "/Main/SimulationFlow/ExecutingBigStep", self)
        
        # state /Main/SimulationFlow/ExecutingSmallStep
        self.states["/Main/SimulationFlow/ExecutingSmallStep"] = State(26, "/Main/SimulationFlow/ExecutingSmallStep", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(27, "/Main/SimulationFlow/Stopped", self)
        
        # state /Main/GodEventManager
        self.states["/Main/GodEventManager"] = State(28, "/Main/GodEventManager", self)
        
        # state /Main/GodEventManager/Listening
        self.states["/Main/GodEventManager/Listening"] = State(29, "/Main/GodEventManager/Listening", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(30, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/ChildInitializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main"].addChild(self.states["/Main/GodEventManager"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Stopped"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/BigStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/ChildInitializer"].addChild(self.states["/Main/ChildInitializer/Waiting"])
        self.states["/Main/ChildInitializer"].addChild(self.states["/Main/ChildInitializer/CreatingChildSimulator"])
        self.states["/Main/ChildInitializer"].addChild(self.states["/Main/ChildInitializer/StartingChildSimulator"])
        self.states["/Main/ChildInitializer"].addChild(self.states["/Main/ChildInitializer/Running"])
        self.states["/Main/ChildInitializer"].addChild(self.states["/Main/ChildInitializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/DebuggerInitialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/ExecutingBigStep"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/ExecutingSmallStep"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states["/Main/GodEventManager"].addChild(self.states["/Main/GodEventManager/Listening"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/BigStep"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/ChildInitializer"].default_state = self.states["/Main/ChildInitializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        self.states["/Main/GodEventManager"].default_state = self.states["/Main/GodEventManager/Listening"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setTrigger(Event("FSASmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/BigStep"]])
        _Main_ModeSelector_Paused_1.setTrigger(Event("FSABigStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        _Main_ModeSelector_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_2.setAction(self._Main_ModeSelector_Paused_2_exec)
        _Main_ModeSelector_Paused_2.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_2)
        
        # transition /Main/ModeSelector/Running/BigStep
        _Main_ModeSelector_Running_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/BigStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_BigStep_0.setAction(self._Main_ModeSelector_Running_BigStep_0_exec)
        _Main_ModeSelector_Running_BigStep_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/BigStep"].addTransition(_Main_ModeSelector_Running_BigStep_0)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("FSABigStep.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/ChildInitializer/Waiting
        _Main_ChildInitializer_Waiting_0 = Transition(self, self.states["/Main/ChildInitializer/Waiting"], [self.states["/Main/ChildInitializer/CreatingChildSimulator"]])
        _Main_ChildInitializer_Waiting_0.setAction(self._Main_ChildInitializer_Waiting_0_exec)
        _Main_ChildInitializer_Waiting_0.setTrigger(None)
        _Main_ChildInitializer_Waiting_0.setGuard(self._Main_ChildInitializer_Waiting_0_guard)
        self.states["/Main/ChildInitializer/Waiting"].addTransition(_Main_ChildInitializer_Waiting_0)
        
        # transition /Main/ChildInitializer/CreatingChildSimulator
        _Main_ChildInitializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/ChildInitializer/CreatingChildSimulator"], [self.states["/Main/ChildInitializer/StartingChildSimulator"]])
        _Main_ChildInitializer_CreatingChildSimulator_0.setAction(self._Main_ChildInitializer_CreatingChildSimulator_0_exec)
        _Main_ChildInitializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/ChildInitializer/CreatingChildSimulator"].addTransition(_Main_ChildInitializer_CreatingChildSimulator_0)
        
        # transition /Main/ChildInitializer/StartingChildSimulator
        _Main_ChildInitializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/ChildInitializer/StartingChildSimulator"], [self.states["/Main/ChildInitializer/Running"]])
        _Main_ChildInitializer_StartingChildSimulator_0.setTrigger(Event("FSABigStep.Initialized", None))
        self.states["/Main/ChildInitializer/StartingChildSimulator"].addTransition(_Main_ChildInitializer_StartingChildSimulator_0)
        
        # transition /Main/ChildInitializer/Running
        _Main_ChildInitializer_Running_0 = Transition(self, self.states["/Main/ChildInitializer/Running"], [self.states["/Main/ChildInitializer/SettleBeforeWaiting"]])
        _Main_ChildInitializer_Running_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ChildInitializer/Running"].addTransition(_Main_ChildInitializer_Running_0)
        
        # transition /Main/ChildInitializer/SettleBeforeWaiting
        _Main_ChildInitializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/ChildInitializer/SettleBeforeWaiting"], [self.states["/Main/ChildInitializer/Waiting"]])
        _Main_ChildInitializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/ChildInitializer/SettleBeforeWaiting"].addTransition(_Main_ChildInitializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/DebuggerInitialized"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/DebuggerInitialized
        _Main_SimulationFlow_DebuggerInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/DebuggerInitialized"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_DebuggerInitialized_0.setAction(self._Main_SimulationFlow_DebuggerInitialized_0_exec)
        _Main_SimulationFlow_DebuggerInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/DebuggerInitialized"].addTransition(_Main_SimulationFlow_DebuggerInitialized_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setAction(self._Main_SimulationFlow_SettleBeforeCheckTermination_1_exec)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setGuard(self._Main_SimulationFlow_SettleBeforeCheckTermination_1_guard)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_1)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/ExecutingBigStep"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/ExecutingSmallStep"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        _Main_SimulationFlow_CheckTermination_2 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_2.setAction(self._Main_SimulationFlow_CheckTermination_2_exec)
        _Main_SimulationFlow_CheckTermination_2.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_2.setGuard(self._Main_SimulationFlow_CheckTermination_2_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_2)
        
        # transition /Main/SimulationFlow/ExecutingBigStep
        _Main_SimulationFlow_ExecutingBigStep_0 = Transition(self, self.states["/Main/SimulationFlow/ExecutingBigStep"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_ExecutingBigStep_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/SimulationFlow/ExecutingBigStep"].addTransition(_Main_SimulationFlow_ExecutingBigStep_0)
        
        # transition /Main/SimulationFlow/ExecutingSmallStep
        _Main_SimulationFlow_ExecutingSmallStep_0 = Transition(self, self.states["/Main/SimulationFlow/ExecutingSmallStep"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_ExecutingSmallStep_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/SimulationFlow/ExecutingSmallStep"].addTransition(_Main_SimulationFlow_ExecutingSmallStep_0)
        
        # transition /Main/GodEventManager/Listening
        _Main_GodEventManager_Listening_0 = Transition(self, self.states["/Main/GodEventManager/Listening"], [self.states["/Main/GodEventManager/Listening"]])
        _Main_GodEventManager_Listening_0.setAction(self._Main_GodEventManager_Listening_0_exec)
        _Main_GodEventManager_Listening_0.setTrigger(Event("FSASimulation.GodEvent", None))
        _Main_GodEventManager_Listening_0.setGuard(self._Main_GodEventManager_Listening_0_guard)
        self.states["/Main/GodEventManager/Listening"].addTransition(_Main_GodEventManager_Listening_0)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Stopped"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("FSASimulation.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
    
    def _Main_ChildInitializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_ChildInitializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ModeSelector_Paused_2_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        event_list = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [clock, state, elapsed, time_next, event_list, executed_transition])]))
        self.clock = clock
        self.state = state
        self.elapsed = elapsed
        self.time_next = time_next
        self.elapsed = elapsed
        self.event_list = event_list
    
    def _Main_ModeSelector_Running_BigStep_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        time_next = parameters[3]
        event_list = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [clock, state, elapsed, time_next, event_list, executed_transition])]))
        self.clock = clock
        self.state = state
        self.elapsed = elapsed
        self.time_next = time_next
        self.elapsed = elapsed
        self.event_list = event_list
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        event_list = parameters[3]
        current_event = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASmallStep.Finished", None, [clock, state, elapsed, event_list, current_event, executed_transition])]))
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_ChildInitializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'FSASimulator_BigStep', self.model, self.state, self.clock, self.elapsed, self.event_list, self.time_next, self.delta]))
    
    def _Main_ChildInitializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_ChildInitializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
    
    def _Main_SimulationFlow_DebuggerInitialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASimulation.Initialized", None, [self.clock, self.state, self.elapsed, self.time_next])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASimulation.Paused", None, [self.clock, self.state])]))
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Paused"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSABigStep.Execute", None, [self.selected_transition])]))
        self.selected_transition = None
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/BigStep"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSASmallStep.Execute", None, [self.selected_transition])]))
        self.selected_transition = None
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/SmallStep"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_2_exec(self, parameters):
        # print '>>> (FSA) simulation executed <<<'
        self.finalize()
        self.raiseInternalEvent(Event("FSASimulation.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASimulation.Finished", None, [self.clock, self.state])]))
    
    def _Main_SimulationFlow_CheckTermination_2_guard(self, parameters):
        return self.endCondition()
    
    def _Main_GodEventManager_Listening_0_exec(self, parameters):
        selected_transition = parameters[0]
        result = self.godEvent(selected_transition)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASimulation.GodEventResult", None, [result])]))
    
    def _Main_GodEventManager_Listening_0_guard(self, parameters):
        selected_transition = parameters[0]
        return self.inState(["/Main/ModeSelector/Paused"])
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class FSASimulator_BigStep(RuntimeClassBase):
    def __init__(self, controller, model, state, clock, elapsed, event_list, time_next, delta):
        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()
        
        # call user defined constructor
        FSASimulator_BigStep.user_defined_constructor(self, model, state, clock, elapsed, event_list, time_next, delta)
    
    def user_defined_constructor(self, model, state, clock, elapsed, event_list, time_next, delta):
        self.model = model
        self.state = state
        self.clock = clock
        self.elapsed = elapsed
        self.event_list = event_list
        self.time_next = time_next
        self.delta = delta
        self.selected_transition = None
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.current_event = self.getInputEventAt(self.clock / 1000.0)
        selected_transition = self.model.getTransitionFrom(self.state, self.current_event, self.elapsed)
        if (selected_transition != None):
            # Transitions triggered by environment events get priority over transitions triggered by state events.
            self.selected_transition = selected_transition
        self.small_step_executed = False
        self.executed_transition = False
    
    
    # user defined method
    def initializeDebugger(self):
        pass
    
    
    # user defined method
    def endCondition(self):
        ''' We make sure to "execute" a small step, even if no transition was selected. '''
        return self.small_step_executed and self.selected_transition == None
    
    
    # user defined method
    def finalize(self):
        self.advanceTime()
    
    
    # user defined method
    def advanceTime(self):
        self.clock = self.time_next
        self.elapsed = self.elapsed + self.delta
        self.time_next = self.clock + self.delta
    
    
    # user defined method
    def getInputEventAt(self, time):
        return self.event_list.getInputAt(time)
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(5, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(6, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(7, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(8, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(9, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(10, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(11, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(12, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(13, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/Initializer/Running
        self.states["/Main/Initializer/Running"] = State(14, "/Main/Initializer/Running", self)
        
        # state /Main/Initializer/SettleBeforeWaiting
        self.states["/Main/Initializer/SettleBeforeWaiting"] = State(15, "/Main/Initializer/SettleBeforeWaiting", self)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setEnter(self._Main_Initializer_SettleBeforeWaiting_enter)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setExit(self._Main_Initializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(16, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(17, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(18, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(19, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(20, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(21, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(22, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(23, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(24, "/Main/SimulationFlow/Stopped", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(25, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Running"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setAction(self._Main_ModeSelector_Paused_0_exec)
        _Main_ModeSelector_Paused_0.setTrigger(Event("FSASmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_1.setAction(self._Main_ModeSelector_Paused_1_exec)
        _Main_ModeSelector_Paused_1.setTrigger(Event("FSABigStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("FSASmallStep.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Running"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("FSASmallStep.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/Initializer/Running
        _Main_Initializer_Running_0 = Transition(self, self.states["/Main/Initializer/Running"], [self.states["/Main/Initializer/SettleBeforeWaiting"]])
        _Main_Initializer_Running_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/Initializer/Running"].addTransition(_Main_Initializer_Running_0)
        
        # transition /Main/Initializer/SettleBeforeWaiting
        _Main_Initializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/Initializer/SettleBeforeWaiting"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/Initializer/SettleBeforeWaiting"].addTransition(_Main_Initializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("FSABigStep.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
    
    def _Main_Initializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_Initializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ModeSelector_Paused_0_exec(self, parameters):
        selected_transition = parameters[0]
        if selected_transition != None:
            self.selected_transition = selected_transition
    
    def _Main_ModeSelector_Paused_1_exec(self, parameters):
        selected_transition = parameters[0]
        if selected_transition != None:
            self.selected_transition = selected_transition
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        event_list = parameters[3]
        current_event = parameters[4]
        executed_transition = parameters[5]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASmallStep.Finished", None, [clock, state, elapsed, event_list, current_event, executed_transition])]))
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'FSASimulator_SmallStep', self.model, self.state, self.clock, self.elapsed, self.selected_transition, self.current_event, self.event_list]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Initialized", None, [])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSASmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return (self.inState(["/Main/ModeSelector/Running/Continuous"]) or self.inState(["/Main/ModeSelector/Running/SmallStep"])) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        # print '>>> (FSA) big step executed <<<'
        self.finalize()
        self.raiseInternalEvent(Event("FSABigStep.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSABigStep.Finished", None, [self.clock, self.state, self.elapsed, self.time_next, self.event_list, self.executed_transition])]))
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.endCondition()
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        clock = parameters[0]
        state = parameters[1]
        elapsed = parameters[2]
        event_list = parameters[3]
        current_event = parameters[4]
        executed_transition = parameters[5]
        self.small_step_executed = True
        self.state = state
        self.elapsed = elapsed
        self.event_list = event_list
        self.current_event = current_event
        self.current_event = self.getInputEventAt(self.clock / 1000.0)
        self.selected_transition = self.model.getTransitionFrom(self.state, self.current_event, self.elapsed)
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class FSASimulator_SmallStep(RuntimeClassBase):
    def __init__(self, controller, model, state, clock, elapsed, selected_transition, current_event, event_list):
        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()
        
        # call user defined constructor
        FSASimulator_SmallStep.user_defined_constructor(self, model, state, clock, elapsed, selected_transition, current_event, event_list)
    
    def user_defined_constructor(self, model, state, clock, elapsed, selected_transition, current_event, event_list):
        self.model = model
        self.state = state
        self.clock = clock
        self.elapsed = elapsed
        self.selected_transition = selected_transition
        self.current_event = current_event
        self.event_list = event_list
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.transition_taken = False
    
    
    # user defined method
    def initializeDebugger(self):
        pass
    
    
    # user defined method
    def endCondition(self):
        ''' In case nothing is to be done, we immediately end. '''
        return (not self.selected_transition) or self.transition_taken
    
    
    # user defined method
    def finalize(self):
        self.elapsed = 0
        self.processEvent(self.current_event)
    
    
    # user defined method
    def processEvent(self, event):
        if (event != None):
            self.event_list.popEvent(event)
            event.processed = True
    
    
    # user defined method
    def getInputEventAt(self, time):
        return self.event_list.getInputAt(time)
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(5, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(6, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(7, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(8, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(9, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(10, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(11, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(12, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/Initializer/Running
        self.states["/Main/Initializer/Running"] = State(13, "/Main/Initializer/Running", self)
        
        # state /Main/Initializer/SettleBeforeWaiting
        self.states["/Main/Initializer/SettleBeforeWaiting"] = State(14, "/Main/Initializer/SettleBeforeWaiting", self)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setEnter(self._Main_Initializer_SettleBeforeWaiting_enter)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setExit(self._Main_Initializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(15, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(16, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(17, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(18, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/DebuggerInitialized
        self.states["/Main/SimulationFlow/DebuggerInitialized"] = State(19, "/Main/SimulationFlow/DebuggerInitialized", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(20, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(21, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(22, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(23, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(24, "/Main/SimulationFlow/Stopped", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(25, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Running"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/DebuggerInitialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_0.setTrigger(Event("FSASmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("FSATransition.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("FSATransition.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Running"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("FSATransition.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/Initializer/Running
        _Main_Initializer_Running_0 = Transition(self, self.states["/Main/Initializer/Running"], [self.states["/Main/Initializer/SettleBeforeWaiting"]])
        _Main_Initializer_Running_0.setTrigger(Event("FSATransition.Finished", None))
        self.states["/Main/Initializer/Running"].addTransition(_Main_Initializer_Running_0)
        
        # transition /Main/Initializer/SettleBeforeWaiting
        _Main_Initializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/Initializer/SettleBeforeWaiting"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/Initializer/SettleBeforeWaiting"].addTransition(_Main_Initializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/DebuggerInitialized"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/DebuggerInitialized
        _Main_SimulationFlow_DebuggerInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/DebuggerInitialized"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_DebuggerInitialized_0.setAction(self._Main_SimulationFlow_DebuggerInitialized_0_exec)
        _Main_SimulationFlow_DebuggerInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/DebuggerInitialized"].addTransition(_Main_SimulationFlow_DebuggerInitialized_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("FSATransition.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("FSASmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
    
    def _Main_Initializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_Initializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'FSASimulator_Transition', self.selected_transition]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
    
    def _Main_SimulationFlow_DebuggerInitialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASmallStep.Initialized", None, [])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("FSATransition.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Continuous"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        # print '>>> (FSA) small step executed <<<'
        self.finalize()
        self.raiseInternalEvent(Event("FSASmallStep.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSASmallStep.Finished", None, [self.clock, self.state, self.elapsed, self.event_list, self.current_event, self.selected_transition])]))
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.endCondition()
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        new_state = parameters[0]
        self.transition_taken = True
        self.state = new_state
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class FSASimulator_Transition(RuntimeClassBase):
    def __init__(self, controller, selectedTransition):
        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()
        
        # call user defined constructor
        FSASimulator_Transition.user_defined_constructor(self, selectedTransition)
    
    def user_defined_constructor(self, selectedTransition):
        self.selectedTransition = selectedTransition
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def executeTransition(self):
        self.newState = self.selectedTransition.target
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /Started
        self.states["/Started"] = State(1, "/Started", self)
        
        # state /Waiting
        self.states["/Waiting"] = State(2, "/Waiting", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(3, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Started"])
        self.states[""].addChild(self.states["/Waiting"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Started"]
        
        # transition /Started
        _Started_0 = Transition(self, self.states["/Started"], [self.states["/Waiting"]])
        _Started_0.setAction(self._Started_0_exec)
        _Started_0.setTrigger(None)
        self.states["/Started"].addTransition(_Started_0)
        
        # transition /Waiting
        _Waiting_0 = Transition(self, self.states["/Waiting"], [self.states["/Stopped"]])
        _Waiting_0.setAction(self._Waiting_0_exec)
        _Waiting_0.setTrigger(Event("FSATransition.Execute", None))
        self.states["/Waiting"].addTransition(_Waiting_0)
    
    def _Started_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSATransition.Initialized", None, [])]))
    
    def _Waiting_0_exec(self, parameters):
        self.executeTransition()
        # print '>>> (FSA) transition executed <<< %s' % self.newState
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("FSATransition.Finished", None, [self.newState])]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Started"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class CBDSimulator_Simulation(RuntimeClassBase):
    def __init__(self, controller, options, model, delta):
        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()
        
        # call user defined constructor
        CBDSimulator_Simulation.user_defined_constructor(self, options, model, delta)
    
    def user_defined_constructor(self, options, model, delta):
        self.options = options
        self.delta = delta
        self.model = model
        self.initialized = False
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.iteration = 0
        self.clock = 0
        self.time_next = self.delta
        self.cbd_controller = CBDController(self.model, self.delta / 1000.0)
        self.cbd_controller.initSimulation()
        self.state = {b.getBlockName(): b.getSignal() for b in self.model.getBlocks()}
        self.initialized = True
    
    
    # user defined method
    def endCondition(self):
        return self.initialized and self.iteration >= self.options.getMaxIterations()
    
    
    # user defined method
    def finalize(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 initializeDebugger(self):
        self.breakpoints = []
        self.triggered_bp = None
    
    
    # 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.initialized:
            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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(5, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ModeSelector/Running/Realtime
        self.states["/Main/ModeSelector/Running/Realtime"] = State(6, "/Main/ModeSelector/Running/Realtime", self)
        
        # state /Main/ModeSelector/Running/BigStep
        self.states["/Main/ModeSelector/Running/BigStep"] = State(7, "/Main/ModeSelector/Running/BigStep", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(8, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(9, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(10, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(11, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(12, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(13, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(14, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(15, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/Initializer/Running
        self.states["/Main/Initializer/Running"] = State(16, "/Main/Initializer/Running", self)
        
        # state /Main/Initializer/SettleBeforeWaiting
        self.states["/Main/Initializer/SettleBeforeWaiting"] = State(17, "/Main/Initializer/SettleBeforeWaiting", self)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setEnter(self._Main_Initializer_SettleBeforeWaiting_enter)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setExit(self._Main_Initializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(18, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(19, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(20, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(21, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(22, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(23, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(24, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/WaitingRealtime
        self.states["/Main/SimulationFlow/WaitingRealtime"] = State(25, "/Main/SimulationFlow/WaitingRealtime", self)
        self.states["/Main/SimulationFlow/WaitingRealtime"].setEnter(self._Main_SimulationFlow_WaitingRealtime_enter)
        self.states["/Main/SimulationFlow/WaitingRealtime"].setExit(self._Main_SimulationFlow_WaitingRealtime_exit)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(26, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(27, "/Main/SimulationFlow/Stopped", self)
        
        # state /Main/GodEventManager
        self.states["/Main/GodEventManager"] = State(28, "/Main/GodEventManager", self)
        
        # state /Main/GodEventManager/Listening
        self.states["/Main/GodEventManager/Listening"] = State(29, "/Main/GodEventManager/Listening", self)
        
        # state /Main/BreakpointManager
        self.states["/Main/BreakpointManager"] = State(30, "/Main/BreakpointManager", self)
        
        # state /Main/BreakpointManager/Listening
        self.states["/Main/BreakpointManager/Listening"] = State(31, "/Main/BreakpointManager/Listening", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(32, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main"].addChild(self.states["/Main/GodEventManager"])
        self.states["/Main"].addChild(self.states["/Main/BreakpointManager"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Realtime"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/BigStep"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Running"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/WaitingRealtime"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states["/Main/GodEventManager"].addChild(self.states["/Main/GodEventManager/Listening"])
        self.states["/Main/BreakpointManager"].addChild(self.states["/Main/BreakpointManager/Listening"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        self.states["/Main/GodEventManager"].default_state = self.states["/Main/GodEventManager/Listening"]
        self.states["/Main/BreakpointManager"].default_state = self.states["/Main/BreakpointManager/Listening"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setAction(self._Main_ModeSelector_Paused_0_exec)
        _Main_ModeSelector_Paused_0.setTrigger(Event("CBDSmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/BigStep"]])
        _Main_ModeSelector_Paused_1.setAction(self._Main_ModeSelector_Paused_1_exec)
        _Main_ModeSelector_Paused_1.setTrigger(Event("CBDBigStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        _Main_ModeSelector_Paused_2 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_2.setTrigger(Event("CBDSimulation.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_2)
        _Main_ModeSelector_Paused_3 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Realtime"]])
        _Main_ModeSelector_Paused_3.setAction(self._Main_ModeSelector_Paused_3_exec)
        _Main_ModeSelector_Paused_3.setTrigger(Event("CBDSimulation.ExecuteRealtime", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_3)
        _Main_ModeSelector_Paused_4 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Paused_4.setAction(self._Main_ModeSelector_Paused_4_exec)
        _Main_ModeSelector_Paused_4.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_4)
        
        # transition /Main/ModeSelector/Running/Continuous
        _Main_ModeSelector_Running_Continuous_0 = Transition(self, self.states["/Main/ModeSelector/Running/Continuous"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Continuous_0.setTrigger(Event("CBDSimulation.Pause", None))
        self.states["/Main/ModeSelector/Running/Continuous"].addTransition(_Main_ModeSelector_Running_Continuous_0)
        
        # transition /Main/ModeSelector/Running/Realtime
        _Main_ModeSelector_Running_Realtime_0 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_Realtime_0.setTrigger(Event("CBDSimulation.Pause", None))
        self.states["/Main/ModeSelector/Running/Realtime"].addTransition(_Main_ModeSelector_Running_Realtime_0)
        _Main_ModeSelector_Running_Realtime_1 = Transition(self, self.states["/Main/ModeSelector/Running/Realtime"], [self.states["/Main/ModeSelector/Running/Realtime"]])
        _Main_ModeSelector_Running_Realtime_1.setAction(self._Main_ModeSelector_Running_Realtime_1_exec)
        _Main_ModeSelector_Running_Realtime_1.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/Realtime"].addTransition(_Main_ModeSelector_Running_Realtime_1)
        
        # transition /Main/ModeSelector/Running/BigStep
        _Main_ModeSelector_Running_BigStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/BigStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_BigStep_0.setAction(self._Main_ModeSelector_Running_BigStep_0_exec)
        _Main_ModeSelector_Running_BigStep_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running/BigStep"].addTransition(_Main_ModeSelector_Running_BigStep_0)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("CBDBigStep.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Running"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("CBDBigStep.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/Initializer/Running
        _Main_Initializer_Running_0 = Transition(self, self.states["/Main/Initializer/Running"], [self.states["/Main/Initializer/SettleBeforeWaiting"]])
        _Main_Initializer_Running_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/Initializer/Running"].addTransition(_Main_Initializer_Running_0)
        
        # transition /Main/Initializer/SettleBeforeWaiting
        _Main_Initializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/Initializer/SettleBeforeWaiting"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/Initializer/SettleBeforeWaiting"].addTransition(_Main_Initializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setAction(self._Main_SimulationFlow_SettleBeforeCheckTermination_1_exec)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_SettleBeforeCheckTermination_1.setGuard(self._Main_SimulationFlow_SettleBeforeCheckTermination_1_guard)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_1)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        _Main_SimulationFlow_CheckTermination_2 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/WaitingRealtime"]])
        _Main_SimulationFlow_CheckTermination_2.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_2.setGuard(self._Main_SimulationFlow_CheckTermination_2_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_2)
        _Main_SimulationFlow_CheckTermination_3 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_3.setAction(self._Main_SimulationFlow_CheckTermination_3_exec)
        _Main_SimulationFlow_CheckTermination_3.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_3.setGuard(self._Main_SimulationFlow_CheckTermination_3_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_3)
        
        # transition /Main/SimulationFlow/WaitingRealtime
        _Main_SimulationFlow_WaitingRealtime_0 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_WaitingRealtime_0.setAction(self._Main_SimulationFlow_WaitingRealtime_0_exec)
        _Main_SimulationFlow_WaitingRealtime_0.setTrigger(Event("_2after"))
        _Main_SimulationFlow_WaitingRealtime_0.setGuard(self._Main_SimulationFlow_WaitingRealtime_0_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_0)
        _Main_SimulationFlow_WaitingRealtime_1 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_WaitingRealtime_1.setAction(self._Main_SimulationFlow_WaitingRealtime_1_exec)
        _Main_SimulationFlow_WaitingRealtime_1.setTrigger(None)
        _Main_SimulationFlow_WaitingRealtime_1.setGuard(self._Main_SimulationFlow_WaitingRealtime_1_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_1)
        _Main_SimulationFlow_WaitingRealtime_2 = Transition(self, self.states["/Main/SimulationFlow/WaitingRealtime"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_WaitingRealtime_2.setAction(self._Main_SimulationFlow_WaitingRealtime_2_exec)
        _Main_SimulationFlow_WaitingRealtime_2.setTrigger(None)
        _Main_SimulationFlow_WaitingRealtime_2.setGuard(self._Main_SimulationFlow_WaitingRealtime_2_guard)
        self.states["/Main/SimulationFlow/WaitingRealtime"].addTransition(_Main_SimulationFlow_WaitingRealtime_2)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/GodEventManager/Listening
        _Main_GodEventManager_Listening_0 = Transition(self, self.states["/Main/GodEventManager/Listening"], [self.states["/Main/GodEventManager/Listening"]])
        _Main_GodEventManager_Listening_0.setAction(self._Main_GodEventManager_Listening_0_exec)
        _Main_GodEventManager_Listening_0.setTrigger(Event("CBDSimulation.GodEvent", None))
        _Main_GodEventManager_Listening_0.setGuard(self._Main_GodEventManager_Listening_0_guard)
        self.states["/Main/GodEventManager/Listening"].addTransition(_Main_GodEventManager_Listening_0)
        
        # transition /Main/BreakpointManager/Listening
        _Main_BreakpointManager_Listening_0 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_0.setAction(self._Main_BreakpointManager_Listening_0_exec)
        _Main_BreakpointManager_Listening_0.setTrigger(Event("Breakpoint.Add", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_0)
        _Main_BreakpointManager_Listening_1 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_1.setAction(self._Main_BreakpointManager_Listening_1_exec)
        _Main_BreakpointManager_Listening_1.setTrigger(Event("Breakpoint.Del", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_1)
        _Main_BreakpointManager_Listening_2 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_2.setAction(self._Main_BreakpointManager_Listening_2_exec)
        _Main_BreakpointManager_Listening_2.setTrigger(Event("Breakpoint.Toggle", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_2)
        _Main_BreakpointManager_Listening_3 = Transition(self, self.states["/Main/BreakpointManager/Listening"], [self.states["/Main/BreakpointManager/Listening"]])
        _Main_BreakpointManager_Listening_3.setAction(self._Main_BreakpointManager_Listening_3_exec)
        _Main_BreakpointManager_Listening_3.setTrigger(Event("Breakpoint.List", None))
        self.states["/Main/BreakpointManager/Listening"].addTransition(_Main_BreakpointManager_Listening_3)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("CBDSimulation.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
        _Main_ModeSelector_Running_1 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_1.setAction(self._Main_ModeSelector_Running_1_exec)
        _Main_ModeSelector_Running_1.setTrigger(None)
        _Main_ModeSelector_Running_1.setGuard(self._Main_ModeSelector_Running_1_guard)
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_1)
    
    def _Main_Initializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_Initializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_SimulationFlow_WaitingRealtime_enter(self):
        self.addTimer(2, self.sccd_yield())
    
    def _Main_SimulationFlow_WaitingRealtime_exit(self):
        self.removeTimer(2)
    
    def _Main_ModeSelector_Running_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.Triggered", None, [self.triggered_bp, self.clock, self.state])]))
    
    def _Main_ModeSelector_Running_1_guard(self, parameters):
        return self.breakpointTriggers(self.inState(["/Main/ModeSelector/Running/Realtime"]))
    
    def _Main_ModeSelector_Paused_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_ModeSelector_Paused_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_ModeSelector_Paused_3_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 CBDSimulation.
        # 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_ModeSelector_Paused_4_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [clock, iteration, time_next, state])]))
    
    def _Main_ModeSelector_Running_Realtime_1_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [clock, iteration, time_next, state])]))
    
    def _Main_ModeSelector_Running_BigStep_0_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [clock, iteration, time_next, state])]))
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        current_component_idx = parameters[0]
        state = parameters[1]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSmallStep.Finished", None, [current_component_idx, state])]))
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'CBDSimulator_BigStep', self.cbd_controller, self.clock, self.iteration, self.time_next, self.delta, self.state]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSimulation.Initialized", None, [self.clock, self.state, self.iteration, self.time_next])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSimulation.Paused", None, [self.clock, self.state])]))
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Paused"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return (self.inState(["/Main/ModeSelector/Running/Continuous"]) or self.inState(["/Main/ModeSelector/Running/BigStep"])) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/SmallStep"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_2_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Realtime"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_3_exec(self, parameters):
        # print '>>> (CBD) simulation executed <<<'
        self.finalize()
        self.raiseInternalEvent(Event("CBDSimulation.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSimulation.Finished", None, [self.clock, self.state])]))
    
    def _Main_SimulationFlow_CheckTermination_3_guard(self, parameters):
        return self.endCondition()
    
    def _Main_SimulationFlow_WaitingRealtime_0_exec(self, parameters):
        self.syncSimulatedTime()
    
    def _Main_SimulationFlow_WaitingRealtime_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_WaitingRealtime_1_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSimulation.Paused", None, [self.clock, self.state])]))
    
    def _Main_SimulationFlow_WaitingRealtime_1_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Paused"]) and (not ((self.waitTime() / 1000.0) <= self.sccd_yield()))
    
    def _Main_SimulationFlow_WaitingRealtime_2_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDBigStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_WaitingRealtime_2_guard(self, parameters):
        return self.waitTime() / 1000.0 <= self.sccd_yield()
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        clock = parameters[0]
        iteration = parameters[1]
        time_next = parameters[2]
        state = parameters[3]
        self.clock = clock
        self.iteration = iteration
        self.time_next = time_next
        self.state = state
    
    def _Main_GodEventManager_Listening_0_exec(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        result = self.godEvent(block_name, new_val)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSimulation.GodEventResult", None, [result])]))
    
    def _Main_GodEventManager_Listening_0_guard(self, parameters):
        block_name = parameters[0]
        new_val = parameters[1]
        return self.inState(["/Main/ModeSelector/Paused"])
    
    def _Main_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.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.AddResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_1_exec(self, parameters):
        name = parameters[0]
        result = self.delBreakpoint(name)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.DelResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_2_exec(self, parameters):
        name = parameters[0]
        result = self.toggleBreakpoint(name)
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.ToggleResult", None, [result])]))
    
    def _Main_BreakpointManager_Listening_3_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("Breakpoint.ListResult", None, [[bp.name for bp in self.breakpoints]])]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class CBDSimulator_BigStep(RuntimeClassBase):
    def __init__(self, controller, cbd_controller, clock, iteration, time_next, delta, state):
        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()
        
        # call user defined constructor
        CBDSimulator_BigStep.user_defined_constructor(self, cbd_controller, clock, iteration, time_next, delta, state)
    
    def user_defined_constructor(self, cbd_controller, clock, iteration, time_next, delta, state):
        self.cbd_controller = cbd_controller
        self.clock = clock
        self.iteration = iteration
        self.time_next = time_next
        self.delta = delta
        self.state = state
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.current_component_idx = 0
        self.dependency_graph = self.cbd_controller.createDepGraph(self.iteration)
        self.strong_component_list = self.cbd_controller.createStrongComponents(self.dependency_graph, self.iteration)
    
    
    # user defined method
    def initializeDebugger(self):
        pass
    
    
    # user defined method
    def endCondition(self):
        return self.current_component_idx >= len(self.strong_component_list)
    
    
    # user defined method
    def finalize(self):
        self.advanceTime()
    
    
    # user defined method
    def advanceTime(self):
        self.clock = self.time_next
        self.iteration = self.iteration + 1
        self.cbd_controller.advanceTimeStep()
        self.time_next = self.clock + self.delta
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(5, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ModeSelector/Running/SmallStep
        self.states["/Main/ModeSelector/Running/SmallStep"] = State(6, "/Main/ModeSelector/Running/SmallStep", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(7, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(8, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(9, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(10, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(11, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(12, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(13, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/Initializer/Running
        self.states["/Main/Initializer/Running"] = State(14, "/Main/Initializer/Running", self)
        
        # state /Main/Initializer/SettleBeforeWaiting
        self.states["/Main/Initializer/SettleBeforeWaiting"] = State(15, "/Main/Initializer/SettleBeforeWaiting", self)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setEnter(self._Main_Initializer_SettleBeforeWaiting_enter)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setExit(self._Main_Initializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(16, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(17, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(18, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(19, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(20, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(21, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(22, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(23, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(24, "/Main/SimulationFlow/Stopped", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(25, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/SmallStep"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Running"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/SmallStep"]])
        _Main_ModeSelector_Paused_0.setAction(self._Main_ModeSelector_Paused_0_exec)
        _Main_ModeSelector_Paused_0.setTrigger(Event("CBDSmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        _Main_ModeSelector_Paused_1 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_1.setTrigger(Event("CBDBigStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_1)
        
        # transition /Main/ModeSelector/Running/SmallStep
        _Main_ModeSelector_Running_SmallStep_0 = Transition(self, self.states["/Main/ModeSelector/Running/SmallStep"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_SmallStep_0.setAction(self._Main_ModeSelector_Running_SmallStep_0_exec)
        _Main_ModeSelector_Running_SmallStep_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running/SmallStep"].addTransition(_Main_ModeSelector_Running_SmallStep_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("CBDSmallStep.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Running"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("CBDSmallStep.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/Initializer/Running
        _Main_Initializer_Running_0 = Transition(self, self.states["/Main/Initializer/Running"], [self.states["/Main/Initializer/SettleBeforeWaiting"]])
        _Main_Initializer_Running_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/Initializer/Running"].addTransition(_Main_Initializer_Running_0)
        
        # transition /Main/Initializer/SettleBeforeWaiting
        _Main_Initializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/Initializer/SettleBeforeWaiting"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/Initializer/SettleBeforeWaiting"].addTransition(_Main_Initializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("CBDBigStep.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
    
    def _Main_Initializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_Initializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ModeSelector_Paused_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_ModeSelector_Running_SmallStep_0_exec(self, parameters):
        new_current_component_idx = parameters[0]
        new_state = parameters[1]
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSmallStep.Finished", None, [new_current_component_idx, new_state])]))
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'CBDSimulator_SmallStep', self.cbd_controller, self.strong_component_list, self.current_component_idx, self.dependency_graph, self.iteration, self.state]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Initialized", None, [])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDSmallStep.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return (self.inState(["/Main/ModeSelector/Running/Continuous"]) or self.inState(["/Main/ModeSelector/Running/SmallStep"])) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        self.finalize()
        # print '>>> (CBD) big step executed <<<'
        self.raiseInternalEvent(Event("CBDBigStep.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBigStep.Finished", None, [self.clock, self.iteration, self.time_next, self.state])]))
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.endCondition()
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        new_current_component_idx = parameters[0]
        new_state = parameters[1]
        self.current_component_idx = new_current_component_idx
        self.state = new_state
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class CBDSimulator_SmallStep(RuntimeClassBase):
    def __init__(self, controller, cbd_controller, strong_component_list, current_component_idx, dependency_graph, iteration, state):
        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()
        
        # call user defined constructor
        CBDSimulator_SmallStep.user_defined_constructor(self, cbd_controller, strong_component_list, current_component_idx, dependency_graph, iteration, state)
    
    def user_defined_constructor(self, cbd_controller, strong_component_list, current_component_idx, dependency_graph, iteration, state):
        self.cbd_controller = cbd_controller
        self.strong_component_list = strong_component_list
        self.current_component_idx = current_component_idx
        self.dependency_graph = dependency_graph
        self.iteration = iteration
        self.state = state
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def initialize(self):
        self.small_step_executed = False
    
    
    # user defined method
    def initializeDebugger(self):
        pass
    
    
    # user defined method
    def endCondition(self):
        return self.small_step_executed
    
    
    # user defined method
    def finalize(self):
        self.current_component_idx += 1
    
    
    # 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/ModeSelector
        self.states["/Main/ModeSelector"] = State(2, "/Main/ModeSelector", self)
        
        # state /Main/ModeSelector/Paused
        self.states["/Main/ModeSelector/Paused"] = State(3, "/Main/ModeSelector/Paused", self)
        
        # state /Main/ModeSelector/Running
        self.states["/Main/ModeSelector/Running"] = State(4, "/Main/ModeSelector/Running", self)
        
        # state /Main/ModeSelector/Running/Continuous
        self.states["/Main/ModeSelector/Running/Continuous"] = State(5, "/Main/ModeSelector/Running/Continuous", self)
        
        # state /Main/ChildState
        self.states["/Main/ChildState"] = State(6, "/Main/ChildState", self)
        
        # state /Main/ChildState/Uninitialized
        self.states["/Main/ChildState/Uninitialized"] = State(7, "/Main/ChildState/Uninitialized", self)
        
        # state /Main/ChildState/Initialized
        self.states["/Main/ChildState/Initialized"] = State(8, "/Main/ChildState/Initialized", self)
        
        # state /Main/Initializer
        self.states["/Main/Initializer"] = State(9, "/Main/Initializer", self)
        
        # state /Main/Initializer/Waiting
        self.states["/Main/Initializer/Waiting"] = State(10, "/Main/Initializer/Waiting", self)
        
        # state /Main/Initializer/CreatingChildSimulator
        self.states["/Main/Initializer/CreatingChildSimulator"] = State(11, "/Main/Initializer/CreatingChildSimulator", self)
        
        # state /Main/Initializer/StartingChildSimulator
        self.states["/Main/Initializer/StartingChildSimulator"] = State(12, "/Main/Initializer/StartingChildSimulator", self)
        
        # state /Main/Initializer/Running
        self.states["/Main/Initializer/Running"] = State(13, "/Main/Initializer/Running", self)
        
        # state /Main/Initializer/SettleBeforeWaiting
        self.states["/Main/Initializer/SettleBeforeWaiting"] = State(14, "/Main/Initializer/SettleBeforeWaiting", self)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setEnter(self._Main_Initializer_SettleBeforeWaiting_enter)
        self.states["/Main/Initializer/SettleBeforeWaiting"].setExit(self._Main_Initializer_SettleBeforeWaiting_exit)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(15, "/Main/SimulationFlow", self)
        
        # state /Main/SimulationFlow/Started
        self.states["/Main/SimulationFlow/Started"] = State(16, "/Main/SimulationFlow/Started", self)
        
        # state /Main/SimulationFlow/Initialized
        self.states["/Main/SimulationFlow/Initialized"] = State(17, "/Main/SimulationFlow/Initialized", self)
        
        # state /Main/SimulationFlow/InitializeDebugger
        self.states["/Main/SimulationFlow/InitializeDebugger"] = State(18, "/Main/SimulationFlow/InitializeDebugger", self)
        
        # state /Main/SimulationFlow/Waiting
        self.states["/Main/SimulationFlow/Waiting"] = State(19, "/Main/SimulationFlow/Waiting", self)
        
        # state /Main/SimulationFlow/SettleBeforeCheckTermination
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"] = State(20, "/Main/SimulationFlow/SettleBeforeCheckTermination", self)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setEnter(self._Main_SimulationFlow_SettleBeforeCheckTermination_enter)
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].setExit(self._Main_SimulationFlow_SettleBeforeCheckTermination_exit)
        
        # state /Main/SimulationFlow/CheckTermination
        self.states["/Main/SimulationFlow/CheckTermination"] = State(21, "/Main/SimulationFlow/CheckTermination", self)
        
        # state /Main/SimulationFlow/Executing
        self.states["/Main/SimulationFlow/Executing"] = State(22, "/Main/SimulationFlow/Executing", self)
        
        # state /Main/SimulationFlow/Stopped
        self.states["/Main/SimulationFlow/Stopped"] = State(23, "/Main/SimulationFlow/Stopped", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(24, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states["/Main"].addChild(self.states["/Main/ModeSelector"])
        self.states["/Main"].addChild(self.states["/Main/ChildState"])
        self.states["/Main"].addChild(self.states["/Main/Initializer"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Paused"])
        self.states["/Main/ModeSelector"].addChild(self.states["/Main/ModeSelector/Running"])
        self.states["/Main/ModeSelector/Running"].addChild(self.states["/Main/ModeSelector/Running/Continuous"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Uninitialized"])
        self.states["/Main/ChildState"].addChild(self.states["/Main/ChildState/Initialized"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Waiting"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/CreatingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/StartingChildSimulator"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/Running"])
        self.states["/Main/Initializer"].addChild(self.states["/Main/Initializer/SettleBeforeWaiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Started"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Initialized"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/InitializeDebugger"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Waiting"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/CheckTermination"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Executing"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/ModeSelector"].default_state = self.states["/Main/ModeSelector/Paused"]
        self.states["/Main/ModeSelector/Running"].default_state = self.states["/Main/ModeSelector/Running/Continuous"]
        self.states["/Main/ChildState"].default_state = self.states["/Main/ChildState/Uninitialized"]
        self.states["/Main/Initializer"].default_state = self.states["/Main/Initializer/Waiting"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/Started"]
        
        # transition /Main/ModeSelector/Paused
        _Main_ModeSelector_Paused_0 = Transition(self, self.states["/Main/ModeSelector/Paused"], [self.states["/Main/ModeSelector/Running/Continuous"]])
        _Main_ModeSelector_Paused_0.setTrigger(Event("CBDSmallStep.Execute", None))
        self.states["/Main/ModeSelector/Paused"].addTransition(_Main_ModeSelector_Paused_0)
        
        # transition /Main/ChildState/Uninitialized
        _Main_ChildState_Uninitialized_0 = Transition(self, self.states["/Main/ChildState/Uninitialized"], [self.states["/Main/ChildState/Initialized"]])
        _Main_ChildState_Uninitialized_0.setTrigger(Event("CBDBlock.Initialized", None))
        self.states["/Main/ChildState/Uninitialized"].addTransition(_Main_ChildState_Uninitialized_0)
        
        # transition /Main/ChildState/Initialized
        _Main_ChildState_Initialized_0 = Transition(self, self.states["/Main/ChildState/Initialized"], [self.states["/Main/ChildState/Uninitialized"]])
        _Main_ChildState_Initialized_0.setAction(self._Main_ChildState_Initialized_0_exec)
        _Main_ChildState_Initialized_0.setTrigger(Event("CBDBlock.Finished", None))
        self.states["/Main/ChildState/Initialized"].addTransition(_Main_ChildState_Initialized_0)
        
        # transition /Main/Initializer/Waiting
        _Main_Initializer_Waiting_0 = Transition(self, self.states["/Main/Initializer/Waiting"], [self.states["/Main/Initializer/CreatingChildSimulator"]])
        _Main_Initializer_Waiting_0.setAction(self._Main_Initializer_Waiting_0_exec)
        _Main_Initializer_Waiting_0.setTrigger(None)
        _Main_Initializer_Waiting_0.setGuard(self._Main_Initializer_Waiting_0_guard)
        self.states["/Main/Initializer/Waiting"].addTransition(_Main_Initializer_Waiting_0)
        
        # transition /Main/Initializer/CreatingChildSimulator
        _Main_Initializer_CreatingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/CreatingChildSimulator"], [self.states["/Main/Initializer/StartingChildSimulator"]])
        _Main_Initializer_CreatingChildSimulator_0.setAction(self._Main_Initializer_CreatingChildSimulator_0_exec)
        _Main_Initializer_CreatingChildSimulator_0.setTrigger(Event("instance_created", None))
        self.states["/Main/Initializer/CreatingChildSimulator"].addTransition(_Main_Initializer_CreatingChildSimulator_0)
        
        # transition /Main/Initializer/StartingChildSimulator
        _Main_Initializer_StartingChildSimulator_0 = Transition(self, self.states["/Main/Initializer/StartingChildSimulator"], [self.states["/Main/Initializer/Running"]])
        _Main_Initializer_StartingChildSimulator_0.setTrigger(Event("CBDBlock.Initialized", None))
        self.states["/Main/Initializer/StartingChildSimulator"].addTransition(_Main_Initializer_StartingChildSimulator_0)
        
        # transition /Main/Initializer/Running
        _Main_Initializer_Running_0 = Transition(self, self.states["/Main/Initializer/Running"], [self.states["/Main/Initializer/SettleBeforeWaiting"]])
        _Main_Initializer_Running_0.setTrigger(Event("CBDBlock.Finished", None))
        self.states["/Main/Initializer/Running"].addTransition(_Main_Initializer_Running_0)
        
        # transition /Main/Initializer/SettleBeforeWaiting
        _Main_Initializer_SettleBeforeWaiting_0 = Transition(self, self.states["/Main/Initializer/SettleBeforeWaiting"], [self.states["/Main/Initializer/Waiting"]])
        _Main_Initializer_SettleBeforeWaiting_0.setTrigger(Event("_0after"))
        self.states["/Main/Initializer/SettleBeforeWaiting"].addTransition(_Main_Initializer_SettleBeforeWaiting_0)
        
        # transition /Main/SimulationFlow/Started
        _Main_SimulationFlow_Started_0 = Transition(self, self.states["/Main/SimulationFlow/Started"], [self.states["/Main/SimulationFlow/Initialized"]])
        _Main_SimulationFlow_Started_0.setAction(self._Main_SimulationFlow_Started_0_exec)
        _Main_SimulationFlow_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Started"].addTransition(_Main_SimulationFlow_Started_0)
        
        # transition /Main/SimulationFlow/Initialized
        _Main_SimulationFlow_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/Initialized"], [self.states["/Main/SimulationFlow/InitializeDebugger"]])
        _Main_SimulationFlow_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/Initialized"].addTransition(_Main_SimulationFlow_Initialized_0)
        
        # transition /Main/SimulationFlow/InitializeDebugger
        _Main_SimulationFlow_InitializeDebugger_0 = Transition(self, self.states["/Main/SimulationFlow/InitializeDebugger"], [self.states["/Main/SimulationFlow/Waiting"]])
        _Main_SimulationFlow_InitializeDebugger_0.setAction(self._Main_SimulationFlow_InitializeDebugger_0_exec)
        _Main_SimulationFlow_InitializeDebugger_0.setTrigger(None)
        self.states["/Main/SimulationFlow/InitializeDebugger"].addTransition(_Main_SimulationFlow_InitializeDebugger_0)
        
        # transition /Main/SimulationFlow/Waiting
        _Main_SimulationFlow_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/Waiting"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_Waiting_0.setTrigger(None)
        _Main_SimulationFlow_Waiting_0.setGuard(self._Main_SimulationFlow_Waiting_0_guard)
        self.states["/Main/SimulationFlow/Waiting"].addTransition(_Main_SimulationFlow_Waiting_0)
        
        # transition /Main/SimulationFlow/SettleBeforeCheckTermination
        _Main_SimulationFlow_SettleBeforeCheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"], [self.states["/Main/SimulationFlow/CheckTermination"]])
        _Main_SimulationFlow_SettleBeforeCheckTermination_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"].addTransition(_Main_SimulationFlow_SettleBeforeCheckTermination_0)
        
        # transition /Main/SimulationFlow/CheckTermination
        _Main_SimulationFlow_CheckTermination_0 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Executing"]])
        _Main_SimulationFlow_CheckTermination_0.setAction(self._Main_SimulationFlow_CheckTermination_0_exec)
        _Main_SimulationFlow_CheckTermination_0.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_0.setGuard(self._Main_SimulationFlow_CheckTermination_0_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_0)
        _Main_SimulationFlow_CheckTermination_1 = Transition(self, self.states["/Main/SimulationFlow/CheckTermination"], [self.states["/Main/SimulationFlow/Stopped"]])
        _Main_SimulationFlow_CheckTermination_1.setAction(self._Main_SimulationFlow_CheckTermination_1_exec)
        _Main_SimulationFlow_CheckTermination_1.setTrigger(None)
        _Main_SimulationFlow_CheckTermination_1.setGuard(self._Main_SimulationFlow_CheckTermination_1_guard)
        self.states["/Main/SimulationFlow/CheckTermination"].addTransition(_Main_SimulationFlow_CheckTermination_1)
        
        # transition /Main/SimulationFlow/Executing
        _Main_SimulationFlow_Executing_0 = Transition(self, self.states["/Main/SimulationFlow/Executing"], [self.states["/Main/SimulationFlow/SettleBeforeCheckTermination"]])
        _Main_SimulationFlow_Executing_0.setAction(self._Main_SimulationFlow_Executing_0_exec)
        _Main_SimulationFlow_Executing_0.setTrigger(Event("CBDBlock.Finished", None))
        self.states["/Main/SimulationFlow/Executing"].addTransition(_Main_SimulationFlow_Executing_0)
        
        # transition /Main/ModeSelector/Running
        _Main_ModeSelector_Running_0 = Transition(self, self.states["/Main/ModeSelector/Running"], [self.states["/Main/ModeSelector/Paused"]])
        _Main_ModeSelector_Running_0.setTrigger(Event("CBDSmallStep.Finished", None))
        self.states["/Main/ModeSelector/Running"].addTransition(_Main_ModeSelector_Running_0)
    
    def _Main_Initializer_SettleBeforeWaiting_enter(self):
        self.addTimer(0, self.sccd_yield())
    
    def _Main_Initializer_SettleBeforeWaiting_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_enter(self):
        self.addTimer(1, self.sccd_yield())
    
    def _Main_SimulationFlow_SettleBeforeCheckTermination_exit(self):
        self.removeTimer(1)
    
    def _Main_ChildState_Initialized_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("delete_instance", None, [self, 'child_simulator']))
    
    def _Main_Initializer_Waiting_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'child_simulator', 'CBDSimulator_Block', self.cbd_controller, self.strong_component_list[self.current_component_idx], self.cbd_controller.componentIsCycle(self.strong_component_list[self.current_component_idx], self.dependency_graph), self.iteration]))
    
    def _Main_Initializer_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"]) and self.inState(["/Main/ChildState/Uninitialized"]) and not self.endCondition()
    
    def _Main_Initializer_CreatingChildSimulator_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'child_simulator']))
    
    def _Main_SimulationFlow_Started_0_exec(self, parameters):
        self.initialize()
    
    def _Main_SimulationFlow_InitializeDebugger_0_exec(self, parameters):
        self.initializeDebugger()
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSmallStep.Initialized", None, [])]))
    
    def _Main_SimulationFlow_Waiting_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running"])
    
    def _Main_SimulationFlow_CheckTermination_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'child_simulator', Event("CBDBlock.Execute", None, [])]))
    
    def _Main_SimulationFlow_CheckTermination_0_guard(self, parameters):
        return self.inState(["/Main/ModeSelector/Running/Continuous"]) and self.inState(["/Main/ChildState/Initialized"]) and not self.endCondition()
    
    def _Main_SimulationFlow_CheckTermination_1_exec(self, parameters):
        # print '>>> (CBD) small step executed <<<'
        self.finalize()
        self.raiseInternalEvent(Event("CBDSmallStep.Finished", None, []))
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDSmallStep.Finished", None, [self.current_component_idx, self.state])]))
    
    def _Main_SimulationFlow_CheckTermination_1_guard(self, parameters):
        return self.endCondition()
    
    def _Main_SimulationFlow_Executing_0_exec(self, parameters):
        new_state = parameters[0]
        self.small_step_executed = True
        self.state = new_state
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class CBDSimulator_Block(RuntimeClassBase):
    def __init__(self, controller, cbd_controller, block_to_compute, is_cycle, iteration):
        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()
        
        # call user defined constructor
        CBDSimulator_Block.user_defined_constructor(self, cbd_controller, block_to_compute, is_cycle, iteration)
    
    def user_defined_constructor(self, cbd_controller, block_to_compute, is_cycle, iteration):
        self.cbd_controller = cbd_controller
        self.block_to_compute = block_to_compute
        self.is_cycle = is_cycle
        self.iteration = iteration
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def computeBlock(self):
        if self.is_cycle:
            self.cbd_controller.computeNextAlgebraicLoop(self.block_to_compute, self.iteration)
        else:
            self.cbd_controller.computeNextBlock(self.block_to_compute, self.iteration)
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /Started
        self.states["/Started"] = State(1, "/Started", self)
        
        # state /Waiting
        self.states["/Waiting"] = State(2, "/Waiting", self)
        
        # state /Stopped
        self.states["/Stopped"] = State(3, "/Stopped", self)
        
        # add children
        self.states[""].addChild(self.states["/Started"])
        self.states[""].addChild(self.states["/Waiting"])
        self.states[""].addChild(self.states["/Stopped"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Started"]
        
        # transition /Started
        _Started_0 = Transition(self, self.states["/Started"], [self.states["/Waiting"]])
        _Started_0.setAction(self._Started_0_exec)
        _Started_0.setTrigger(None)
        self.states["/Started"].addTransition(_Started_0)
        
        # transition /Waiting
        _Waiting_0 = Transition(self, self.states["/Waiting"], [self.states["/Stopped"]])
        _Waiting_0.setAction(self._Waiting_0_exec)
        _Waiting_0.setTrigger(Event("CBDBlock.Execute", None))
        self.states["/Waiting"].addTransition(_Waiting_0)
    
    def _Started_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBlock.Initialized", None, [])]))
    
    def _Waiting_0_exec(self, parameters):
        self.computeBlock()
        # print '>>> (CBD) block executed <<<'
        self.big_step.outputEventOM(Event("narrow_cast", None, [self, 'parent', Event("CBDBlock.Finished", None, [{b.getBlockName(): b.getSignal() for b in self.cbd_controller.model.getBlocks()}])]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Started"].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 == "WovenSimulator_Coordinator":
            instance = WovenSimulator_Coordinator(self.controller, construct_params[0], construct_params[1], construct_params[2])
            instance.associations = {}
            instance.associations["child_simulator"] = Association("WovenSimulator_Simulation", 0, 1)
        elif class_name == "WovenSimulator_Simulation":
            instance = WovenSimulator_Simulation(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3])
            instance.associations = {}
            instance.associations["parent"] = Association("WovenSimulator_Coordinator", 1, 1)
            instance.associations["child_fsa_simulator"] = Association("FSASimulator_Simulation", 0, 1)
            instance.associations["child_cbd_simulator"] = Association("CBDSimulator_Simulation", 0, 1)
        elif class_name == "FSASimulator_Simulation":
            instance = FSASimulator_Simulation(self.controller, construct_params[0], construct_params[1], construct_params[2])
            instance.associations = {}
            instance.associations["parent"] = Association("WovenSimulator_Coordinator", 1, 1)
            instance.associations["child_simulator"] = Association("FSASimulator_BigStep", 0, 1)
        elif class_name == "FSASimulator_BigStep":
            instance = FSASimulator_BigStep(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3], construct_params[4], construct_params[5], construct_params[6])
            instance.associations = {}
            instance.associations["parent"] = Association("FSASimulator_Simulation", 1, 1)
            instance.associations["child_simulator"] = Association("FSASimulator_SmallStep", 0, 1)
        elif class_name == "FSASimulator_SmallStep":
            instance = FSASimulator_SmallStep(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3], construct_params[4], construct_params[5], construct_params[6])
            instance.associations = {}
            instance.associations["parent"] = Association("FSASimulator_BigStep", 1, 1)
            instance.associations["child_simulator"] = Association("FSASimulator_Transition", 0, 1)
        elif class_name == "FSASimulator_Transition":
            instance = FSASimulator_Transition(self.controller, construct_params[0])
            instance.associations = {}
            instance.associations["parent"] = Association("FSASimulator_SmallStep", 1, 1)
        elif class_name == "CBDSimulator_Simulation":
            instance = CBDSimulator_Simulation(self.controller, construct_params[0], construct_params[1], construct_params[2])
            instance.associations = {}
            instance.associations["parent"] = Association("FSASimulator_Simulation", 1, 1)
            instance.associations["child_simulator"] = Association("CBDSimulator_BigStep", 0, 1)
        elif class_name == "CBDSimulator_BigStep":
            instance = CBDSimulator_BigStep(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3], construct_params[4], construct_params[5])
            instance.associations = {}
            instance.associations["parent"] = Association("CBDSimulator_Simulation", 1, 1)
            instance.associations["child_simulator"] = Association("CBDSimulator_SmallStep", 0, 1)
        elif class_name == "CBDSimulator_SmallStep":
            instance = CBDSimulator_SmallStep(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3], construct_params[4], construct_params[5])
            instance.associations = {}
            instance.associations["parent"] = Association("CBDSimulator_BigStep", 1, 1)
            instance.associations["child_simulator"] = Association("CBDSimulator_Block", 0, 1)
        elif class_name == "CBDSimulator_Block":
            instance = CBDSimulator_Block(self.controller, construct_params[0], construct_params[1], construct_params[2], construct_params[3])
            instance.associations = {}
            instance.associations["parent"] = Association("CBDSimulator_SmallStep", 1, 1)
        else:
            raise Exception("Cannot instantiate class " + class_name)
        return instance

class Controller(ThreadsControllerBase):
    def __init__(self, woven_model, fsa_events, cbd_options, 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("WovenSimulator_Coordinator", [woven_model, fsa_events, cbd_options])