LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically generating controls

I have a project where I need to programmatically generate controls like LabWindows/CVI (or any other language) can.

For example, I need a Numeric Control of dimensions "such and such" placed here, and a Boolean Control placed over there.

Can LabVIEW do this?
0 Kudos
Message 1 of 13
(5,226 Views)
although labview doesnt support the dynamic creation of controls (like 'new' object in OO languages) there are many work arrounds depending on what you need to do.  If you post some more details a work around can be suggested. 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 13
(5,219 Views)
OK, try this.

8-bit registers need to be represented as various combinations of bits and integers. For example, the first two bits are seen as bit, the next four bits are seen as a four-bit integer, and the rest of the bits are seen as bits. Or any combination of that last long sentence!

I need to dynamically create LabVIEW controls that handle any combination of that aforementioned stuff, like I could do (with eyes closed) using LabWindows/CVI, or anything in Microsofts' Visual Studio.NET package. My job is stuck with LabVIEW though.


0 Kudos
Message 3 of 13
(5,214 Views)


@bmihura wrote:
My job is stuck with LabVIEW though.


What a bummer Smiley Wink

But what you could do is using hidden controls, if you know on forehand what you have to do, otherwise XControl can do some off the things you want.
But you have 2 booleans, 1 digital, and 2 booleans, that's not that many options (3*2*1) so I'd go for a hidden tab page implementation. Create a tab with 6 pages, hide the selector and select the correct page programmatically.
Same approach goes for XControl, just have it 6 states

If you want to do it really fancy, go for the picture indicator!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 13
(5,205 Views)

Yes this is not so bad since you have only a few options I was thinking you were talking about open ended dynamic interface design (which would be very hard to do in labview (but not impossible).  The fact that all controls are booleans makes it even easier since you can make all of your subvi's take an array of boolean references that can be changed (in quantity and value) dynamically at runtime.  All properties of the controls can be changed at runtime such as visible, possition, color, boolean text ....

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 13
(5,197 Views)
There are too many combinations and permutations of Boolean and Numeric Controls to try the hidden control or XControl approach.

But your Picture Control idea should work nicely, thanks!
0 Kudos
Message 6 of 13
(5,198 Views)
You should note that there's a good reason that this task has to be done differently in LabVIEW as it would in CVI or some other programming langauge. The reason is that a LabVIEW front panel control is always bound to a block diagram terminal, and can be bound to a subVI's connector pane. That means that a control is part of the compiled code of a program, and you can't change the compiled code at run-time. You can change things like its appearance or visibility, but not its datatype or existance.

Other languages like CVI allow you to create soft front panels, but they are not bound to the compiled code. Instead, they can be dynamically linked to and altered at run-time. These languages usually provide interfaces that allow you to configure controls or set up callbacks for certain user events. LabVIEW gives the advantage that reading and writing to these controls is as easy as accessing their block diagram terminals, whereas in CVI you'd have to call a special function and pass in handles to the panel, the control, etc.  Both methods have their advantage in different situations.

(On a side note I was playing around with Mac's integrated programming environment called Xcode. I walked through the tutorial for the most basic Hello World Carbon application, and the process involved no less than 15-20 steps, including inheriting a new class from a generic View class and calling special methods on that. I'm sure it's great once you get used to it, but I yearned for LabVIEW's simplicity!)

Hopefully you see that this is not so much a deficiency in what LabVIEW allows you to do at run-time, but a completely different paradigm for programming. The suggestions listed above will hopefully allow you to solve the problem with not too much more effort than you're used to.
Jarrod S.
National Instruments
Message 7 of 13
(5,180 Views)


@jarrod S. wrote:
...
Other languages like CVI allow you to create soft front panels, but they are not bound to the compiled code. Instead, they can be dynamically linked to and altered at run-time. These languages usually provide interfaces that allow you to configure controls or set up callbacks for certain user events.
...

You can do this with LabVIEW if you cheat a little. LabVIEW can build a front panel of a VI dynamically, as long as that front panel is not running or reserved for running.  You can create a VI's front panel and then dynamically call that front panel's objects.  This is not easy (and mainly not supported).  You will have to look to the LAVA message board about scripting to get at all the pieces.  http://forums.lavag.org/LabVIEW-VI-Scripting-f29.html

Hope that this helps,
Bob Young

0 Kudos
Message 8 of 13
(5,161 Views)
Bob Y.:

I'll never do a scripting solution in LabVIEW, given these facts:

* Scripting is not supported by NI.
* Any scripting feature could disappear in the next version of LabVIEW.

The "Picture Control" solution I'll implement was suggested by TonP earlier in this thread (thanks TonP!).

Downside: I'll have to make all my GUI controls programmatically. This only involves high school level math and busywork, but I can handle that! Woops, this is 2007, so let me change that to "college level" math.

Upside: I'll be able to write a tight little piece of LabVIEW code that can handle any of the hundreds of ways of dividing up an 8-bit register into bits and numeric fields. This will be extensible to any size of register.
0 Kudos
Message 9 of 13
(5,148 Views)
I'd go for a control inside an XControl.
Make 8 of these XControls on your GUI and you have all you need!
You can send pieces of the byte onto the correct XControl, the XControl can show a boolean or numeric and act on the user actions.
You can hide the XControls you don't need!

So you don't need the picture control but can have an XControl showing either a boolean or a numeric

(wrap this all up into one XControl and you can make a multi-byte register)
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 10 of 13
(5,137 Views)