LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between Shared Variable Refnum and Control

Dabbing my toes in Shared Variables for another project.  Glad to see A LOT more support from NI in terms of Shared Variables (especially now that built executables can be set to automatically deploy shared variable libraries...thats a big help).

 

In the Shared Variable block diagram palette (under Data Communication) there are a number of VIs that can be used to progmatically access and consume shared variables.  Awesome.  One thing that I have noticed is there is a difference between a "Shared Variable Control" (from the I/O front panel palette) and the "Shared Variable Refnum In" that you obtain from right-clicking one of the VIs from the Shared Variable palette and selected "Create Control".

 

My first thought was that these two were one and the same, but they are not.  Visually they look different:

shared variable 0.png

 

Also, the reference input to the VIs in the Shared Variable palette only take the "shared variable refnum" control as input.  The control from the "I/O" palette does not work.

shared variable 1.png

 

This wouldn't be much of a problem, but I prefer the look of the Silver Shared Variable Control much more to the control I get from the "Create->Control".  Also, the variable browser in the Shared Variable Control is A LOT nicer than the control refnum gives me.

 

Here is the Shared Variable refnum variable browser:

shared variable 2.png


Here is the much nicer looking browser that pops up from the Shared Variable Control:

shared variable 3.png

 

So I guess my questions are:

 

Why are there two reference data types that seemingly perform the same function but are incompatible with one another in LabVIEW?

How can I use the Shared Variable Control with the Shared Variable palette VIs?

 

Thanks for your input.

 

 

0 Kudos
Message 1 of 13
(7,018 Views)

I can't figure out if there is anything I can do with this Shared Variable Control.  Any ideas why the properties and methods of this control are greyed out?  Thank you for your time and input.  LV 2012 SP1

 

shared variable 4.png

0 Kudos
Message 2 of 13
(6,993 Views)

Do you have the DSC module?

 

I have the DSC module and that is where I see the shared variable constant, which I can turn into a control.  When I right click, I have the Create Method greyed out, but Create Property is not greyed out and there are a number of properties from there I can pick.

0 Kudos
Message 3 of 13
(6,989 Views)

Hi RavensFan - No I don't have a DSC Module.  Not sure how the two would be related, but the Shared Variable Control has no function that I can find in LabVIEW... the most I seem to be able to do with it is run it through a Flatten to String and use that string as an address to get to a PSP variable...

0 Kudos
Message 4 of 13
(6,966 Views)

I mentioned it because I saw the Shared Variable Constant on the DSC palette.  (Data and Supervisory Control).  (See attached).  When I turn that constant into a control, it seems to be the same data type shown in your diagram.  It does have some relationship to the DSC module because the DSC module adds enhancements to shared variables such as logging and alarms.

 

The shared variable to string and string to shared variable on the same top line of that palette all connect to the shared variable control/constant.  Beyond that, I don't know what else they would connect to.

 

I'm curious to find out what the answer to your original question is on how the SV control and the SV refnum are related and how each are used.

Message 5 of 13
(6,963 Views)

Yeah.  I suspect that NI intended the Shared Variable Control to replace the refnum but it was someones incomplete thought.

 

I guess I'll just use the old-style control and browser until it gets fixed.  Unless I'm missing something, I'll just assume that this is a bug.  It would be nice if an application engineer from NI would chime in 😉

0 Kudos
Message 6 of 13
(6,946 Views)

Hello Nickerbocker,

 

You actually want to use the Shared Variable Control in the context of Alarms, I/O Servers and other categories inside the DSC Module. Like you already saw, to use the basic functionality of a Shared Variable, such as programmatically reading / writing to it, you need to use a refnum.

 

Shared variables.PNG

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 7 of 13
(6,932 Views)

I see.  It might make sense then to only include it with the DSC module and not in the base installation.  Any chance of getting a "Silver" control for the Shared Variable Refnum?

0 Kudos
Message 8 of 13
(6,921 Views)

Fair enough. I created CAR # 401668 to have the SV control appear under the DSC Module palette, and not under the I/O controls palette, which is a good point. Regarding the Silver control for the Shared Variable Refnum, I'm not really sure why it's not on the Silver palette. However, you can always post it as a suggestion on ni.com/ideas. There are already some suggestions to make other silver controls, like tab controls.

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 9 of 13
(6,907 Views)

Hello Nickerbocker,

 

The reason that the Shared Variable control is not in the DSC module palette, is that the former can work with the DataSocket APIs, which doesn't make it solely a DSC module specific control.

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 10 of 13
(6,834 Views)