cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

If I have multiple things using the same template how do I differentiate them in the template?

elit
1-Newbie

If I have multiple things using the same template how do I differentiate them in the template?

Here is my config.lua:

scripts.TestThing = {

     file = "thing.lua",

     template = "display"

}

scripts.TestThing_Interface_0 = {

     file = "thing.lua",

     template = "interface"

}

scripts.TestThing_Interface_1 = {

     file = "thing.lua",

     template = "interface"

}

In the template when I am getting the properties how do I differentiate which interface I am getting properties for?

7 REPLIES 7

Let me explore the question more.

If they are of the same templates that would be different?

Have you considered multiple templates say

                    base template

                              I

subtemplate1 subtemplate2 subtemplate3 (where the sub templates have something different

if they are not different then the question is what makes them different is it a property value?

Maybe I'm off base. if so can you provide more detail

They are based on the same template on the server side, they will have different property values. The differentiating property value is called InterfaceID. This question is coming from the lua script resource environment.

Are you asking how to get the property value for interfaceID in Lua?

There are 2 properties that I am trying to use to differentiate between the interfaces.

log.info("Interface ID: ", properties.InterfaceIdentificationNumber.value)

log.info("Interface is redundant: ", properties.IsRedundantInterface.value)

This prints out the same thing for each interface

Interface ID: 0

Interface is redundant: false

I'm not a Lua expect - I'm assuming you added  InterfaceIdentificationNumber to your template?

Yes. On the server side they have correct values, but they are all 0 in the lua script resource.

ttielebein
12-Amethyst
(To:elit)

I believe you should set the identifier for each of these things on the Platform, and then make use of the identifier property of these lua tables. From the config.lua.example file:

"identifier: Register with the EMS and Platform using this identifier."

This would effectively distinguish between each of these on the Lua side of things. I hope this helps!

Top Tags