From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two independant programs running simultaneously

Hello all,

I have written two independant LabVIEW 6.0 programs that I would like to execute at the same time.

One is a Frequency Stability test and the other a Power Stability test.

Both programs write data to Microsoft Excel files using ActiveX automation.

Problems occur when both programs access excel at the same time. I would like to avoid this occuring.

In both programs, the code which calls ActiveX is isolated. These subVIs are called "Freq Stability Flush Data" and "Power Stability Flush Data" respectively.

Is there a method by which I can ensure that only 1 of these subVIs are executed at the one time. If I set their execution priorities to "time critical priority (highest)", will this ensure that only one of these subVIs will execute at a given time.

The ideal situation is that if while Frequency stability "Flush Data" is executing the "Power Stability Flush Data" is called, it will wait until "Freq Stability Flush Data" completes.


I am trying to avoid writing a single LabVIEW program to include code from both programs.

Thank you greatly.

Sincerly,

Dean
0 Kudos
Message 1 of 4
(2,532 Views)
I'm sure other people will give you a more elegant solution but I'll start with the obvious.

To synchronize this type of setup you need to share memory somehow. The easiest way obviously is to build the two programs together but as you've already stated you'd rather not do that.

The first kluge is to use a fixed temporary file on disk. That's about the slowest and worst way I can think of. You can use the file like a semaphore in essence.

A second way is to use a DLL. There is code floating around (I've seen it recently but can't remember where) that will let you share memory using a DLL. This is still a bit of a kluge as you have to check the memory repeatedly until it clears and gives your routine access to write.

A third way is to have a way of notifying the applications involved of the events as they are happening, or a way of querying each other if there are only two of them for example. I imagine you could use a network protocol to localhost (UDP or TCP/IP) to easily communicate between programs. Something I've messed with a little bit in this arena (but never to the point of complete functionality) is creating a Win2k/XP service that runs in the background and can provide services to your applications that are running. You can find examples on that by searching.

I'm interested in hearing some more elegant solutions on this idea.
0 Kudos
Message 2 of 4
(2,527 Views)
I dont know if this is going to be an elegant one !...but you can try this...

It seems the underlying problem is calling excel simultaneously, which has to be avoided.

One way to achieve this could be to have a common VI which writes data to excel using ActiveX. This VI could be as simple as having a case structure which selects appropriate case (Freq. Stability Test or Power Stavility Test) and write corresponding data to excel file. The case structure can be passed the right input by making use of Queues.

Now even if both the programs are independent, Queue is common between them. Also Since data is written in one VI using case structure, there will not be any conflict. It may be required to store data temporarily, before the queue actually selects the correct case.

Hope this helps.

JC
0 Kudos
Message 3 of 4
(2,520 Views)
Thank you for the response J.A.C.

I agree that having a single VI to do the job of writing to excel for both programs is advantageous.

However, if I were to create an application (i.e. an .exe file) (using the application builder), these two programs would no longer be accessing a shared VI, am i correct? If that is the case, then both .exe programs could access excel simultaneously.

It appears that the easiest way, and most assured way, is to amalgamate both programs into a single program. However, as I mentioned before, this is not the ideal situation. I would like to keep the programs separate.

It would be great to hear more responses. Thank you to everyone who has responded thus far.

Dean.
0 Kudos
Message 4 of 4
(2,516 Views)