Exemplo n.º 1
0
def tryCallbackParams(params, compRef):
    '''
    Takes in some parameters that were passed to a component method and checks
    to see if any of them are actually callbacks. If this is the case, the
    callbacks done method is invoked.
    '''
    from Acssim.Corba.Generator import getRandomValue
    
    compl = ACSErr.Completion(long(getTimeStamp().value),  #ULL
                              0L,  #ACSErr::CompletionType type;
                              0L,  #ACSErr::CompletionCode code;
                              ())
                              
    cbId = 0L    #default value
    for param in params:
        if isinstance(param, ACS.CBDescIn):
            cbId = param.id_tag
            break
        
    cbDescOut = ACS.CBDescOut(0L, cbId)

    for param in params:
        if isinstance(param, ACS._objref_CBvoid):
            param.done(compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBpattern):
            param.done(getRandomValue(ACS._tc_pattern, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBpattern):
            param.done(getRandomValue(ACS._tc_pattern, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBdouble):
            param.done(getRandomValue(CORBA._tc_double, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBstring):
            param.done(getRandomValue(CORBA._tc_string, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBstringSeq):
            param.done(getRandomValue(ACS._tc_stringSeq, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBlong):
            param.done(getRandomValue(CORBA._tc_long, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBdoubleSeq):
            param.done(getRandomValue(ACS._tc_doubleSeq, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBlongSeq):
            param.done(getRandomValue(ACS._tc_longSeq, compRef),
                       compl,
                       cbDescOut)
        else:
            pass
Exemplo n.º 2
0
 def __typecodesToObjects(self, in_list):
     '''
     Converts a list full of typecodes to real implementations of those 
     types.
     '''
     #good - no in/inout parameters
     if len(in_list) == 1:
         ret_val = [getRandomValue(in_list[0], self.comp_ref)]
     
     else:
         #iterate through the return value and all 
         for i in range(0, len(in_list)):
             in_list[i] = getRandomValue(in_list[i], self.comp_ref)
         ret_val = [tuple(in_list)]
         
     return ret_val
Exemplo n.º 3
0
    def __typecodesToObjects(self, in_list):
        '''
        Converts a list full of typecodes to real implementations of those 
        types.
        '''
        #good - no in/inout parameters
        if len(in_list) == 1:
            ret_val = [getRandomValue(in_list[0], self.comp_ref)]

        else:
            #iterate through the return value and all
            for i in range(0, len(in_list)):
                in_list[i] = getRandomValue(in_list[i], self.comp_ref)
            ret_val = [tuple(in_list)]

        return ret_val
Exemplo n.º 4
0
def supplyEventByType(component_name, channel_name, ifr_id):
    '''
    Supplies an event to a notification channel by the event's IFR ID type.
    
    Parameters:
        component_name - name of the component publisihing the event
        channel_name - name of the channel the event should be published
        on
        ifr_id - the interface repository ID of the IDL structure that 
        should be dynamically created and sent as an event
        
    Returns: Nothing
    
    Raises: ???
    '''
    from Acssim.Corba.Generator import getRandomValue
    
    #create an instance of the IDL struct
    #get the type code first
    type_code = getTypeCode(ifr_id)
    event_instance = getRandomValue(type_code, 
                                    getComponent(component_name))
                                    
    #now just delegate to another function
    supplyEventByInstance(component_name, channel_name, event_instance)
Exemplo n.º 5
0
def testType(idl_type):
    '''
    Helper function completely tests a single IDL type
    '''
    #get the typecode
    tc = getTypeCode(idl_type)

    #get a random instance
    rv = getRandomValue(tc, FAKE_MS)

    print "Created an instance of '", idl_type, "':", type(rv)
Exemplo n.º 6
0
def testType(idl_type):
    '''
    Helper function completely tests a single IDL type
    '''
    #get the typecode
    tc = getTypeCode(idl_type)
    
    #get a random instance
    rv = getRandomValue(tc,
                        FAKE_MS)
                        
    print "Created an instance of '", idl_type, "':", type(rv)
Exemplo n.º 7
0
def supplyEventByType(component_name, channel_name, ifr_id):
    '''
    Supplies an event to a notification channel by the event's IFR ID type.
    
    Parameters:
        component_name - name of the component publisihing the event
        channel_name - name of the channel the event should be published
        on
        ifr_id - the interface repository ID of the IDL structure that 
        should be dynamically created and sent as an event
        
    Returns: Nothing
    
    Raises: ???
    '''
    from Acssim.Corba.Generator import getRandomValue

    #create an instance of the IDL struct
    #get the type code first
    type_code = getTypeCode(ifr_id)
    event_instance = getRandomValue(type_code, getComponent(component_name))

    #now just delegate to another function
    supplyEventByInstance(component_name, channel_name, event_instance)