I have a drop down list that I want to have confirmation on before setting the bound tag value under certain conditions. The Selected Value is bound to a PLC tag and the list items are as below:
0 - Manual
1 - Storage
2 - Ferment
3 - Rummage
4 - Cycle
When the mode is in Ferment, I want to have a confirmation message pop up if the mode is attempted to be changed to warn the operator.
I can’t work out how to do this without setting the tag to the new value first and then using the propertyChange event.
Leave the dropdown not bound to the tag, then in the property change event of the dropdown filter for the selected value property, and add a system.gui.confirm call before writing the tag value:
if event.propertyName == "selectedValue":
title = "Confirm"
message = "Press Yes to confirm new value for tag"
if system.gui.confirm(title, message):
system.tag.write("SomeTag", event.newValue)
There’s still a minor issue where if the PLC value changes and this page is open, the confirm prompt shows up if the condition is met. This will very rarely occur however and it’s a simple solution for the operator to accept the confirmation, so this will be fine.
[quote=“nminchin”]There’s still a minor issue where if the PLC value changes and this page is open, the confirm prompt shows up if the condition is met.[/quote]This can be filtered out by adding an intermediate property in your bindings: bind the tag to the new custom property, then bind the dropdown value to the custom property (uni-directional). Then in your property change script, check the new value and the current value of the custom property. If either is null/None, ignore it. If they match, the new value came from the PLC. Otherwise, it’s a new value from the user.