NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

reference a numeric array in PostUIMessageEX

I defined a local numeric array (locals.data[]).
I would like to pass the numeric array to TestStand-Execution Display.VI.
I can pass one single number OK. So I understand the way UIMessage Handler and Execution Display work.
My next challenge is to pass more than one number.
In PostUIMessageEX, there is a parameter activeXDataParam (type Activex IUnknown). I try to set activeXDataParam value to Locals.data.
In TestStand - Execution Display.VI, I have the property TS.UIMessage ->ActiveXData. I connect the output of the property to Variant to Data.VI with type input as a numeric array; and use array index to obtain the value of the array. This doesn't work. I have an error type mismatch. Please help me passing more than one
number with PostUIMessageEX.
0 Kudos
Message 1 of 12
(5,128 Views)
Hello trout00 -

Passing the array directly as your ActiveX parameter probably isn't going to give you the behavior that you want. When customers are in a situation where they have to pass arrays as messages, one thing that I have seen sucessfully implemented is to pass a sequence context reference, and a lookup string.

For example (1)in your Sequence, use PostUIMessageEx() to send the lookup string to your variable along to your OI, sending the sequence context (ThisContext) pointer is optional. (2) in your operator interface, use these two items to get the Variant container that is your local array variable, and then typecast this variant into your 1-D array.

The sequence context pointer for this is optional since it can be obtained via the wires that
already exist in your operator interface (you can retrieve a reference to 'Thread' from the UIMessage object, and a reference to 'Sequence Context' from this thread.

--Regards,

Elaine R.
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 12
(5,130 Views)

Hello Elaine,

I just saw this post and wonder if there is a way to use the PostUIMessageEX for passing a TS 4.0 container to UI in Labview.

I guess the explanation will apply to TS container as well but you talk about example.

Please explain or direct me to an example how to handle the TS container especially in the Labview callback module.

Thank you.

Elik

0 Kudos
Message 3 of 12
(4,774 Views)

You can pass arrays, containers, or just about anything via the activeXDataParam property. However, LabVIEW will see the data as an ActiveX object. It will let you access PropertyObject (or another interface if you pass a non-PropertyObject) methods and properties to get the values within your TestStand array or container. However, no LabVIEW node such as Variant to Data is going to know how to convert an arbitrary ActiveX object to its most analogous LabVIEW data type, presuming there even is one, which there happens to be in the case of numeric arrays.The LabVIEW adapter contains code which can do conversions like this, but you have to call a VI directly from TestStand to use it.

 

You could write your own VI that takes a reference to a TestStand array and outputs a labview array, or you could just use the PropertyObject members to access the TestStand array within Labview (which is the same method you would use to implement the afore mentioned conversion VI).

0 Kudos
Message 4 of 12
(4,770 Views)

Thank you James.

I assume that on the TS side I set the RunState.SequenceContext as the reference object and extract Locals.MyCluster on the receiving side.

Using the UI custom message call back VIOn the receiving side I invoked the property nodes  UIMessage>>Thread>>GetSequenceContext>>SequenceContext>>AsPropertyObject. From here I'm a bit confused.

I might figure it all wrong.

Thanks again.

 

Elik

0 Kudos
Message 5 of 12
(4,737 Views)

I would set Locals.MyCluster as the reference object for ActiveXData on the sending side.  That avoids anything bad happening if the locals go out of scope before you access them (better to be safe). Also, you don't have to dig as deep to get your values.

 

On the receiving side, you'd do:

 

PropertyObject myCluster = (PropertyObject)uiMessage.ActiveXData;

 

Boolean myBooleanValue = myCluster.GetValBoolean("MyBooleanClusterField", PropOptions_NoOptions);

 

etc...

0 Kudos
Message 6 of 12
(4,734 Views)

Hi James,

Thanks for your quick response. Just another question.

Would it be possible or more efficient to use GetValVariant and unbundle the reference through variant to data?

 

Elik

 

0 Kudos
Message 7 of 12
(4,731 Views)
That won't work. See my first post in this thread for the reason why. Besides, I wouldn't worry about microsecond range efficiency for this use case. I'm presuming you aren't going to try posting millions of UIMessages per second.
Message Edited by James Grey on 04-27-2009 05:46 PM
0 Kudos
Message 8 of 12
(4,727 Views)

OK. Good advice. It works fine as is and thank you.

Elik

0 Kudos
Message 9 of 12
(4,724 Views)

Be sure to read this KB when using the Variant to Data element in LabVIEW with a variant that holds an ActiveX reference.

LabVIEW UserInterface gives PropertyObject Warnings when using UIMessages

 

You need to be very careful to avoid leaks.

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 10 of 12
(4,692 Views)