LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically access XControl Methods

I have developed a XControl that includes several internal methods. I would like to programmatically invoke these methods from outside the XCtl but I can't find a way to programmatically obtain an appropriate XCtl reference (i.e. one that allows access to these methods). Among other things, I have tried using the OpenG VI "Open VI Object Reference" which gives the correct reference but no access to the internal methods (probably cos it doesn't recognize XCtls as an allowable vi object class).
 
Any help or suggestions would be greatly appreciated.
 
Andrew
0 Kudos
Message 1 of 9
(4,344 Views)

Hi DrewBob,

To access the methods and properties of the XControl, you can simply right-click on an XControl on your block diagram and select Create>>Invoke Node.  If the Methods are in the XControl's Methods folder in your project then they should show up here. 

I think this is what you are looking for but please let me know if I have misunderstood your question!
Cheers,
Megan B.
National Instruments

0 Kudos
Message 2 of 9
(4,327 Views)
Megan,

Thanks for your suggestions. The steps you suggest also work for me however my problem is a little more complicated. To elaborate a little: I'm wanting to create and manipulate multiple instances of the same Xctl at run-time. I want to manipulate these Xctls by calling their internal methods (and properties) using control references. I can instigate multiple XCtls just fine but referencing them after that hasn't been possible so far.

DrewBob
0 Kudos
Message 3 of 9
(4,323 Views)

Hi DrewBob!

I'm afraid I don't really understand why you need to use references.  Even with multiple instances of the XControls, each instance will have a unique name so you should be able to use Property Nodes and Invoke nodes to interface with the different XControls. 

Let me know if what I'm missing.. maybe a simple example VI would clear it up.
Thanks!
Megan B.
National Instruments.

0 Kudos
Message 4 of 9
(4,312 Views)

Megan B. wrote:

I'm afraid I don't really understand why you need to use references.  Even with multiple instances of the XControls, each instance will have a unique name so you should be able to use Property Nodes and Invoke nodes to interface with the different XControls. 

I need to use references so I can operate on these controls (alone or as a group) in subVIs. As soon as I pass a reference from a XCtl into a subVI its internal methods & properties are no longer visible.

DrewBob

Message Edited by DrewBob on 03-24-2006 03:42 PM

0 Kudos
Message 5 of 9
(4,305 Views)

Hi DrewBob,

I can't reproduce the issue you're seeing. I can indeed access properties and methods for an Xcontrol from its reference inside a subVI.

In any case, you can definitely get around this by following these steps. This is overkill, and these steps weren't necessary for me, but should ensure that you can do what you want:

1. Create a reference to your Xcontrol. Right click the reference and select Create >> Control. Right click the new control and select Advanced >> Customize.

2. In the Control Editor window, select Type-Def from the control type drop down menu. Save this type-def control reference.

3. For the reference input in your subVI, use a generic control reference. You can find one of these in the controls palette under Modern Controls >> Refnum >> Control Refnum.

4. Now wire that reference in your subVI into a To More Specific Class subVI. Place a copy of your control reference type def on the block diagram of the subVI and wire its output into the Target Class input. The resulting reference should resemble the picture below and will contain all necessary custom properties and methods. Furthermore, you could use a case structure and use this one VI to alter multiple different kinds of Xcontrols using one control reference input.

If this doesn't work for you, could you post a small VI (or zipped project) that demonstrates the problems you are having?

Message Edited by Jarrod S. on 03-27-200611:50 AM

Jarrod S.
National Instruments
0 Kudos
Message 6 of 9
(4,278 Views)

Jarrod,

Thanks for your suggestions. Using a variation of what you suggested I was able to expose but not invoke/change the methods/properties of interest. I have created a source distribution that illustrates my problem. A VI called NumX_testbed.vi demonstrates this problem further. It includes a "Source VI" that contains the original XCtl (both control & indicator versions).  A downstream "Sink VI" accepts references to these XCtls from the Source VI and then tries to change/invoke properties/methods in the original XCtls Additional explanation is included in the VIs. Unfortunately, it doesn't quite work as it should.

Thanks for any additional assistance you can provide.

DrewBob

0 Kudos
Message 7 of 9
(4,268 Views)

Ok, I'm a little confused. I'm not 100% sure what you're example is supposed to do, but it definitely does successfully change properties and invoke methods for the xcontrol. What exactly should it do that it doesn't?

As I said, the method I gave you using To More Specific Class shouldn't be necessary at all, but would definitely get you access to all custom properties and methods. I moved a few wires around in your example and wired the xcontrol reference input directly into the property node as shown below, and there was no change in the properties exposed or the functionality of the VIs when run as shown below.

 

What do you see when you run NumX_testbed? Does the control color change successfully? Can you execute the show background numbers method? I can do both, so I'm not sure what functionality is missing.

Message Edited by Jarrod S. on 03-27-200602:22 PM

Jarrod S.
National Instruments
0 Kudos
Message 8 of 9
(4,268 Views)

Jarrod,

Thanks for your help (& patience).

To answer your questions:

What do you see when you run NumX_testbed?

I saw nothing in the original testbed cos it was poorly formed (Sorry...my bad). The reference passed referred to a control in a VI that ceased running before it could be acted on. I'm surprised it didn't throw an error.

Does the control color change successfully?

Yes. Now when I use a more sensible testbed the reference refers to a live control and manipulation of the properties/methods in the original VI  (i.e. still running VI) have the desired effect.

Can you execute the show background numbers method?

Now, Yes.

0 Kudos
Message 9 of 9
(4,254 Views)