#104 EoN, Device, Host, Payload: Optionally and by default, send metrics using Aliases

closed
2022-04-01
2020-12-18
i-campbell
No

It is more data- and processing- efficient to use aliases for metrics than to use the full metric name.
A setting should be available to enable aliases.
1. send xBIRTH will send both the name and alias.
2. send xDATA will send only the alias.
3. receive xCMD should match first on Alias, but if no Alias is in the metric then it should match on Name.

  • Edge and Device Alias xBIRTH and XDATA mechanism are implemented.
  • Edge and Device decode xCMD alias implemented,
  • CODESYS Host decodes aliases in xBIRTH and xDATA
  • CODESYS Host sends alias xCMD

Release note:
For an Edge, the input to the function UseAliases controls whether aliases are generated and used for each metric in the edge and its child devices.
For a Host, the use of aliases is entirely up to the Edge and its Devices - if the edge births with aliases, FB_Host will send NCMDs with aliases. Similarly if a device is birthed with aliases, FB_Host will send DCMDs with aliases.

Related

Tickets: #145
Tickets: #146

Discussion

  • i-campbell

    i-campbell - 2021-07-25

    From the spec. Only metrics have aliases, i.e. Properties do not have aliases.
    "alias
    ◦ This is an unsigned 64-bit integer representing an optional alias for a Sparkplug B payload.
    If supplied in an NBIRTH or DBIRTH it MUST be a unique number across this Edge
    Node’s entire set of metrics. In other words, no two metrics for the same Edge Node can
    have the same alias. Upon being defined in the NBIRTH or DBIRTH, subsequent messages
    can supply only the alias instead of the metric friendly name to reduce overall message size."

     
  • i-campbell

    i-campbell - 2021-10-28

    So it seems Edge1/Device1 Metrics must have different aliases to Edge1/Device2 Metrics, as well as Edge1 Metrics. So FB_Edge will have to provide a "getNewAlias()", which will return an ever increasing ULINT.

    during DBIRTH and NBIRTH, if a metric does not already have an alias, it must request one from itfEdge.getNewAlias() or THIS^.getNewAlias().

    an input to the FB_Edge, VAR_INPUT UseAliasing : BOOL := TRUE; will determine whether to calculate and use aliasing.

     

    Last edit: hermsen 2021-10-30
    • hermsen

      hermsen - 2021-10-28
      // regard following as pseudo code
      
      // declaration of interface property usesAliases
      getter ONLY, returns input value of useAliasing.
      
      // Declaration of interface method
      Method getNewAlias : ULINT;
      
      // Body method implementation
      getNewAlias := _Alias;
      _Alias := _Alias +1; // 0 is reserved to flag no alias is given, never reset it
      
      // FB_Edge
      VAR_INPUT 
          UseAliasing : BOOL := TRUE; // enables usage of aliases during communication, default enabled as it will optimize bandwidth usage
      END_VAR
      VAR
         _Alias : ULINT := 1; // 0 means no alias is given
      END_VAR
      
      // NBIRTH & DBIRTH methods will test if the input is enabled and force the metric to obtain an alias.
      Alias is a property of Metric but can also be implemented as a method
      
      IF UseAliases THEN
         FOR i := 1 TO AllmetricsList.Count DO
             IF Metric.Alias = 0 THEN // get set property on metric
                Metric.Alias := This.GetNewAlias();
             END_IF;
         END_FOR;a
      END_IF;
      
       

      Last edit: hermsen 2021-10-30
  • hermsen

    hermsen - 2021-11-04

    Definition;
    If use aliases = False then all aliases are 0 and thus not used.
    If Use aliases = True then all aliases are unique and start counting with 1,2 etc.

    All NCMD's are also sent during xBIRTH with an alias number if the alias mechanism is enabled (TRUE by default).

    • Edge and Device Alias xBIRTH and XDATA mechanism are implemented.
    • Edge and Device decode xCMD alias implemented,
    • CODESYS Host decode aliases in xBIRTH and xDATA
    • CODESYS Host sends alias xCMD
     

    Last edit: i-campbell 2021-11-11
  • i-campbell

    i-campbell - 2021-11-11
    • summary: EoN, Device, Paylaod: Optionally and by default, send metrics using Aliases --> EoN, Device, Host, Payload: Optionally and by default, send metrics using Aliases
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,10 @@
    -It is more data and processing efficient to use Aliases for metrics than to use the full metric name.
    +It is more data- and processing- efficient to use aliases for metrics than to use the full metric name.
     A setting should be available to enable aliases.
     1. send xBIRTH will send both the name and alias.
     2. send xDATA will send only the alias.
     3. receive xCMD should match first on Alias, but if no Alias is in the metric then it should match on Name.
    +
    +* [x] Edge and Device Alias xBIRTH and XDATA mechanism are implemented. 
    +* [x] Edge and Device decode xCMD alias implemented,
    +* [ ] CODESYS Host decodes aliases in xBIRTH and xDATA
    +* [ ] CODESYS Host sends alias xCMD
    
     
  • i-campbell

    i-campbell - 2022-04-01
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -6,5 +6,9 @@
    
     * [x] Edge and Device Alias xBIRTH and XDATA mechanism are implemented. 
     * [x] Edge and Device decode xCMD alias implemented,
    -* [ ] CODESYS Host decodes aliases in xBIRTH and xDATA
    -* [ ] CODESYS Host sends alias xCMD
    +* [x] CODESYS Host decodes aliases in xBIRTH and xDATA
    +* [x] CODESYS Host sends alias xCMD
    +
    +Release note:
    +For an Edge, the input to the function UseAliases controls whether aliases are generated and used for each metric in the edge and its child devices.
    +For a Host, the use of aliases is entirely up to the Edge and its Devices - if the edge births with aliases, FB_Host will send NCMDs with aliases.  Similarly if a device is birthed with aliases, FB_Host will send DCMDs with aliases.
    
    • status: open --> closed
     
  • i-campbell

    i-campbell - 2022-04-01

    completed in host v1.3.0.6 and stack v1.4.3.2

     

Log in to post a comment.