Factory Talk View Site Edition 9.0 Auto logout/login after idle time

Daiana87

Member
Join Date
Mar 2018
Location
italy
Posts
5
Hi everybody. First of all thanks for your help! You've been really helpful for me in these years but now I'm facing a problem that I can't solve. I'm developing a software with Factory Talk View Se 9.0 that runs on a Panel Pc with Windows 7 64 bit on. I have 2 run time users, View Only (default user that logs in at startup) and Maintenance. I want to implement a function to automatically log out only the Maintenance user after 5 minutes of inactivity and auto log in the default user. I tried with the implemented functionality of auto logout but I don't want that when nobody is logged in, you just see a blank screen and have to do a manual login. I want it that to be automatic. I've searched in this forum and I've found this thread http://www.plctalk.net/qanda/showthread.php?t=95319 but I can't get done with the solution suggested. Can anyone help me?
Thanks in advance
 
Unfortunately I've already seen these posts but I still can't solve my problem. I don't need a logout button, everything has to be automatic. Startup -> autologin defaut user (it's already like that) --> login maintenance (if maintenance has to insert certain values or has to set certain memories to bypass conditions in plc software) and then auto "logout" after an idle time ( actually it would be an auto login to default user to avoid the blank screen and the manual login)
 
Can you point the run time user level to a PLC address? I don't use SE so my apologies if that's a dumb question - just basing it off of what I know in ME :)

If so, you could create a logout screen on the Panelview that is opened from the Inactivity timeout. On that screen run a macro to default the user level in the PLC address. After the user closes/acknowledges the logout screen the panelview could reference the PLC address to determine what to display.
 
There are two ways to approach this: one very simple, and one quite complex.

The simple way is to use the IdleDetect ActiveX provided by Rockwell. Unfortunately, the knowledgebase appears to be down for me right at the moment so I can't point you to that option right now, but it's definitely the best option if you can get at it.

The other option is using VBA. There are three parts to this problem:
1. Trigger code regularly to check if a logout (i.e. login of default user) is required
2. Check how long the system has been idle for
3. Perform logout

The first part is required because VBA is different to a PLC in that where a PLC runs code cyclically (i.e. over and over repeatedly), a VBA sub only executes if something specifically triggers it. So, we need to find something that we can use to repeatedly trigger some code.

In the HMI tags, there are tags which relate to the system time. Obviously, the "seconds" tag will change every second, and the "minutes" tag will change every minute. If we can detect a change in one of these tags, we can use that even to trigger VBA code every second or every minute.

To achieve this, have a look at these two threads. Have a play with this code and see if you can get something to work - perhaps to begin with just try putting some text on your screen and making it change colour or position or caption when the code is triggered - that way you at least know you're capturing the event. Note that these links do not relate directly to your problem - one of them relates to me trying to cause a pop-up to appear when a PLC tag changed. But the principle of what you're trying to achieve is the same - cause VBA code to execute when a tag changes, whether that's a PLC tag or a system tag.
http://www.plctalk.net/qanda/showthread.php?t=99558
http://www.plctalk.net/qanda/showthread.php?t=89416

Next, we have to check how long the system has been idle, and see if it exceeds out time limit. Microsoft have an example of how to do this here: https://msdn.microsoft.com/en-us/vba/access-vba/articles/detect-user-idle-time-or-inactivity
...but I found this this example from Stack Exchange was much simpler, and I think that's how I ended up doing it: https://stackoverflow.com/questions/25257484/get-idle-time-in-windows-7-64-bit-with-vba

Once you've got the two steps above working, you're pretty much home. Every time your system minute tag changes, trigger code to check the idle time. If it exceeds the maximum idle time for your auto logout, then run code to login a default user. The code to do that can be found in this thread, which Garry already linked you to: http://www.plctalk.net/qanda/showthread.php?t=95067

One final thing: ALWAYS, ALWAYS, ALWAYS PUT ERROR HANDLING IN YOUR VBA CODE

See how you go with that - if you get stuck on any of the parts of it, post back with some more details and someone will pop up to help further.
 
I would say also the IdleDetect ActiveX is the way to go.
Its a shame that Rockwell cant integrate simple features like that their $$$ HMI Software.
 
There are two ways to approach this: one very simple, and one quite complex(..)

Thanks for all your suggestions. Here it is what I have so far:
-I created a new display called VbaCode -> Display type Overlay with "keep it back" checked. Cache after displaying and always update checked.
-This display is opened on client startup page like this: Display VbaCode /B /ZA

In this display I have a "display string" linked to the tag "system/minutes" and I expose to vba this object. This is the vba code.

Code:
Private Type LASTINPUTINFO
   cbSize As Long
   dwTime As Long
End Type

Private Declare Function GetLastInputInfo Lib "user32" (lii As LASTINPUTINFO) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long


Private Sub StringDisplay2_Change()
On Error GoTo errHandler

If Application.CurrentUserName Like "*USER" Then Exit Sub

idleTime = GetIdleTime()
If idleTime > IdleLogoutTime Then
    Application.Login "user", "Pr*****5"
End If

Exit Sub

errHandler:
    LogDiagnosticsMessage "VBA Error in StringDisplay2_Change():  " & Hex(Err.Number) & " - " & Err.Description, ftDiagSeverityError

End Sub
Private Function GetIdleTime()
    Dim LastInput As LASTINPUTINFO
    With LastInput
        .cbSize = Len(LastInput)
        Call GetLastInputInfo(LastInput)
        GetIdleTime = (GetTickCount() - .dwTime) / 60000
    End With
End Function

There is a problem: If user "user" is already logged in nothing happens (correct) but if admin is logged the vba runs and logs in the user "user" after 1 minute even when I'm using pc. Any suggestions?
 
I've abandoned the VBA way since I got IdleDetect ActiveX (thanks to crawler009). I put it into the vbaCode Display, in the Enable field I put my condition CurrentUserName()=="admin",
in the Interval field the amount of idle time and in the event "EnterIdleState" the action to login my default user. So when I login with "admin" user, it logs in my default user after the idle time set. Everything works fine! Thanks again!:geek::geek:

Immagine.png Immagine2.jpg
 
Great, glad you got it working.

As to why your VBA didn't work, I suspect that you didn't set "IdleLogoutTime" to a value - it was probably still zero. So when your code executes, it sees that the idle time is greater than zero and logs you out. You just need to set the IdleLogoutTime to a suitable value at display animation start.

But in any case, as you've no doubt discovered, the ActiveX is a much easier way of doing things!
 
1. Create user group. Example "Maintenance"
2. User1, User2, User3 all add under "Maintenance" user goup
3. On runtime security, goto "Maintenance" user group & use this "pause 60;Login DEFAULT DEFAULT" at Login Macro
4. each time User1, User2, User3 login in FTView Client, there will be timer 60sec then will automatically login to default user.
5. Change the name & time base on your application.


đź“šo_O
 

Similar Topics

Hi all, Attached below is an example of what is happening to our existing SCADA. It seems after patching some Rockwell Software that I thought...
Replies
9
Views
261
The client has an application that when communication between the PLC and the Factory Talk VIEW supervisory fails, the object in the supervisory...
Replies
5
Views
224
Hello all, I am looking for a way to have a user get logged out after an X amount of time because to default so that user privilages are no...
Replies
4
Views
506
Hello everybody. I was wondering if there is a way in FTVIEW Studio to close ) view after x min without interaction . My issue is the following...
Replies
2
Views
330
Is there a way to choose the base font in ME. Text in the Arial Unicode MS which is the default font on my FTVS doesnt show up properly on a...
Replies
1
Views
620
Back
Top Bottom