If anyone out there could help we would really appreciate some tips- We’re trying to bind a single
checkbox to the property of 4 different tags. Using the tutorials and help files we’re unable to find an example that helps with this exact challenge. Here’s what we’re doing:
We have a checkbox property named “ChcBX_AlmEnab_2.props.selected” that when true will change the following 4 tag’s property to true:
[default]PLC Main Program/Raw Water Area/LIT_201/HAlm.AlarmEvalEnabled
[default]PLC Main Program/Raw Water Area/LIT_201/LAlm.AlarmEvalEnabled
[default]PLC Main Program/Raw Water Area/LIT_201/HHAlm.AlarmEvalEnabled
[default]PLC Main Program/Raw Water Area/LIT_201/LLAlm.AlarmEvalEnabled
Whether this can be done through scripting, expression, or any other option, we’d greatly appreciate some direction. Thank you in advance.
Sounds like you want a change script on the selected
property of the check box (seems like you are using Perspective from your syntax)
if currentValue.value == True:
tags = ['[default]PLC Main Program/Raw Water Area/LIT_201/HAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/LAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/HHAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/LLAlm.AlarmEvalEnabled']
values = [True, True, True, True]
system.tag.writeBlocking(tags, values)
In perspective, select your checkbox, and then on the property editor right click selected and click Add Change Script to add a script that runs each time that specific property changes
This worked like a charm, I think I also understand the structure of your script so I’m able to replicate and make small changes as needed. Thank you for your support!
A fun micro-optimization:
values = [True] * len(tags)
You can use this to avoid having to keep adding elements to the values
list if you ever change the tags
list.
True, I was thinking of a nicer way. With this, you could even do
tags = ['[default]PLC Main Program/Raw Water Area/LIT_201/HAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/LAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/HHAlm.AlarmEvalEnabled',
'[default]PLC Main Program/Raw Water Area/LIT_201/LLAlm.AlarmEvalEnabled']
values = [currentValue.value] * len(tags)
system.tag.writeBlocking(tags, values)
So that this would also turn the alarms off when you uncheck it.