Esempio n. 1
0
 def update(self, dt):
     System.update(self, dt)
     for event in tdl.event.get(): # Iterate over recent events.
         if event.type == 'KEYDOWN':
             if event.keychar not in IGNORED_INPUTS:
                 EventManager.Instance().fireEvent("EVENT_KeyPressed", {"char" : event.keychar.upper()})
                 if (event.keychar.upper() == "Q"): EventManager.Instance().fireEvent("EVENT_QuitGame", {})
         if event.type == 'KEYUP':
             if event.keychar not in IGNORED_INPUTS:
                 EventManager.Instance().fireEvent("EVENT_KeyReleased", {"char" : event.keychar.upper()})
Esempio n. 2
0
    def __init__(self, width, height, font='assets/terminal_8x12.png'):
        System.__init__(self)

        # Define screen sizes
        self.screen_width = width
        self.screen_height = height

        # Set rendered font
        tdl.set_font(font)

        # Create console window
        self.window = tdl.init(self.screen_width, self.screen_height, "gripe engine")

        # Initial screen properties
        self.console_mid = Vector2D(int(self.screen_width / 2), int(self.screen_height / 2))
        self.offset_transform = Transform2D(self.console_mid)

        # Add initial game panel (panel[0] is main game always)
        self.game_panel = GamePanel(self.window, 0, 0, self.screen_width, self.screen_height, None, None, self)
        self.panels = []
Esempio n. 3
0
    def __init__(self, namespace, name):
        self.name = name
        self.namespace = namespace

        # Mi prendo il system associato e se questo non esiste ne creo uno nuovo
        self.system = sm.getSystemForNamespace(namespace)

        if self.system is None:
            self.system = System(system_root=None, namespace=namespace)
            sm.addSystem(self.system)

        self.parameters = []
        self.dependencies = []
def generateSystemCode(system_root, system_parent):
    # Generando il system si generano anche i file CMakeLists e PackageXML
    # Viene generata tutto l'albero delle cartelle e viene resettato se necessario
    namespace = tfs.getNamespace(system_root)

    system = sm.getSystemForNamespace(namespace)
    if system is None:
        system = System(system_root)
        sm.addSystem(system)

    # Se il system non ha un launch file associato e serve crearlo, allora lo creo
    # Il launch file a questo punto è vuoto
    if system.launch_file is None:
        system.createLaunchFile()

        # Se ho un genitore, ovvero un system che mi ha incluso,
        # lo avviso che dovrà includermi
        if system_parent:
            if system_parent.launch_file:
                system_parent.launch_file.addSubSystem(system.launch_file)

    # Ricerco tutti i processi all'interno del system
    processes = system_root.findall("./" + XMLTags.tags['TAG_SUBCOMPONENTS'] +
                                    "/" + XMLTags.tags['TAG_SUBCOMPONENT'] +
                                    "/" + "[" + XMLTags.tags['TAG_CATEGORY'] +
                                    "='process']" + "[" +
                                    XMLTags.tags['TAG_NAMESPACE'] + "='" +
                                    system.namespace + "']")

    # Scorro ogni processo. Per ogni processo controllo i subcomponent: in base alle varie tipologie
    # di subcomponent avvio la generazione di diversi nodi ROS
    for process in processes:
        threads = process.findall("./" + XMLTags.tags['TAG_SUBCOMPONENTS'] +
                                  "/" + XMLTags.tags['TAG_SUBCOMPONENT'] +
                                  "/" + "[" + XMLTags.tags['TAG_CATEGORY'] +
                                  "='thread']")

        # Cerco il main thread, che formerà la base per tutti gli altri thread.
        main_thread = process.find("./" + XMLTags.tags['TAG_SUBCOMPONENTS'] +
                                   "/" + XMLTags.tags['TAG_SUBCOMPONENT'] +
                                   "/" + "[" + XMLTags.tags['TAG_CATEGORY'] +
                                   "='thread']" + "/" + "[" +
                                   XMLTags.tags['TAG_NAME'] +
                                   "='main_thread']" + "/" + "[" +
                                   XMLTags.tags['TAG_NAMESPACE'] + "='ros']")
        if main_thread:
            thread_type = (tfs.getType(main_thread)).lower()

            p = AADLProcess(process, system_root, system)
            renameExistingNodeClass(p, system.system_folder)

            gen_main_thread = createNewThread(
                system_root, process, main_thread,
                getPythonClassFromAADLThreadType(thread_type), p)
            p.threads.append(gen_main_thread)

            for thread in threads:
                # name        = (tfs.getName(thread)).lower()
                thread_type = (tfs.getType(thread)).lower()
                namespace = (tfs.getNamespace(thread)).lower()

                if (namespace == "ros" or namespace == "global_state_machine"
                    ) and not isMainThread(thread_type):
                    new_thread = createNewThread(
                        system_root, process, thread,
                        getPythonClassFromAADLThreadType(thread_type), p)
                    if new_thread:
                        p.threads.append(new_thread)

            p.addTransformationFrameComponent()
            system.addNode(p)
Esempio n. 5
0
 def __init__(self):
     System.__init__(self)