1

I am trying to access keywords in the SRI using python. There are no examples or documentation for doing this in python.

I want to grab the SRI, check for a keyword, and if present, copy the corresponding value.

I think the SRI will copy over as a tuple, but there are probably CF transformations and I cant find any examples.

How would I do this?

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
testfire
  • 13
  • 4

2 Answers2

0

As you may have seen, you can receive the SRI object in python in the same way as the HardLimit python implementation shown here.

data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataFloat_in.getPacket()

Once you have the sri object, the keywords are a list. Let's look at an example in the python sandbox. I'm using REDHAWK 2.0.1 and SigGen 2.0.1 which will output the keywords CHAN_RF and COL_RF if the properties are set.

>>> from ossie.utils import sb
>>> src = sb.launch('rh.SigGen')
>>> src.chan_rf = 1e6
>>> src.col_rf = 1e3
sink = sb.DataSink()
>>> src.connect(sink, usesPortName="dataFloat_out")
>>> sb.start()
>>> sb.stop()
>>> sri = sink.sri()
>>> sri.keywords
[ossie.cf.CF.DataType(id='CHAN_RF', value=CORBA.Any(CORBA.TC_double, 1000000.0)), ossie.cf.CF.DataType(id='COL_RF', value=CORBA.Any(CORBA.TC_double, 1000.0))]
>>> sri.keywords[0].id
'CHAN_RF'
>>> sri.keywords[0].value
CORBA.Any(CORBA.TC_double, 1000000.0)
>>> sri.keywords[0].value.value()
1000000.0
Youssef Bagoulla
  • 1,229
  • 1
  • 7
  • 16
0

The keywords are passed with the SRI as a list of CF DataTypes, which are string/CORBA::Any pairs. In Python, the keywords can be accessed using something like:

from omniORB import any
packet = self.port_myPortName.getPacket() # note that the return value is a little different for REDHAWK versions < 2.0
if packet.dataBuffer is None:
    return NOOP
for keyword in packet.SRI.keywords:
    if "keywordOfInterest" == keyword.id:
        myValue = any.from_any(keyword.value)
DrewC
  • 168
  • 5