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.
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.
12-07-2008 04:01 PM
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
Solved! Go to Solution.
12-08-2008 04:24 AM
I have two solutions:
12-08-2008 06:55 PM
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
12-09-2008 02:00 AM
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
12-10-2008 03:03 PM
Thank you Ton! That did the trick. Here's a screenshot of the working Facade block diagram.
Hans