LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting access on remote panels

Since you cannot limit the number of people able to view a remote front panel (I am under the assumption that either everyone can view the panel or no one can), I am trying to come up with a way to only allow one person to control and VIEW the remote panel.  I think it might be possible to create an "access" VI that will redirect a user to the experiment VI if no one else is using it or not allow them to access the experiment VI if someone else is using it at the time.  Is it possible for one remote panel to tell if another remote panel is being accessed, and if so, can a remote panel link you to another remote panel?
0 Kudos
Message 1 of 10
(3,682 Views)

I haven't tried this, but you can try using 2 Application class properties to control this.

Place a property node (Application Control palette) on the diagram and select the Remote Panel>>Connections to Clients property.
This will tell you if you have someone is connected to the VI.

Once you detect someone is connected, you can try using the Web Server>>TCP/IP Access List property to only allow the connected IP address to be connected.

Once you detect there are no more connections, you can allow all the clients to connect again.


___________________
Try to take over the world!
Message 2 of 10
(3,667 Views)

I am very new to LabVIEW, so what you wrote makes sense logically, but I'm not really sure how to implement it.  I have placed the two property nodes on the VI, but how do I wire them?  Thank you for your time.

-Tek

0 Kudos
Message 3 of 10
(3,648 Views)

I don't have LV in front of me at the moment, so I will do this from memory.

The first property, if memory serves, is an array of clusters. Each cluster holds the details for one active connection. You need to place it in a loop with a wait to periodically (let's say once a second) check if there is a connection to your VI. You can do this by wiring the array into a for loop, wiring the resulting cluster into an unbundle node and read the VI name and the IP address fields of the cluster.

If the VI name is identical to the VI you want to block, you need to take the IP address and wire it into the second property. I'm not sure about the exact way you need to feed it in (right click the property name and select Help for... to get a description of it. This will block access to the VI to all other callers. Now, go back to the part where you read the first property. Once the connection stops, use the second property to allow all connections (you probably need to wire * into it).

You can probably do this in a single loop where the first part executes all the time and the second part is in a case structure and only executes when there is a change. You can't detect changes by right clicking the loop wall and adding a shift register, which allows you to pass data from one iteration to the next.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 4 of 10
(3,639 Views)

First, thank you for your help so far.  I think things are working pretty well exept the part to check if there is a connection to my VI.  You said I could "place it in a loop with a wait to periodically check if there is a connection to the VI."  I put everything in a for loop with a "wait until next ms multiple" and have wired a very large constant to the for loop (so that it would continue to execute loops for a long time...would a while loop be better?).  My actions were based on the thought that the for loop would execute after each ms multiple and therefore update the data in the remote panel connection to client property node; however, when I run the VI remotely and view the progress on the server computer, the data updates the first time the client connects but not when he releases control of the VI.  Therefore, it appears that the client is accessing the VI all the time, even when he has already cosed the web page.  The property node only updates when a new user gains control of the VI.  Obviously I need some help, but I'm not sure where.  Can you come to save the day again?

-Tek

 

0 Kudos
Message 5 of 10
(3,620 Views)

First of all, a for loop is a conceptually wrong solution in this case. A for loop should be used when you (or the program) know the number of times the loop will run before entering the loop. In all other cases, you should use a while loop. You should stop the while loop with the rest of program (properly closing a program by ending all the code and not by aborting is important). You really should read the tutorials I linked to.

Second, what you're saying doesn't sound right. I can't test this at the moment, but it seems to me that the array should be empty once the user disconnected. I suggest you post the VI, and it will hopefully be much easier to help.


___________________
Try to take over the world!
Message 6 of 10
(3,613 Views)
Okay I've made a few changes, but now the array does not update at all.  I have attached the VI, but note that it is a work in progress.  I have not made all of the property node connections because right now I am simply looking at the display indicator to see if it updates the array when a user accesses and ends the VI.
 
-Tek
0 Kudos
Message 7 of 10
(3,600 Views)

The way you have it set up is basically correct, but I'll make some comments before explaining the problem.

First, don't use clusters functions to process arrays. If you want to get the first element of the array, use Index Array (as it is or with a 0 wired into the index input).

Second, maybe it's just me, but I don't like the icon displays for the terminals (takes too much diagram space and doesn't really help). You can switch it with a right click for each terminal or disable it in the options menu competely. On the same note, the wire should continue straight to the Array function, and have an extension going up to the indicator, instead of taking a detour through the indicator. It just looks better and is clearer to read. You really should look at those tutorials and the style guide.

Third, your timeout case isn't necessary. A timeout case should only be used if you have code that you need to execute if no event has occured. You can simply delete the timeout and delete the case. To stop the loop, simply add an event for the stop button and wire T only out of that case. As a side point, there is no point in having a 100 ms wait if you are already waiting the 10 ms of the timeout.

Now, to the problem.

The indicator isn't being updated because the loop isn't running, and the loop isn't running because you wired the stop condition from the top loop into the bottom loop. This means (the biggest rule of dataflow programming) that the top loop will have to complete before that information will be available, which means the bottom loop will only start running after the top loop. To debug and know if your loops are running, create an indicator for the i terminal or use a probe on wires inside the area you need to check.

What you need to do is cut the loops. The easiest way is to place the stop control in the bottom loop and to use a value change event to stop the top loop. If you have more than 2 loops, it's usually easiest to create a local variable (you will need to change the mechanical action for the boolean control).

Once you did this it should work and my quick test (on the same computer) shows that the array is updated as soon as the browser goes to another page.


___________________
Try to take over the world!
Message 8 of 10
(3,592 Views)

Thank you for your help and suggestions.  The links you sent were also helpful.  I now have a better understanding of how everything in my VI is running, and the connection to clients array does update as you suspected it should, but after all that, I may not be able to use that property node as I hoped I'd be able to.  The array only updates when the VI is running.  If the initial user accesses the page, the array only updates after he presses the run arrow.  If the user presses the stop button, the array does not update because the loop has ended.  If the user simply closes the window without pressing stop first, the array does update because the VI is still running.  So unless there is a way to start running the VI immediately and automatically when the user gains access to the page and exit the page, update the array, and stop running the VI in that order automatically, I see several problems with the way it is working now since I want to be able to limit the access to the remote front panel to one colltroller and no viewers at a time.

-Tek

0 Kudos
Message 9 of 10
(3,581 Views)

Remember your suggestion from the first post about creating an "access" VI?

Well, that's what you can do here. Simply run the loop with the property nodes in a competely different VI, which does not even need to be visible to the local user. That VI can detect the connection and do the blocking just as well as your VI. There are various ways to set it to run automatically.

As another point, you should probably set your own VI to run automatically and not allow remote users to stop it. You can do this by going to File>>VI Properties>>Window Appearance or Execution. You can disable the stop button using a property node if you detect someone has connected to the VI.

You can also set the VI to run automatically by building the entire thing into an executable (if you have the application builder).


___________________
Try to take over the world!
Message 10 of 10
(3,569 Views)