#3 What is the difference between a Template definition and instance?

open
nobody
None
2020-04-26
2020-04-26
aliazzz
No

Q: What is the difference between a Template definition and instance?

A: There are two parts to a Template
Template Definition
This metric will will contain all the member Metrics with their default values/properties,
as well as any Parameters with their default values. This metric is always only published
in the NBIRTH message

Template Instance
This metric is one or more "instances" of the above definition. It will contain the any
member metrics with values/properties that are overridden/different from the defaults in
the Template Definition. They are published as you would normal tags (BIRTH/DAT/CMD). 
When published in a NDATA/DDATA/NCMD/DCMD message they may only contain a
subset of the member Metrics (if those are the only values that have changed)

Other template fields
        isdefinition
            True for a Template Definition metric, False for a Template Instance Metric
        templateref
            This is used by a Template Instance to specify the "name" of the Template Definition
        ishistorical
            Used to mark a Template Instance (or any Metric) as a historical (rather than a live) 
            value. MQTT Engine may handle historical Metrics differently depending on how it
            is configured (see MQTT Engine documentation)
        istransient
            Not currently used, will be ignored by MQTT Engine, can be omitted or set to false
        version
            Not currently used, will be ignored by MQTT Engine, can be omitted or set to null

This template_samples.txt (see attachment) contains some sample template structures (in JSON) as well as some Java code for creating a Template. These should help show the basic Template structure and contain the important fields of a Template Definition and Instance. However, they are just references expressed in JSON, not actual protobuf representations (which may be a bit more verbose)

1 Attachments

Discussion

  • aliazzz

    aliazzz - 2020-04-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,31 +1,30 @@
     Q: What is the difference between a Template definition and instance?
    
     A: There are two parts to a Template
    -    * **Template Definition**
    +    *Template Definition*
         This metric will will contain all the member Metrics with their default values/properties,
         as well as any Parameters with their default values. This metric is always only published
         in the NBIRTH message
    
    -    * **Template Instance**
    +    *Template Instance*
         This metric is one or more "instances" of the above definition. It will contain the any
         member metrics with values/properties that are overridden/different from the defaults in
         the Template Definition. They are published as you would normal tags (BIRTH/DAT/CMD). 
         When published in a NDATA/DDATA/NCMD/DCMD message they may only contain a
         subset of the member Metrics (if those are the only values that have changed)
    
    -    * **Other template fields**
    -            *isdefinition*
    +    * Other template fields*
    +            isdefinition
                     True for a Template Definition metric, False for a Template Instance Metric
    -            *templateref*
    +            templateref
                     This is used by a Template Instance to specify the "name" of the Template Definition
    -            *ishistorical*
    +            ishistorical
                     Used to mark a Template Instance (or any Metric) as a historical (rather than a live) 
                     value. MQTT Engine may handle historical Metrics differently depending on how it
                     is configured (see MQTT Engine documentation)
    -            *istransient*
    +            istransient
                     Not currently used, will be ignored by MQTT Engine, can be omitted or set to false
    -
    -            *version *
    +            version
                     Not currently used, will be ignored by MQTT Engine, can be omitted or set to null
    
    • status: --> open
     
  • aliazzz

    aliazzz - 2020-04-26
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +0,0 @@
    -template_samples.txt (2.6 kB; text/plain)
    
     
  • aliazzz

    aliazzz - 2020-04-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,19 +1,19 @@
     Q: What is the difference between a Template definition and instance?
    
     A: There are two parts to a Template
    -    *Template Definition*
    +    Template Definition
         This metric will will contain all the member Metrics with their default values/properties,
         as well as any Parameters with their default values. This metric is always only published
         in the NBIRTH message
    
    -    *Template Instance*
    +    Template Instance
         This metric is one or more "instances" of the above definition. It will contain the any
         member metrics with values/properties that are overridden/different from the defaults in
         the Template Definition. They are published as you would normal tags (BIRTH/DAT/CMD). 
         When published in a NDATA/DDATA/NCMD/DCMD message they may only contain a
         subset of the member Metrics (if those are the only values that have changed)
    
    -    * Other template fields*
    +    Other template fields
                 isdefinition
                     True for a Template Definition metric, False for a Template Instance Metric
                 templateref
    @@ -27,180 +27,4 @@
                 version
                     Not currently used, will be ignored by MQTT Engine, can be omitted or set to null
    
    -
    -This template_samples.txt (see also the attachment) contains some sample template structures (in JSON) as well as some Java code for creating a Template. These should help show the basic Template structure and contain the important fields of a Template Definition and Instance. However, they are just references expressed in JSON, not actual protobuf representations (which may be a bit more verbose)
    -
    -~~~
    -{
    -"name": 
    -"TemplateDef",
    -"timestamp": 
    -1499817463261,
    -"dataType": 
    -"Template",
    -"value": 
    -{
    -"version": 
    -"v1.0",
    -"isDefinition": 
    -true,
    -"metrics": 
    -[
    -{
    -"name": 
    -"floatMember",
    -"timestamp": 
    -1499817463260,
    -"dataType": 
    -"Float",
    -"value": 
    -1.23
    -},
    -{
    -"name": 
    -"stringMember",
    -"timestamp": 
    -1499817463260,
    -"dataType": 
    -"String",
    -"value": 
    -"123"
    -}
    -],
    -"parameters": 
    -[
    -{
    -"name": 
    -"Param1",
    -"type": 
    -"Boolean",
    -"value": 
    -true
    -},
    -{
    -"name": 
    -"Param2",
    -"type": 
    -"Int32",
    -"value": 
    -123
    -}
    -]
    -}
    -}
    -{
    -"name": 
    -"TemplateInst",
    -"timestamp": 
    -1499817757169,
    -"dataType": 
    -"Template",
    -"value": 
    -{
    -"reference": 
    -"TemplateDef",
    -"isDefinition": 
    -false,
    -"metrics": 
    -[
    -{
    -"name": 
    -"floatMember",
    -"timestamp": 
    -1499817757169,
    -"dataType": 
    -"Float",
    -"value": 
    -3.21
    -},
    -{
    -"name": 
    -"stringMember",
    -"timestamp": 
    -1499817757169,
    -"dataType": 
    -"String",
    -"value": 
    -"321"
    -}
    -],
    -"parameters": 
    -[
    -{
    -"name": 
    -"Param1",
    -"type": 
    -"Boolean",
    -"value": 
    -false
    -},
    -{
    -"name": 
    -"Param2",
    -"type": 
    -"Int32",
    -"value": 
    -321
    -}
    -]
    -}
    -}
    -Template 
    -templateDef 
    -=    new 
    -TemplateBuilder()
    -.version("v1.0")
    -.definition(true)
    -.addParameter(new 
    -Parameter("Param1", 
    -ParameterDataType.Boolean, 
    -true))
    -.addParameter(new 
    -Parameter("Param2", 
    -ParameterDataType.Int32, 
    -(int)123))
    -.addMetric(new 
    -MetricBuilder("floatMember",
    -MetricDataType.Float, 
    -1.23F).createMetric())
    -.addMetric(new 
    -MetricBuilder("stringMember", 
    -MetricDataType.String, 
    -"123").createMetric())
    -.createTemplate();
    -Metric 
    -metric 
    -=    new
    - MetricBuilder("TemplateDef",
    - Template, 
    -templateDef).createMetric();
    -Template 
    -templateInst 
    -=    new 
    -TemplateBuilder()
    -.definition(false)
    -.templateRef("TemplateDef")
    -.addParameter(new 
    -Parameter("Param1", 
    -ParameterDataType.Boolean, 
    -false))
    -.addParameter(new 
    -Parameter("Param2", 
    -ParameterDataType.Int32, 
    -(int)321))
    -.addMetric(new 
    -MetricBuilder("floatMember",
    -MetricDataType.Float, 
    -3.21F).createMetric())
    -.addMetric(new 
    -MetricBuilder("stringMember", 
    -MetricDataType.String, 
    -"321").createMetric())
    -.createTemplate();
    -Metric 
    -metric 
    -=    new
    - MetricBuilder("TemplateInst",
    - Template, 
    -templateInst).createMetric(
    -~~~
    +This template_samples.txt (see attachment) contains some sample template structures (in JSON) as well as some Java code for creating a Template. These should help show the basic Template structure and contain the important fields of a Template Definition and Instance. However, they are just references expressed in JSON, not actual protobuf representations (which may be a bit more verbose)
    
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +template_samples.txt (2.6 kB; text/plain)
    
     
  • i-campbell

    i-campbell - 2020-04-26

    So in CODESYS land, Template Definition = Struct definition OR FB definition
    Template instance = struct instance or FB instance
    Nice work

     

Log in to post a comment.