Switching Roles

I have a timer script that runs and basically gets the current user role and sets a memory tag.

[quote]if “View” in system.security.getRoles():
value = 0
system.tag.writeToTag(‘View Only’, value)

if “Control” in system.security.getRoles():
value = 1
system.tag.writeToTag(‘View Only’, value)[/quote]

It works fine, but sometimes after an extended period I’ll get an error popup saying that writing to tag View Only timedout.

I have changed the Viewonly tag to a OPC tag and will see if I still have the same problem.

Is there something I am missing that is causing the write to tag to time out?

My best guess would be the number of Clients open all writing to the same tag at once causing this issue occasionally.

Not sure what you are doing with this tag however.
If you are controlling view / control as it appears to me, then Ignition has better ways of handling security.
‘View Only’ is a global tag. Since it is a global tag, you are depending on order of execution. This is not the best approach for security. ‘[Client]View Only’ would be better as it a Client Tag (Still not great).

If this is for security, I would use Ignition’s built-in tag security and/or object security.

Cheers,
Chris

Just to expand a little on CPowell’s response: Client tags are client scoped (I know this is implied but i just wanted to explicitly state it). This means that each client gets their own instance of the tag and any changes made to it by a specific client will only be visible to that client.

I think that may be it. It’s an application with a local HMI and only one remote client used occasionally. I think the problem has only come up when the one remote client is also in use.

The purpose of the tag is to disable a few buttons when an operator is not logged in.

You would certainly want to use a client tag for this, not a memory tag.

Why the write was timing out is another issue, and I’m not sure what the cause was, it’s impossible to say with the information given, but my guess would be some sort of network issue or server performance issue.