Example Code

Prevent Reconnect Issues with Remote Front Panels and Real-Time

Code and Documents

Attachment

Introduction

When using remote front panels to communicate with a Real-Time target, you may have noticed that if you disconnect your client panel, you might see certain issues with attributes of front panel objects. It is often good programming practice to avoid using property nodes in Real-Time applications, but sometimes it is unavoidable. The reason for that weird behavior is that the active front panel of a Real-Time application changes depending on which client has control. If no clients are connected, then the issue of determining where front panel attributes are saved becomes a headache. In order to get around this type of problem, it is a great idea to store attributes in an additional location in memory, such as functional global variable, as opposed to allowing VI Server to manage all of this data. That's where this code can help. The project is attached and is intended to help demonstrate the issue.

These are screenshots of a functional global variable used to prevent this issue. Attribute settings are stored in the uninitialized shift register for when the VI is called again later to refresh any active or newly connected front panels.

front panel refresher.jpgfront panel refresher 2.jpg

Here is a screenshot of the main VI that calls this functional global variable. The top loop sends a command through a queue to the middle loop. Otherwise, the middle loop will time out. If the command is sent, the "Set" mode of "refresher.vi" is called with a value of 2 (disabled & grayed). If no command is sent, the middle loop times out after 8 seconds and the "Set" mode of "refresher.vi" is called with a value of 0 (enabled). The bottom loop is constantly refreshing the last set attribute to all connected front panels every 2 seconds.

front panel refresher main.jpg

You'll need to adapt this code for your application quite a bit, but the concept will be exactly the same. Once you figure out that your code is working properly, you can decrease timeouts and loop delays so that updates are not noticeable to the operator.

Steps to Run Code

To run this code, you'll need a Real-Time target and you'll need to build both the HTML page and the startup executable.

Additional Notes

Code built in LabVIEW 8.6.1 with LabVIEW Real-Time.

cRIO target in this project is a cRIO 9004

Dan Richards
Certified LabVIEW Developer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors