Hello everyone,
For an application, I have two screens, the top view, and the button view and I toggle between those two screens using an OPT touch button. I created a script in the client tag change script to do that.
Now, I want the user to see the top view screen first when he/she enters the barcode. Is this possible?
The barcode is a memory tag for now, but later on, the barcode should enter a number in a numeric entry box. The barcode uses a USB interface.
I know that I can probably use tag change but not sure where should I add the script. Is it from client events → Tag change or from Tag events → value changed
Thank you in advance for your response.
What I would do is create a client tag called windowToggle
or something like that. Create your window swapping script as a client tag change event set to the client toggle tag. Then you can swap windows from several different events by simply writing to the toggle tag.
2 Likes
Thank you for your response.
I am not quite sure how to do the last part.
Basically, what I want to do is when the barcode value changed I want the top view to be shown.
In the client tag I can have a script for the value changed but how does the value of the client tag related to the barcode tag?
I already have a memory tag for my barcode and that has a script to split the 16 digits number of the barcode and assign them to 4 tags.
I think you said that you are reading the serial number into a numeric field. Put a script in the propertyChange event handler on that numeric text field.
if event.propertyName == 'intValue':
system.tag.writeBlocking(['[Client]windowToggle'],[1])
1 Like
Thank you very much for your response and for helping me with this.
So I have a numeric entry field for my barcode scanner and the Long Value of that numeric field is bounded to a memory tag value.
What I did here based on your advice. I created a boolean client tag called “WindowToggle” and I wrote this script for its tag events → value change.
When this value changed I want the top screen to be shown.
val= system.tag.readBlocking('{[~]WindowToggle}').value
if val:
if system.nav.getCurrentWindow()== "Bottom":
system.nav.swapTo('Top')
else:
system.nav.swapTo('Top')
After that, I wrote a script for that numeric entry box on its property change. The script is:
if event.propertyName == 'LongValue':
system.tag.writeBlocking(['[client]DefaultScreen.Value'],[1])
Although I did not have any errors I still could not see any outcome. My WindowToggle tag did not change upon changing the barcode value. Even when I manually toggle the WindowToggle value ON/OFF the screen does not change to the top view.
You'll want the binary state of the boolean client tag to represent your two windows.
boolean True -> Top
boolean False -> Bottom
So for the window swapping script..
val= system.tag.readBlocking('{[~]WindowToggle}').value
if val:
system.nav.swapTo('Top')
else:
system.nav.swapTo('Bottom')
Also, notice how in your script you have both of your swapping scripts set to swap to Top
1 Like
Thank you! The thing is I do not want to swap to bottom. I want the top screen to be shown always when the barcode value is changed and then I toggle the screens using an OPT touch button
Although I changed the swapping script as you mentioned. Nothing is changed.
Add some print statements or logger.info() statements to your script to see what is actually being evaluated/if its being triggered at all.
It will only swap to bottom when you write False
to the boolean tag. If you want the Top
window open any time you scan a barcode, then always write True
to the boolean tag. It will only swap to Bottom
if you write False
.
2 Likes
I wrote this for my boolean WindowToggle client tag on its value change:
But I did not see any outcome in output console.
val= system.tag.readBlocking('{[~]WindowToggle}').value
if val:
print "y"
else:
print "n"
You won’t see that in the output console, the tag is on the gateway not the client. For gateway script printing, you would use a logger
val= system.tag.readBlocking('{[~]WindowToggle}').value
logger = system.util.getLogger("windowToggle")
if val:
logger.info("Toggle Bool: True")
else:
logger.info("Toggle Bool: False")
The logs can be seen on the gateway webpage (Status → Diagnostics → Logs)
1 Like
Thank you!
I copy pasted your script:
However, I do not see any logs, the picture below is for my recent logs:
Also I have my tag as a client tag.
Type in “WindowToggle” in the filter
1 Like
Since you are doing this in the tag itself and not the client tag change event script, do this instead
if not initialChange:
logger = system.util.getLogger("windowToggle")
if currentValue.value:
logger.info("Toggle Bool: True")
else:
logger.info("Toggle Bool: False")
1 Like
Oops, also it was windowToggle
not WindowToggle
1 Like
I tried this both with WindowToggle and windowToggle. Also, I wrote my script in the tag itself (Vision Client Tags → Tag Events → Value Changed.) . I could not see anything in the output console nor could I see it in the log infor.
However, if I write this in the client tag change event script, I get the response in the output console:
So should I continue in the client tag change event?
If its a client tag it is in the client logs. You have to go to your Diagnostics page in the client to see client logs.
1 Like
I totally missed that it was a client tag
2 Likes