This lesson is part of the Tags in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off
Take topic challenge

Supplemental Videos

LESSON

Derived Tags

Description

Derived tags are similar to expression tags, in that they utilize Ignition's Expression Language. They differ in that they must be associated with another tags (known as the "source tag"), as well as support writing to the source tag from the Derived Tag.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] In this lesson, we'll take a look at Derived Tags. A Derived Tag references the value of another tag but allows you to write an expression to determine the value we show on the Derived Tag as well as the value we write back to the source tag. So to begin with, I have a Memory Tag here. Let's create a Derived Tag and set the source path and have it reference this Memory Tag. So we'll hit the Add Tag dropdown at the top of the Tag Browser, under New Standard Tag we'll select Derived Tag. We'll change the name here. And in the very least, you need to set the Source Tag Path. So for the Source Tag Path property, we'll hit the edit button, under the Tags folder, I'll select My_Memory_Tag, hit Commit, and hit OK. We now have our Derived Tag in the Tag Browser. So if my Designer is in read-write mode, I can write to my Derived Tag which then writes back to the source tag, and of course if the source tag changes for some reason, the value on the Derived Tag will update to match. So right now, very similar to how the Reference Tag works. The Derived Tag allows you to do a bit more. So if we go back to the settings on the Derived Tag, I'll double-click on it, let's look at this Read Expression property. So this basically determines what should the value on the Derived Tag look like. So for the Read Expression, if I hit the edit button here, we get to write an Expression Language expression and we have this built-in source here. I'll zoom in with Control and the mouse wheel. So this is just a property reference to the value that's on the source tag. So we could make a little modification. So maybe I'll multiply it by two so we'll take the value that's on My_Memory_Tag, multiply it by two, whatever we get, that's the value we're going to show on the derived tag. I'll hit Commit here and we'll hit OK. If we try it out, you can see it kick into effect. So if I change My_Memory_Tag to 100, our Derived Tag shows us 200. Now this doesn't really change the writing right now. If I try a write to this tag, it's going to be a little silly. I'll try writing a value of 500 to our Derived Tag which will then pass the 500 to the Memory Tag which then doubles our Derived Tag. So if you made a change to the Read Expression, you probably want to make a change to the Write Expression as well. So if I double-click on the Derived Tag, the write expression has a built-in value property reference so let's take a look at this. We'll edit this property. So again in that same scenario when I was trying to write a 500, this value referenced here would represent that incoming value and this expression would allow us to do something with it. So we could go ahead and try to scale it back the other way so now we can actually divide the value that's coming in by two and then write that to the memory tag. I'll commit this here and let's try it out. So I'll hit OK. So on my derived tag, if I try that again, if I try to write a value of 500 and hit Enter, we're taking that value, dividing it by two, and then passing it over to the Memory Tag. So we're doing some simple scaling. There are other ways to scale incoming writes but what's great about a derived tag is that you can do considerably more than scaling. They have access to the full expression language including all of its functions so you can add additional logic, formatting, and other tools to modify how these reads and writes are handled.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.