Page 1 of 1

A rectangle object using multiple tags

Posted: Wed May 15, 2019 9:00 am
by markpb
Hi,

I am by trial and error, learning how to develop the HMI. I have an instance where I need a rectangle object to be filled a different colour when the value is 1. I have done this using one tag but ultimately 2 tags (either tag will have a value of 1 to fill the object a different colour) will be required to fill the object. A trawl through internet doesnt seem to give me any answers.

Thanks.

Re: A rectangle object using multiple tags

Posted: Fri May 24, 2019 9:49 am
by Russ C.
I would add 1 more tag and set its value in scripting in the Tags page.

If you go to Tags -> Scripting -> select one of your tags to check its value and click the + next to its name in the list and double click the Value Change event to create a blank function.
Then in that function add an if statement to check if either Tag1 or Tag2 are 1, and set Tag3 to 1 if so. See below:

Code: Select all

	void Tag1_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
		{
			if(Tag1.Value == 1 || Tag2.Value == 1)
			{
				Tag3.Value = 1;
			}
				
		}

Then to get Tag2 to check on value change as well you can right click its Value change and "Hook up event" and select the same function as Tag1
Tags_Events.png
Tags_Events.png (38.6 KiB) Viewed 4601 times

Then set your Rectangle color to change based on Tag3's value