Esempio n. 1
0
    def _getComplexConfigValues(self, value):
        '''
        Go from:
            [complex(a,b), complex(a,b), ..., complex(a,b)]
        to:
            [CF.complexType(a,b), CF.complexType(a,b), ..., complexType(a,b)]
        '''

        memberTypeStr = mapComplexToSimple(self.valueType)
        newValues = []
        for val in value:
            # value is actually a list.  loop through each val
            # in the list and validate it
            try:
                real = val.real
                imag = val.imag
            except AttributeError:
                # In Python 2.4, basic types don't support 'real' and 'imag',
                # so assume that val is the real component and use its type to
                # create an imaginary component with a value of 0
                real = val
                imag = type(val)(0)
            realValue = _type_helpers.checkValidValue(real, memberTypeStr)
            imagValue = _type_helpers.checkValidValue(imag, memberTypeStr)
        
            # convert to CORBA type (e.g., CF.complexFloat)
            newValues.append(getCFType(self.valueType)(realValue, imagValue))
        return newValues
Esempio n. 2
0
    def _getComplexConfigValues(self, value):
        '''
        Go from:
            [complex(a,b), complex(a,b), ..., complex(a,b)]
        to:
            [CF.complexType(a,b), CF.complexType(a,b), ..., complexType(a,b)]
        '''

        memberTypeStr = mapComplexToSimple(self.valueType)
        newValues = []
        for val in value:
            # value is actually a list.  loop through each val
            # in the list and validate it
            realValue = _type_helpers.checkValidValue(val.real, 
                                                      memberTypeStr)
            imagValue = _type_helpers.checkValidValue(val.imag, 
                                                      memberTypeStr)
        
            # convert to CORBA type (e.g., CF.complexFloat)
            newValues.append(getCFType(self.valueType)(realValue, imagValue))
        return newValues
Esempio n. 3
0
    def toAny(self, value):
        '''
        Converts the input value in Python format to a CORBA Any.
        '''
        if value == None:
            return _any.to_any(None)

        # If property is an enumeration, enforce proper value
        if self._enums != None:
            value = self._enumValue(value)

        if self.valueType.startswith("complex"):
            memberTypeStr = mapComplexToSimple(self.valueType)
            real, imag = _type_helpers._splitComplex(value)
            realValue = _type_helpers.checkValidValue(real, memberTypeStr)
            imagValue = _type_helpers.checkValidValue(imag, memberTypeStr)

            # Convert to CORBA type (e.g., CF.complexFloat)
            value = getCFType(self.valueType)(realValue, imagValue)
        else:
            # Validate the value
            value = _type_helpers.checkValidValue(value, self.valueType)

        return _CORBA.Any(self.typecode, value)
Esempio n. 4
0
    def toAny(self, value):
        '''
        Converts the input value in Python format to a CORBA Any.
        '''
        if value == None:
            return _any.to_any(None)

        # If property is an enumeration, enforce proper value
        if self.id in _enums.keys():
            value = self._enumValue(value)

        if self.valueType.startswith("complex"):
            memberTypeStr = mapComplexToSimple(self.valueType)
            real, imag = _type_helpers._splitComplex(value)
            realValue = _type_helpers.checkValidValue(real, memberTypeStr)
            imagValue = _type_helpers.checkValidValue(imag, memberTypeStr)

            # Convert to CORBA type (e.g., CF.complexFloat)
            value = getCFType(self.valueType)(realValue, imagValue)
        else:
            # Validate the value
            value = _type_helpers.checkValidValue(value, self.valueType)

        return _CORBA.Any(self.typecode, value)