LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ring constants, type defs and updating

Okay, I've read some past threads and this app note:
 
 
and I'm still confused.
 
Do the *values* update?
 
If I create a ring-constant and one element is called "pi" and I specify it at 3.14159265 and later change it to "3.0" (some people will get that) will the number update throughout wherever that ring constant is used?
 
Lee Jay
0 Kudos
Message 1 of 8
(3,811 Views)
The answer is yes and no. They update, but not for already existing instances of the control. That's what the article is talking about. If you create a new instance of the type def ring you'll get the new values. An enum, on the other hand (and as the article says), will have all instances updated if it's a type def.
Message 2 of 8
(3,805 Views)

Just to be sure, you can't do what I want to do with an enum, correct?  They don't allow you do customize the value, the value is always the integer index of the element.

So, there's no way to make a named constant that automatically updates in LV, is that correct?

Lee Jay

0 Kudos
Message 3 of 8
(3,787 Views)
Can't do what you want with an enum. You have a couple of options:

One, you can create a custom enum, and then create a "conversion" VI that spits out numerical value you want for the given enum value. I've used this technique frequently.

Second, you can create an XControl if you have LabVIEW 8. Unfortunately, with XControls I don't think you can set what the constant looks like on the block diagram. You can set it to use an enum in the Facade VI, but that applies to the front panel only. In the block diagram you'd see a regular ol' DBL so you couldn't (as far as I know) drag the XControl to the block diagram and create an enum instance on the block diagram the same way you can with an enum typedef.

On a personal opinion, I've tried playing around with XControls, and I just can't seem to figure them out - they seem overly complicated to me. Maybe my head is just too dense. Or maybe, the implementation lacks a certain finesse. Don't really know. You might have better luck than me.
0 Kudos
Message 4 of 8
(3,775 Views)

Thanks,

What about a ring control that can be somehow tricked into updating across all the VIs in a project?  Something like a global search and replace or a trick like changing the type to something else and then back.  Do you know of any such tricks that can work around the ring control limitation?

Lee Jay

0 Kudos
Message 5 of 8
(3,771 Views)
I'm not aware of any tricks like what you're suggesting, and the search and replace function in LabVIEW won't work for trying to replace a control that's a typedef.

You can, however, use scripting. LabVIEW has a hidden feature called scripting that lets you do all sorts of nasty things. In LabVIEW 7.1 you could unlock scripting with a couple of .ini file variables. You can head over to the Lava forums to read more about it. In LabVIEW 8 my understanding is that scripting has been locked to require a license, but it seems that you can write a VI in 7.1 to use scripting, and running the VI in 8 will still work.

With respect to your example you can try the attached example as a scripting sample. The "Replace Controls" VI will replace the rings on "Untitled". One drawback that I found is that the selected value doesn't get updated, and I couldn't find a way to do that. Still, if you're game you might want to play around with it.
Message 6 of 8
(3,761 Views)

mercurio wrote;

"

On a personal opinion, I've tried playing around with XControls, and I just can't seem to figure them out - they seem overly complicated to me. Maybe my head is just too dense. Or maybe, the implementation lacks a certain finesse. Don't really know. You might have better luck than me.

"

Don't feel alone!

The LabVIEW Advanced Application Development course say that XControls should only be developed by architects!

A line from page 4-4 of the manual reads;

"XControls are powerful, difficult to create." ( Smiley Surprised misprint or freudian slip, you decide ).

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(3,746 Views)
Well, that certainly makes me feel better. The main problem I found was fairly unclear documentation and a paucity of examples. I was hoping to see an improvement in the implementation or a more clean and concise explanation of how to create and use them, but no luck. Still, there's always the good graces of the LabVIEW community to provide interesting implementations and if I ever find myself needing to use one perhaps a modification of an existing one is the best place to start.

0 Kudos
Message 8 of 8
(3,734 Views)