Ignition List box and Login behaviour

8.1.38

I have a list box where I'm using the selected index, originally bound to a PLC tag. However, it appears on load of the window, the list box selected index, reverts back long enough to the last saved value in Designer, which was briefly changing the tag value in the PLC.

So, I removed the direct binding, and put a windows open script to read the PLC value and update the selected index value, and added a property change script to the list box, to write the selected index to the PLC.

Still didn't work. The write from the open window script somehow lagged the list box property change script, and the property change script fired once with the designer value, and a second time with the open window script.

I resorted to just creating a button that the operator uses to effectively confirm the list box value instead of auto bindings.

This raised its head because apprently login/logout events force a reopening of the window.

Was there a more elegant way out of this delimma. I've never seen a component “write” a default value on window load. I expect to see read value lags as the bindings update, but was surprised to see this issue.

Is/was your binding bidirectional? What was it bound on? I've seen this before a while ago and recall the bidirectional binding was writing the saved value on initial load. I don't remember the details of the why though...

Yes sir, the initial binding was bi directional on the list box selected index property. But I removed that binding completely and did a readblocking tag/write to selected index on window load, and then on the list box property change, added a writeblock of selected index to the the PLC tag. What I observed on both methods was on window load the PLC tag changed briefly (I have a 250ms poll on that tag) to the default selected value of the list box when it was saved in designer.

I imagine the onWindowOpened script is executing before the listbox component is fully initialized. I recommend running any component initialization script directly on the component itself using the componentRunning propertyChange event.

Example:

# Written for the listbox's propertyChange event handler

# Runs only once at initialization
# NOTE: For this event to occur in the designer,
# ...preview mode MUST be running PRIOR to opening the window
if event.propertyName == 'componentRunning' and event.newValue:
	#listBoxValue = system.tag.readBlocking...
2 Likes