LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication Between Multiple Executables

I'm building a system that needs to communicate with several different external executables (all were programmed in LabVIEW) at approximately the same time.  I say several because this number is not known until runtime, and I say approximately the same time because all of the executables will be communicating asynchronously.  Essentially I need to receive commands from each executable, put them in a queue of some sort, run a test with my system in the order the commands were received, and then send a result back to each executable.

 

Because the number of external executables is not known until runtime, I was thinking about using a network published variable that would be an array of clusters.  I could then tell each executable which array element it should use to communicate with and then when data needs to be sent back and forth I could update or read from this array element in each executable as necessary.  In my VI, I would simply build a watcher that would constantly watch the array to see if new data came in, put this data in a queue, and then process it as necessary.  The communication back to the executables would be handled in the same way (perhaps with a second network published variable only to be used for results).

 

The problem with this approach is that I would need to lock the network published variable (a functional global would really help here) while I'm writing to it from each of the executables so I could be sure that I wouldn't miss data.  The number of commands won't be high, but there is a chance that 2 commands could arrive at the same time.  I've played around with this in the Shared Variable Properties dialog ("Single Writer" and "Use Buffering"), but can't seem to get it right.

 

I know that I could open a TCP communication port for each executable and then use that port to communicate directly between my program and the executable, but I was wondering if anyone had any other suggestions.  If you've got a suggestion, I'd love to hear about it.  Thanks.

0 Kudos
Message 1 of 10
(5,652 Views)

This is a difficult question to answer without knowing the entire problem.  Are all the executable running on the same computr or is it a distributed system?  If on the same computer then you have more options available.

 

If on the same computer I typically use TCP or shared variables (not network published).  

 

Have you looked at Network Streams?

http://www.ni.com/white-paper/12267/en

 

Just a few ideas.  There are many ways to solve the problem.  Let us know if you are running on one computer or many and how many.

 

Matt

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 10
(5,634 Views)

Matt, thanks for your response.  Unfortunately this is a distributed system.  I'm being asked to add functionality to a system that is already in place and I can only make minimal changes to the original executables (eg a link to a variable/TCP).

 

For a more complete picture, basically what I'm dealing with is an end of line machine that does functional testing of our products.  During the end of line test, we want to add a check of the noise characteristics of the product, but this can't be easily integrated into the source code of the end of line.  Instead we want to send a command from the end of line cell to the noise system that signals that it should start measuring and do the analysis.  The maximum number of PCs I will be dealing with is 4, but most of the time there will only be communication between 2 computers, the end of line computer and the computer running the noise test.

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

Would creating independent network streams work well for this application?  With independent streams you don't have to worry about PC stepping on each others messages.  Let me know if this is an acceptable solution or looking for something different.

 

Matt

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 4 of 10
(5,609 Views)

Matt,

 

I think network streaming is an option, but it's probably unnecessary since I'm only sending commands and not data.  I've already got something working with TCP/IP.  Basically I have a transmitter and a receiver on the EOL station and I have a transmitter and receiver in my program.  The transmitters and receivers are using different ports.   When I want to send a command from the EOL, I send it and wait for a response from my program to indicate that the command was received.  I do the same thing when I want to send a command from the program back to the EOL.  I also have a timeout command that is sent every second to indicate that communication is still taking place between the two.  This should be easy to scale up because I can just change the port for each station.  It also works when the programs are running on different machines and when they are running on the same machine which is nice.

 

If you can see any holes in this theory let me know, but otherwise I'll just go with this approach.  Thanks for your suggestions.

0 Kudos
Message 5 of 10
(5,572 Views)

You could set up a web service to which you send your commands which would work as a queue, the consumer could then read this queue.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 10
(5,555 Views)

You can use a network queue. The attached code works very well for us. It is a modified version from some code I got from LAVA several years back. Just unzip this file into your user.lib directly. The queues work like normal queues except they work over TCP. This means your messages will be added to the receiving queue in the order they were sent. Simply dequeue the commands and execute them.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 10
(5,529 Views)

Mark,

 

Thanks for the code.  I had some problems opening it because I'm missing the TCP_NoDelay.vi from the TCP_NODELAY.llb file, but if I remove the calls to this VI I can open it without a problem.  I hope this isn't a critical part of the functions.

 

I'm still trying out some different things, so I'm not sure which way I'm going to go with this.  I'll update the message when I figure it out.  Thanks everyone for your help.

0 Kudos
Message 8 of 10
(5,495 Views)

Sorry about that. Here is the other library.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 10
(5,482 Views)

Sorry got it solved....

 

0 Kudos
Message 10 of 10
(2,555 Views)