LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Do I have to Bind Shared Variables in Executables?

I want to have shared variables work between two executables that will be installed on seperate machines.  I've managed to get the code working, but am not satisfied with the approach.
Attached is a .zip file with my project files that contain what I've been able to get to work.

What I don't like, is how I need to have double the amount of network variables.  Right now I have a program that is a publisher and another is a subscriber (based on an example provided on this forum at some point).  The Publisher has its own shared variables inside a library, and the subscriber has its own shared variables inside a different library.  The Subscriber's shared variables are "bound" to the Publisher's shared variables in the project file and is a concrete physical network path that cannot be changed.

Once the executable is made and installed, this works.  I've tried getting it to work w/o one of the executables using a shared variable library that contain bound shared variables through a concrete physical network path but I obviously do not know what I am doing.  Ultimatly, I would like to have a single shared variable library that both the publisher and subscriber use.  I want the publisher executable to post the variables to the variable manager running on the publishers machine, and then have the subscriber program running on the subscriber's machine to consume the shared variables from the variable manager on the publisher's machine.

Please help me!

:S 😐 :).

-Nic
0 Kudos
Message 1 of 13
(6,722 Views)
Woops...i forgot to attach my file. 
0 Kudos
Message 2 of 13
(6,721 Views)
Well, according to http://zone.ni.com/devzone/cda/tut/p/id/5715 I have to have a seperate library of variables that are bound to a specific computer/library/shared variable.  The only apparent way to do this is to build a concrete network path in the dialog box provided to create the link between source data and sink data.

I wish there were more flexibility at runtime as to what the host machine's networking address is.  Is there anyway to progmatically set the host name for the bound to variables?

This is undesirable, but here is my current work around:

  • Bind the variables in the subscriber's library to a deployed publisher's library variable through the browse interface.
  • Change the network path from '\\<actual_computer_name\Library\Variable' to '\\lvsvhost\Library\Variable'.  lvsvhost = labview shared variable host
  • Once deployed to all the machines, add an entry to C:\Windows\system32\drivers\etc\hosts that points the name 'lvsvhost' to the IP address of the actual publisher of the variables.  I'm not sure, but you may be able to link to the host name.... i need to try it out.
Another option is to have access to your companies DNS server (which i'm currently working on :P).

Does anyone know of a more graceful solution (while staying in the scope of shared variables)?

What would be more ideal would either be to set the bindings up progmatically... which according to: http://digital.ni.com/public.nsf/websearch/2E8BAD0EA218A7558625712E0003F044?OpenDocument is only possible with the DataLogging LabVIEW module which I do not currently have.  A slightly less ideal solution would be to trick the tcp layer in labview into catching "lvsvhost" and pointing it to the actual host at runtime.

Thanks for your time.
-Nic
0 Kudos
Message 3 of 13
(6,697 Views)

Hey Nickerbocker,

The Knowledge base you found was an article that I was also looking at.  It looks like if you had the DSC module, you could accomplish what you are looking for.  Are looking to possibly acquire the DSC module?

I will see if I can find any documentation that can help you out.

Regards,

Kevin H

National Instruments
WSN/Wireless DAQ Product Support Engineer
0 Kudos
Message 4 of 13
(6,687 Views)
I do not know much about the DSC module.  Upon looking into it, it appears that the DSC module is targetting really large scale plant operations while we are a relativly small scale operation :|.  I'd have a hard time justifying the cost of the DSC module for this one feature that I need.

Using a DNS alias to set the address of the primary shared variable location works for me and will be what I use for now.  It is a shame that a more programmable solution does not exist.  Especially for developers who package and sell the software they develop in their developers suite as they really can't utilize shared network variables for their product unless they are able to setup the host locations at runtime or provide extraneous install procedures that involve DNS entries or hosts file modifications.  Smiley Sad

-Nic
0 Kudos
Message 5 of 13
(6,677 Views)
Isn't it possible to use datasocket open, read and write to communicate with a shared variable on another computer using the psp:// protocol?
 
If so, the path to the shared variable could be created in the string to the datasocket open.
0 Kudos
Message 6 of 13
(6,674 Views)
Yes it does appear that you can at least consume variables on a host progmatically.  I've played around with doing this progmatically and trying to make a decision on whether or not to go that route for my application. 

I have some questions and would like to have a discussion regarding these points.  So please put in your two cents if you have them.

  • If you use the DataSocket API to connect to a variable that resides on another machine, is your local machine's variable engine involved at all?
    • If the application is setup to deploy a library of shared variables that are bound to a particular host, it appears that the installed variable engine is what does the bindings and handles the network communciation.  Meanwhile, your application consumes the information from the local variable engine.
    • If the Variable Engine is not used locally, does it need to be included with your application installer?
    • If I'm correct, whats better?  To use the variable engine locally, or to connect directly to a remote variable engine?
  • The default time-out on the DataSocket Read vi is 10 seconds.  If you are doing multiple DataSocket reads in the same polling loop, one variable may update but the other datasocket read is waiting for its timeout before allowing the loop to itterate.  This creates a really laggy scenario (see progmatic subscriber.vi in the attached .zip).  Setting the timeout to something low, say 10msecs, reduce the "lag" but...
    • Having the ability to set a decent time-out is a really nice performance feature that isn't availabe to you when you Bind to a shared variable (I don't think).  It may make performance since to not do any loop iterations until the data from the host has changed.... how to manage this w/o seperating each read into its own loop however is my question.... ???
  • Is there any unseen advantages with using the National Instrument's Shared Variable API over the DataSockets API?
Thanks for input.

-Nic

0 Kudos
Message 7 of 13
(6,547 Views)
Woops...forgot to attach my example project.
0 Kudos
Message 8 of 13
(6,546 Views)
Hey Nic,
 
I am going to try and answer those questions for you.
 
  • If you use the DataSocket API to connect to a variable that resides on another machine, is your local machine's variable engine involved at all?

No, it should not be involved at all.

  • If the Variable Engine is not used locally, does it need to be included with your application installer?

Yes, it is going to need to included with the installer.

  • If I'm correct, whats better?  To use the variable engine locally, or to connect directly to a remote variable engine?

Can you please give a little more information here?  I'm not quite sure if I understand your question.

  • The default time-out on the DataSocket Read vi is 10 seconds.  If you are doing multiple DataSocket reads in the same polling loop, one variable may update but the other datasocket read is waiting for its timeout before allowing the loop to itterate.  This creates a really laggy scenario (see progmatic subscriber.vi in the attached .zip).  Setting the timeout to something low, say 10msecs, reduce the "lag" but...
  • Having the ability to set a decent time-out is a really nice performance feature that isn't availabe to you when you Bind to a shared variable (I don't think).  It may make performance since to not do any loop iterations until the data from the host has changed.... how to manage this w/o seperating each read into its own loop however is my question.... ???

Can you please explain this a little more as well?  If I understand you correctly, it sounds like you have many datasockets open in one while loop.  Are you using one datasocket per variable?

  • Is there any unseen advantages with using the National Instrument's Shared Variable API over the DataSockets API?

Shared variables are in general more easier to use, and provide a simple way to implement the idea of passing data between machines.  Obviously, using TCP, you can create more control using your own protocol to exchange information, but in general, Shared Variables are normally just easier to use.

 

Feel free to post any questions or dicussion issues here.

 

Regards,

Kevin H

National Instruments
WSN/Wireless DAQ Product Support Engineer
0 Kudos
Message 9 of 13
(6,491 Views)
Hey Nic,

I think we met the same problems with shared variables...
I posted something about that yesterday.
http://forums.ni.com/ni/board/message?board.id=170&thread.id=29109
You can probably use the same solution as me (one executable do the deployment of the shared variable programatically, and other executables just have to put the IP adress of the deployment computer in the "psp://ipadress/lvlibname/variablename"). Things worked for me and you can ask questions about it. I share your view that this is a good solution for small applications like ours.

If you find out how to solve my buffering problem... would be nice !

Bo
0 Kudos
Message 10 of 13
(6,347 Views)