Remark: Currently (2016/06/01) not working.

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 = RECEIVE({
                  source = 'SampleArray',
                  transport = 'dds',
                  datahandler = 'tuple',
                  options=[
                    ['qosFile','${WORKSPACEPROJECT}/USER_QOS_PROFILES.xml'],
                    ['idlFile','${WORKSPACEPROJECT}/ice.idl'],
                    ['topic','SampleArray'],
                    ['topicType','SampleArray'],
                    ['qosLibrary','ice_library'],
                    ['qosProfile','waveform_data'],
                    ['domain','0']
                  ],
                  schema = [
                    ['unique_device_identifier', 'String'],
                    ['metric_id', 'String'],
                    ['instance_id','Long'],
                    ['unit_id','String'],
                    ['frequency','long'],
                    ['values','List<Double>'],
                    ['time','Tuple<Long,Long>']
                  ]                                                        
                }                                              
              )

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:

http://sourceforge.net/p/mdpnp/code/ci/master/tree/data-types/x73-idl/src/main/idl/ice/ice.idl
https://github.com/mdpnp/hello-openice/blob/master/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 attribute 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.

#