Get measurement value

How to get measurement value from the Find Measurement Query

Hi,

I hope you are using the “Query for measurements” as a starting point to get the pattern to react the results properly.

As you can see there you receive a
https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/FindMeasurementResponse.html

which contains a Measurement
https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/Measurement.html

now a measurement has a “measurements” dictionary, which contains as values additional dictionaries of which the values are MeasurementValue:
https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/MeasurementValue.html

which in turn contain the actual “value” field. This mirrors the fragment and series structures of measurements. If you are a 100% what kind of values the measurements have you are receiving you can use operator to extract them:

float value := resp.measurement.measurements["<<fragment>>"]["<<series>>"].value;

Note that if the fragment or series are not present, this will crash your EPL App. Better would be to include proper tests:

if (resp.measurement.measurements.hasKey("<<fragment>>") {
  dictionary<string, MeasurementValue> f := resp.measurement.measurements["<<fragment>>"];
  if(f.hasKey("<<series>>") {
    float value := f["<<series>>"].value;
  }
}

Same code snippet works to get time of that measurement?

Time is easier as it is a top-level field:

float ts := resp.measurement.time;

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.