This script looks like it should be executing the navigation, but its not. It is executing everything up to that point. It will even execute the navigation outside of the “if”, any ideas would be great.
status_word = system.tag.readBlocking(['[default]ABS Concentrate System/Barcode_Scanner/_'+str(scanner_id)+'_/Status_Word'])[0].value. # [0] to get the 0th index returned QualifiedValue, and .value to obtain the value of the QV
self.getSibling("Label_1").meta.visible = True
self.getSibling("BadMachine").meta.visible = True
self.getSibling("Label_1").meta.visible = False
The system.tag.writeBlocking line is almost certainly where your code is failing, but you should have seen logging in the Gateway that this code was failing on that line.
I was under the same impression, that system.tag.[read|write]Blocking expected a list of tagPaths, but in reality it does work if you pass a string. I was shocked when I saw it, but an Integrator did that very same thing all over one project and it was working.
Also time.sleep() might break in some cases where the computer’s Locale is not English, I’d recommend using java.lang.Thread.sleep() instead.
These are incorrect. A single tag path and value work as well outside of a list. In earlier versions of 8 they didn't, but a feature request added this back in to mimick the v7 function. However the return is still an array of qualifiedValues
Thanks alot guys! lots of great suggestions. I totally forgot that the readBlocking does in fact return an array. after fixing that issue, it navigated liked it should have. thanks again for help.
For future reference, it’s also super handy especially for Perspective, to add try/except blocks around your code to capture and report any errors to the operators. Make sure you have two excepts, one to catch java.lang.Throwable errors and the other a catch all (which doesn’t catch java).
E.g.
from java.lang import Throwable
try:
# do stuff
except Throwable:
shared.perspective.errors.displayError()
except:
shared.perspective.errors.displayError()
I use a shared library function to display an error to keep it in one spot. For simplicity’s sake, you could just write the error to the console:
@thecesrom.git , @nminchin :
After speaking with the Dev behind the change here, we don't officially support single tag paths - allowing for only a single tag path (and value) was only added to resolve some other issue. The documentation is the supported usage, and so you should always be wrapping your tag paths and values as lists.
Hmm, bummer… will do from now on, but there are lots of places I haven’t! (and not because I’m being dumb and reading single tags when I should be reading multiple together, just to clarify )