Connect multiple Boolean states to dropdown menu

Hello,

I have 3 OPC Boolean tags that I need to connect to the values of a dropdown menu on a screen. The user should select one option and it writes a True out to one, and a False out to the others.

Use a propertyChange script to write to your three tags when the selected value changes. I would show the current state of those three booleans separately, and/or have an on-startup script that would set the value based on the current booleans.

I tried that, but whenever my cursor moved over it then it wrote a 1 out to the first of the values and kept me from selecting anything else.

I was able to get a memory tag to pull an integer value from the list, and I tried to get that to write out values, but nothing would allow me to actually write out a value on the tag.

Can we see the script(s)? And vision or perspective?

I went ahead and tested this out on my own, using Perspective.

I combined the three booleans into a single "intermediate" memory expression tag "BoolINT":

image

BoolINT = {[.]Bool1}*1+{[.]Bool2}*2+{[.]Bool3}*3

The dropdown's value is bound to BoolINT (not bidirectionally) and a propertyChange script is applied:
image

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value == 1:
		values = [True,False,False]
	elif currentValue.value == 2:
		values = [False,True,False]
	elif currentValue.value == 3:
		values = [False,False,True]
		
	system.tag.writeBlocking(["[default]Test/Bool1","[default]Test/Bool2","[default]Test/Bool3"], values)

The same idea would apply in Vision, just applied slightly differently.

I have this same question, but for Vision. I have tried to copy your script and expression tag, inserting my tags instead of yours, but I cannot get it to work. I get an Error_Configuration in the tag and Quality of the component. This is my first Ignition project, so much of this is new to me. Much appreciation for any help.



Looks like you are missing a quote in your writeBlocking line in the script on the last tag.

For your expression, you can remove the 'systemOperationModeSelector =' as well. I don't think that would be a valid expression which is probably why you are getting the Error_Configuration.

thank you, yes, i had already found the missing quote. I also changed the 'systemOperationModeSelector' to the actual tag. should i just remove it completely?

Correct, if you do an equals typically in an expression it just turns into a boolean comparison and not assigning the value on the right side of the equation. Assuming you want the tag to have the value of what you are evaluating on the right, you will just leave that portion as the Expression.

This section of the manual is useful when starting out with Expressions to know syntax and some of the different options you have.

https://docs.inductiveautomation.com/display/DOC81/Expression+Language+and+Syntax

Thank you so much!

1 Like