aws-samples / shopfloor-connectivity

Shop Floor Connectivity (SFC) is an industrial data ingestion enabler, that can quickly deliver customizable greenfield & brownfield connectivity solutions.
https://aws.amazon.com/blogs/industries/collecting-data-from-industrial-devices-to-aws-services/
MIT No Attribution
30 stars 4 forks source link

[Feature Request] Piggyback Channel Filter #6

Closed qoomon closed 7 months ago

qoomon commented 10 months ago

For my current customer setup I need to read multiple parameters from an S7 PLC in high frequency (10ms)

The parameters change infrequently so i make use of a change filter ({"Type": "Always", "AtLeast": 60_000}). One parameter is system time however this change rapidly by its nature, however I only need this parameter if any other parameter has changed.

Is the any way to achieve this behaviour?

arieleeuw commented 10 months ago

Would it work for you to include timestamps at value level by setting the "TimestampLevel" configuration to "Channel" or "Both"?

qoomon commented 10 months ago

Unfortunately no. System Time was probably a little confusing, it is rather the write time of the sensor measurement. For our use case we need pretty accurate data, because of network delay we can not use the sfc system time.

arieleeuw commented 10 months ago

So basically you need an filter a value, in case the system date-time, if after applying the filters, one or more other values are included in the output set of values.

qoomon commented 10 months ago

Yes, i need a piggyback filter. e.g.

{ 
    "Type": "Piggyback", 
    "Channels": [ "OtherChannelA", "OtherChannelB" ],
}

if "Channels" is not set or empty, it should be send, if any other channel of the corresponding schedule is send.

arieleeuw commented 7 months ago

Implemented in version 1.1.1 by adding Condition filtering.

https://github.com/aws-samples/shopfloor-connectivity/tree/mainline/docs#condition-filters

Add the new Condition filters section at top level of config

  "ConditionFilters":{
      "NotJustTheTimeStamp": {
             "Operator" : "only",
             "Value" : "false"
            }
      }
  }

Add

     "ConditionFilter" : "NotJustTheTimeStamp"

to the timestamp channel for your sources

qoomon commented 7 months ago

Thanks a lot

qoomon commented 7 months ago

What would be the easiest solution for ConditionFilters to send Channel A and B Values only if any other channel has a value? Or would it work if I apply NotJustTheTimeStamp on channel A and B?

arieleeuw commented 7 months ago

The easiest way is to use the "present" operator in a condition filter. The condition filter named "OnlyIfCExists" (use any name you want) will check if channel C has a value in it's source.

  "CondtionFilters" : {
      "OnlyIfCExists" : {
          "Operator" : "present",
           "Value" : "C"
      }
  }

Then apply this filter to channel A and B. A and B are only in the output if C has a value.

 "Channels" : {
  "A": {
          "NodeId": "ns=0;i=2256",
          "ConditionFilter" : "OnlyIfCExists"
      },
 "B": {
          "NodeId": "ns=0;i=2259",
          "ConditionFilter" : "OnlyIfCExists"
      }
  "C": {
          "NodeId": "ns=0;i=2260"
      }
}

If you also have a ChangeFilter or a ValueFilter on a channels, these are applied first on all these channels before the condition filter is applied. So if C has a value, but is filtered out using a Value or a ChangeFilter, the because of the ConditonFilter A and B will filtered out as well.

There is a rich set op operators which let you test if channels are present or absent, or if any, none or all channels in a list of channels are present. It is even possible to combine multiple operators using the or and and operators. See complete list of operators and examples at https://github.com/aws-samples/shopfloor-connectivity/tree/mainline/docs#condition-filters