07-15-2015 06:01 AM
Hello everybody,
I need to produce a tool for an external machine which has to initialize an hardware then communicate with it.
The machine runs its own software and just calls my executables, one for initialize and one for communication.
I cannot do all in the same EXE since the machine has to perform some operations between initialization and communication.
Unfortunately, the initialization VIs that I have use Global Variables to keep initialization data.
This means that everything works properly in Development Env, but when I build the executables I can't communicate since the global variables belongs (I think) to a different context and it seems the hardware was not initialized...
I've read some sections of the forum and it seems I can use TCP to communicate between executions.. Could somebody explain me how?
Can I use different solution? It occurs rarely for me to build applications, so maybe I'm not very expert in this.
Many thanks,
Denise
07-15-2015 06:07 AM
If you use network-published shared variables instead of single-process globals you will be able to read the values over the network. This is the simplest way of doing it and works fairly well if you just want to read the current value of various variables (e.g. as a tag/snapshot of the values).
Of course, if you want to get more complicated you can:
- Use network streams to stream LabVIEW data over TCP/IP
- Use raw TCP/IP (end-to-end connection) or UDP (can do UDP broadcasting) to transmit data over the network
07-15-2015 06:22 AM
Just to be clear, the Initialize and the Communications executables are both running the entire time? If so, then just use the Network Published Shared Variables (NPSV). If not, then you need to save the data to a file. I would use a configuration file.
07-16-2015 01:39 AM
Hello crossrulz,
I'm afraid I will need this file, since the inizialization does not run the entire time..
Thank you both for your answers!
07-16-2015 06:55 AM
denise78 wrote:
The machine runs its own software and just calls my executables, one for initialize and one for communication.
I cannot do all in the same EXE since the machine has to perform some operations between initialization and communication.
Why can't you? There are options to both wait and to call other things using the command prompt (system exec) in LabVIEW. Why wouldn't you build your VI, and later executable, such that it runs the initialization task, calls the other operations (or waits if that's all you're doing), and then starts the communication? Wouldn't this be easier than the balancing act you're trying to accomplish now with multiple EXEs to perform the same task?
07-16-2015 06:59 AM
You can still use Network Shared Variables even if Init.EXE and Compute.EXE run not at the same time. The key is where the variables are hosted -- if they are hosted on your PC, then they "live" there, retain their values, and can be read and written by Init and Compute at will.
That having been said, it is certainly easier to use Windows to browse to "My Settings.ini" and use Notepad to read the file, examine the settings, then change them (and easier to tell a colleague how to do this) than to go looking for NI's Distributed Systems Manager to examine NSVs.
Bob Schor
07-21-2015 01:16 AM
In fact this is the solution I adopted in the end, since nothing else worked.
Shared variables seems not to be available in LabVIEW 7.1 (I am working on an old product) and I had no idea about how to do with TCP..
So I built all in the same exe, it initializes, it waits and then it continues, and it seems working in the development machine.
I used external files to perform syncronization.. yes, it was the simplest solution.
Thank you,
Denise