View Full Version : WinCC Flexible 2008
blutak
October 14th, 2009, 04:57 AM
Hi everyone, new to the site but just want to say hi first.
Ive been trying to find a way to set a tag to 1 when logged in as a admin or another high level user and keep that same tag 0 when logged in as just an operator.
Ive tried writing a script but it doesnt seem to work, any ideas would be great!! Thanks!!
:dance:
GetGroupNumber SmartTags("group number")
If SmartTags("group number") = "9" Or "2" Then
SetBit SmartTags("Engineering Bit")
Else
ResetBit SmartTags("Engineering Bit")
End If
when i run the script it just sets the bit as -1 in the tag simulator thing and wont change? Numbers 9 and 2 are the higher level Groups and anything else (in my case number 1) is the operator group number.
Jeebs
October 14th, 2009, 06:00 AM
Exactly how is this script triggered?
Where does "group number" come from?
blutak
October 14th, 2009, 06:36 AM
im triggering it off the login button and some menu buttons, the group number as far as im aware gets written to the tag automatically after log in.
JesperMP
October 14th, 2009, 06:41 AM
Do not make a script for this !
Do it this way in stead:
Device Settings .. Scheduler.
Add a Job, to be triggered on the event "change user".
Add the following functions to the job:
"GetGroupNumber", assign to an internal integer tag.
"GetUserName", assign to an internal string tag.
"TraceUserChange".
You can now use the tags to show the current level and name of the user.
CharlesM
October 14th, 2009, 07:38 AM
Does the "change user" event run after the log in timeout? I know it should run when the user logs in but by default the user will be logged out after 5 minutes. If it does run on log out what values does it return?
JesperMP
October 14th, 2009, 07:43 AM
It does run at timeout. Because the user is logged out.
The userlevel or "group" returned is "0" (zero).
RMA
October 15th, 2009, 10:06 AM
Jesper, do you know off-hand how long the String for the User Name can be? I can't find it anywhere in the help files.
Edit: While we're on the subject, how do you enter the DB adress in the String compare block (FC10 EQ_STRING). Looking at String functions I've used before it shows up as P#DB2.DBX40.0, but if I try to enter that, it stays red. Trying to enter it symbolically as '"HMI_DB".User_Name' didn't work either.
Another of these things you only do every couple of years and always forget how it works! :(
JesperMP
October 15th, 2009, 04:11 PM
Unfortunately I do not know how long the username can be.
Longer than what practically makes sense I guess.
Comparing strings by entering the symbolic names seems to work for me.
Maybe save the DB, shutdown the LAD/STL/FBD editor, and try again ?
RMA
October 16th, 2009, 02:06 AM
Maybe save the DB, shutdown the LAD/STL/FBD editor, and try again ?
Yes, that was the problem, saving the DB alone isn't enough, on reopening the editor this morning it worked fine, of course. If I'd tried to save the FC, that would also have solved the problem (or at least the change in the DB would have been recognised), but I didn't think of that at the time.
I've settled on thirty characters for the String, hopefully that will be enough for most people!
.