1

I created a measurements Java class called LoraRfInfo. I add LoraRfInfo as a measurement into Cumulocity as follows:

measurementRep.setSource(mo);
measurementRep.setType("tl_LoraRfInfo");
measurementRep.set(loraRfSignal);
measurementRep.setTime(new Date());
measurements.create(measurementRep);

I would like to visualize the stored LoraRfInfo measurement data in a "data points graph" widget, but can't figure out how to do that. Anyone knows how to visualize custom data points (i.e. non c8y_xxx) in a Cumulocity "data points graph" widget?

2 Answers2

1

It's been a while since the question came up, but this might be useful for anyone who's looking for this.

In Java, you can create your own class if you want to visualize your custom data. The value however always has to be in a

com.cumulocity.model.measurement.MeasurementValue

Therefore, MeasurementValue has to be a property in your custom class.

The display name in Cumulocity will always be packageName_ClassName.

DaGroove
  • 192
  • 1
  • 10
0

To use measurements in widgets, they need to follow the structure described in http://cumulocity.com/guides/reference/measurements/. On REST level, this structure is

{ "tl_LoraRfSignal": {
   "<your measurement>": { "value": ..., "unit": "..." },
   "<your measurement>": { "value": ..., "unit": "..." },
   ...
}

(Assuming that the class behind your variable loraRfSignal is tl.LoraRfSignal.)

On Java level, add properties of type MeasurementValue to locaRfSignal. An example can be found here: https://bitbucket.org/m2m/cumulocity-clients-java/src/53216dc587e24476e0578b788672416e8566f92b/device-capability-model/src/main/java/c8y/SignalStrength.java?at=default&fileviewer=file-view-default.

The "c8y_" in the beginning does not matter. It's merely a naming convention.

André
  • 668
  • 6
  • 11
  • Thanks for your answer and the code example. It works fine and I am able to add custom data points to the "data points graph" widget. – Olaf Peters Mar 23 '16 at 16:26