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

To access object via the google protobuf format, some preparations need to be done.

The generic bundle ...wrapper.protobuf contains the common elements to receive and decode object sends via the protobuf protocol

Addtionally, a bundle must be provided that contains information about the object type, that is send.

In the following, we will give an example of the usage. We show how to integrate data from the Debs Grand Challenge 2012 (http://www.csw.inf.fu-berlin.de/debs2012/grandchallenge.html)

The following code block, shows how to integrate a protobuf source. Here a tcp server is opened on port 9999 that can handle objects of the type debs.challenge.msg.CDataPoint.

gchSource := 
	RECEIVE({SOURCE = 'GrandChallengeDataPoint',
	 	TRANSPORT='ProtobufServer', 
	 	DataHandler = 'Tuple',
		OPTIONS=[
			['type','debs.challenge.msg.CDataPoint'],
			['port','9999']
		],
		SCHEMA=[['ts','StartTimeStamp'],
		    ['index','long'],
 		    ['mf01','integer'],
		    ['mf02','integer'],
		    ['mf03','integer'],
		    ['pc13','integer'],
		    ['pc14','integer'],
		    ['pc15','integer'],
		    ['pc25','long'],
		    ['pc26','long'],
		    ['pc27','long'],
		    ['res','long'],
		    ['bm05','Boolean'],
		    ['bm06','Boolean'],
		    ['bm07','Boolean'],
		    ['bm08','Boolean'],
		    ['bm09','Boolean'],
		    ['bm10','Boolean'],
		    ['pp01','Boolean'],
		    ['pp02','Boolean'],
		    ['pp03','Boolean'],
		    ['pp04','Boolean'],
		    ['pp05','Boolean'],
		    ['pp06','Boolean'],
		    ['pp07','Boolean'],
		    ['pp08','Boolean'],
		    ['pp09','Boolean'],
		    ['pp10','Boolean'],
		    ['pp11','Boolean'],
		    ['pp12','Boolean'],
		    ['pp13','Boolean'],
		    ['pp14','Boolean'],
		    ['pp15','Boolean'],
		    ['pp16','Boolean'],
		    ['pp17','Boolean'],
		    ['pp18','Boolean'],
		    ['pp19','Boolean'],
		    ['pp20','Boolean'],
		    ['pp21','Boolean'],
		    ['pp22','Boolean'],
		    ['pp23','Boolean'],
		    ['pp24','Boolean'],
		    ['pp25','Boolean'],
		    ['pp26','Boolean'],
		    ['pp27','Boolean'],
		    ['pp28','Boolean'],
		    ['pp29','Boolean'],
		    ['pp30','Boolean'],
		    ['pp31','Boolean'],
		    ['pp32','Boolean'],
		    ['pp33','Boolean'],
		    ['pp34','Boolean'],
		    ['pp35','Boolean'],
		    ['pp36','Boolean'],
		    ['pc01','Boolean'],
		    ['pc02','Boolean'],
		    ['pc03','Boolean'],
		    ['pc04','Boolean'],
		    ['pc05','Boolean'],
		    ['pc06','Boolean'],
		    ['pc19','Boolean'],
		    ['pc20','Boolean'],
		    ['pc21','Boolean'],
		    ['pc22','Boolean'],
		    ['pc23','Boolean'],
		    ['pc24','Boolean']]})

The schema corresponds to the definition of this point with the google protobuf description, which can be found in the following:

package debs.challenge.msg;
option optimize_for = SPEED;
option java_outer_classname = "CManufacturingMessages";
message CDataPoint {
    required fixed64    ts        = 1; //time stamp: nanoseconds since 1st Jan 1970
    required fixed64    index     = 2; //message index
    required fixed32    mf01    = 3; //Electrical Power Main Phase 1
    required fixed32    mf02    = 4; //Electrical Power Main Phase 2
    required fixed32     mf03    = 5; //Electrical Power Main Phase 3
    required fixed32    pc13    = 6; //Anode Current Drop Detection Cell 1
    required fixed32    pc14    = 7; //Anode Current Drop Detection Cell 2
    required fixed32    pc15    = 8; //Anode Current Drop Detection Cell 3
    required uint32    pc25    = 9;    //Anode Voltage Drop Detection Cell 1
    required uint32    pc26    = 10;    //Anode Voltage Drop Detection Cell 2
    required uint32    pc27    = 11;    //Anode Voltage Drop Detection Cell 3
    required uint32 res        = 12;
    optional bool bm05        = 13; //Chem A Additive Sense
    optional bool bm06        = 14; //Chem B Additive Sense
    optional bool bm07        = 15; //Chem C Additive Sense
    optional bool bm08        = 16; //Chem A Additive Release Valve VL26
    optional bool bm09        = 17; //Chem B Additive Release Valve VL27
    optional bool bm10        = 18; //Chem C Additive Release Valve VL28
    optional bool pp01        = 19;
    optional bool pp02        = 20;
    optional bool pp03        = 21;
    optional bool pp04        = 22;
    optional bool pp05        = 23;
    optional bool pp06        = 24;
    optional bool pp07        = 25;
    optional bool pp08        = 26;
    optional bool pp09        = 27;
    optional bool pp10        = 28;
    optional bool pp11        = 29;
    optional bool pp12        = 30;
    optional bool pp13        = 31;
    optional bool pp14        = 32;
    optional bool pp15        = 33;
    optional bool pp16        = 34;
    optional bool pp17        = 35;
    optional bool pp18        = 36;
    optional bool pp19        = 37;
    optional bool pp20        = 38;
    optional bool pp21        = 39;
    optional bool pp22        = 40;
    optional bool pp23        = 41;
    optional bool pp24        = 42;
    optional bool pp25        = 43;
    optional bool pp26        = 44;
    optional bool pp27        = 45;
    optional bool pp28        = 46;
    optional bool pp29        = 47;
    optional bool pp30        = 48;
    optional bool pp31        = 49;
    optional bool pp32        = 50;
    optional bool pp33        = 51;
    optional bool pp34        = 52;
    optional bool pp35        = 53;
    optional bool pp36        = 54;
    optional bool pc01        = 55;
    optional bool pc02        = 56;
    optional bool pc03        = 57;
    optional bool pc04        = 58;
    optional bool pc05        = 59;
    optional bool pc06        = 60;
    optional bool pc19        = 61;
    optional bool pc20        = 62;
    optional bool pc21        = 63;
    optional bool pc22        = 64;
    optional bool pc23        = 65;
    optional bool pc24        = 66;
}

This format needs to be transformed into a java class with the google protobuf tools (see https://code.google.com/p/protobuf/)

The resulting class is CManufacturingMessages.

This generated class must be placed in new osgi bundle (or must be accessable somehow).

To register this type a declarative service of the type IProtobufDatatypeProvider must be defined.

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="de.uniol.inf.is.odysseus.wrapper.protobuf.gc2012.cdatatypeprovider">
   <implementation class="de.uniol.inf.is.odysseus.wrapper.protobuf.gc2012.CManufacturingMessageProvider"/>
   <service>
      <provide interface="de.uniol.inf.is.odysseus.wrapper.protobuf.IProtobufDatatypeProvider"/>
   </service>
</scr:component>

With the implementing class, that wrappes the generated file.

package de.uniol.inf.is.odysseus.wrapper.protobuf.gc2012;

import com.google.protobuf.GeneratedMessage;

import de.uniol.inf.is.odysseus.wrapper.protobuf.IProtobufDatatypeProvider;
import debs.challenge.msg.CManufacturingMessages.CDataPoint;

public class CManufacturingMessageProvider implements IProtobufDatatypeProvider {

    @Override
    public String getName() {
        return CDataPoint.getDescriptor().getFullName();
    }

    @Override
    public GeneratedMessage getMessageType() {
        return CDataPoint.getDefaultInstance();
    }

}

 

 

 

  • No labels