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

Date:   Wed Nov 16 11:54:42 2016

Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
Model name:   Weaved_CBD_FSA_Simulator_Manual
Model description:
Automatically woven CBD and FSA simulators with the FSA being the dominant.
"""

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_weaved_classes import CBDState
from weaved_cbd_fsa_lib import FSACBDLib

# package "Weaved_CBD_FSA_Simulator_Manual"

class Weaved_CBD_FSA_Simulator(RuntimeClassBase):
    def __init__(self, controller, cbd_options, amodel, fsa_events):
        RuntimeClassBase.__init__(self, controller)
        
        self.semantics.big_step_maximality = StatechartSemantics.TakeMany
        self.semantics.internal_event_lifeline = StatechartSemantics.Queue
        self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
        self.semantics.priority = StatechartSemantics.SourceParent
        self.semantics.concurrency = StatechartSemantics.Single
        
        # build Statechart structure
        self.build_statechart_structure()
        
        # user defined attributes
        self.weaved_global_state = None
        self.fsa_elapsed = None
        self.cbd_options = None
        self.weaved_lib = None
        self.woven_child_initialized = None
        self.cbd_clock = None
        self.fsa_currentEvent = None
        self.weaved_delta = None
        self.weaved_model = None
        self.cbd_controller = None
        self.fsa_timestep = None
        self.cbd_currentCompIdx = None
        self.fsa_eventList = None
        self.cbd_depGraph = None
        self.fsa_selectedTransition = None
        self.cbd_strongComponentList = None
        self.weaved_previous_global_state = None
        self.cbd_delta = None
        self.weaved_triggered_when_transition = None
        self.cbd_iteration = None
        self.fsa_logicalTime = None
        self.fsa_currentState = None
        
        # call user defined constructor
        Weaved_CBD_FSA_Simulator.user_defined_constructor(self, cbd_options, amodel, fsa_events)
    
    def user_defined_constructor(self, cbd_options, amodel, fsa_events):
        self.weaved_lib = FSACBDLib()
        self.cbd_options = cbd_options
        self.cbd_delta = self.cbd_options.getDeltaT()
        self.weaved_model = amodel
        self.fsa_eventList = fsa_events
        self.fsa_timestep = 1.0
    
    def user_defined_destructor(self):
        pass
    
    
    # user defined method
    def fsa_processEvent(self, event):
        if (event != None):
        	self.fsa_eventList.popEvent(event)
        	event.processed = True
    
    
    # user defined method
    def updateCBDState(self):
        self.weaved_lib.updateCBDState(self.weaved_global_state, self.fsa_currentState.cbd)
    
    
    # user defined method
    def cbd_maxIterationsReached(self):
        return self.cbd_iteration >= self.cbd_options.getMaxIterations()
    
    
    # user defined method
    def fsa_getInputEventAt(self, time):
        return self.fsa_eventList.getInputAt(time)
    
    
    # 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 updateGlobalState(self):
        self.weaved_previous_global_state = copy.deepcopy(self.weaved_global_state)
        self.weaved_lib.updateGlobalState(self.weaved_global_state, self.fsa_currentState.cbd, self.cbd_clock)
    
    
    # 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 getTriggeredWhenTransition(self):
        return self.weaved_lib.getTriggeredWhenTransition(self.weaved_model, self.fsa_currentState, self.weaved_global_state, self.weaved_previous_global_state)
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /FSA
        self.states["/FSA"] = State(1, "/FSA", self)
        
        # state /FSA/Started
        self.states["/FSA/Started"] = State(2, "/FSA/Started", self)
        
        # state /FSA/Initialized
        self.states["/FSA/Initialized"] = State(3, "/FSA/Initialized", self)
        
        # state /FSA/CheckTermination
        self.states["/FSA/CheckTermination"] = State(4, "/FSA/CheckTermination", self)
        
        # state /FSA/CheckTermination/MacroStepProcessed
        self.states["/FSA/CheckTermination/MacroStepProcessed"] = State(5, "/FSA/CheckTermination/MacroStepProcessed", self)
        
        # state /FSA/DoSimulation
        self.states["/FSA/DoSimulation"] = State(6, "/FSA/DoSimulation", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared
        self.states["/FSA/DoSimulation/MacroStepPrepared"] = State(7, "/FSA/DoSimulation/MacroStepPrepared", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ParentPaused
        self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"] = State(8, "/FSA/DoSimulation/MacroStepPrepared/ParentPaused", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ChildNotDetected
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"] = State(9, "/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ChildDetected
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"] = State(10, "/FSA/DoSimulation/MacroStepPrepared/ChildDetected", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ChildInitialized
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"] = State(11, "/FSA/DoSimulation/MacroStepPrepared/ChildInitialized", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"] = State(12, "/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/CBD
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD"] = State(13, "/FSA/DoSimulation/MacroStepPrepared/CBD", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/CBD/Started
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"] = State(14, "/FSA/DoSimulation/MacroStepPrepared/CBD/Started", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/CBD/Initialized
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"] = State(15, "/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized", self)
        
        # state /FSA/DoSimulation/MacroStepPrepared/ChildProcessed
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"] = State(16, "/FSA/DoSimulation/MacroStepPrepared/ChildProcessed", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed
        self.states["/FSA/DoSimulation/MicroStepProcessed"] = State(17, "/FSA/DoSimulation/MicroStepProcessed", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ParentPaused
        self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"] = State(18, "/FSA/DoSimulation/MicroStepProcessed/ParentPaused", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ChildNotDetected
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"] = State(19, "/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ChildDetected
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildDetected"] = State(20, "/FSA/DoSimulation/MicroStepProcessed/ChildDetected", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ChildInitialized
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"] = State(21, "/FSA/DoSimulation/MicroStepProcessed/ChildInitialized", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"] = State(22, "/FSA/DoSimulation/MicroStepProcessed/CBD", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"] = State(23, "/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"] = State(24, "/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"] = State(25, "/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"] = State(26, "/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"] = State(27, "/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"] = State(28, "/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/CBD/Terminated
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"] = State(29, "/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ChildPaused
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"] = State(30, "/FSA/DoSimulation/MicroStepProcessed/ChildPaused", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected
        self.states["/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"] = State(31, "/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/StateEventDetected
        self.states["/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"] = State(32, "/FSA/DoSimulation/MicroStepProcessed/StateEventDetected", self)
        
        # state /FSA/DoSimulation/MicroStepProcessed/ChildProcessed
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"] = State(33, "/FSA/DoSimulation/MicroStepProcessed/ChildProcessed", self)
        
        # state /FSA/DoSimulation/MicroStepPrepared
        self.states["/FSA/DoSimulation/MicroStepPrepared"] = State(34, "/FSA/DoSimulation/MicroStepPrepared", self)
        
        # state /FSA/DoSimulation/ParentMicroStepProcessed
        self.states["/FSA/DoSimulation/ParentMicroStepProcessed"] = State(35, "/FSA/DoSimulation/ParentMicroStepProcessed", self)
        
        # state /FSA/Terminated
        self.states["/FSA/Terminated"] = State(36, "/FSA/Terminated", self)
        
        # state /ParentStarted
        self.states["/ParentStarted"] = State(37, "/ParentStarted", self)
        
        # state /HybridTerminated
        self.states["/HybridTerminated"] = State(38, "/HybridTerminated", self)
        
        # add children
        self.states[""].addChild(self.states["/FSA"])
        self.states[""].addChild(self.states["/ParentStarted"])
        self.states[""].addChild(self.states["/HybridTerminated"])
        self.states["/FSA"].addChild(self.states["/FSA/Started"])
        self.states["/FSA"].addChild(self.states["/FSA/Initialized"])
        self.states["/FSA"].addChild(self.states["/FSA/CheckTermination"])
        self.states["/FSA"].addChild(self.states["/FSA/DoSimulation"])
        self.states["/FSA"].addChild(self.states["/FSA/Terminated"])
        self.states["/FSA/CheckTermination"].addChild(self.states["/FSA/CheckTermination/MacroStepProcessed"])
        self.states["/FSA/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared"])
        self.states["/FSA/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed"])
        self.states["/FSA/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MicroStepPrepared"])
        self.states["/FSA/DoSimulation"].addChild(self.states["/FSA/DoSimulation/ParentMicroStepProcessed"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/CBD"])
        self.states["/FSA/DoSimulation/MacroStepPrepared"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"])
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"])
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD"].addChild(self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ChildDetected"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"])
        self.states["/FSA/DoSimulation/MicroStepProcessed"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"])
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].addChild(self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/FSA"]
        self.states["/FSA"].default_state = self.states["/FSA/Started"]
        self.states["/FSA/CheckTermination"].default_state = self.states["/FSA/CheckTermination/MacroStepProcessed"]
        self.states["/FSA/DoSimulation"].default_state = self.states["/FSA/DoSimulation/MacroStepPrepared"]
        self.states["/FSA/DoSimulation/MacroStepPrepared"].default_state = self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"]
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD"].default_state = self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"]
        self.states["/FSA/DoSimulation/MicroStepProcessed"].default_state = self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"]
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD"].default_state = self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"]
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"].default_state = self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"]
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"].default_state = self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"]
        
        # transition /FSA/Started
        _FSA_Started_0 = Transition(self, self.states["/FSA/Started"], [self.states["/ParentStarted"]])
        _FSA_Started_0.setAction(self._FSA_Started_0_exec)
        _FSA_Started_0.setTrigger(None)
        self.states["/FSA/Started"].addTransition(_FSA_Started_0)
        
        # transition /FSA/Initialized
        _FSA_Initialized_0 = Transition(self, self.states["/FSA/Initialized"], [self.states["/FSA/CheckTermination"]])
        _FSA_Initialized_0.setAction(self._FSA_Initialized_0_exec)
        _FSA_Initialized_0.setTrigger(None)
        self.states["/FSA/Initialized"].addTransition(_FSA_Initialized_0)
        
        # transition /FSA/CheckTermination/MacroStepProcessed
        _FSA_CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/FSA/CheckTermination/MacroStepProcessed"], [self.states["/FSA/DoSimulation"]])
        _FSA_CheckTermination_MacroStepProcessed_0.setAction(self._FSA_CheckTermination_MacroStepProcessed_0_exec)
        _FSA_CheckTermination_MacroStepProcessed_0.setTrigger(None)
        _FSA_CheckTermination_MacroStepProcessed_0.setGuard(self._FSA_CheckTermination_MacroStepProcessed_0_guard)
        self.states["/FSA/CheckTermination/MacroStepProcessed"].addTransition(_FSA_CheckTermination_MacroStepProcessed_0)
        _FSA_CheckTermination_MacroStepProcessed_1 = Transition(self, self.states["/FSA/CheckTermination/MacroStepProcessed"], [self.states["/FSA/Terminated"]])
        _FSA_CheckTermination_MacroStepProcessed_1.setAction(self._FSA_CheckTermination_MacroStepProcessed_1_exec)
        _FSA_CheckTermination_MacroStepProcessed_1.setTrigger(None)
        _FSA_CheckTermination_MacroStepProcessed_1.setGuard(self._FSA_CheckTermination_MacroStepProcessed_1_guard)
        self.states["/FSA/CheckTermination/MacroStepProcessed"].addTransition(_FSA_CheckTermination_MacroStepProcessed_1)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ParentPaused
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"]])
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setTrigger(None)
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0.setGuard(self._FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_guard)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ParentPaused_0)
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"]])
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setAction(self._FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_exec)
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setTrigger(None)
        _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1.setGuard(self._FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_guard)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ParentPaused"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ParentPaused_1)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ChildNotDetected
        _FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotDetected"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ChildDetected
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setTrigger(None)
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0.setGuard(self._FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_guard)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildDetected_0)
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setTrigger(None)
        _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1.setGuard(self._FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_guard)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildDetected"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildDetected_1)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ChildInitialized
        _FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized
        _FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"], [self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildNotInitialized"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/CBD/Started
        _FSA_DoSimulation_MacroStepPrepared_CBD_Started_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"], [self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"]])
        _FSA_DoSimulation_MacroStepPrepared_CBD_Started_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_CBD_Started_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_CBD_Started_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Started"].addTransition(_FSA_DoSimulation_MacroStepPrepared_CBD_Started_0)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/CBD/Initialized
        _FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"], [self.states["/FSA/DoSimulation/MacroStepPrepared/ChildInitialized"]])
        _FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/CBD/Initialized"].addTransition(_FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0)
        
        # transition /FSA/DoSimulation/MacroStepPrepared/ChildProcessed
        _FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0 = Transition(self, self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"], [self.states["/FSA/DoSimulation/MicroStepProcessed"]])
        _FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0.setAction(self._FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0_exec)
        _FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MacroStepPrepared/ChildProcessed"].addTransition(_FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ParentPaused
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildDetected"]])
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ParentPaused_0)
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"]])
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setAction(self._FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_exec)
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ParentPaused"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ParentPaused_1)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ChildNotDetected
        _FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildNotDetected"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ChildDetected
        _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildDetected"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildDetected"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildDetected_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ChildInitialized
        _FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildInitialized"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0)
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1.setGuard(self._FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/CheckTermination/MacroStepProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MacroStepPrepared"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1.setGuard(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"], [self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepProcessed"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/DoSimulation/MicroStepPrepared"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepPrepared_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/CBD/Terminated
        _FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"], [self.states["/HybridTerminated"]])
        _FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/CBD/Terminated"].addTransition(_FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ChildPaused
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"], [self.states["/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildPaused_0)
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"], [self.states["/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildPaused"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildPaused_1)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected
        _FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/NoStateEventDetected"].addTransition(_FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/StateEventDetected
        _FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"], [self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"]])
        _FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepProcessed/StateEventDetected"].addTransition(_FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0)
        
        # transition /FSA/DoSimulation/MicroStepProcessed/ChildProcessed
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"], [self.states["/FSA/DoSimulation/MicroStepPrepared"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0)
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1 = Transition(self, self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"], [self.states["/FSA/CheckTermination"]])
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setAction(self._FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_exec)
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setTrigger(None)
        _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1.setGuard(self._FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_guard)
        self.states["/FSA/DoSimulation/MicroStepProcessed/ChildProcessed"].addTransition(_FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1)
        
        # transition /FSA/DoSimulation/MicroStepPrepared
        _FSA_DoSimulation_MicroStepPrepared_0 = Transition(self, self.states["/FSA/DoSimulation/MicroStepPrepared"], [self.states["/FSA/DoSimulation/ParentMicroStepProcessed"]])
        _FSA_DoSimulation_MicroStepPrepared_0.setAction(self._FSA_DoSimulation_MicroStepPrepared_0_exec)
        _FSA_DoSimulation_MicroStepPrepared_0.setTrigger(None)
        self.states["/FSA/DoSimulation/MicroStepPrepared"].addTransition(_FSA_DoSimulation_MicroStepPrepared_0)
        
        # transition /FSA/DoSimulation/ParentMicroStepProcessed
        _FSA_DoSimulation_ParentMicroStepProcessed_0 = Transition(self, self.states["/FSA/DoSimulation/ParentMicroStepProcessed"], [self.states["/FSA/DoSimulation/MacroStepPrepared"]])
        _FSA_DoSimulation_ParentMicroStepProcessed_0.setAction(self._FSA_DoSimulation_ParentMicroStepProcessed_0_exec)
        _FSA_DoSimulation_ParentMicroStepProcessed_0.setTrigger(None)
        self.states["/FSA/DoSimulation/ParentMicroStepProcessed"].addTransition(_FSA_DoSimulation_ParentMicroStepProcessed_0)
        
        # transition /FSA/Terminated
        _FSA_Terminated_0 = Transition(self, self.states["/FSA/Terminated"], [self.states["/HybridTerminated"]])
        _FSA_Terminated_0.setAction(self._FSA_Terminated_0_exec)
        _FSA_Terminated_0.setTrigger(None)
        self.states["/FSA/Terminated"].addTransition(_FSA_Terminated_0)
        
        # transition /ParentStarted
        _ParentStarted_0 = Transition(self, self.states["/ParentStarted"], [self.states["/FSA/Initialized"]])
        _ParentStarted_0.setAction(self._ParentStarted_0_exec)
        _ParentStarted_0.setTrigger(None)
        self.states["/ParentStarted"].addTransition(_ParentStarted_0)
    
    def _FSA_Started_0_exec(self, parameters):
        print('From FSA/Started to ParentStarted... ')
        self.weaved_delta = min(self.fsa_timestep, self.cbd_delta)
        self.fsa_logicalTime = 0.0
        self.fsa_elapsed = 0
        self.fsa_timestep = self.weaved_delta
        self.fsa_currentState = self.weaved_model.initialState
    
    def _FSA_Initialized_0_exec(self, parameters):
        print('From FSA/Initialized to FSA/CheckTermination... ')
    
    def _FSA_CheckTermination_MacroStepProcessed_0_exec(self, parameters):
        print('From FSA/CheckTermination/MacroStepProcessed to FSA/DoSimulation and reading events... ')
        self.fsa_currentEvent = self.fsa_getInputEventAt(self.fsa_logicalTime)
        self.fsa_selectedTransition = self.weaved_model.getTransitionFrom(self.fsa_currentState, 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_currentState, CBDState)))
    
    def _FSA_CheckTermination_MacroStepProcessed_0_guard(self, parameters):
        return not self.fsa_currentState.final
    
    def _FSA_CheckTermination_MacroStepProcessed_1_exec(self, parameters):
        print('From FSA/CheckTermination/MacroStepProcessed to Terminated... ')
    
    def _FSA_CheckTermination_MacroStepProcessed_1_guard(self, parameters):
        return self.fsa_currentState.final
    
    def _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_exec(self, parameters):
        print('From FSA/ParentPaused to FSA/ChildDetected... ')
        self.cbd_model = self.fsa_currentState.cbd
    
    def _FSA_DoSimulation_MacroStepPrepared_ParentPaused_0_guard(self, parameters):
        return isinstance(self.fsa_currentState, CBDState)
    
    def _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_exec(self, parameters):
        print('From ParentPaused to ChildNotDetected without any child to process... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ParentPaused_1_guard(self, parameters):
        return not isinstance(self.fsa_currentState, CBDState)
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildNotDetected_0_exec(self, parameters):
        print('From ChildNotDetected to ChildProcessed... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_exec(self, parameters):
        print('From ChildDetected to ChildInitialized... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildDetected_0_guard(self, parameters):
        return self.woven_child_initialized
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_exec(self, parameters):
        print('From ChildDetected to ChildNotInitialized... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildDetected_1_guard(self, parameters):
        return not self.woven_child_initialized
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildInitialized_0_exec(self, parameters):
        print('From ChildInitialized to ChildProcessed... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildNotInitialized_0_exec(self, parameters):
        print('From ChildNotInitialized to CBD/Started... ')
        self.cbd_delta = self.weaved_delta
        self.updateCBDState()
        self.woven_child_initialized = True
    
    def _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)
        self.cbd_controller.initSimulation()
        print('Performing initialization... DONE')
    
    def _FSA_DoSimulation_MacroStepPrepared_CBD_Initialized_0_exec(self, parameters):
        print('From CBD/Initialized to ChildInitialized... ')
    
    def _FSA_DoSimulation_MacroStepPrepared_ChildProcessed_0_exec(self, parameters):
        print('From MacroStepPrepared/ChildProcessed to MicroStepProcessed... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_exec(self, parameters):
        print('From FSA/ParentPaused to FSA/ChildDetected... ')
        self.cbd_model = self.fsa_currentState.cbd
    
    def _FSA_DoSimulation_MicroStepProcessed_ParentPaused_0_guard(self, parameters):
        return isinstance(self.fsa_currentState, CBDState)
    
    def _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_exec(self, parameters):
        print('From ParentPaused to ChildNotDetected without any child to process... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ParentPaused_1_guard(self, parameters):
        return not isinstance(self.fsa_currentState, CBDState)
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildNotDetected_0_exec(self, parameters):
        print('From ChildNotDetected to ChildProcessed... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_exec(self, parameters):
        print('From ChildDetected to ChildInitialized... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildDetected_0_guard(self, parameters):
        return self.woven_child_initialized
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildInitialized_0_exec(self, parameters):
        print('From ChildInitialized to ChildProcessed... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_exec(self, parameters):
        print('From CBD/MacroStepProcessed to Terminated... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_0_guard(self, parameters):
        return self.cbd_maxIterationsReached()
    
    def _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 _FSA_DoSimulation_MicroStepProcessed_CBD_CheckTermination_MacroStepProcessed_1_guard(self, parameters):
        return not self.cbd_maxIterationsReached()
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MacroStepPrepared_0_exec(self, parameters):
        print('From CBD/MacroStepPrepared to MicroStepProcessed... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_exec(self, parameters):
        print('From CBD/MicroStepProcessed to MicroStepPrepared')
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_0_guard(self, parameters):
        return self.cbd_hasNextStrongComponent()
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_exec(self, parameters):
        print('From CBD/MicroStepProcessed to ChildPaused and detecting triggered transitions... ')
        self.updateGlobalState()
        self.weaved_lib.dumpGlobalState(self.weaved_model, self.weaved_global_state, self.fsa_logicalTime, self.fsa_currentState)
        self.weaved_triggered_when_transition = self.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))
        print('CBD iteration: ' + str(self.cbd_iteration))
    
    def _FSA_DoSimulation_MicroStepProcessed_CBD_DoSimulation_MicroStepProcessed_1_guard(self, parameters):
        return not self.cbd_hasNextStrongComponent()
    
    def _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 _FSA_DoSimulation_MicroStepProcessed_CBD_Terminated_0_exec(self, parameters):
        print('From CBD/Terminated to HybridTerminated... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_exec(self, parameters):
        print('From ChildPaused to NoStateEventDetected... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildPaused_0_guard(self, parameters):
        return self.weaved_triggered_when_transition == None
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_exec(self, parameters):
        print('From ChildPaused to StateEventDetected... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildPaused_1_guard(self, parameters):
        return self.weaved_triggered_when_transition != None
    
    def _FSA_DoSimulation_MicroStepProcessed_NoStateEventDetected_0_exec(self, parameters):
        print('From NoStateEventDetected to ChildProcessed... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_StateEventDetected_0_exec(self, parameters):
        print('From StateEventDetected to ChildProcessed... ')
        if self.fsa_selectedTransition == None:
        	self.fsa_selectedTransition = self.weaved_triggered_when_transition
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_exec(self, parameters):
        print('From FSA/MicroStepProcessed/ChildProcessed to MicroStepPrepared... ')
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_0_guard(self, parameters):
        return self.fsa_selectedTransition != None
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_exec(self, parameters):
        print('From FSA/MicroStepProcessed/ChildProcessed to FSA/CheckTermination and advancing time... ')
        self.fsa_logicalTime = self.fsa_logicalTime + self.fsa_timestep
        self.fsa_elapsed = self.fsa_elapsed + self.fsa_timestep
        print(self.fsa_logicalTime)
        print(self.fsa_elapsed)
    
    def _FSA_DoSimulation_MicroStepProcessed_ChildProcessed_1_guard(self, parameters):
        return self.fsa_selectedTransition == None
    
    def _FSA_DoSimulation_MicroStepPrepared_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_currentState = self.fsa_selectedTransition.target
        self.fsa_elapsed = 0
        self.fsa_processEvent(self.fsa_currentEvent)
        self.weaved_lib.dumpDiscreteEvent(self.weaved_model, self.fsa_logicalTime, self.fsa_currentState, self.fsa_selectedTransition)
        self.weaved_lib.dumpGlobalState(self.weaved_model, self.weaved_global_state, self.fsa_logicalTime, self.fsa_currentState)
        print('New state: ' + str(self.fsa_currentState))
        print('Reading events:')
        self.fsa_currentEvent = self.fsa_getInputEventAt(self.fsa_logicalTime)
        self.fsa_selectedTransition = self.weaved_model.getTransitionFrom(self.fsa_currentState, self.fsa_currentEvent, self.fsa_elapsed)
        print(self.fsa_currentEvent)
        print(self.fsa_selectedTransition)
    
    def _FSA_DoSimulation_ParentMicroStepProcessed_0_exec(self, parameters):
        print('From ParentMicroStepProcessed to ParentPaused and resetting the child... ')
        self.woven_child_initialized = False
    
    def _FSA_Terminated_0_exec(self, parameters):
        print('From FSA/Terminated to HybridTerminated... ')
    
    def _ParentStarted_0_exec(self, parameters):
        print('From ParentStarted to FSA/Initialized... ')
        self.weaved_global_state = dict()
        self.weaved_previous_global_state = dict()
        self.woven_child_initialized = False
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/FSA"].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 == "Weaved_CBD_FSA_Simulator":
            instance = Weaved_CBD_FSA_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, amodel, 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.object_manager.createInstance("Weaved_CBD_FSA_Simulator", [cbd_options, amodel, fsa_events])