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

Date:   Tue Oct 25 13:19:09 2016

Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes and Simon Van Mierlo
Model name:   Woven_FSA_CBD_Simulator
Model description:
Automatically woven FSA and CBD simulator with the FSA being the dominant, including debugging.
"""

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

class Woven_FSA_CBD_Simulator(RuntimeClassBase):
    def __init__(self, controller, cbd_options, model, fsa_events):
        RuntimeClassBase.__init__(self, controller)
        
        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
        self.semantics.internal_event_lifeline = StatechartSemantics.NextComboStep
        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
        self.semantics.priority = StatechartSemantics.SourceParent
        self.semantics.concurrency = StatechartSemantics.Single
        
        # build Statechart structure
        self.build_statechart_structure()
        
        # user defined attributes
        self.fsa_elapsed = None
        self.fsa_delta = None
        self.fsa_clock = None
        self.fsa_state = None
        self.fsa_currentEvent = None
        self.fsa_selectedTransition = None
        self.fsa_eventList = None
        self.cbd_iteration = None
        self.cbd_delta = None
        self.cbd_clock = None
        self.cbd_state = None
        self.cbd_depGraph = None
        self.cbd_strongComponentList = None
        self.cbd_currentCompIdx = None
        self.cbd_controller = None
        self.cbd_options = None
        self.woven_global_state = None
        self.woven_lib = None
        self.woven_child_initialized = None
        self.woven_delta = None
        self.woven_model = None
        self.woven_previous_global_state = None
        self.woven_triggered_when_transition = None
        
        # call user defined constructor
        Woven_FSA_CBD_Simulator.user_defined_constructor(self, cbd_options, model, fsa_events)
    
    def user_defined_constructor(self, cbd_options, model, fsa_events):
        self.cbd_options = cbd_options
        self.cbd_delta = self.cbd_options.getDeltaT() * 1000.0
        self.fsa_eventList = fsa_events
        self.fsa_delta = 1.0 * 1000.0
        self.woven_delta = min(self.fsa_delta, self.cbd_delta)
        self.woven_lib = FSACBDLib()
        self.woven_model = model
        self.initialized = False
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def fsa_initialize(self):
        self.fsa_clock = 0.0
        self.fsa_elapsed = 0
        self.fsa_delta = self.woven_delta
        self.fsa_state = self.woven_model.initialState
        self.fsa_time_next = self.fsa_delta
        self.initialized = True
    
    
    # user defined method
    def fsa_endCondition(self):
        return self.initialized and self.fsa_state and self.fsa_state.final
    
    
    # user defined method
    def fsa_advanceTime(self):
        self.fsa_clock = self.fsa_time_next
        self.fsa_elapsed = self.fsa_elapsed + self.fsa_delta
        self.fsa_time_next = self.fsa_clock + self.fsa_delta
    
    
    # user defined method
    def fsa_finalize(self):
        print 'Simulation finalized.'
    
    
    # user defined method
    def fsa_processEvent(self, event):
        if (event != None):
            self.fsa_eventList.popEvent(event)
            event.processed = True
    
    
    # user defined method
    def fsa_getInputEventAt(self, time):
        return self.fsa_eventList.getInputAt(time)
    
    
    # user defined method
    def cbd_initialize(self):
        pass
    
    
    # user defined method
    def cbd_endCondition(self):
        return self.cbd_iteration >= self.cbd_options.getMaxIterations()
    
    
    # user defined method
    def cbd_advanceTime(self):
        pass
    
    
    # user defined method
    def cbd_finalize(self):
        pass
    
    
    # user defined method
    def cbd_currentComponentIsCycle(self):
        return self.cbd_controller.componentIsCycle(self.cbd_strongComponentList[self.cbd_currentCompIdx], self.cbd_depGraph)
    
    
    # user defined method
    def cbd_hasNextStrongComponent(self):
        return (self.cbd_currentCompIdx) < len(self.cbd_strongComponentList)
    
    
    # user defined method
    def cbd_computeBlock(self):
        if self.cbd_currentComponentIsCycle():
            self.cbd_controller.computeNextAlgebraicLoop(self.cbd_strongComponentList[self.cbd_currentCompIdx], self.cbd_iteration)
        else:
            self.cbd_controller.computeNextBlock(self.cbd_strongComponentList[self.cbd_currentCompIdx], self.cbd_iteration)
    
    
    # user defined method
    def woven_initialize(self):
        self.woven_global_state = dict()
        self.woven_previous_global_state = dict()
        self.woven_child_initialized = False
    
    
    # user defined method
    def woven_updateCBDState(self):
        self.woven_lib.updateCBDState(self.woven_global_state, self.fsa_state.cbd)
    
    
    # user defined method
    def woven_updateGlobalState(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 woven_getTriggeredWhenTransition(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 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.fsa_time_next - simulated_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.fsa_clock if is_realtime_simulation else self.fsa_time_next) / 1000.0, 'state': self.fsa_state, 'event': self.fsa_currentEvent}):
                # 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, new_state):
        filtered_states = [s for s in self.woven_model.states if s.name == new_state]
        if not len(filtered_states) == 1:
            return -1
        self.fsa_state = filtered_states[0]
        return 0
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, self)
        
        # state /Main
        self.states["/Main"] = ParallelState(1, self)
        
        # state /Main/SimulationState
        self.states["/Main/SimulationState"] = State(2, self)
        
        # state /Main/SimulationState/Paused
        self.states["/Main/SimulationState/Paused"] = State(3, self)
        
        # state /Main/SimulationState/PrePaused
        self.states["/Main/SimulationState/PrePaused"] = State(4, self)
        self.states["/Main/SimulationState/PrePaused"].setEnter(self._Main_SimulationState_PrePaused_enter)
        self.states["/Main/SimulationState/PrePaused"].setExit(self._Main_SimulationState_PrePaused_exit)
        
        # state /Main/SimulationState/PreBreakpointTriggered
        self.states["/Main/SimulationState/PreBreakpointTriggered"] = State(5, self)
        self.states["/Main/SimulationState/PreBreakpointTriggered"].setEnter(self._Main_SimulationState_PreBreakpointTriggered_enter)
        self.states["/Main/SimulationState/PreBreakpointTriggered"].setExit(self._Main_SimulationState_PreBreakpointTriggered_exit)
        
        # state /Main/SimulationState/Running
        self.states["/Main/SimulationState/Running"] = State(6, self)
        
        # state /Main/SimulationState/Running/Continuous
        self.states["/Main/SimulationState/Running/Continuous"] = State(7, self)
        
        # state /Main/SimulationState/Running/BigStep
        self.states["/Main/SimulationState/Running/BigStep"] = State(8, self)
        
        # state /Main/SimulationState/Running/BigStepDone
        self.states["/Main/SimulationState/Running/BigStepDone"] = State(9, self)
        self.states["/Main/SimulationState/Running/BigStepDone"].setEnter(self._Main_SimulationState_Running_BigStepDone_enter)
        self.states["/Main/SimulationState/Running/BigStepDone"].setExit(self._Main_SimulationState_Running_BigStepDone_exit)
        
        # state /Main/SimulationState/Running/SmallStep
        self.states["/Main/SimulationState/Running/SmallStep"] = State(10, self)
        
        # state /Main/SimulationState/Running/SmallStepDone
        self.states["/Main/SimulationState/Running/SmallStepDone"] = State(11, self)
        self.states["/Main/SimulationState/Running/SmallStepDone"].setEnter(self._Main_SimulationState_Running_SmallStepDone_enter)
        self.states["/Main/SimulationState/Running/SmallStepDone"].setExit(self._Main_SimulationState_Running_SmallStepDone_exit)
        
        # state /Main/SimulationState/Running/Realtime
        self.states["/Main/SimulationState/Running/Realtime"] = State(12, self)
        self.states["/Main/SimulationState/Running/Realtime"].setEnter(self._Main_SimulationState_Running_Realtime_enter)
        
        # state /Main/SimulationState/PreStopped
        self.states["/Main/SimulationState/PreStopped"] = State(13, self)
        self.states["/Main/SimulationState/PreStopped"].setEnter(self._Main_SimulationState_PreStopped_enter)
        self.states["/Main/SimulationState/PreStopped"].setExit(self._Main_SimulationState_PreStopped_exit)
        
        # state /Main/SimulationState/Stopped
        self.states["/Main/SimulationState/Stopped"] = State(14, self)
        
        # state /Main/SimulationFlow
        self.states["/Main/SimulationFlow"] = State(15, self)
        
        # state /Main/SimulationFlow/FSA
        self.states["/Main/SimulationFlow/FSA"] = State(16, self)
        
        # state /Main/SimulationFlow/FSA/Started
        self.states["/Main/SimulationFlow/FSA/Started"] = State(17, self)
        
        # state /Main/SimulationFlow/FSA/Initialized
        self.states["/Main/SimulationFlow/FSA/Initialized"] = State(18, self)
        
        # state /Main/SimulationFlow/FSA/DebuggerInitialized
        self.states["/Main/SimulationFlow/FSA/DebuggerInitialized"] = State(19, self)
        
        # state /Main/SimulationFlow/FSA/CheckTermination
        self.states["/Main/SimulationFlow/FSA/CheckTermination"] = State(20, self)
        
        # state /Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"] = State(21, self)
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"].setEnter(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_enter)
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"].setExit(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_exit)
        
        # state /Main/SimulationFlow/FSA/Waiting
        self.states["/Main/SimulationFlow/FSA/Waiting"] = State(22, self)
        self.states["/Main/SimulationFlow/FSA/Waiting"].setEnter(self._Main_SimulationFlow_FSA_Waiting_enter)
        self.states["/Main/SimulationFlow/FSA/Waiting"].setExit(self._Main_SimulationFlow_FSA_Waiting_exit)
        
        # state /Main/SimulationFlow/FSA/DoSimulation
        self.states["/Main/SimulationFlow/FSA/DoSimulation"] = State(23, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"] = State(24, self)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].setEnter(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_enter)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"] = State(25, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"] = State(26, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"] = State(27, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"] = State(28, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"] = State(29, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD"] = State(30, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"] = State(31, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"] = State(32, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"] = State(33, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"] = State(34, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"] = State(35, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"] = State(36, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected"] = State(37, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"] = State(38, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"] = State(39, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"] = State(40, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"] = State(41, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"] = State(42, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"] = State(43, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"] = State(44, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"] = State(45, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"] = State(46, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"] = State(47, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"] = State(48, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"] = State(49, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"] = State(50, self)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].setEnter(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_enter)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].setExit(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_exit)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared
        self.states["/Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared"] = State(51, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared
        self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared"] = State(52, self)
        
        # state /Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed
        self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed"] = State(53, self)
        
        # state /Main/SimulationFlow/FSA/Terminated
        self.states["/Main/SimulationFlow/FSA/Terminated"] = State(54, self)
        
        # state /Main/SimulationFlow/ParentStarted
        self.states["/Main/SimulationFlow/ParentStarted"] = State(55, self)
        
        # state /Main/BreakpointManager
        self.states["/Main/BreakpointManager"] = State(56, self)
        
        # state /Main/BreakpointManager/Listening
        self.states["/Main/BreakpointManager/Listening"] = State(57, self)
        
        # state /Main/GodEventManager
        self.states["/Main/GodEventManager"] = State(58, self)
        
        # state /Main/GodEventManager/Listening
        self.states["/Main/GodEventManager/Listening"] = State(59, self)
        
        # state /Main/UserOutput
        self.states["/Main/UserOutput"] = State(60, self)
        
        # state /Main/UserOutput/Waiting
        self.states["/Main/UserOutput/Waiting"] = State(61, self)
        
        # state /HybridTerminated
        self.states["/HybridTerminated"] = State(62, self)
        
        # add children
        self.states[""].addChild(self.states["/Main"])
        self.states[""].addChild(self.states["/HybridTerminated"])
        self.states["/Main"].addChild(self.states["/Main/SimulationState"])
        self.states["/Main"].addChild(self.states["/Main/SimulationFlow"])
        self.states["/Main"].addChild(self.states["/Main/BreakpointManager"])
        self.states["/Main"].addChild(self.states["/Main/GodEventManager"])
        self.states["/Main"].addChild(self.states["/Main/UserOutput"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/Paused"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/PrePaused"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/PreBreakpointTriggered"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/Running"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/PreStopped"])
        self.states["/Main/SimulationState"].addChild(self.states["/Main/SimulationState/Stopped"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/Continuous"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/BigStep"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/BigStepDone"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/SmallStep"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/SmallStepDone"])
        self.states["/Main/SimulationState/Running"].addChild(self.states["/Main/SimulationState/Running/Realtime"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/FSA"])
        self.states["/Main/SimulationFlow"].addChild(self.states["/Main/SimulationFlow/ParentStarted"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/Started"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/Initialized"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/DebuggerInitialized"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/CheckTermination"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/Waiting"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation"])
        self.states["/Main/SimulationFlow/FSA"].addChild(self.states["/Main/SimulationFlow/FSA/Terminated"])
        self.states["/Main/SimulationFlow/FSA/CheckTermination"].addChild(self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"])
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"])
        self.states["/Main/BreakpointManager"].addChild(self.states["/Main/BreakpointManager/Listening"])
        self.states["/Main/GodEventManager"].addChild(self.states["/Main/GodEventManager/Listening"])
        self.states["/Main/UserOutput"].addChild(self.states["/Main/UserOutput/Waiting"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/Main"]
        self.states["/Main/SimulationState"].default_state = self.states["/Main/SimulationState/Paused"]
        self.states["/Main/SimulationState/Running"].default_state = self.states["/Main/SimulationState/Running/Continuous"]
        self.states["/Main/SimulationFlow"].default_state = self.states["/Main/SimulationFlow/FSA"]
        self.states["/Main/SimulationFlow/FSA"].default_state = self.states["/Main/SimulationFlow/FSA/Started"]
        self.states["/Main/SimulationFlow/FSA/CheckTermination"].default_state = self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"]
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].default_state = self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"]
        self.states["/Main/BreakpointManager"].default_state = self.states["/Main/BreakpointManager/Listening"]
        self.states["/Main/GodEventManager"].default_state = self.states["/Main/GodEventManager/Listening"]
        self.states["/Main/UserOutput"].default_state = self.states["/Main/UserOutput/Waiting"]
        
        # transition /Main/SimulationState/Paused
        _Main_SimulationState_Paused_0 = Transition(self, self.states["/Main/SimulationState/Paused"], [self.states["/Main/SimulationState/Running/Continuous"]])
        _Main_SimulationState_Paused_0.setTrigger(Event("continuous", "user_input"))
        self.states["/Main/SimulationState/Paused"].addTransition(_Main_SimulationState_Paused_0)
        _Main_SimulationState_Paused_1 = Transition(self, self.states["/Main/SimulationState/Paused"], [self.states["/Main/SimulationState/Running/Realtime"]])
        _Main_SimulationState_Paused_1.setAction(self._Main_SimulationState_Paused_1_exec)
        _Main_SimulationState_Paused_1.setTrigger(Event("realtime", "user_input"))
        self.states["/Main/SimulationState/Paused"].addTransition(_Main_SimulationState_Paused_1)
        _Main_SimulationState_Paused_2 = Transition(self, self.states["/Main/SimulationState/Paused"], [self.states["/Main/SimulationState/Running/BigStep"]])
        _Main_SimulationState_Paused_2.setTrigger(Event("big_step", "user_input"))
        self.states["/Main/SimulationState/Paused"].addTransition(_Main_SimulationState_Paused_2)
        _Main_SimulationState_Paused_3 = Transition(self, self.states["/Main/SimulationState/Paused"], [self.states["/Main/SimulationState/Running/SmallStep"]])
        _Main_SimulationState_Paused_3.setTrigger(Event("small_step", "user_input"))
        self.states["/Main/SimulationState/Paused"].addTransition(_Main_SimulationState_Paused_3)
        _Main_SimulationState_Paused_4 = Transition(self, self.states["/Main/SimulationState/Paused"], [self.states["/Main/SimulationState/PreStopped"]])
        _Main_SimulationState_Paused_4.setTrigger(None)
        _Main_SimulationState_Paused_4.setGuard(self._Main_SimulationState_Paused_4_guard)
        self.states["/Main/SimulationState/Paused"].addTransition(_Main_SimulationState_Paused_4)
        
        # transition /Main/SimulationState/PrePaused
        _Main_SimulationState_PrePaused_0 = Transition(self, self.states["/Main/SimulationState/PrePaused"], [self.states["/Main/SimulationState/Paused"]])
        _Main_SimulationState_PrePaused_0.setAction(self._Main_SimulationState_PrePaused_0_exec)
        _Main_SimulationState_PrePaused_0.setTrigger(Event("_0after"))
        self.states["/Main/SimulationState/PrePaused"].addTransition(_Main_SimulationState_PrePaused_0)
        
        # transition /Main/SimulationState/PreBreakpointTriggered
        _Main_SimulationState_PreBreakpointTriggered_0 = Transition(self, self.states["/Main/SimulationState/PreBreakpointTriggered"], [self.states["/Main/SimulationState/Paused"]])
        _Main_SimulationState_PreBreakpointTriggered_0.setAction(self._Main_SimulationState_PreBreakpointTriggered_0_exec)
        _Main_SimulationState_PreBreakpointTriggered_0.setTrigger(Event("_1after"))
        self.states["/Main/SimulationState/PreBreakpointTriggered"].addTransition(_Main_SimulationState_PreBreakpointTriggered_0)
        
        # transition /Main/SimulationState/Running/BigStep
        _Main_SimulationState_Running_BigStep_0 = Transition(self, self.states["/Main/SimulationState/Running/BigStep"], [self.states["/Main/SimulationState/Running/BigStepDone"]])
        _Main_SimulationState_Running_BigStep_0.setTrigger(Event("big_step_done", None))
        self.states["/Main/SimulationState/Running/BigStep"].addTransition(_Main_SimulationState_Running_BigStep_0)
        
        # transition /Main/SimulationState/Running/BigStepDone
        _Main_SimulationState_Running_BigStepDone_0 = Transition(self, self.states["/Main/SimulationState/Running/BigStepDone"], [self.states["/Main/SimulationState/Paused"]])
        _Main_SimulationState_Running_BigStepDone_0.setTrigger(Event("_2after"))
        self.states["/Main/SimulationState/Running/BigStepDone"].addTransition(_Main_SimulationState_Running_BigStepDone_0)
        
        # transition /Main/SimulationState/Running/SmallStep
        _Main_SimulationState_Running_SmallStep_0 = Transition(self, self.states["/Main/SimulationState/Running/SmallStep"], [self.states["/Main/SimulationState/Running/SmallStepDone"]])
        _Main_SimulationState_Running_SmallStep_0.setTrigger(Event("small_step_done", None))
        self.states["/Main/SimulationState/Running/SmallStep"].addTransition(_Main_SimulationState_Running_SmallStep_0)
        
        # transition /Main/SimulationState/Running/SmallStepDone
        _Main_SimulationState_Running_SmallStepDone_0 = Transition(self, self.states["/Main/SimulationState/Running/SmallStepDone"], [self.states["/Main/SimulationState/Paused"]])
        _Main_SimulationState_Running_SmallStepDone_0.setTrigger(Event("_3after"))
        self.states["/Main/SimulationState/Running/SmallStepDone"].addTransition(_Main_SimulationState_Running_SmallStepDone_0)
        
        # transition /Main/SimulationState/PreStopped
        _Main_SimulationState_PreStopped_0 = Transition(self, self.states["/Main/SimulationState/PreStopped"], [self.states["/Main/SimulationState/Stopped"]])
        _Main_SimulationState_PreStopped_0.setAction(self._Main_SimulationState_PreStopped_0_exec)
        _Main_SimulationState_PreStopped_0.setTrigger(Event("_4after"))
        self.states["/Main/SimulationState/PreStopped"].addTransition(_Main_SimulationState_PreStopped_0)
        
        # transition /Main/SimulationFlow/FSA/Started
        _Main_SimulationFlow_FSA_Started_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/Started"], [self.states["/Main/SimulationFlow/ParentStarted"]])
        _Main_SimulationFlow_FSA_Started_0.setAction(self._Main_SimulationFlow_FSA_Started_0_exec)
        _Main_SimulationFlow_FSA_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/Started"].addTransition(_Main_SimulationFlow_FSA_Started_0)
        
        # transition /Main/SimulationFlow/FSA/Initialized
        _Main_SimulationFlow_FSA_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/Initialized"], [self.states["/Main/SimulationFlow/FSA/DebuggerInitialized"]])
        _Main_SimulationFlow_FSA_Initialized_0.setAction(self._Main_SimulationFlow_FSA_Initialized_0_exec)
        _Main_SimulationFlow_FSA_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/Initialized"].addTransition(_Main_SimulationFlow_FSA_Initialized_0)
        
        # transition /Main/SimulationFlow/FSA/DebuggerInitialized
        _Main_SimulationFlow_FSA_DebuggerInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DebuggerInitialized"], [self.states["/Main/SimulationFlow/FSA/CheckTermination"]])
        _Main_SimulationFlow_FSA_DebuggerInitialized_0.setAction(self._Main_SimulationFlow_FSA_DebuggerInitialized_0_exec)
        _Main_SimulationFlow_FSA_DebuggerInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DebuggerInitialized"].addTransition(_Main_SimulationFlow_FSA_DebuggerInitialized_0)
        
        # transition /Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/Terminated"]])
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0.setAction(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0_exec)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0.setTrigger(Event("_5after"))
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0.setGuard(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0_guard)
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/Waiting"]])
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1.setTrigger(None)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1.setGuard(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1_guard)
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2 = Transition(self, self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation"]])
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2.setAction(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2_exec)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2.setTrigger(None)
        _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2.setGuard(self._Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2_guard)
        self.states["/Main/SimulationFlow/FSA/CheckTermination/MacroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2)
        
        # transition /Main/SimulationFlow/FSA/Waiting
        _Main_SimulationFlow_FSA_Waiting_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/Waiting"], [self.states["/Main/SimulationFlow/FSA/CheckTermination"]])
        _Main_SimulationFlow_FSA_Waiting_0.setAction(self._Main_SimulationFlow_FSA_Waiting_0_exec)
        _Main_SimulationFlow_FSA_Waiting_0.setTrigger(Event("_6after"))
        self.states["/Main/SimulationFlow/FSA/Waiting"].addTransition(_Main_SimulationFlow_FSA_Waiting_0)
        _Main_SimulationFlow_FSA_Waiting_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/Waiting"], [self.states["/Main/SimulationFlow/FSA/DoSimulation"]])
        _Main_SimulationFlow_FSA_Waiting_1.setTrigger(None)
        _Main_SimulationFlow_FSA_Waiting_1.setGuard(self._Main_SimulationFlow_FSA_Waiting_1_guard)
        self.states["/Main/SimulationFlow/FSA/Waiting"].addTransition(_Main_SimulationFlow_FSA_Waiting_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ParentPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Started"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ParentPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildPaused"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setTrigger(Event("_7after"))
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"], [self.states["/Main/SimulationFlow/FSA/CheckTermination"]])
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setAction(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_exec)
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setTrigger(Event("_8after"))
        _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared
        _Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared"]])
        _Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0.setTrigger(None)
        _Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0.setGuard(self._Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0_guard)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/PreParentMicroStepPrepared"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed"]])
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepPrepared"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0)
        
        # transition /Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0 = Transition(self, self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed"], [self.states["/Main/SimulationFlow/FSA/DoSimulation/MacroStepPrepared"]])
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0.setAction(self._Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0_exec)
        _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0.setTrigger(None)
        self.states["/Main/SimulationFlow/FSA/DoSimulation/ParentMicroStepProcessed"].addTransition(_Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0)
        
        # transition /Main/SimulationFlow/ParentStarted
        _Main_SimulationFlow_ParentStarted_0 = Transition(self, self.states["/Main/SimulationFlow/ParentStarted"], [self.states["/Main/SimulationFlow/FSA/Initialized"]])
        _Main_SimulationFlow_ParentStarted_0.setAction(self._Main_SimulationFlow_ParentStarted_0_exec)
        _Main_SimulationFlow_ParentStarted_0.setTrigger(None)
        self.states["/Main/SimulationFlow/ParentStarted"].addTransition(_Main_SimulationFlow_ParentStarted_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("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/Listening"]])
        _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/Listening"]])
        _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/Listening"]])
        _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/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("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/UserOutput/Waiting
        _Main_UserOutput_Waiting_0 = Transition(self, self.states["/Main/UserOutput/Waiting"], [self.states["/Main/UserOutput/Waiting"]])
        _Main_UserOutput_Waiting_0.setAction(self._Main_UserOutput_Waiting_0_exec)
        _Main_UserOutput_Waiting_0.setTrigger(Event("termination_condition", None))
        self.states["/Main/UserOutput/Waiting"].addTransition(_Main_UserOutput_Waiting_0)
        _Main_UserOutput_Waiting_1 = Transition(self, self.states["/Main/UserOutput/Waiting"], [self.states["/Main/UserOutput/Waiting"]])
        _Main_UserOutput_Waiting_1.setAction(self._Main_UserOutput_Waiting_1_exec)
        _Main_UserOutput_Waiting_1.setTrigger(Event("paused", None))
        self.states["/Main/UserOutput/Waiting"].addTransition(_Main_UserOutput_Waiting_1)
        _Main_UserOutput_Waiting_2 = Transition(self, self.states["/Main/UserOutput/Waiting"], [self.states["/Main/UserOutput/Waiting"]])
        _Main_UserOutput_Waiting_2.setAction(self._Main_UserOutput_Waiting_2_exec)
        _Main_UserOutput_Waiting_2.setTrigger(Event("big_step_done", None))
        _Main_UserOutput_Waiting_2.setGuard(self._Main_UserOutput_Waiting_2_guard)
        self.states["/Main/UserOutput/Waiting"].addTransition(_Main_UserOutput_Waiting_2)
        _Main_UserOutput_Waiting_3 = Transition(self, self.states["/Main/UserOutput/Waiting"], [self.states["/Main/UserOutput/Waiting"]])
        _Main_UserOutput_Waiting_3.setAction(self._Main_UserOutput_Waiting_3_exec)
        _Main_UserOutput_Waiting_3.setTrigger(Event("small_step_done", None))
        _Main_UserOutput_Waiting_3.setGuard(self._Main_UserOutput_Waiting_3_guard)
        self.states["/Main/UserOutput/Waiting"].addTransition(_Main_UserOutput_Waiting_3)
        _Main_UserOutput_Waiting_4 = Transition(self, self.states["/Main/UserOutput/Waiting"], [self.states["/Main/UserOutput/Waiting"]])
        _Main_UserOutput_Waiting_4.setAction(self._Main_UserOutput_Waiting_4_exec)
        _Main_UserOutput_Waiting_4.setTrigger(Event("breakpoint_triggered", None))
        self.states["/Main/UserOutput/Waiting"].addTransition(_Main_UserOutput_Waiting_4)
        
        # transition /Main
        _Main_0 = Transition(self, self.states["/Main"], [self.states["/HybridTerminated"]])
        _Main_0.setAction(self._Main_0_exec)
        _Main_0.setTrigger(None)
        _Main_0.setGuard(self._Main_0_guard)
        self.states["/Main"].addTransition(_Main_0)
        
        # transition /Main/SimulationState/Running
        _Main_SimulationState_Running_0 = Transition(self, self.states["/Main/SimulationState/Running"], [self.states["/Main/SimulationState/PreStopped"]])
        _Main_SimulationState_Running_0.setTrigger(None)
        _Main_SimulationState_Running_0.setGuard(self._Main_SimulationState_Running_0_guard)
        self.states["/Main/SimulationState/Running"].addTransition(_Main_SimulationState_Running_0)
        _Main_SimulationState_Running_1 = Transition(self, self.states["/Main/SimulationState/Running"], [self.states["/Main/SimulationState/PrePaused"]])
        _Main_SimulationState_Running_1.setTrigger(Event("pause", "user_input"))
        self.states["/Main/SimulationState/Running"].addTransition(_Main_SimulationState_Running_1)
        _Main_SimulationState_Running_2 = Transition(self, self.states["/Main/SimulationState/Running"], [self.states["/Main/SimulationState/PreBreakpointTriggered"]])
        _Main_SimulationState_Running_2.setTrigger(None)
        _Main_SimulationState_Running_2.setGuard(self._Main_SimulationState_Running_2_guard)
        self.states["/Main/SimulationState/Running"].addTransition(_Main_SimulationState_Running_2)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_enter(self):
        print('Reading event and selecting transition...')
        self.fsa_currentEvent = self.fsa_getInputEventAt(self.fsa_clock / 1000.0)
        self.fsa_selectedTransition = self.woven_model.getTransitionFrom(self.fsa_state, self.fsa_currentEvent, self.fsa_elapsed)
        print('Current event:' + str(self.fsa_currentEvent))
        print('Current transition:' + str(self.fsa_selectedTransition))
        print('Child detected?:' + str(isinstance(self.fsa_state, CBDState)))
    
    def _Main_SimulationState_PrePaused_enter(self):
        self.addTimer(0, self.sccd_yield() * 2)
    
    def _Main_SimulationState_PrePaused_exit(self):
        self.removeTimer(0)
    
    def _Main_SimulationState_PreBreakpointTriggered_enter(self):
        self.addTimer(1, self.sccd_yield() * 2)
    
    def _Main_SimulationState_PreBreakpointTriggered_exit(self):
        self.removeTimer(1)
    
    def _Main_SimulationState_Running_BigStepDone_enter(self):
        self.addTimer(2, self.sccd_yield())
    
    def _Main_SimulationState_Running_BigStepDone_exit(self):
        self.removeTimer(2)
    
    def _Main_SimulationState_Running_SmallStepDone_enter(self):
        self.addTimer(3, self.sccd_yield())
    
    def _Main_SimulationState_Running_SmallStepDone_exit(self):
        self.removeTimer(3)
    
    def _Main_SimulationState_Running_Realtime_enter(self):
        # If the simulation was paused, we need to reset the start time of the simulation.
        # The start time of the simulation is equal to the point in wall-clock time where simulated time is 0.
        # If the simulation was paused, we have to recompute this point in time: it is the difference of the wall-clock time and the simulated time.
        # If the scale was changed after the pause, this point of course moves backwards (for scales smaller than 1) or forwards (for scales larger than 1)
        self.realtime_start_time = accurate_time.time() - (self.fsa_clock / self.realtime_scale)
    
    def _Main_SimulationState_PreStopped_enter(self):
        self.addTimer(4, self.sccd_yield() * 2)
    
    def _Main_SimulationState_PreStopped_exit(self):
        self.removeTimer(4)
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_enter(self):
        self.addTimer(5, self.sccd_yield())
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_exit(self):
        self.removeTimer(5)
    
    def _Main_SimulationFlow_FSA_Waiting_enter(self):
        self.addTimer(6, self.sccd_yield())
    
    def _Main_SimulationFlow_FSA_Waiting_exit(self):
        self.removeTimer(6)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_enter(self):
        self.addTimer(7, self.sccd_yield() * 2)
        self.addTimer(8, self.sccd_yield())
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_exit(self):
        self.removeTimer(7)
        self.removeTimer(8)
    
    def _Main_0_exec(self, parameters):
        self.fsa_finalize()
    
    def _Main_0_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Stopped"]) and (self.inState(["/Main/SimulationFlow/FSA/Terminated"]) or self.inState(["/Main/SimulationFlow/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"]))
    
    def _Main_SimulationState_Running_0_guard(self, parameters):
        return self.fsa_endCondition()
    
    def _Main_SimulationState_Running_2_guard(self, parameters):
        return self.breakpointTriggers(self.inState(["/Main/SimulationState/Running/Realtime"]))
    
    def _Main_SimulationState_Paused_1_exec(self, parameters):
        realtime_scale = parameters[0]
        self.realtime_scale = float(realtime_scale)
    
    def _Main_SimulationState_Paused_4_guard(self, parameters):
        return self.fsa_endCondition()
    
    def _Main_SimulationState_PrePaused_0_exec(self, parameters):
        self.raiseInternalEvent(Event("paused", None, []))
    
    def _Main_SimulationState_PreBreakpointTriggered_0_exec(self, parameters):
        self.raiseInternalEvent(Event("breakpoint_triggered", None, []))
    
    def _Main_SimulationState_PreStopped_0_exec(self, parameters):
        self.raiseInternalEvent(Event("termination_condition", None, []))
    
    def _Main_SimulationFlow_FSA_Started_0_exec(self, parameters):
        print('From FSA/Started to ParentStarted... ')
        self.fsa_initialize()
    
    def _Main_SimulationFlow_FSA_Initialized_0_exec(self, parameters):
        print('From FSA/Initialized to FSA/CheckTermination... ')
        self.initializeDebugger()
    
    def _Main_SimulationFlow_FSA_DebuggerInitialized_0_exec(self, parameters):
        print('From FSA/Initialized to FSA/CheckTermination... ')
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0_exec(self, parameters):
        print('From FSA/CheckTermination/MacroStepProcessed to Terminated... ')
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_0_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Stopped"])
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_1_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Running/Realtime"])
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2_exec(self, parameters):
        print('From FSA/CheckTermination/MacroStepProcessed to FSA/DoSimulation...')
    
    def _Main_SimulationFlow_FSA_CheckTermination_MacroStepProcessed_2_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Running/Continuous"]) or self.inState(["/Main/SimulationState/Running/BigStep"]) or self.inState(["/Main/SimulationState/Running/SmallStep"])
    
    def _Main_SimulationFlow_FSA_Waiting_0_exec(self, parameters):
        diff = accurate_time.time() - self.realtime_start_time
        self.fsa_clock = diff * self.realtime_scale
    
    def _Main_SimulationFlow_FSA_Waiting_1_guard(self, parameters):
        return self.waitTime() / 1000.0 <= self.sccd_yield()
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_exec(self, parameters):
        print('From FSA/ParentPaused to FSA/ChildDetected... ')
        self.cbd_model = self.fsa_state.cbd
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_guard(self, parameters):
        return isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_exec(self, parameters):
        print('From ParentPaused to ChildNotDetected without any child to process... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_guard(self, parameters):
        return not isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0_exec(self, parameters):
        print('From ChildNotDetected to ChildProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_exec(self, parameters):
        print('From ChildDetected to ChildInitialized... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_guard(self, parameters):
        return self.woven_child_initialized
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_exec(self, parameters):
        print('From ChildDetected to ChildNotInitialized... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_guard(self, parameters):
        return not self.woven_child_initialized
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0_exec(self, parameters):
        print('From ChildInitialized to ChildProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0_exec(self, parameters):
        print('From ChildNotInitialized to CBD/Started... ')
        self.cbd_delta = self.woven_delta
        self.woven_updateCBDState()
        self.woven_child_initialized = True
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0_exec(self, parameters):
        print('From CBD/Started to Initialized... ')
        print('Performing initialization...')
        self.cbd_iteration = 0
        self.cbd_clock = 0
        self.cbd_controller = CBDController(self.cbd_model, self.cbd_delta / 1000.0)
        self.cbd_controller.initSimulation()
        print('Performing initialization... DONE')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0_exec(self, parameters):
        print('From CBD/Initialized to ChildInitialized... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0_exec(self, parameters):
        print('From MacroStepPrepared/ChildProcessed to MicroStepProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_exec(self, parameters):
        print('From FSA/ParentPaused to FSA/ChildDetected... ')
        self.cbd_model = self.fsa_state.cbd
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_guard(self, parameters):
        return isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_exec(self, parameters):
        print('From ParentPaused to ChildNotDetected without any child to process... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_guard(self, parameters):
        return not isinstance(self.fsa_state, CBDState)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0_exec(self, parameters):
        print('From ChildNotDetected to ChildProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_exec(self, parameters):
        print('From ChildDetected to ChildInitialized... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_guard(self, parameters):
        return self.woven_child_initialized
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0_exec(self, parameters):
        print('From ChildInitialized to ChildProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_exec(self, parameters):
        print('From CBD/MacroStepProcessed to Terminated... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_guard(self, parameters):
        return self.cbd_endCondition()
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_exec(self, parameters):
        print('From CBD/MacroStepProcessed to MacroStepPrepared... ')
        self.cbd_currentCompIdx = 0
        self.cbd_depGraph = self.cbd_controller.createDepGraph(self.cbd_iteration)
        self.cbd_strongComponentList = self.cbd_controller.createStrongComponents(self.cbd_depGraph, self.cbd_iteration)
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_guard(self, parameters):
        return not self.cbd_endCondition()
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0_exec(self, parameters):
        print('From CBD/MacroStepPrepared to MicroStepProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_exec(self, parameters):
        print('From CBD/MicroStepProcessed to MicroStepPrepared')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_guard(self, parameters):
        return self.cbd_hasNextStrongComponent()
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_exec(self, parameters):
        print('From CBD/MicroStepProcessed to ChildPaused and detecting triggered transitions... ')
        self.woven_updateGlobalState()
        self.woven_lib.dumpGlobalState(self.woven_model, self.woven_global_state, self.fsa_clock / 1000.0, self.fsa_state)
        self.woven_triggered_when_transition = self.woven_getTriggeredWhenTransition()
        self.cbd_clock = self.cbd_clock + self.cbd_delta
        self.cbd_iteration = self.cbd_iteration + 1
        self.cbd_controller.advanceTimeStep()
        print('CBD clock: ' + str(self.cbd_clock / 1000.0))
        print('CBD iteration: ' + str(self.cbd_iteration))
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_guard(self, parameters):
        return not self.cbd_hasNextStrongComponent()
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0_exec(self, parameters):
        print('From CBD/MicroStepPrepared to MicroStepProcessed...')
        self.cbd_computeBlock()
        self.cbd_currentCompIdx = self.cbd_currentCompIdx + 1
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_exec(self, parameters):
        print('From ChildPaused to NoStateEventDetected... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_guard(self, parameters):
        return self.woven_triggered_when_transition == None
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_exec(self, parameters):
        print('From ChildPaused to StateEventDetected... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_guard(self, parameters):
        return self.woven_triggered_when_transition != None
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0_exec(self, parameters):
        print('From NoStateEventDetected to ChildProcessed... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0_exec(self, parameters):
        print('From StateEventDetected to ChildProcessed... ')
        if self.fsa_selectedTransition == None:
            self.fsa_selectedTransition = self.woven_triggered_when_transition
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_exec(self, parameters):
        print('From FSA/MicroStepProcessed/ChildProcessed to MicroStepPrepared... ')
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_guard(self, parameters):
        return self.fsa_selectedTransition != None
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_exec(self, parameters):
        print('From FSA/MicroStepProcessed/ChildProcessed to FSA/CheckTermination and advancing time... ')
        self.fsa_advanceTime()
        print('fsa_clock: %s' % (self.fsa_clock / 1000.0))
        print('fsa_elapsed: %s' % (self.fsa_elapsed / 1000.0))
        self.raiseInternalEvent(Event("small_step_done", None, []))
        self.raiseInternalEvent(Event("big_step_done", None, []))
    
    def _Main_SimulationFlow_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_guard(self, parameters):
        return self.fsa_selectedTransition == None
    
    def _Main_SimulationFlow_FSA_DoSimulation_PreParentMicroStepPrepared_0_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Running"])
    
    def _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepPrepared_0_exec(self, parameters):
        print('From FSA/MicroStepPrepared to ParentMicroStepProcessed and attempting to take transition... ')
        print('Transition to be taken: ' + str(self.fsa_selectedTransition))
        self.fsa_state = self.fsa_selectedTransition.target
        self.fsa_elapsed = 0
        self.fsa_processEvent(self.fsa_currentEvent)
        self.woven_lib.dumpDiscreteEvent(self.woven_model, self.fsa_clock / 1000.0, self.fsa_state, self.fsa_selectedTransition)
        self.woven_lib.dumpGlobalState(self.woven_model, self.woven_global_state, self.fsa_clock / 1000.0, self.fsa_state)
        print('New state: ' + str(self.fsa_state))
        print('Reading events:')
        self.fsa_currentEvent = self.fsa_getInputEventAt(self.fsa_clock / 1000.0)
        self.fsa_selectedTransition = self.woven_model.getTransitionFrom(self.fsa_state, self.fsa_currentEvent, self.fsa_elapsed /1000.0)
        print(self.fsa_currentEvent)
        print(self.fsa_selectedTransition)
        self.raiseInternalEvent(Event("small_step_done", None, []))
    
    def _Main_SimulationFlow_FSA_DoSimulation_ParentMicroStepProcessed_0_exec(self, parameters):
        print('From ParentMicroStepProcessed to ParentPaused and resetting the child... ')
        self.woven_child_initialized = False
    
    def _Main_SimulationFlow_ParentStarted_0_exec(self, parameters):
        print('From ParentStarted to FSA/Initialized... ')
        self.woven_initialize()
    
    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.outputEvent(Event("add_breakpoint_result", "user_output", [result]))
    
    def _Main_BreakpointManager_Listening_1_exec(self, parameters):
        name = parameters[0]
        result = self.delBreakpoint(name)
        self.big_step.outputEvent(Event("del_breakpoint_result", "user_output", [result]))
    
    def _Main_BreakpointManager_Listening_2_exec(self, parameters):
        name = parameters[0]
        result = self.toggleBreakpoint(name)
        self.big_step.outputEvent(Event("toggle_breakpoint_result", "user_output", [result]))
    
    def _Main_BreakpointManager_Listening_3_exec(self, parameters):
        self.big_step.outputEvent(Event("list_breakpoints_result", "user_output", [[bp.name for bp in self.breakpoints]]))
    
    def _Main_GodEventManager_Listening_0_exec(self, parameters):
        new_state = parameters[0]
        result = self.godEvent(new_state)
        self.big_step.outputEvent(Event("god_event_result", "user_output", [result]))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def _Main_GodEventManager_Listening_0_guard(self, parameters):
        new_state = parameters[0]
        return self.inState(["/Main/SimulationState/Paused"])
    
    def _Main_UserOutput_Waiting_0_exec(self, parameters):
        self.big_step.outputEvent(Event("terminated", "user_output", []))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def _Main_UserOutput_Waiting_1_exec(self, parameters):
        self.big_step.outputEvent(Event("paused", "user_output", []))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def _Main_UserOutput_Waiting_2_exec(self, parameters):
        self.big_step.outputEvent(Event("big_step_done", "user_output", []))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def _Main_UserOutput_Waiting_2_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Running/Realtime"]) or self.inState(["/Main/SimulationState/Running/BigStep"]) or self.inState(["/Main/SimulationState/Running/BigStepDone"])
    
    def _Main_UserOutput_Waiting_3_exec(self, parameters):
        self.big_step.outputEvent(Event("small_step_done", "user_output", []))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def _Main_UserOutput_Waiting_3_guard(self, parameters):
        return self.inState(["/Main/SimulationState/Running/SmallStep"]) or self.inState(["/Main/SimulationState/Running/SmallStepDone"])
    
    def _Main_UserOutput_Waiting_4_exec(self, parameters):
        self.big_step.outputEvent(Event("breakpoint_triggered", "user_output", [self.triggered_bp]))
        self.big_step.outputEvent(Event("current_state", "user_output", [self.fsa_clock / 1000.0, self.fsa_state]))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/Main"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class ObjectManager(ObjectManagerBase):
    def __init__(self, controller):
        ObjectManagerBase.__init__(self, controller)
    
    def instantiate(self, class_name, construct_params):
        if class_name == "Woven_FSA_CBD_Simulator":
            instance = Woven_FSA_CBD_Simulator(self.controller, construct_params[0], construct_params[1], construct_params[2])
            instance.associations = {}
        else:
            raise Exception("Cannot instantiate class " + class_name)
        return instance

class Controller(ThreadsControllerBase):
    def __init__(self, cbd_options, model, fsa_events, 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.addOutputPort("user_output")
        self.object_manager.createInstance("Woven_FSA_CBD_Simulator", [cbd_options, model, fsa_events])