Exemplo n.º 1
0
    def testPushConnectionId(self):
        # Create and connect a second consumer port
        consumer_2 = MessageConsumerPort()
        self._portManager.addPort(consumer_2)
        objref = consumer_2._this()
        self._supplier.connectPort(objref, 'connection_2')

        # Set up 2 receivers to distinguish which connection received a message
        receiver_1 = MessageReceiver()
        self._consumer.registerMessage(None, None, receiver_1.messageReceived)

        receiver_2 = MessageReceiver()
        consumer_2.registerMessage(None, None, receiver_2.messageReceived)

        # Pack the messages ourselves and target the first connection
        messages_1 = []
        messages_1.append(CF.DataType('first', to_any(100)))
        messages_1.append(CF.DataType('second', to_any('some text')))
        messages_1.append(CF.DataType('third', to_any(0.25)))

        self._supplier.push(props_to_any(messages_1), 'connection_1')
        self.failUnless(receiver_1.waitMessages(3, 1.0))
        self.assertEqual(3, len(receiver_1.messages))
        self.failIf(receiver_2.waitMessages(1, 0.1))

        # Target the second connection with a different set of messages
        messages_2 = []
        messages_2.append(CF.DataType('one', to_any('abc')))
        messages_2.append(CF.DataType('two', to_any(False)))
        messages_2 = props_to_any(messages_2)
        self._supplier.push(messages_2, "connection_2")

        self.failUnless(receiver_2.waitMessages(2, 1.0))
        self.assertEqual(2, len(receiver_2.messages))
        self.failIf(receiver_1.waitMessages(4, 0.1))

        # Target both connections with yet another set of messages
        messages_3 = props_to_any([CF.DataType('all', to_any(3))])
        self._supplier.push(messages_3)
        self.failUnless(receiver_2.waitMessages(3, 1.0))
        self.assertEqual(3, len(receiver_2.messages))
        self.failUnless(receiver_1.waitMessages(4, 1.0))
        self.assertEqual(4, len(receiver_1.messages))

        # Target invalid connection
        messages_4 = props_to_any(
            [CF.DataType('bad', to_any('bad_connection'))])
        self.assertRaises(ValueError, self._supplier.push, messages_4,
                          'bad_connection')
        self.failIf(receiver_2.waitMessages(4, 0.1))
        self.failIf(receiver_1.waitMessages(5, 0.1))
        self.assertEqual(3, len(receiver_2.messages))
        self.assertEqual(4, len(receiver_1.messages))
Exemplo n.º 2
0
    def sendMessages(self, data_structs, connectionId=None):
        """
        Sends a list of messages.

        Args:
            data_structs: Sequence of messages to send.
            connectionId: Target connection (default: all).

        Raises:
            ValueError: If connectionId is given and does not match any
                        connection.
        """
        outgoing = []
        msgid = None
        for msg in data_structs:
            msgid = msg.getId()
            outgoing.append(
                CF.DataType(id=msg.getId(), value=struct_to_any(msg)))
        outmsg = props_to_any(outgoing)

        try:
            # try to push entire message set
            self._push(outmsg, connectionId)
        except CORBA.MARSHAL:
            if len(data_structs) == 1:
                self._port_log.warn("Could not deliver the message id=" +
                                    str(msgid) +
                                    ". Maximum message size exceeded")
            else:
                self._port_log.warn(
                    "Could not deliver the message. Maximum message size exceeded, trying individually"
                )
                # try resending individually
                for msg in data_structs:
                    outm = props_to_any([
                        CF.DataType(id=msg.getId(), value=struct_to_any(msg))
                    ])
                    try:
                        self._push(outm, connectionId)
                    except CORBA.MARSHAL:
                        self._port_log.warn(
                            "Could not deliver the message id=" +
                            str(msg.getId()) +
                            ". Maximum message size exceeded")
                        break
                    except:
                        print "WARNING: Unable to send data to", connection
Exemplo n.º 3
0
    def sendMessages(self, data_structs):
        self.portInterfaceAccess.acquire()
        try:
            outgoing = []
            for msg in data_structs:
                outgoing.append(CF.DataType(id=msg.getId(),value=struct_to_any(msg)))
            outmsg = props_to_any(outgoing)
        except:
            self.portInterfaceAccess.release()
            raise

        for connection in self._connections:
            try:
                self._connections[connection]['proxy_consumer'].push(outmsg)
            except:
                print "WARNING: Unable to send data to",connection
        self.portInterfaceAccess.release()
Exemplo n.º 4
0
    def sendMessages(self, data_structs):
        self.portInterfaceAccess.acquire()
        try:
            outgoing = []
            for msg in data_structs:
                outgoing.append(CF.DataType(id=msg.getId(),value=struct_to_any(msg)))
            outmsg = props_to_any(outgoing)
        except:
            self.portInterfaceAccess.release()
            raise

        for connection in self._connections:
            try:
                self._connections[connection]['proxy_consumer'].push(outmsg)
            except:
                print "WARNING: Unable to send data to",connection
        self.portInterfaceAccess.release()
Exemplo n.º 5
0
    def testPush(self):
        receiver = MessageReceiver()
        self._consumer.registerMessage(None, None, receiver.messageReceived)

        # Pack the messages ourselves
        messages = []
        messages.append(CF.DataType('first', to_any(100)))
        messages.append(CF.DataType('second', to_any('some text')))
        messages.append(CF.DataType('third', to_any(0.25)))

        self._supplier.push(props_to_any(messages))

        self.failUnless(receiver.waitMessages(3, 1.0))
        self.assertEqual(3, len(receiver.messages))
        self.assertEqual(100, from_any(receiver.messages[0].value))
        self.assertEqual('some text', from_any(receiver.messages[1].value))
        self.assertEqual(0.25, from_any(receiver.messages[2].value))
Exemplo n.º 6
0
    def runEnumTest(self, testValues):
        unknown = []

        for prop in testValues:
            value = {}
            if prop.id == "floatenum":
                value['DEFAULT'] = enums.floatenum.DEFAULT
                value['OTHER'] = enums.floatenum.OTHER
            elif prop.id == "stringenum":
                value['START'] = enums.stringenum.START
                value['STOPPED'] = enums.stringenum.STOPPED
            elif prop.id == "structprop":
                number_enums = {}
                number_enums['ZERO'] = enums.structprop.number.ZERO
                number_enums['ONE'] = enums.structprop.number.ONE
                number_enums['TWO'] = enums.structprop.number.TWO
                value['structprop::number'] = number_enums

                alpha_enums = {}
                alpha_enums['ABC'] = enums.structprop.alpha.ABC
                alpha_enums['DEF'] = enums.structprop.alpha.DEF
                value['structprop::alpha'] = alpha_enums
            elif prop.id == "structseq":
                number_enums = {}
                number_enums[
                    'POSITIVE'] = enums.structseq_struct.number.POSITIVE
                number_enums['ZERO'] = enums.structseq_struct.number.ZERO
                number_enums[
                    'NEGATIVE'] = enums.structseq_struct.number.NEGATIVE
                value['structseq::number'] = number_enums

                text_enums = {}
                text_enums['HEADER'] = enums.structseq_struct.text.HEADER
                text_enums['BODY'] = enums.structseq_struct.text.BODY
                text_enums['FOOTER'] = enums.structseq_struct.text.FOOTER
                value['structseq::text'] = text_enums
            else:
                unknown.append(prop)
            prop.value = properties.props_to_any(
                properties.props_from_dict(value))

        if unknown:
            raise CF.UnknownProperties(unknown)

        return testValues
Exemplo n.º 7
0
    def sendMessage(self, data_struct):
        self.portInterfaceAccess.acquire()
        if not isinstance(data_struct, CORBA.Any):
            try:
                outgoing = [CF.DataType(id=data_struct.getId(),value=struct_to_any(data_struct))]
                outmsg = props_to_any(outgoing)
            except:
                self.portInterfaceAccess.release()
                raise
        else:
            outmsg = data_struct

        for connection in self._connections:
            try:
                self._connections[connection]['proxy_consumer'].push(outmsg)
            except:
                print "WARNING: Unable to send data to",connection
        self.portInterfaceAccess.release()
Exemplo n.º 8
0
    def sendMessage(self, data_struct):
        self.portInterfaceAccess.acquire()
        if not isinstance(data_struct, CORBA.Any):
            try:
                outgoing = [CF.DataType(id=data_struct.getId(),value=struct_to_any(data_struct))]
                outmsg = props_to_any(outgoing)
            except:
                self.portInterfaceAccess.release()
                raise
        else:
            outmsg = data_struct

        for connection in self._connections:
            try:
                self._connections[connection]['proxy_consumer'].push(outmsg)
            except:
                print "WARNING: Unable to send data to",connection
        self.portInterfaceAccess.release()
Exemplo n.º 9
0
    def sendMessage(self, data_struct, connectionId=None):
        """
        Sends a single message.

        Args:
            data_struct:  Message structure or CORBA.Any to send.
            connectionId: Target connection (default: all).

        Raises:
            ValueError: If connectionId is given and does not match any
                        connection.
        """
        if not isinstance(data_struct, CORBA.Any):
            outgoing = [CF.DataType(id=data_struct.getId(),value=struct_to_any(data_struct))]
            outmsg = props_to_any(outgoing)
        else:
            outmsg = data_struct
        self.push(outmsg, connectionId)
    def process(self):
        self.mymessage.EnterMessageHere = "Congrats on your new message!"
        self.port_message_out.sendMessage(self.mymessage)

        # This code only handles 1 connection to the port
        if len(self.port_eventChannel_out.getConnectionIds()) != 0:
            connectionID = self.port_eventChannel_out.getConnectionIds()[0]
            if self.consumer is None:
                self.consumer = self.port_eventChannel_out.for_suppliers(connectionID).obtain_push_consumer()
                self.consumer.connect_push_supplier(self.Supplier_i()._this())

            dt = CF.DataType(id=self.mymessage.getId(), value=properties.struct_to_any(self.mymessage))
            anyProps = properties.props_to_any([dt])
            try:
                self.consumer.push(anyProps)
            except:
                try:
                    self.consumer.disconnect_push_consumer()
                except:
                    pass
                self.consumer = None

        time.sleep(2)
        return NOOP
    def getPropertySet(self, kinds=("configure",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        for prop in self.prf.get_simple():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_value() is not None:
                    dt = properties.to_tc_value(prop.get_value(), prop.get_type())
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Simple Sequences
        for prop in self.prf.get_simplesequence():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_values() is not None:
                    seq = []
                    for v in prop.get_values().get_value():
                        seq.append(properties.to_pyvalue(v, prop.get_type()))
                    dt = any.to_any(seq)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Structures
        for prop in self.prf.get_struct():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_simple() is not None:
                    fields = []
                    hasValue = False
                    for s in prop.get_simple():
                        if s.get_value() is not None:
                            hasValue = True
                        dt = properties.to_tc_value(s.get_value(), s.get_type())
                        fields.append(CF.DataType(id=str(s.get_id()), value=dt))
                    if not hasValue and not includeNil:
                        continue
                    dt = any.to_any(fields)
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)
        # Structures

        for prop in self.prf.get_structsequence():
            if self.isMatch(prop, modes, kinds, (action,)):
              baseProp = []
              if prop.get_struct() != None:
                fields = []
                for internal_prop in prop.get_struct().get_simple():
                    fields.append(CF.DataType(id=str(internal_prop.get_id()), value=any.to_any(None)))
              for val in prop.get_structvalue():
                baseProp.append(copy.deepcopy(fields))
                for entry in val.get_simpleref():
                  val_type = None
                  for internal_prop in prop.get_struct().get_simple():
                      if str(internal_prop.get_id()) == entry.refid:
                          val_type = internal_prop.get_type()
                  for subfield in baseProp[-1]:
                      if subfield.id == entry.refid:
                        subfield.value = properties.to_tc_value(entry.get_value(), val_type)
              anybp = []
              for bp in baseProp:
                  anybp.append(properties.props_to_any(bp))
              p = CF.DataType(id=str(prop.get_id()), value=any.to_any(anybp))
              propertySet.append(p)
        # Struct Sequence

        return propertySet
Exemplo n.º 12
0
    def getPropertySet(self, kinds=("configure","property",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True,
                             commandline=False):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        if self.prf != None:
            for prop in self.prf.get_simple():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if prop.get_value() is not None:
                        if prop.complex.lower() == "true":
                            type = mapComplexType(prop.get_type())
                            value = stringToComplex(prop.get_value(), type)
                        else:
                            type = prop.get_type()
                            value = prop.get_value()
                        dt = properties.to_tc_value(value, type)
                    elif not includeNil:
                        continue
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Simple Sequences
            for prop in self.prf.get_simplesequence():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if prop.get_values() is not None:
                        seq = []
                        if prop.complex.lower() == "true":
                            type = mapComplexType(prop.get_type())
                            for v in prop.get_values().get_value():
                                seq.append(stringToComplex(v, type))
                            expectedType = properties.getTypeCode(type)
                            expectedTypeCode = tcInternal.createTypeCode(
                                (tcInternal.tv_sequence, expectedType._d, 0))
                            dt = CORBA.Any(expectedTypeCode, [
                                properties._convertComplexToCFComplex(
                                    item, type) for item in seq
                            ])
                        else:
                            type = prop.get_type()
                            for v in prop.get_values().get_value():
                                value = v
                                seq.append(properties.to_pyvalue(value, type))
                            dt = any.to_any(seq)
                    elif not includeNil:
                        continue
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Structures
            for prop in self.prf.get_struct():
                if self.isMatch(prop, modes, kinds, (action, )):
                    if (prop.get_simple()
                            is not None) or (prop.get_simplesequence()
                                             is not None):
                        fields = []
                        hasValue = False
                        if prop.get_simple() is not None:
                            for p in prop.get_simple():
                                if p.get_value() is not None:
                                    hasValue = True
                                dt = properties.to_tc_value(
                                    p.get_value(), p.get_type())
                                fields.append(
                                    CF.DataType(id=str(p.get_id()), value=dt))
                        if prop.get_simplesequence() is not None:
                            for p in prop.get_simplesequence():
                                if p.get_values() is not None:
                                    hasValue = True
                                dt = properties.to_tc_value(
                                    p.get_values(), p.get_type())
                                fields.append(
                                    CF.DataType(id=str(p.get_id()), value=dt))
                        if not hasValue and not includeNil:
                            continue
                        dt = any.to_any(fields)
                    else:
                        dt = any.to_any(None)
                    p = CF.DataType(id=str(prop.get_id()), value=dt)
                    propertySet.append(p)

            # Struct Sequence
            for prop in self.prf.get_structsequence():
                if self.isMatch(prop, modes, kinds, (action, )):
                    baseProp = []
                    if prop.get_struct() != None:
                        fields = []
                        for internal_prop in prop.get_struct().get_simple():
                            fields.append(
                                CF.DataType(id=str(internal_prop.get_id()),
                                            value=any.to_any(None)))
                        for internal_prop in prop.get_struct(
                        ).get_simplesequence():
                            fields.append(
                                CF.DataType(id=str(internal_prop.get_id()),
                                            value=any.to_any(None)))
                    for val in prop.get_structvalue():
                        baseProp.append(copy.deepcopy(fields))
                        for entry in val.get_simpleref():
                            val_type = None
                            for internal_prop in prop.get_struct().get_simple(
                            ):
                                if str(internal_prop.get_id()) == entry.refid:
                                    val_type = internal_prop.get_type()
                            for subfield in baseProp[-1]:
                                if subfield.id == entry.refid:
                                    subfield.value = properties.to_tc_value(
                                        entry.get_value(), val_type)
                        for entry in val.get_simplesequenceref():
                            val_type = None
                            for internal_prop in prop.get_struct(
                            ).get_simplesequence():
                                if str(internal_prop.get_id()) == entry.refid:
                                    val_type = internal_prop.get_type()
                            for subfield in baseProp[-1]:
                                if subfield.id == entry.refid:
                                    subfield.value = properties.to_tc_value(
                                        entry.get_values(), val_type)
                    anybp = []
                    for bp in baseProp:
                        anybp.append(properties.props_to_any(bp))
                    p = CF.DataType(id=str(prop.get_id()),
                                    value=any.to_any(anybp))
                    propertySet.append(p)

        return propertySet
Exemplo n.º 13
0
subkw5 = CF.DataType('GEOLOCATION_GPS::ALTITUDE',
                     CORBA.Any(CORBA._tc_double, 32.0))
subkw6 = CF.DataType('GEOLOCATION_GPS::GROUND_SPEED',
                     CORBA.Any(CORBA._tc_double, 26.0))
subkw7 = CF.DataType('GEOLOCATION_GPS::HEADING_ANGLE',
                     CORBA.Any(CORBA._tc_double, 36.0))
subkw8 = CF.DataType('GEOLOCATION_GPS::TRACK_ANGLE',
                     CORBA.Any(CORBA._tc_double, 15.0))
subkw9 = CF.DataType('GEOLOCATION_GPS::MAGNETIC_VARIATION',
                     CORBA.Any(CORBA._tc_double, 16.0))

list = [
    subkw, subkw1, subkw2, subkw3, subkw4, subkw5, subkw6, subkw7, subkw8,
    subkw9
]
value = sb.SRIKeyword('GEOLOCATION_GPS', properties.props_to_any(list),
                      'IDL:CF/Properties:1.0')

subkw = CF.DataType('GEOLOCATION_INS::TIME_SECONDS',
                    CORBA.Any(CORBA._tc_double, 1111))
subkw1 = CF.DataType('GEOLOCATION_INS::TIME_FRACTIONAL',
                     CORBA.Any(CORBA._tc_double, .00002))
subkw2 = CF.DataType('GEOLOCATION_INS::MANUFACTURER_ID',
                     CORBA.Any(CORBA._tc_long, 123546))
subkw3 = CF.DataType('GEOLOCATION_INS::LATITUDE',
                     CORBA.Any(CORBA._tc_double, 10.0))
subkw4 = CF.DataType('GEOLOCATION_INS::LONGITUDE',
                     CORBA.Any(CORBA._tc_double, 25.0))
subkw5 = CF.DataType('GEOLOCATION_INS::ALTITUDE',
                     CORBA.Any(CORBA._tc_double, 32.0))
subkw6 = CF.DataType('GEOLOCATION_INS::GROUND_SPEED',
Exemplo n.º 14
0
    def getPropertySet(self, kinds=("configure","property",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True,
                             commandline=False):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        if self.prf != None:
          for prop in self.prf.get_simple():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_value() is not None:    
                    if prop.complex.lower() == "true":
                        type = mapComplexType(prop.get_type())
                        value = stringToComplex(prop.get_value(), type)
                    else:
                        type = prop.get_type()
                        value = prop.get_value()
                    dt = properties.to_tc_value(value, type)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

          # Simple Sequences
          for prop in self.prf.get_simplesequence():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if prop.get_values() is not None:
                    seq = []
                    if prop.complex.lower() == "true":
                        type = mapComplexType(prop.get_type())
                        for v in prop.get_values().get_value():
                            seq.append(stringToComplex(v, type))
                        expectedType = properties.getTypeCode(type)
                        expectedTypeCode = tcInternal.createTypeCode(
                            (tcInternal.tv_sequence, expectedType._d, 0))
                        dt = CORBA.Any(expectedTypeCode, 
                                       [properties._convertComplexToCFComplex(item, type) 
                                            for item in seq])
                    else:
                        type = prop.get_type()
                        for v in prop.get_values().get_value():
                            value = v
                            seq.append(properties.to_pyvalue(value, type))
                        dt = any.to_any(seq)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

          # Structures
          for prop in self.prf.get_struct():
            if self.isMatch(prop, modes, kinds, (action,)): 
                if (prop.get_simple() is not None) or (prop.get_simplesequence() is not None):
                    fields = []
                    hasValue = False
                    if prop.get_simple() is not None:
                        for p in prop.get_simple():
                            if p.get_value() is not None:
                                hasValue = True
                            dt = properties.to_tc_value(p.get_value(), p.get_type())
                            fields.append(CF.DataType(id=str(p.get_id()), value=dt))
                    if prop.get_simplesequence() is not None:
                        for p in prop.get_simplesequence():
                            if p.get_values() is not None:
                                hasValue = True
                            dt = properties.to_tc_value(p.get_values(), p.get_type())
                            fields.append(CF.DataType(id=str(p.get_id()), value=dt))
                    if not hasValue and not includeNil:
                        continue
                    dt = any.to_any(fields)
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)
                
          # Struct Sequence
          for prop in self.prf.get_structsequence():
            if self.isMatch(prop, modes, kinds, (action,)):
              baseProp = []
              if prop.get_struct() != None:
                fields = []
                for internal_prop in prop.get_struct().get_simple():
                    fields.append(CF.DataType(id=str(internal_prop.get_id()), value=any.to_any(None)))
                for internal_prop in prop.get_struct().get_simplesequence():
                    fields.append(CF.DataType(id=str(internal_prop.get_id()), value=any.to_any(None)))
              for val in prop.get_structvalue():
                baseProp.append(copy.deepcopy(fields))
                for entry in val.get_simpleref():
                  val_type = None
                  for internal_prop in prop.get_struct().get_simple():
                      if str(internal_prop.get_id()) == entry.refid:
                          val_type = internal_prop.get_type()
                  for subfield in baseProp[-1]:
                      if subfield.id == entry.refid:
                          subfield.value = properties.to_tc_value(entry.get_value(), val_type)
                for entry in val.get_simplesequenceref():
                  val_type = None
                  for internal_prop in prop.get_struct().get_simplesequence():
                      if str(internal_prop.get_id()) == entry.refid:
                          val_type = internal_prop.get_type()
                  for subfield in baseProp[-1]:
                      if subfield.id == entry.refid:
                          subfield.value = properties.to_tc_value(entry.get_values(), val_type)
              anybp = []
              for bp in baseProp:
                  anybp.append(properties.props_to_any(bp))
              p = CF.DataType(id=str(prop.get_id()), value=any.to_any(anybp))
              propertySet.append(p)

        return propertySet
Exemplo n.º 15
0
kw12 = sb.SRIKeyword("TEMPERATURE",100,'float')
kw13 = sb.SRIKeyword("DEVICE_IDENTIFIER",1111,'long')

subkw  = CF.DataType('GEOLOCATION_GPS::TIME_SECONDS', CORBA.Any(CORBA._tc_double, 1111))
subkw1 = CF.DataType('GEOLOCATION_GPS::TIME_FRACTIONAL',CORBA.Any(CORBA._tc_double, .00002))
subkw2 = CF.DataType('GEOLOCATION_GPS::MANUFACTURER_ID',CORBA.Any(CORBA._tc_long, 123546))
subkw3 = CF.DataType('GEOLOCATION_GPS::LATITUDE',CORBA.Any(CORBA._tc_double, 10.0))
subkw4 = CF.DataType('GEOLOCATION_GPS::LONGITUDE',CORBA.Any(CORBA._tc_double, 25.0))
subkw5 = CF.DataType('GEOLOCATION_GPS::ALTITUDE',CORBA.Any(CORBA._tc_double, 32.0))
subkw6 = CF.DataType('GEOLOCATION_GPS::GROUND_SPEED',CORBA.Any(CORBA._tc_double, 26.0))
subkw7 = CF.DataType('GEOLOCATION_GPS::HEADING_ANGLE',CORBA.Any(CORBA._tc_double, 36.0))
subkw8 = CF.DataType('GEOLOCATION_GPS::TRACK_ANGLE',CORBA.Any(CORBA._tc_double, 15.0))
subkw9 = CF.DataType('GEOLOCATION_GPS::MAGNETIC_VARIATION',CORBA.Any(CORBA._tc_double, 16.0))

list = [subkw, subkw1, subkw2, subkw3, subkw4, subkw5, subkw6, subkw7, subkw8, subkw9]
value = sb.SRIKeyword('GEOLOCATION_GPS',properties.props_to_any(list), 'IDL:CF/Properties:1.0')

subkw  = CF.DataType('GEOLOCATION_INS::TIME_SECONDS', CORBA.Any(CORBA._tc_double, 1111))
subkw1 = CF.DataType('GEOLOCATION_INS::TIME_FRACTIONAL',CORBA.Any(CORBA._tc_double, .00002))
subkw2 = CF.DataType('GEOLOCATION_INS::MANUFACTURER_ID',CORBA.Any(CORBA._tc_long, 123546))
subkw3 = CF.DataType('GEOLOCATION_INS::LATITUDE',CORBA.Any(CORBA._tc_double, 10.0))
subkw4 = CF.DataType('GEOLOCATION_INS::LONGITUDE',CORBA.Any(CORBA._tc_double, 25.0))
subkw5 = CF.DataType('GEOLOCATION_INS::ALTITUDE',CORBA.Any(CORBA._tc_double, 32.0))
subkw6 = CF.DataType('GEOLOCATION_INS::GROUND_SPEED',CORBA.Any(CORBA._tc_double, 26.0))
subkw7 = CF.DataType('GEOLOCATION_INS::HEADING_ANGLE',CORBA.Any(CORBA._tc_double, 36.0))
subkw8 = CF.DataType('GEOLOCATION_INS::TRACK_ANGLE',CORBA.Any(CORBA._tc_double, 15.0))
subkw9 = CF.DataType('GEOLOCATION_INS::MAGNETIC_VARIATION',CORBA.Any(CORBA._tc_double, 16.0))

list = [subkw, subkw1, subkw2, subkw3, subkw4, subkw5, subkw6, subkw7, subkw8, subkw9]
value1 = sb.SRIKeyword('GEOLOCATION_INS',properties.props_to_any(list), 'IDL:CF/Properties:1.0')
Exemplo n.º 16
0
    def getPropertySet(self, kinds=("configure",), \
                             modes=("readwrite", "writeonly", "readonly"), \
                             action="external", \
                             includeNil=True):
        """
        A useful utility function that extracts specified property types from
        the PRF file and turns them into a CF.PropertySet
        """
        propertySet = []

        # Simples
        for prop in self.prf.get_simple():
            if self.isMatch(prop, modes, kinds, (action, )):
                if prop.get_value() is not None:
                    dt = properties.to_tc_value(prop.get_value(),
                                                prop.get_type())
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Simple Sequences
        for prop in self.prf.get_simplesequence():
            if self.isMatch(prop, modes, kinds, (action, )):
                if prop.get_values() is not None:
                    seq = []
                    for v in prop.get_values().get_value():
                        seq.append(properties.to_pyvalue(v, prop.get_type()))
                    dt = any.to_any(seq)
                elif not includeNil:
                    continue
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)

        # Structures
        for prop in self.prf.get_struct():
            if self.isMatch(prop, modes, kinds, (action, )):
                if prop.get_simple() is not None:
                    fields = []
                    hasValue = False
                    for s in prop.get_simple():
                        if s.get_value() is not None:
                            hasValue = True
                        dt = properties.to_tc_value(s.get_value(),
                                                    s.get_type())
                        fields.append(CF.DataType(id=str(s.get_id()),
                                                  value=dt))
                    if not hasValue and not includeNil:
                        continue
                    dt = any.to_any(fields)
                else:
                    dt = any.to_any(None)
                p = CF.DataType(id=str(prop.get_id()), value=dt)
                propertySet.append(p)
        # Structures

        for prop in self.prf.get_structsequence():
            if self.isMatch(prop, modes, kinds, (action, )):
                baseProp = []
                if prop.get_struct() != None:
                    fields = []
                    for internal_prop in prop.get_struct().get_simple():
                        fields.append(
                            CF.DataType(id=str(internal_prop.get_id()),
                                        value=any.to_any(None)))
                for val in prop.get_structvalue():
                    baseProp.append(copy.deepcopy(fields))
                    for entry in val.get_simpleref():
                        val_type = None
                        for internal_prop in prop.get_struct().get_simple():
                            if str(internal_prop.get_id()) == entry.refid:
                                val_type = internal_prop.get_type()
                        for subfield in baseProp[-1]:
                            if subfield.id == entry.refid:
                                subfield.value = properties.to_tc_value(
                                    entry.get_value(), val_type)
                anybp = []
                for bp in baseProp:
                    anybp.append(properties.props_to_any(bp))
                p = CF.DataType(id=str(prop.get_id()), value=any.to_any(anybp))
                propertySet.append(p)
        # Struct Sequence

        return propertySet