/* */ [Goal of the feature] */ To handle use cases where the Data Source value has a different unit than the one we want to use in, we ensure an appropriate unit conversion. With units feature you can set your signal unit and the agent will handle the conversion for you. This feature is supported by the IntervalMonitor.

Usage

To set the signal unit you can call the method setSignalUnit with the signal unit as a string. When updateValue is called the value will be automatically converted to the target unit. For example if your Data Source is a speed in km/h you can pass the unit as in the following code snippet :

IntervalMonitor sampleInstance(monitorUuid, serverIp, serverPort);
sampleInstance.setSignalUnit("km/h");    // Provide the unit of input data
sampleInstance.awaitReady();
while (true)
{
  double speed = (std::rand() % 150000) / 1000.0;
  HEEX_LOG(info) << "Speed is " << speed << " " << sampleInstance.getSignalUnit() << std::endl;
  sampleInstance.updateValue(speed);
  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

If the unit in setSignalUnit is not compatible with the target unit, the following error message will be generated by the monitor : Cannot convert [signal unit] to [target unit] as they are not compatible and the updateValue() won’t notify the Kernel. You can also get the unit with the method getSignalUnit which returns the unit.

About the library