10-26-2011 03:44 PM
I need to create networked shared variables programmatically so I use the DSC Create Shared Variable.vi, which returns a SharedVariableIO reference. Next I need to read and write the shared variable. I could do that with the Read Variable/Write Variable functions, but those functions take a reference to an object of Variable class.
How do I get from a SharedVariableIO ref to a Variable ref?
Alternatively, is there a different mechanism for reading/writing SVs using a SharedVariableIO reference?
10-28-2011 01:51 AM
There are a number of examples to do exactly what you are talking about. Here are links to a few of them:
https://decibel.ni.com/content/docs/DOC-15518
http://zone.ni.com/devzone/cda/epd/p/id/6017
https://decibel.ni.com/content/docs/DOC-3079
You can also search our developer zones for other examples here:
http://zone.ni.com/dzhp/app/main
If after looking through these examples you still have questions please reply.
Thanks,
Jacob K
10-28-2011 08:20 PM
I programatically create (Add Variable Connection.vi) and destroy (Delete Variable Connection.vi) Shared Variables using these subVIs. But it seems to take a long time to run each subVI. This might be tolerable for a single Shared Variable, but it gets rather lengthy if several need to be created or destroyed. The user specifies how many depending on how they are using the application; in other words, they don't necessarily know how many they are creating or destroying. Is there a more efficient way of doing this?
Also, after a Share Variable is "created," it can take a while before it is usable for reading and writing in another part of the application. Is there a way to determine a Share Variable is ready prior to using Search Variable Container and Open Variable Connection functions to find and use it?
10-31-2011 04:54 PM
Because you are churning through many shared variables dynamically it can be expected to take some time. One error I did notice is that you are using an open application vi but not any close application to go with it. That should improve your performance.
Jacob K
11-07-2011 07:17 PM
Thank you for the reply. It will be a few weeks until I can get back to this issue. I'll follow up when I've studied the examples you suggest.
Mark Z.
11-08-2011 04:05 PM
I have 1000 parameters. I have x number of users that each can examine up to 400 parameters a piece. Multiple users can be examining the same parameter. Since programmatically adding and deleting connections seems to take so much time, would creating all 1000 connections at the start of the application and deleting them at the end of the application be the most efficient use of CPU time?
11-10-2011 01:05 AM
Creating all of the parameters (I assume you mean shared variables) at start up would free processing time but it will use more memory if you do not need all 1000 variables. Many times it is necessary to initialize the variables as well. Here is a link to another tutorial that describes in great detail how to work with shared variables:
http://zone.ni.com/devzone/cda/tut/p/id/4679
It looks as though you are on the right track.