Ejemplo n.º 1
0
    def __setupNamesPanel(self):
        '''
        Helper method sets up the panel displaying the names of all
        components that can be simulated.
        '''
        #get a list from manager of all known components
        #note that this will NOT work with dynamic components!
        comp_info_list = getManager().get_component_info(
            getClient().token.h, [], "*", "*", 0)
        #must add active components to this list as well
        comp_info_list = comp_info_list + getManager().get_component_info(
            getClient().token.h, [], "*", "*", 1)

        #add all components to the list iff they are actually simulator objects
        for comp_info in comp_info_list:
            if comp_info.code == "Acssim.Servants.GUISimulator" and self.comp_names.count(
                    comp_info.name) == 0:
                self.comp_names.append(comp_info.name)
        #tidy up the list
        self.comp_names.sort()

        #now add the widget
        self.comp_names_panel = Pmw.OptionMenu(self.interior(),
                                               command=self.compNameUpdate,
                                               labelpos='w',
                                               label_text='Component Name:',
                                               items=self.comp_names,
                                               menubutton_width=20)
        self.comp_names_panel.pack(anchor='w', padx=10, pady=10)
Ejemplo n.º 2
0
    def updateMethods(self, selection):
        '''
        Helper function returns a list of methods or attributes the component has available.
        
        Parameters:
        - selection ("Methods" or "Attributes")

        Returns: a list of available methods/attributes.
        '''
        retList = []

        #component name
        compName = self.current_comp_name

        #retrieve comp IDL type from manager
        compInfoList = []
        compInfoList = getManager().get_component_info(getClient().token.h, [],
                                                       compName, "*", 0)
        compInfoList = compInfoList + getManager().get_component_info(
            getClient().token.h, [], compName, "*", 1)

        if len(compInfoList) > 1:
            print "Potential error: more than 1 matching component found - ", compName, len(
                compInfoList)
        elif len(compInfoList) == 0:
            print "Bad...no matching component found:", compName
            return retList

        #need to know the IDL type in order to figure out the list of components
        compIDLType = compInfoList[0].type

        #Get a description from the IFR
        interf = IR.lookup_id(compIDLType)._narrow(
            CORBA.InterfaceDef).describe_interface()

        if selection == "Methods":
            for method in interf.operations:
                retList.append(method.name)
        else:
            #must be an attribute
            for method in interf.attributes:
                retList.append(method.name)

        retList.sort()
        return retList
Ejemplo n.º 3
0
    def updateMethods(self, selection):
        '''
        Helper function returns a list of methods or attributes the component has available.
        
        Parameters:
        - selection ("Methods" or "Attributes")

        Returns: a list of available methods/attributes.
        '''
        retList = []
        
        #component name
        compName = self.current_comp_name

        #retrieve comp IDL type from manager
        compInfoList = []
        compInfoList = getManager().get_component_info(getClient().token.h, [], compName, "*", 0)
        compInfoList = compInfoList + getManager().get_component_info(getClient().token.h, [], compName, "*", 1)
        
        if len(compInfoList) > 1:
            print "Potential error: more than 1 matching component found - ", compName, len(compInfoList)
        elif len(compInfoList)==0:
            print "Bad...no matching component found:", compName
            return retList

        #need to know the IDL type in order to figure out the list of components
        compIDLType = compInfoList[0].type
        
        #Get a description from the IFR
        interf = IR.lookup_id(compIDLType)._narrow(CORBA.InterfaceDef).describe_interface()

        if selection == "Methods":
            for method in interf.operations:
                retList.append(method.name)
        else:
            #must be an attribute
            for method in interf.attributes:
                retList.append(method.name)

        retList.sort()
        return retList
Ejemplo n.º 4
0
 def __setupNamesPanel(self):
     '''
     Helper method sets up the panel displaying the names of all
     components that can be simulated.
     '''
     #get a list from manager of all known components
     #note that this will NOT work with dynamic components!
     comp_info_list = getManager().get_component_info(getClient().token.h, 
                                                      [], 
                                                      "*", 
                                                      "*", 
                                                      0)
     #must add active components to this list as well
     comp_info_list = comp_info_list + getManager().get_component_info(getClient().token.h, 
                                                                       [],
                                                                       "*", 
                                                                       "*", 
                                                                       1)
                                                                       
     #add all components to the list iff they are actually simulator objects
     for comp_info in comp_info_list:
         if comp_info.code == "Acssim.Servants.GUISimulator" and self.comp_names.count(comp_info.name)==0:
             self.comp_names.append(comp_info.name)
     #tidy up the list
     self.comp_names.sort()
     
     #now add the widget
     self.comp_names_panel = Pmw.OptionMenu(self.interior(),
                                          command = self.compNameUpdate,
                                          labelpos = 'w',
                                          label_text = 'Component Name:',
                                          items = self.comp_names,
                                          menubutton_width = 20)
     self.comp_names_panel.pack(anchor = 'w',
                              padx = 10,
                              pady = 10)
Ejemplo n.º 5
0
def getCompIfrID(comp_name):
    '''
    Given a component's name, returns said component's interface repository ID
    or throws an exception if the ID cannot be determined.
    
    Raises: CORBA.NO_RESOURCES
    '''
    #get a list of component info's
    comp_list = getManager().get_component_info(getClient().token.h, [], "*",
                                                "*", 0)

    for comp in comp_list:
        if comp.name == comp_name:
            return comp.type

    #sanity check
    raise CORBA.NO_RESOURCES()
Ejemplo n.º 6
0
def getCompIfrID(comp_name):
    '''
    Given a component's name, returns said component's interface repository ID
    or throws an exception if the ID cannot be determined.
    
    Raises: CORBA.NO_RESOURCES
    '''
    #get a list of component info's
    comp_list = getManager().get_component_info(getClient().token.h, 
                                                [], 
                                                "*", 
                                                "*", 
                                                0)
    
    for comp in comp_list:
        if comp.name == comp_name:
            return comp.type
        
    #sanity check
    raise CORBA.NO_RESOURCES()