Link Search Menu Expand Document

Transform Manager

Jan 1 2022 at 12:00 AM

  1. Set up
  2. Configuration

Transform Manager is used to change the value of a device property from the raw value produced by the physical device to a standardised value for upload to the Commanderâ„¢ Portal.

Transform manager maintains a list of Transform sets, where each set can contain one or more functions to execute.

When configuring a property for a device, if supported, a Transform Set ID can be specified.

When the device reads that property, it will pass it to Transform Manager. Transform manager will pass the property to each function in the specified set sequentially and the function will change the property value in a defined way.

Before executing the transform set, Transform manager will set the Current Raw Value of the property to the Current Value. This is the original value as read from the physical device.

Set up

Add the following NuGet packages:

  • IoTnxt.Raptor.TransformManager
  • IoTnxt.Raptor.Common.Async

In the Program.cs file of the AspNetCore service, add the following lines in the CreateHostBuilder method:

    .AddRaptorDevice()
    .AddObjectCache<ITransformState>()
    .AddRaptorTransformManager("TransformSets", (services, configuration, builder) =>
    {
        builder.AddDefaultTransformationFunctions(services);
    }

Configuration

Configuration of the various transformations is done via a configuration file in the /config folder. An example configuration file is shown below:

{
  "TransformSets": {
    "Set1": {
      "X100":  {
        "FunctionType": "MultiplyScaling",
        "ScalingFactor":  100 
      }
    }
  } 
}

In the configuration file, TransformSets can have one or more sets defined where, in this example, Set1 is the unique identifier (key) of the set. Each transform set can have one or more functions defined where, in this example, X100 is the unique name (unique within the set) of the function that will multiply the value by 100.

Additional transform functions can be added by developers simply by registering them through Dependency Injection.