I need to turn on a bit when a user is logged into the system session.props.auth.user.userName. I can get it work in my dashboard but not sure how to get a tag to 1/0 to turn on a bit in my plc to prevent machine from running without an operator being logged into the system.
You need to look into isAuthorized | Ignition User Manual
thanks i read that over prior but not the best some of this stuff, i created a expression tag Boolean and used isAuthorized(true) i get error configuration
Is there any chance that multiple operators might be logged in at the same time? What should happen in that case?
Note that this expression does not work everywhere (from link above):
Scope is Perspective Sessions only.
no just one
You should not try to do this in the session. Instead, use a gateway timer event that calls system.perspective.getSessionInfo() every ten seconds, or minute, or whatever you need. The script would loop through the results to check for the desired status, perhaps ignoring designer sessions, and writing True
to the target tag if a suitable session is found. (And returning early.) Write False
if no qualifying session is found.
(I'd include a check of lastComm
in your logic, to catch crashed browsers or abrupt shutdowns as early as practical.)
Unsure if this option fits your mold - I would build security level rules which are tied to appropriately authenticated users, and ensure that all appropriate writes (start, hand/auto, etc) to the PLC are with from authenticated operators only (using tag security). Animation (to disable/enable a button or setpoint entry) can be tied to the .CanWrite
property on a tag, which is unique to each user of the project.
yes have users and levels set and controlling access to params and etc. just need a bit to tell me they are logged into the system.
yes have users and levels set and controlling access to params and etc. just need a bit to tell me they are logged into the system.
Yes, use a gateway timer event that writes the bit based on the sessions present.