Page tree
Skip to end of metadata
Go to start of metadata

In this example I will show how to connect data from a DDS (Data distribution service for Real-Time Systems). Be aware, that this is very alpha (wink)

First of all you have to install the DDS Feature:

 

After that, you can download the MD PnP Software from here:

http://sourceforge.net/projects/mdpnp/

https://github.com/mdpnp/mdpnp

Start the application

 

Choose Domain Id 0 (or remeber the choosen value) and run "Start ICE_Supervisor".

You can now "Create an ICE Device Adapter"

 

And choose e.g. Simulated Pulse Oximeter. Call "Start Simlulated Pulse Oximeter" and call "Start PO_Simulator".

Now you will get to the main screen:

When you double click on Puls Ox (Simulated) you will see:

Now back to Odysseus:

Create a new Project and add the following script:

#PARSER PQL
#RUNQUERY
sampleArray := DDSSOURCE({
                    source = 'SampleArray',
                    qosfile='${WORKSPACEPROJECT}/ice_library.xml',
                    idlfile='${WORKSPACEPROJECT}/ice.idl',
                    topic='SampleArray',
                    topictype='ice::SampleArray',
                    qoslibrary='ice_library',
                    qosprofile='waveform_data',
                    domain=0                                                                                                                 
                  }                                                                                        
                )

There are two important files:

USER_QOS_PROFILES.xml 
ice.idl

They contain information necessary for DDS. You can download the files from the following locations:

https://github.com/mdpnp/mdpnp/blob/master/data-types/x73-idl/src/main/idl/ice/ice.idl

https://github.com/mdpnp/mdpnp/blob/master/data-types/x73-idl-rti-dds/USER_QOS_PROFILES.xml

Copy them to the workspace.

If you changed the domain, please update domain value in the options above.

Now run the query, and show as table. You should see something like:

As you can see, the values attribute contains a list, and the time attributes a tuple.

Storing to a relational database

If you want to store this data in a database this is not possible directly. You have to "flatten" the data. This can be done as follows:

mappedValues = MAP({
                    expressions = [
                     'unique_device_identifier',                                                        
                     ['elementAt(time,0)','seconds'],
                     ['elementAt(time,1)','nanoseconds'],                                  
                     'values'                                  
                    ]                  
                  },
                  sampleArray
                )
table1 = UNNEST({
              attribute = 'values'            
            },
            mappedValues
          )            
          
table1_WithNumbers = MAP({
                          expressions = [
                              'unique_device_identifier',
                              'seconds',
                              'nanoseconds',
                              ['counter()','pos'],
                              ['values','value']
                               ]
                        },
                        table1
                      )
table2 = MAP({
              expressions = [
                'unique_device_identifier',
                ['elementAt(time,0)','seconds'],
                ['elementAt(time,1)','nanoseconds'],
                'metric_id',
                'instance_id',
                'unit_id',
                'frequency'                            
              ]            
            },
            sampleArray
          )

table1_WithNumbers is only necessary if you want to keep the order of the measurements.

The output will be as:

and

 

Storing to a document store

You can store complex objects to a document store like MongoDB. For this, you have to convert the tuple to a KeyValueObject. This can be done with the TupleToKeyValueOperator.

See MongoDB Feature for more information on the Mongo DB feature.

#RUNQUERY
kv = TUPLETOKEYVALUE(sampleArray)
mongo = MONGODBSINK({PORT = port, HOST = 'host', COLLECTIONNAME = 'collectionname', DATABASE = 'database'}, kv)

 

 

  • No labels