I'm a newcomer to Cumulocity, currently evaluating both Java and C++ agents. In Java MeasurementValue class has a method setType(ValueType), which can have ValueType.STRING as argument but container for measurement value is BigDecimal. In general, is it possible to have non numeric measurements ?
1 Answers
The value property needs to be numeric, since Cumulocity aggregates it, renders it on axes of graphs and the like. However, you can store any kind of additional properties along with measurement, events, managed objects, ... and these can also be non-numeric (e.g., is the value valid). To visualize such additional properties, you may need an own widget.
To add other data structures and types, you can use the same mechanism as described on http://cumulocity.com/guides/java/developing/ in the "Tariff" example. E.g. create a Java bean with your string property and add that using
measurement.set(instanceOfMyClass);
Or use a HashMap, add your additional properties to it and use
measurement.set(myHashMap, "myExtendedProperties");
Note: There are two classes with the name ValueType. The one that belongs to MeasurementValue does not have ValueType.STRING.

- 668
- 6
- 11
-
Can you provide an example or link to one how to add, for example a string in as measurement property. – Hannu_H Jan 18 '17 at 09:34
-
Maybe that helps. – André Jan 18 '17 at 17:14
-
Actually managed to do this, quite straight forward once you know how – Hannu_H Jan 19 '17 at 07:14
-
Great! Good luck. – André Jan 19 '17 at 10:19