LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Separate VI for GUI and Main programs: Using global variables to share data

Hi,

Thanks you for all your responses earlier.

 

Continuing from before: I think my predecessors used that structure so they could write a test which they could deploy to a compact rio and leave it running for several days without needing any input from the user desktop/GUI input. The GUI could graphically display some feedback from the CRIO if desired by using Global variables. To stop a test global variables were used to send a stop command to the CRIO.

 

The test I am setting up is shorter in duration (1 hour), again will be deployed/run on a CRIO, but requires frequent inputs from the user from a GUI interface on the desktop. I wish to send commands for test stages, pass/fail, stop etc to the VI on the CRIO from the desktop GUI, and receive some calculations and feedback of progress from that VI back to the GUI interface. 

I have adopted some of the templates you suggested:

-GUI has a producer consumer structure, using a queue. Commands will be written to the queue, and executed accordingly in it's consumer loop.

 

-I'd like the UI to take commands it receives and use a similar queue structure to carry out appropriate actions associated with the test stage etc.

 

The CRIO is connected via ethernet and ni max, and all variables etc on the CRIO can be seen and edited in the labview project.

 

[?] How do you suggest I send commands to the VI on the CRIO without having a risk of race conditions associated with global variables.

I tried using network streams due to their queue capacity, but am struggling to get them working, and it seems like a very complex solution.

 

Thanks in advance for you help.

0 Kudos
Message 11 of 12
(420 Views)

@Curious_Mal wrote:

Continuing from before: I think my predecessors used that structure so they could write a test which they could deploy to a compact rio and leave it running for several days without needing any input from the user desktop/GUI input. The GUI could graphically display some feedback from the CRIO if desired by using Global variables. To stop a test global variables were used to send a stop command to the CRIO.


Ok, now we are talking a completely different setup.  Producer/Consumer, User Events, QMH, etc are for a single executable.  If you are going to talk with a cRIO, then we need to use network protocols.  What you are currently using are Network Published Shared Variables, which I have deemed evil (race conditions not just with your own application, but anybody else on the network; security risk; high latency, even for TCP).  What you should be doing is use TCP/IP primitives or Network Streams to send commands and data back and forth.  This way you can stream data to your GUI and you do not have to poll variables (just wait for data to come in).  Personally, I like to use the STM library, which uses the TPC/IP primitives with some additional framing to make the protocol simple.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 12 of 12
(410 Views)