Closed Llorx closed 1 year ago
So for template definitions there is no reason/point in including an alias. Conceptually, the aliases are used in place of the metric name in DATA messages. Since template definitions only exist in NBIRTH messages, an alias has no significance or use in a template definition. So, you should use aliases in the template instances only. Then you only need to include the aliases for those given template metric members that change in subsequent DATA messages.
Ok, perfect. And metrics of two different instances of the same template should have different alias IDs I guess, right? For example, having the metric test1 inside a Template named INV, if I instance this Template as INV01 and INV02, I guess that the metric test1 inside INV01 should have a different alias than the metric test1 inside INV02.
Thank you @wes-johnson for the clarification.
Hi,
I can't find info about this in the Sparkplug specification.
Having alises enabled, it says that for each metric you should send an alias and that not two metrics should have the same alias. It also says that you have to send the alias and name on each NBIRTH and DBIRTH message.
Now the problem arises when I'm sending Templates and instances of those templates.
It says that I have to send all the metric info in my NBIRTH and DBIRTH messages, so here is the situation:
With this premise I send these messages:
As you can see, there's a metric named
INV
, which is a Template definition, that includes a metric namedtest
with an alias id1
. Everything fine up here.And here is the problem. The specification says that I have to send the name along with the alias for each metric when sending a NBIRTH or DBIRTH command, so although I've already sent an alias for the metric
test
inside theINV
template in the NBIRTH command, I'm also sending an alias along the nametest
in the DBIRTH command, but being an instance of the INV template I'm unsure if I have to define a new alias id (in this case I'm sending a 1 in the definition and a 4 in the instance), because is a new device so inside this device this metric is considered a different one, or I should send the same alias id as the NBIRTH command (sending 1 for both the template and the instance), because in the end is the same alias.And another problem is if I should even send the metric name, as it has already been sent by the NBIRTH command so I should only send the updated data, for example, not sending the name and not sending the "not_updated_prop" property as the value has not changed, like it is just a DDATA inside the template instance, because this metric definition has already been sent with the NBIRTH command, so is duplicated data.