From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XControl formatting

Solved!
Go to solution

Hello,

 

I am creating an XControl that has a DBL indicator.  I created a property read VI for the Xcontrol to get the XControl instance's label text by getting the Refnum from the Container State, wiring that to a Ctl property node, and reading the Label.Text property.  That works nicely.

 

Now I would like to be able to programmatically control the display format and precision for each instance of the XControl.  I created read properties for both format and precision in the XControl project, but I'm having trouble setting those values in the corresponding Xcontrol Write VIs.  I get the Refnum from the Container State but a Ctl refnum does not give access to the display format or precision properties because not all controls have those properties.  If I cast to a more specific Digital reference type before wiring it to a property node, I can wire to the Format and Precision properties, but I get a runtime error saying

 

"Error 1057 occurred at Property Node in Test Numeric X Control.vi

 

Possible reason(s):

LabVIEW:  Type mismatch: Object cannot be type casted to the specified type.

 

To More Specific Class in Numeric X Control.xctl:Precision Write.vi->Numeric X Control.xctl:Precision Write.vi.ProxyCaller" when the Write VIs execute."

 

Here's a PNG of the block diagram for the Precision Write.vi.

 

Hans 

0 Kudos
Message 1 of 5
(3,307 Views)

I have two solutions:

  1. Add the reference to the FP element on the facade to the XControl's state reference, you can adjust this reference's representation
  2. Add a messaging system to the XControl's state control. In the property you set a message 'Format Control', in the facade you check for this message and edit the FP control
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!
Message 2 of 5
(3,285 Views)

Thanks for the reply Ton.
 
I tried to implement your first suggestion since it looked simpler.  I also found a related knowledge base article:
Obtaining a Reference in a Facade VI to the VI that Calls the XControl
http://digital.ni.com/public.nsf/allkb/80491590A4CAA1B1862573370014A0B8
 
which showed editing the State control type def to add a reference and modifying the Facade VI to fill the reference.
 
I tried the following
1) Added a DigNum Refnum control ref to my State control typedef
2) Modified the Facade VI's Display State change event case to take the Container State Ctl Ref and store it in the Display State DigNum Ref.  I had to cast the Ref to a more specific class to prevent a broken wire.  This is different from the Knowledge Base example because the e dxample derived the Owning VI ref without having to cast.
 
Unfortunately, the same Type Mismatch shown in my first message error occurs at the cast in the Facade VI so and null reference is stored in the Display State control and an error occurs when I try to set the control's precision.  Here's a screenshot of the block diagram.

 

It seems like I'm still stuck with the same underlying problem - casting from a Ctl ref to a more specific ref creates an error.
 
Hans

0 Kudos
Message 3 of 5
(3,255 Views)
Solution
Accepted by topic author hans17

You are taking the wrong reference.

The  container state returns the reference to the XControl on the owing VI.

You should add the reference to the control on the front panel of the Facade VI.

 

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!
Message 4 of 5
(3,243 Views)

Thank you Ton!  That did the trick.  Here's a screenshot of the working Facade block diagram.

 

Hans 

0 Kudos
Message 5 of 5
(3,219 Views)