LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Value access to dynamic created controls?

Hallo everyone,

Is there a way (in LabVIEW NXG 4.0) to get access to the value of dynamic generated controls e.g. to interact with element events?

0 Kudos
Message 1 of 10
(3,831 Views)

I think you'll get references when creating the controls. There might be alternative ways to get all controls, including the newly create controls. Like a front panel property All Controls[]. Can't verify right now.

 

Use those references to dynamically register for events.

 

You'll have to use a "Register for Events" node.

 

0 Kudos
Message 2 of 10
(3,754 Views)

Thanks a lot. I have two questions on that.

1)
I have tried using dynamically event registration, but I struggling using the “Register for Events” node in the right order because it seems that I have to use the “Register for Event” node before I enter the event structure. But then it makes no sense to me with using dynamical controls which I only able to generate if I already in this structure?

2)
But even if I able to get this event. It is still just linked with the reference of the control, not with the value right? Ones I generated the dynamically control and I change the value of this control on the panel, it wouldn’t triggering the event because the reference wouldn’t be changed.

0 Kudos
Message 3 of 10
(3,732 Views)

@Tofr4n wrote:

1)
I have tried using dynamically event registration, but I struggling using the “Register for Events” node in the right order because it seems that I have to use the “Register for Event” node before I enter the event structure. But then it makes no sense to me with using dynamical controls which I only able to generate if I already in this structure?


In that case, you have to use the Register for Events with an empty array of references before the event structure. Then, when you get the references, use the registration wire to re-register with Register for Events. The event registration wire should be propagated with a shift register in the loop the event structure is in.

 

So, Register For Events, but just to get the right event type. Put the event registration wire in a shift register. Use it to Register for Events in the event structure. The next iteration of the event structure, it will use the newly registered controls.

 


@Tofr4n wrote:

But even if I able to get this event. It is still just linked with the reference of the control, not with the value right? Ones I generated the dynamically control and I change the value of this control on the panel, it wouldn’t triggering the event because the reference wouldn’t be changed.


If you just want the control values, use a value property from the control reference. You don't need to register for events. Just put the control references in a shift register, so you can use it in subsequent iterations of your loop.

 

If you want events when the controls change, use Register for Events with the (array of) control reference(s). Register for value change events. You will get an event every time the control changes value.

 

In the value change event (that you should have added to the event structure at edit time), you'll get the changed control reference and the old and new value.

 

If you have LV CG, there are examples for this (dynamic control events). I'm not sure if there are examples like this in NXG.

0 Kudos
Message 4 of 10
(3,710 Views)

Ok, if I’m right it seems here is a limit in what we can do in NXG right now, because I can’t find a comparable solution of value change registration for dynamic events like in LV CG:

LV CGLV CGLV NXGLV NXG

Message 5 of 10
(3,691 Views)

I've found the same thing. Control refs or arrays of control refs can't be dynamically registered.

 

LV_dynamic_event_reg.pngNXG_dynamic_event_reg.png

 

I think NXG only supports dynamic event registration for user events and external I/O events (from DAQmx). So your only option is to wire the dynamic control ref to a property node and poll the value.

 

Take care if you place all your dynamic control references into an array and poll them in a loop though, the value property might disappear all together!

NXG_array_no_value.png

0 Kudos
Message 6 of 10
(3,668 Views)

How are you supposed to handle events from controls in a different VI, then?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 10
(3,659 Views)

@billko wrote:

How are you supposed to handle events from controls in a different VI, then?


I think you have two options:

1) Search for a way around it.

2) Wait until it's implemented.

 

Guess 1) means we're back to polling values...

0 Kudos
Message 8 of 10
(3,655 Views)

wiebe@CARYA wrote:

@billko wrote:

How are you supposed to handle events from controls in a different VI, then?


I think you have two options:

1) Search for a way around it.

2) Wait until it's implemented.

 

Guess 1) means we're back to polling values...


Ugh.  it's 4.0 already.  And here I was ready to take the plunge and start messing around with it.  This says to me that it's still not quite ready for primetime.  It's close, but it won't supplant LV Classic - yet.  I wholeheartedly agree that NXG is the way to go.  It's just not quite there, yet.  😞

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(3,653 Views)

CG 4.0 didn't have any event, not control references! Not being spoiled, we still used it 😋...

 

But also for me a definite showstopper.

0 Kudos
Message 10 of 10
(3,584 Views)