Maker edition 8.1.7
TLDR: Using the writeBlocking script function to update an array memory tag does work but an expression tag dependent on that array does not update. Additionally the tag browser does not show the updated array values in designer. I can force the expression and the tag browser to update by right clicking on the array tag and selecting “Restart Tag”.
Manually toggling the array bits on and off in the the designers tag browser updates the expression tag every time as expected.
More details here
I am using a python script (writeBlocking function) to write to a memory tag of type BoolArray with 9 elements, I am writing the whole array at once.
In the script if I read back the tag and print it to the wrapper log it shows the new values, as expected so far so good. But the tag browser in the designer does not the update the array elements when the writeBlocking occurs and is stuck on the old values.
My major issue here is an expression tag which is dependent on the array elements which does not update when the writeBlocking to the array occurs. However if I “Restart Tag” the array tag in the designer everything will then update and work, additionally the writeBlocking and dependent expression will work one more time, but then stop working for all future writeBlocking executions until I restart it again.
If I manually toggle the bits on/off in the designer the expression works, so this does not appear to be an issue with the expression tag specifically but how I am updating the array.
The following describes how the writeBlocking is used in context, hopefully this makes scenes:
In my application user interacts with a multi-state dropdown box, a memory tag of type “Document” is bidirectionally linked to the value of the dropdown box. When the value changes the below python scrip runs to map the selected values to a boolean array in a UDT:
# read in the selectedSwitches bool array. Mainly for the length of the array # as this may change in the future. All other values will be # overwritten currentSwitches = system.tag.readBlocking(["[.]SelectedSwitches"]).value optionsLength = len(currentSwitches) #Debugging, Print origional array print("****Valued changed") print("Oritional:") print(currentSwitches) # Blank the existing values for i in range(optionsLength): currentSwitches[i] = False # Read in the new list from the multi-state dropdown box. # This is a list of indexs that need to be True in the Bool array newSwitchList = currentValue.value # iterate through the list and select each bool swtich (only if it contains something) if newSwitchList is not None: for item in newSwitchList: currentSwitches[item] = True # Finally write the results bak to the bool array system.tag.writeBlocking(["[.]SelectedSwitches"],[currentSwitches]) # Debugging, Read back the tag value now to verify succssfull write currentSwitches = system.tag.readBlocking(["[.]SelectedSwitches"]).value print("Read Back:") print(currentSwitches)
Here is the output:
INFO | jvm 1 | 2021/09/27 13:39:39 | ****Valued changed
INFO | jvm 1 | 2021/09/27 13:39:39 | Oritional:
INFO | jvm 1 | 2021/09/27 13:39:39 | array(java.lang.Boolean, [True, False, True, False, False, False, False, False, False])
INFO | jvm 1 | 2021/09/27 13:39:39 | Read Back:
INFO | jvm 1 | 2021/09/27 13:39:39 | array(java.lang.Boolean, [True, True, True, False, False, False, False, False, False])
Here is the Tag Browser showing the same tag with element 1 as OFF:
Here is the same tag after I select ‘restart tag’:
This appears to be an issue with how I am using WriteBlocking to update the bool array but as there are no errors and its kinda working I am not sure where to go.
Is this a Bug or what am I doing wrong?