andrews
December 16, 2021, 3:48pm
1
After switching between pages 4-5 times it works. But at first it does not do anything. The page icon loads, the tags change because i see my component disappear. But it stays on the same page, like something stops it from switching. right it works after swapping a few times i have no ideas.
here is logout button code.
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")
system.tag.writeToTag("[Client]BadgeSystem/DisplayCountdown", 0)
system.tag.writeToTag("[Client]BadgeSystem/TimerRunning", 0)
system.tag.writeToTag("[Client]BadgeSystem/TimerValue", 0)
im using 7.8.5
thank you , it is critical i figure this out.
lrose
December 16, 2021, 3:50pm
2
Then you should contact support.
From the script you’ve provided I don’t see anything that would cause this not to work.
andrews
December 16, 2021, 3:51pm
3
@lrose my company does not have a support contract which is why I am here.
Idk much about vision, and i doubt it rly matters for this but still. Avoid running code after navigating away. do the nav at the end.
andrews
December 16, 2021, 3:57pm
5
@victordcq I tried moving the swap to the end but still get the same results.
andrews
December 16, 2021, 4:00pm
7
@victordcq its just so weird that it works perfectly after a few clicks then the occasional mess up.
andrews
December 16, 2021, 4:00pm
8
I also do not see anything in the diagnostic window
andrews
December 16, 2021, 4:02pm
9
I get this in my console log
SQLTagsClientProxy Removing Tags due to switching user.
any relation?
andrews
December 16, 2021, 4:19pm
10
I adjusted the code, and it does not work for the time i.e. page to logout. then i go back to page and logout and it all works. very weird.
lrose
December 16, 2021, 4:24pm
11
Try writing the tags first, then changing the user, then navigating.
Also, not familiar with 7.8, do you have a system.tag.writeAll()
?
pturmel
December 16, 2021, 4:29pm
12
I would do the switch user last, and in a separate function via invokeLater.
Also consider using a single call to write all the tags synchronously.
andrews
December 16, 2021, 6:13pm
13
@pturmel @lrose I do this is revised code, does not look to be writing to tags.
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
def testwrite(tags, values)):
system.tag.writeAll(tags,values)
system.util.invokeLater(testwrite)
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")
i also tried
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
def testwrite(tags, values):
import system
system.tag.writeAll(tags,values)
system.util.invokeLater(testwrite)
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")
pturmel
December 16, 2021, 6:19pm
14
Do this. And I see typos and wrong indentation.
andrews
December 16, 2021, 6:33pm
15
@pturmel tags writing, still not swapping window though.
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
system.tag.writeAll(tags,values)
system.nav.swapTo('Logged Off')
def switcharu():
import system
system.security.switchUser("plc", "plc")
system.util.invokeLater(switcharu)
andrews
December 16, 2021, 6:37pm
16
first time it does not, but if log back in to window then try to log out again it works.
pturmel
December 16, 2021, 6:54pm
17
Try a 1000 millisecond delay on the invokeLater.
andrews
December 16, 2021, 7:06pm
18
@pturmel I added the delay and still not working. I see the loading refresh icon in the upper right corner but it stays on the same page even if i click 10 times. However I can swap between other windows no problem. just not the log out button one, very strange.
I am gonna try something i like dislike and adding the extra code in the other buttons. i’ll post back if it works.
andrews
December 16, 2021, 7:29pm
19
@pturmel @lrose @victordcq
Thank you for all your help. The original code I posted works! As ugly as it may be.
The issue was the logged off page set to open on startup. Once I turned that off, duplicated that page, changed the name, set duplicated page to open on start up, it works perfectly now.
andrews
December 16, 2021, 7:32pm
20
not sure why the open on startup would cause those issues. maybe a bug?