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

Date:   Thu Nov 10 14:05:46 2016

Model author: Glenn De Jonghe
Model name:   Player Tank
Model description:
Handling the player tank.
"""

from sccd.runtime.statecharts_core import *

# package "Player Tank"

class Main(RuntimeClassBase):
    def __init__(self, controller, tank):
        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.tank = None
        
        # call user defined constructor
        Main.user_defined_constructor(self, tank)
    
    def user_defined_constructor(self, tank):
        self.tank = tank
    
    def user_defined_destructor(self):
        pass
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /state_1
        self.states["/state_1"] = State(1, "/state_1", self)
        
        # state /state_2
        self.states["/state_2"] = State(2, "/state_2", self)
        
        # state /state_3
        self.states["/state_3"] = State(3, "/state_3", self)
        
        # state /state_4
        self.states["/state_4"] = State(4, "/state_4", self)
        
        # state /end
        self.states["/end"] = State(5, "/end", self)
        
        # add children
        self.states[""].addChild(self.states["/state_1"])
        self.states[""].addChild(self.states["/state_2"])
        self.states[""].addChild(self.states["/state_3"])
        self.states[""].addChild(self.states["/state_4"])
        self.states[""].addChild(self.states["/end"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/state_1"]
        
        # transition /state_1
        _state_1_0 = Transition(self, self.states["/state_1"], [self.states["/state_2"]])
        _state_1_0.setAction(self._state_1_0_exec)
        _state_1_0.setTrigger(None)
        self.states["/state_1"].addTransition(_state_1_0)
        
        # transition /state_2
        _state_2_0 = Transition(self, self.states["/state_2"], [self.states["/state_3"]])
        _state_2_0.setTrigger(Event("instance_created", None))
        self.states["/state_2"].addTransition(_state_2_0)
        
        # transition /state_3
        _state_3_0 = Transition(self, self.states["/state_3"], [self.states["/state_4"]])
        _state_3_0.setAction(self._state_3_0_exec)
        _state_3_0.setTrigger(None)
        self.states["/state_3"].addTransition(_state_3_0)
        
        # transition /state_4
        _state_4_0 = Transition(self, self.states["/state_4"], [self.states["/end"]])
        _state_4_0.setAction(self._state_4_0_exec)
        _state_4_0.setTrigger(Event("instance_created", None))
        self.states["/state_4"].addTransition(_state_4_0)
    
    def _state_1_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'cannon', 'Cannon', self.tank]))
    
    def _state_3_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("create_instance", None, [self, 'body', 'Body', self.tank]))
    
    def _state_4_0_exec(self, parameters):
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'cannon']))
        self.big_step.outputEventOM(Event("start_instance", None, [self, 'body']))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/state_1"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class Cannon(RuntimeClassBase):
    def __init__(self, controller, tank):
        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.tank = None
        self.reload_time = None
        
        # call user defined constructor
        Cannon.user_defined_constructor(self, tank)
    
    def user_defined_constructor(self, tank):
        self.tank = tank
        self.reload_time = tank.getReloadTime()
    
    def user_defined_destructor(self):
        pass
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /container
        self.states["/container"] = ParallelState(1, "/container", self)
        
        # state /container/rotating
        self.states["/container/rotating"] = State(2, "/container/rotating", self)
        
        # state /container/rotating/none
        self.states["/container/rotating/none"] = State(3, "/container/rotating/none", self)
        
        # state /container/rotating/left
        self.states["/container/rotating/left"] = State(4, "/container/rotating/left", self)
        
        # state /container/rotating/both
        self.states["/container/rotating/both"] = State(5, "/container/rotating/both", self)
        
        # state /container/rotating/right
        self.states["/container/rotating/right"] = State(6, "/container/rotating/right", self)
        
        # state /container/shoot
        self.states["/container/shoot"] = State(7, "/container/shoot", self)
        
        # state /container/shoot/hold
        self.states["/container/shoot/hold"] = State(8, "/container/shoot/hold", self)
        
        # state /container/shoot/shoot
        self.states["/container/shoot/shoot"] = State(9, "/container/shoot/shoot", self)
        
        # state /container/ammo
        self.states["/container/ammo"] = State(10, "/container/ammo", self)
        
        # state /container/ammo/loaded
        self.states["/container/ammo/loaded"] = State(11, "/container/ammo/loaded", self)
        
        # state /container/ammo/unloaded
        self.states["/container/ammo/unloaded"] = State(12, "/container/ammo/unloaded", self)
        self.states["/container/ammo/unloaded"].setEnter(self._container_ammo_unloaded_enter)
        self.states["/container/ammo/unloaded"].setExit(self._container_ammo_unloaded_exit)
        
        # add children
        self.states[""].addChild(self.states["/container"])
        self.states["/container"].addChild(self.states["/container/rotating"])
        self.states["/container"].addChild(self.states["/container/shoot"])
        self.states["/container"].addChild(self.states["/container/ammo"])
        self.states["/container/rotating"].addChild(self.states["/container/rotating/none"])
        self.states["/container/rotating"].addChild(self.states["/container/rotating/left"])
        self.states["/container/rotating"].addChild(self.states["/container/rotating/both"])
        self.states["/container/rotating"].addChild(self.states["/container/rotating/right"])
        self.states["/container/shoot"].addChild(self.states["/container/shoot/hold"])
        self.states["/container/shoot"].addChild(self.states["/container/shoot/shoot"])
        self.states["/container/ammo"].addChild(self.states["/container/ammo/loaded"])
        self.states["/container/ammo"].addChild(self.states["/container/ammo/unloaded"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/container"]
        self.states["/container/rotating"].default_state = self.states["/container/rotating/none"]
        self.states["/container/shoot"].default_state = self.states["/container/shoot/hold"]
        self.states["/container/ammo"].default_state = self.states["/container/ammo/loaded"]
        
        # transition /container/rotating/none
        _container_rotating_none_0 = Transition(self, self.states["/container/rotating/none"], [self.states["/container/rotating/left"]])
        _container_rotating_none_0.setTrigger(Event("cannon-left-pressed", "input"))
        self.states["/container/rotating/none"].addTransition(_container_rotating_none_0)
        _container_rotating_none_1 = Transition(self, self.states["/container/rotating/none"], [self.states["/container/rotating/right"]])
        _container_rotating_none_1.setTrigger(Event("cannon-right-pressed", "input"))
        self.states["/container/rotating/none"].addTransition(_container_rotating_none_1)
        
        # transition /container/rotating/left
        _container_rotating_left_0 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/none"]])
        _container_rotating_left_0.setTrigger(Event("cannon-left-released", "input"))
        self.states["/container/rotating/left"].addTransition(_container_rotating_left_0)
        _container_rotating_left_1 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/both"]])
        _container_rotating_left_1.setTrigger(Event("cannon-right-pressed", "input"))
        self.states["/container/rotating/left"].addTransition(_container_rotating_left_1)
        _container_rotating_left_2 = Transition(self, self.states["/container/rotating/left"], [self.states["/container/rotating/left"]])
        _container_rotating_left_2.setAction(self._container_rotating_left_2_exec)
        _container_rotating_left_2.setTrigger(Event("update", "engine"))
        self.states["/container/rotating/left"].addTransition(_container_rotating_left_2)
        
        # transition /container/rotating/both
        _container_rotating_both_0 = Transition(self, self.states["/container/rotating/both"], [self.states["/container/rotating/right"]])
        _container_rotating_both_0.setTrigger(Event("cannon-left-released", "input"))
        self.states["/container/rotating/both"].addTransition(_container_rotating_both_0)
        _container_rotating_both_1 = Transition(self, self.states["/container/rotating/both"], [self.states["/container/rotating/left"]])
        _container_rotating_both_1.setTrigger(Event("cannon-right-released", "input"))
        self.states["/container/rotating/both"].addTransition(_container_rotating_both_1)
        
        # transition /container/rotating/right
        _container_rotating_right_0 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/both"]])
        _container_rotating_right_0.setTrigger(Event("cannon-left-pressed", "input"))
        self.states["/container/rotating/right"].addTransition(_container_rotating_right_0)
        _container_rotating_right_1 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/none"]])
        _container_rotating_right_1.setTrigger(Event("cannon-right-released", "input"))
        self.states["/container/rotating/right"].addTransition(_container_rotating_right_1)
        _container_rotating_right_2 = Transition(self, self.states["/container/rotating/right"], [self.states["/container/rotating/right"]])
        _container_rotating_right_2.setAction(self._container_rotating_right_2_exec)
        _container_rotating_right_2.setTrigger(Event("update", "engine"))
        self.states["/container/rotating/right"].addTransition(_container_rotating_right_2)
        
        # transition /container/shoot/hold
        _container_shoot_hold_0 = Transition(self, self.states["/container/shoot/hold"], [self.states["/container/shoot/shoot"]])
        _container_shoot_hold_0.setAction(self._container_shoot_hold_0_exec)
        _container_shoot_hold_0.setTrigger(Event("shoot-pressed", "input"))
        self.states["/container/shoot/hold"].addTransition(_container_shoot_hold_0)
        
        # transition /container/shoot/shoot
        _container_shoot_shoot_0 = Transition(self, self.states["/container/shoot/shoot"], [self.states["/container/shoot/hold"]])
        _container_shoot_shoot_0.setTrigger(Event("shoot-released", "input"))
        self.states["/container/shoot/shoot"].addTransition(_container_shoot_shoot_0)
        _container_shoot_shoot_1 = Transition(self, self.states["/container/shoot/shoot"], [self.states["/container/shoot/shoot"]])
        _container_shoot_shoot_1.setAction(self._container_shoot_shoot_1_exec)
        _container_shoot_shoot_1.setTrigger(Event("loaded", None))
        self.states["/container/shoot/shoot"].addTransition(_container_shoot_shoot_1)
        
        # transition /container/ammo/loaded
        _container_ammo_loaded_0 = Transition(self, self.states["/container/ammo/loaded"], [self.states["/container/ammo/unloaded"]])
        _container_ammo_loaded_0.setAction(self._container_ammo_loaded_0_exec)
        _container_ammo_loaded_0.setTrigger(Event("shoot", None))
        self.states["/container/ammo/loaded"].addTransition(_container_ammo_loaded_0)
        
        # transition /container/ammo/unloaded
        _container_ammo_unloaded_0 = Transition(self, self.states["/container/ammo/unloaded"], [self.states["/container/ammo/loaded"]])
        _container_ammo_unloaded_0.setAction(self._container_ammo_unloaded_0_exec)
        _container_ammo_unloaded_0.setTrigger(Event("_0after"))
        self.states["/container/ammo/unloaded"].addTransition(_container_ammo_unloaded_0)
    
    def _container_ammo_unloaded_enter(self):
        self.addTimer(0, self.reload_time)
    
    def _container_ammo_unloaded_exit(self):
        self.removeTimer(0)
    
    def _container_rotating_left_2_exec(self, parameters):
        self.tank.turnCannonLeft()
    
    def _container_rotating_right_2_exec(self, parameters):
        self.tank.turnCannonRight()
    
    def _container_shoot_hold_0_exec(self, parameters):
        self.raiseInternalEvent(Event("shoot", None, []))
    
    def _container_shoot_shoot_1_exec(self, parameters):
        self.raiseInternalEvent(Event("shoot", None, []))
    
    def _container_ammo_loaded_0_exec(self, parameters):
        self.tank.shoot()
        self.big_step.outputEvent(Event("reloading", "gui", []))
    
    def _container_ammo_unloaded_0_exec(self, parameters):
        self.raiseInternalEvent(Event("loaded", None, []))
        self.big_step.outputEvent(Event("loaded", "gui", []))
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/container"].getEffectiveTargetStates()
        RuntimeClassBase.initializeStatechart(self)

class Body(RuntimeClassBase):
    def __init__(self, controller, tank):
        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.tank = None
        
        # call user defined constructor
        Body.user_defined_constructor(self, tank)
    
    def user_defined_constructor(self, tank):
        self.tank = tank
    
    def user_defined_destructor(self):
        pass
    
    
    # builds Statechart structure
    def build_statechart_structure(self):
        
        # state <root>
        self.states[""] = State(0, "", self)
        
        # state /container
        self.states["/container"] = ParallelState(1, "/container", self)
        
        # state /container/horizontal
        self.states["/container/horizontal"] = State(2, "/container/horizontal", self)
        
        # state /container/horizontal/none
        self.states["/container/horizontal/none"] = State(3, "/container/horizontal/none", self)
        
        # state /container/horizontal/left
        self.states["/container/horizontal/left"] = State(4, "/container/horizontal/left", self)
        
        # state /container/horizontal/both
        self.states["/container/horizontal/both"] = State(5, "/container/horizontal/both", self)
        
        # state /container/horizontal/right
        self.states["/container/horizontal/right"] = State(6, "/container/horizontal/right", self)
        
        # state /container/vertical
        self.states["/container/vertical"] = State(7, "/container/vertical", self)
        
        # state /container/vertical/none
        self.states["/container/vertical/none"] = State(8, "/container/vertical/none", self)
        
        # state /container/vertical/down
        self.states["/container/vertical/down"] = State(9, "/container/vertical/down", self)
        
        # state /container/vertical/both
        self.states["/container/vertical/both"] = State(10, "/container/vertical/both", self)
        
        # state /container/vertical/up
        self.states["/container/vertical/up"] = State(11, "/container/vertical/up", self)
        
        # add children
        self.states[""].addChild(self.states["/container"])
        self.states["/container"].addChild(self.states["/container/horizontal"])
        self.states["/container"].addChild(self.states["/container/vertical"])
        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/none"])
        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/left"])
        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/both"])
        self.states["/container/horizontal"].addChild(self.states["/container/horizontal/right"])
        self.states["/container/vertical"].addChild(self.states["/container/vertical/none"])
        self.states["/container/vertical"].addChild(self.states["/container/vertical/down"])
        self.states["/container/vertical"].addChild(self.states["/container/vertical/both"])
        self.states["/container/vertical"].addChild(self.states["/container/vertical/up"])
        self.states[""].fixTree()
        self.states[""].default_state = self.states["/container"]
        self.states["/container/horizontal"].default_state = self.states["/container/horizontal/none"]
        self.states["/container/vertical"].default_state = self.states["/container/vertical/none"]
        
        # transition /container/horizontal/none
        _container_horizontal_none_0 = Transition(self, self.states["/container/horizontal/none"], [self.states["/container/horizontal/left"]])
        _container_horizontal_none_0.setTrigger(Event("left-pressed", "input"))
        self.states["/container/horizontal/none"].addTransition(_container_horizontal_none_0)
        _container_horizontal_none_1 = Transition(self, self.states["/container/horizontal/none"], [self.states["/container/horizontal/right"]])
        _container_horizontal_none_1.setTrigger(Event("right-pressed", "input"))
        self.states["/container/horizontal/none"].addTransition(_container_horizontal_none_1)
        
        # transition /container/horizontal/left
        _container_horizontal_left_0 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/none"]])
        _container_horizontal_left_0.setTrigger(Event("left-released", "input"))
        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_0)
        _container_horizontal_left_1 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/both"]])
        _container_horizontal_left_1.setTrigger(Event("right-pressed", "input"))
        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_1)
        _container_horizontal_left_2 = Transition(self, self.states["/container/horizontal/left"], [self.states["/container/horizontal/left"]])
        _container_horizontal_left_2.setAction(self._container_horizontal_left_2_exec)
        _container_horizontal_left_2.setTrigger(Event("update", "engine"))
        self.states["/container/horizontal/left"].addTransition(_container_horizontal_left_2)
        
        # transition /container/horizontal/both
        _container_horizontal_both_0 = Transition(self, self.states["/container/horizontal/both"], [self.states["/container/horizontal/right"]])
        _container_horizontal_both_0.setTrigger(Event("left-released", "input"))
        self.states["/container/horizontal/both"].addTransition(_container_horizontal_both_0)
        _container_horizontal_both_1 = Transition(self, self.states["/container/horizontal/both"], [self.states["/container/horizontal/left"]])
        _container_horizontal_both_1.setTrigger(Event("right-released", "input"))
        self.states["/container/horizontal/both"].addTransition(_container_horizontal_both_1)
        
        # transition /container/horizontal/right
        _container_horizontal_right_0 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/both"]])
        _container_horizontal_right_0.setTrigger(Event("left-pressed", "input"))
        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_0)
        _container_horizontal_right_1 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/none"]])
        _container_horizontal_right_1.setTrigger(Event("right-released", "input"))
        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_1)
        _container_horizontal_right_2 = Transition(self, self.states["/container/horizontal/right"], [self.states["/container/horizontal/right"]])
        _container_horizontal_right_2.setAction(self._container_horizontal_right_2_exec)
        _container_horizontal_right_2.setTrigger(Event("update", "engine"))
        self.states["/container/horizontal/right"].addTransition(_container_horizontal_right_2)
        
        # transition /container/vertical/none
        _container_vertical_none_0 = Transition(self, self.states["/container/vertical/none"], [self.states["/container/vertical/down"]])
        _container_vertical_none_0.setTrigger(Event("down-pressed", "input"))
        self.states["/container/vertical/none"].addTransition(_container_vertical_none_0)
        _container_vertical_none_1 = Transition(self, self.states["/container/vertical/none"], [self.states["/container/vertical/up"]])
        _container_vertical_none_1.setTrigger(Event("up-pressed", "input"))
        self.states["/container/vertical/none"].addTransition(_container_vertical_none_1)
        
        # transition /container/vertical/down
        _container_vertical_down_0 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/none"]])
        _container_vertical_down_0.setTrigger(Event("down-released", "input"))
        self.states["/container/vertical/down"].addTransition(_container_vertical_down_0)
        _container_vertical_down_1 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/both"]])
        _container_vertical_down_1.setTrigger(Event("up-pressed", "input"))
        self.states["/container/vertical/down"].addTransition(_container_vertical_down_1)
        _container_vertical_down_2 = Transition(self, self.states["/container/vertical/down"], [self.states["/container/vertical/down"]])
        _container_vertical_down_2.setAction(self._container_vertical_down_2_exec)
        _container_vertical_down_2.setTrigger(Event("update", "engine"))
        self.states["/container/vertical/down"].addTransition(_container_vertical_down_2)
        
        # transition /container/vertical/both
        _container_vertical_both_0 = Transition(self, self.states["/container/vertical/both"], [self.states["/container/vertical/up"]])
        _container_vertical_both_0.setTrigger(Event("down-released", "input"))
        self.states["/container/vertical/both"].addTransition(_container_vertical_both_0)
        _container_vertical_both_1 = Transition(self, self.states["/container/vertical/both"], [self.states["/container/vertical/down"]])
        _container_vertical_both_1.setTrigger(Event("up-released", "input"))
        self.states["/container/vertical/both"].addTransition(_container_vertical_both_1)
        
        # transition /container/vertical/up
        _container_vertical_up_0 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/both"]])
        _container_vertical_up_0.setTrigger(Event("down-pressed", "input"))
        self.states["/container/vertical/up"].addTransition(_container_vertical_up_0)
        _container_vertical_up_1 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/none"]])
        _container_vertical_up_1.setTrigger(Event("up-released", "input"))
        self.states["/container/vertical/up"].addTransition(_container_vertical_up_1)
        _container_vertical_up_2 = Transition(self, self.states["/container/vertical/up"], [self.states["/container/vertical/up"]])
        _container_vertical_up_2.setAction(self._container_vertical_up_2_exec)
        _container_vertical_up_2.setTrigger(Event("update", "engine"))
        self.states["/container/vertical/up"].addTransition(_container_vertical_up_2)
    
    def _container_horizontal_left_2_exec(self, parameters):
        self.tank.turnLeft()
    
    def _container_horizontal_right_2_exec(self, parameters):
        self.tank.turnRight()
    
    def _container_vertical_down_2_exec(self, parameters):
        self.tank.moveDown()
    
    def _container_vertical_up_2_exec(self, parameters):
        self.tank.moveUp()
    
    def initializeStatechart(self):
        # enter default state
        self.default_targets = self.states["/container"].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 == "Main":
            instance = Main(self.controller, construct_params[0])
            instance.associations = {}
            instance.associations["cannon"] = Association("Cannon", 1, 1)
            instance.associations["body"] = Association("Body", 1, 1)
        elif class_name == "Cannon":
            instance = Cannon(self.controller, construct_params[0])
            instance.associations = {}
        elif class_name == "Body":
            instance = Body(self.controller, construct_params[0])
            instance.associations = {}
        else:
            raise Exception("Cannot instantiate class " + class_name)
        return instance

class Controller(EventLoopControllerBase):
    def __init__(self, tank, event_loop_callbacks, finished_callback = None, behind_schedule_callback = None):
        if finished_callback == None: finished_callback = None
        if behind_schedule_callback == None: behind_schedule_callback = None
        EventLoopControllerBase.__init__(self, ObjectManager(self), event_loop_callbacks, finished_callback, behind_schedule_callback)
        self.addInputPort("engine")
        self.addInputPort("input")
        self.addOutputPort("gui")
        self.object_manager.createInstance("Main", [tank])