LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Share Global Variables data between two separate programs in one machine

Hi all,

I would like Program A to retrieve data from program B. Should my global variables have the same name?

Please provide guidance and explaination in doing it.

Much appreciated,
keng
0 Kudos
Message 1 of 5
(3,306 Views)
Hi keng,

you cannot access global variables from program B in program A if the programs are really different executables.
You can do this if the programs run in the same instance and the programs consists of two VI hirarchies. In this case the global variables must have the same name.
Transfering data from one program to another must always use some interprocess communication. There are some methods to do this:
- Data Socket Server
- TCP/IP network communication
- VI server methods
You can find ready to use examples in LabVIEW under Find Examples >> Networking or Find Examples >> Progamatically controling VIs

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 5
(3,306 Views)
Hi Waldemar,

Thanks for explaining. Could you please clearify with me again?

When you say the programs must consist of two hirarchies, do you mean that the program A and Program B must be in the same executable (or one executable) in order to share the same name global variables?

In my scenario, the program A needs to retrieve data from program B because the data is required for calculation in program A.

Program B can be just a retrieving data program but I also don't want to limit my options to expand program B capabilities.

At the moment, the data is transfered within the same machine.

In your opinion, which method of inteprocess communication would you suggest for my requirement?

Thank you,
keng
0 Kudos
Message 3 of 5
(3,306 Views)
Hi Waldemar,

Let me rephrase my question.

If I want to create two separate programs (two execs.) and to share data in one machine, would the VI server be the appropiate methods to use?

Regards,
keng
0 Kudos
Message 4 of 5
(3,306 Views)
To choose the better method you must consider following:
If program A and B are alternatively doing their work (A is working B waits and vice versa) VI server is the easiest method to implement. You need to set some parameters with "Set Control Value", then let the VI run and read the the data with "Get Control Value". Now you can do your calculations.
If the programs would do their work in parallel you can only use the TCP/IP or DataSocket solution. With them you can retrieve data with program B send them to program A which will do the calculations. Depending on the time each program needs it can be neccessary to handshake between the programs to avoid loss of data. We have done this in the following way: Create a named queue which will
have a strict typedef datatype to hold (LV6.1) or the flattened string (LV6.0.2). With VI server we started a VI which also creates this queue. This VI waits an unlimited time for reading an element. If an element is read the element is send over TCP/IP and the VI now waits for an answer from the other program. If the answer comes it waits for the next element. Ending the program the queue will be destroyed and the read will end with an error. In this case the VI will stop running. If you are not sure that program A will always answer (someone killed it with the task manager (windows) or the kill command(UNIX)) you have to do some error handling during the wait for the answer too.

In the case of global variables the programs must be in the same executable.

Sorry for my late response but 1st May is a holiday (Feiertag) in Germany so I had 4 free days.
Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 5 of 5
(3,306 Views)