VB Code in FactoryTalk View SE

travisroberts88

Lifetime Supporting Member
Join Date
Aug 2017
Location
Navarre, Ohio
Posts
34
I have a plant with multiple areas, users, codes, etc. I have an auto logout command that triggers if a supervisor logs in and walks away. I use the RSView Idle Detect Active X Event.
As it stands right now, when the plant adds an HMI, I have to update the code on EVERY SINGLE DISPLAY. I'm not talking a handful, I'm talking almost 500 displays.
Any Rockwell reccommended thing for auto logout/login never worked. Here is my code to start:

Private Sub RSView32SEIdleDetectControl1_EnterIdleState() 'ActiveX Control Command for Idle time.

Dim compname As String 'Declaring compname As a String.
compname = Environ$("computername") 'we use the Windows environment variable "computername" to resolve the name of the device' that's running our code. It is accessed via the Environ$(string environmentVariableName) function.

Select Case compname 'compname Select Case statements.

Case "4HEAD-HMI" 'This is the 4 Head Labeler HMI.

Select Case CurrentUserName() 'Grabbing current user.
Case "supv" 'For when user "supv" is logged in.
Application.Login "operatorX", "operatorX" 'Application executing the login for user "operatorX."
Case Else
End Select

So the breakdown is really this. The Active X event is the Sub. We delcare compname as the computer name (HMI IPCs) and the compname is a windows environment variable to resolve the device that is running the code. We then are using case statements for each individual HMI. This is done because the supervisor could log in at any HMI and go to any screen, so the code has to have every single HMI name on every single display.

I've tried having a hidden display that would house the code for all the HMIs and commands. Then have the displays call that function, then I would only need to edit 1 display, not 500. I have roughly 50 HMIs at the time, and more adding constantly. I also have 10 users for the different areas in the plant in the SE environment, all with different user codes.

I only copied one HMIs code, but it is repeated for individual cases of HMIs up to all 50, utilizing the 10 users through the plant.

What I need is a way for ALL displays to call one global function or one display that always stays active. Then when I add an HMI I just have to edit the VBA code on one display, not 500.

I hope this makes sense, if you need me to try and explain differently please let me know and I can try to!
 
I dont really follow you, sorry.
Why doesnt it work if you have this vba code on one display that is always active, maybe in the background? We do something similar and it works. For that we use a header, but we could also use the "menu bar".

Shared vba code is sadly not possible across differnt screens.

And for the different "supervisors" you could make a group, and check if someone of that group is logged on, instead of checking/updating every username on every display.

Or maybe i understood something wrong.
 
The shared VBA code not being able to go across multiple displays is what I was afraid of. I would need a "master" code that over 500 displays call to across 50+ HMIs. Cache on the display won't work.
I'll try to elaborate more.
-A supervisor can log in on any HMI in the plant.
-Certain user groups have access to certain areas. Since this is SE with a menu navigation so you cannot isolate areas without user codes. Some are legacy some are new so making a header wouldn't work for some things.
- I am trying to avoid having to make a display loads with with each other display to try and "trick it" as the issues with legacy layouts and new layouts. Really I am trying to avoid having to create a header or status screen to have the login on. If I were to do this I would have to rely on other people making sure they add this load to any future screen they make. However, it seems more so daily that I am going to have to figure something like that out.
-If a supervisor logs in back in injection molding to access the filler screens and then walks away, that HMI needs to log back in as injection molding, so therefore the code has to be on any and all screens a supervisor can access (all of them, yes around 500).
-If having a "hidden display" running in the background or a header is the only way that is really going to suck.

It is incredibly stupid if in the VBA code you can't have a Public Sub with a globally accessible action that other screens "call" to that Public Sub. I guess it just shows how Rockwell doesn't really taking into consideration things that could make your life easier.

What I really want is something like this:


Public Sub RSView32SEIdleDetectControl1_EnterIdleState()
'ActiveX Control Command for Idle time.


Dim compname As String
'Declaring compname As a String.
compname = Environ$("computername")
'we use the Windows environment variable "computername" to resolve the name of the device' that's running our code. It is accessed via the Environ$(string environmentVariableName) function.

Select Case compname
'compname Select Case statements.

Case "4HEAD-HMI" 'This is the 4 Head Labeler HMI.

Select Case CurrentUserName() 'Grabbing current user.
Case "supv" 'For when user "supv" is logged in.
Application.Login "operatorX", "operatorX" 'Application executing the login for user "operatorX."
Case Else
End Select

----

Any other display

A routine to call the master CodeDisplay routine.


----

Essentially this would create a global set of code for logins for all users and groups if a supervisor is logged in no matter where in the plant. Then any other display calls the code.


-------

Since it seems like I cannot do that I am pulling any other options that I can try so other ideas help as well unless someone has an idea how to do this global public sub.
 
You can actually use VBA from another display, something like:

Call Application.LoadedDisplays(MyVBADisplay).IsSupervisor

I've never tried returning a variable from a remote module, as in:

bolSuper = application.loadeddisplays(MyVBADisplay).IsSupervisor

but it would be worth a try.
 

Similar Topics

Hi, I have a question regarding FactoryTalk view studio. I have a page with bunch of editable variables and it works perfectly, it means that as...
Replies
1
Views
4,819
Hi Friends, I have a problem in getting data from a barcode scanner in to my FTView SE scada. Basically, I am new to this and haven't done this...
Replies
10
Views
5,859
Hi - Recently, I upgraded the firmware on a PanelView Plus 1000 to V 5.10.10; I think it was V 4. This meant that I needed to update the .MER...
Replies
3
Views
3,565
Hi all, First time poster. I am having some issues getting some VBA code to copy over to FactoryTalk in hopes of displaying a screen for a...
Replies
6
Views
13,528
Hello guys, can anyone help me with FactoryTalk View Studio. I need to use a Global Object that contains VBA Macros in different displays, but it...
Replies
1
Views
1,635
Back
Top Bottom