Hallo.
I need to set a tag if user is logged in.
I tried this with no success.
public partial class Tags
{
void SystemTagCurrentUser_ValueOn(System.Object sender, System.EventArgs e)
{
Globals.Tags.TestBit.Value = 1;
}
}
Basicly i just need to check if the SystemTagCurrentUse string is empty or not.
Setting tag if user is logged in.
Re: Setting tag if user is logged in.
I don't believe the "ValueOn" action works as it's name indicates. I would try using the "ValueChanged" action instead.
Best Regards,
Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer
Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer
Re: Setting tag if user is logged in.
I tried that. But have not clue why it changes. When i start run time it goes 1 right away. When when i login nothing happens. So i actually have no idea what status of SystemUser is.
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Setting tag if user is logged in.
The current user is a string. The system may change it to a string with nothing in it, which would then trigger the ValueChange event.
You need to check the value of the tag to see if it is empty, or if it has something in it. If it has something in it, then you know that there is a user.
You need to check the value of the tag to see if it is empty, or if it has something in it. If it has something in it, then you know that there is a user.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Setting tag if user is logged in.
Yes. That is what i wrote in first post. I basically need help to see if the string is empty.
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Setting tag if user is logged in.
There are many C# tutorials available online. The best is to look at one of those.
http://csharp.net-tutorials.com/basics/if-statement/
if(Globals.Tags.MyString.Value == "")
//Do something if my string is empty
if(Globals.Tags.MyString.Value != "")
//Do something if my string is not empty
http://csharp.net-tutorials.com/basics/if-statement/
if(Globals.Tags.MyString.Value == "")
//Do something if my string is empty
if(Globals.Tags.MyString.Value != "")
//Do something if my string is not empty
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Setting tag if user is logged in.
I can figure out the basic of checking tags and doing if's etc.
My problem is, if i cant use the "build-in" event handlers like screen opened and closed etc. i don't know how to start a simple if statement.
My problem is, if i cant use the "build-in" event handlers like screen opened and closed etc. i don't know how to start a simple if statement.
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Setting tag if user is logged in.
Why can't you use the built in screen handles? The screen open/closed handles work.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Setting tag if user is logged in.
True.
But when user hits ok after typing username and password the screen is already opened. I would require to somehow refresh the screen or something.
But when user hits ok after typing username and password the screen is already opened. I would require to somehow refresh the screen or something.
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Setting tag if user is logged in.
When the user logs in, then the tag changes value, which fires its ValueChange event. Therefore put your code in the SystemTagCurrentUser ValueChange event. That tag changes value when the unit turns on because the system is initializing the tag to empty. That is why you need to check the value of the tag in the value change event. If the tag is not a user, then you do nothing because you know that the tag was initialized by the system, and no one logged in.
You can put an AnalogNumeric Box on your screen and associate it with the SystemTagCurrentUser tag and see what is in that tag.
You can put an AnalogNumeric Box on your screen and associate it with the SystemTagCurrentUser tag and see what is in that tag.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer