fledge-iot / fledge

An open source platform for the Industrial Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems.

Home Page:https://www.lfedge.org/projects/fledge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Control pipelines: missing conversion from asset_code to operation name

FlorentP42 opened this issue · comments

Describe the bug
As explained in the documentation:

Mapping Rules

For a set point write the name of the asset will always be set to reading, the asset that is created will have a set of datapoints, one per each setpoint write operation that is to be executed. The name of the datapoint is the name of the set point to be written and the value of the datapoint is the value to to set.

For example, if a set point write wishes to set the Pump Speed set point to 80 and the Pump Running set point to True then the reading that would be created and passed to the filter would have the asset_code of reading and two data points, one called Pump Speed with a value of 80 and another called Pump Running with a value of True.

This reading can then be manipulated by a filter in the same way as in any other pipeline. For example the expression filter filter could be used to scale the pump speed. If the required was to multiply the pump speed by 10, then the expression defined would be Pump Speed * 10 .

In the case of an operation the mapping is very similar, except that the asset_code in the reading becomes the operation name and the data points are the parameters of the operation.

For example, if an operation Start Fan required a parameter of Fan Speed then a reading with an asset_code of Start Fan with a single datapoint called Fan Speed would be created and passed through the filter pipeline.

This works as intended when entering a control pipeline: operation name is converted into asset_code of the reading to process.
But this is not respected when exiting the pipeline: here for consistency we expect the asset_code to be converted back into operation name as it may have changed during filtering, and this is not happening.

To Reproduce
Steps to reproduce the behavior:

  1. Create a north service that can call an operation named "NorthOP".
  2. Create a south service that can receive an operation named "SouthOP".
  3. Create a control pipeline between those services.
  4. Add a filter to this pipeline that will change the asset_code of the readings being filtered from "NorthOP" to "SouthOP".
  5. Restart Fledge so that the pipeline becomes active.
  6. Call the operation "NorthOP" from the north plugin.
  7. Notice that the operation received in the south plugin is still called "NorthOP" when it should be "SouthOP".

Expected behavior
Operation name is properly updated with the value from asset_code when exiting a control pipeline.

Additional context
N/A