NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

passing object reference from sequence to C#

hi all,

I'm trying to pass a simple array that was created in locals at the sequence to a UI application.

I created an expression in NI:

 

 

RunState.Thread.PostUIMessageEx(10201,454,"this is my test",Locals.arr,True)

 

and in the application i implemented:

 

private void axApplicationMgr_UIMessageEvent(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_UIMessageEventEvent e)
{
            if (e.uiMsg.Event == (NationalInstruments.TestStand.Interop.API.UIMessageCodes)10201)
            {
               
            }
}

when the expression executed the UIMessageEvent happend and I get the numericData (454) and the stringData ( this is my test) but I don't know How to get the object reference of the array.

How can I cast the object ( e ) to get the array.

Tnx

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 3
(3,890 Views)

 

NationalInstruments.TestStand.Interop.API.PropertyObject myArrayVariable = (NationalInstruments.TestStand.Interop.API.PropertyObject)e.uiMsg.ActiveXData;

 

You can then either use the teststand API to access the individual elements, or, if the array is an array of a basic type, you can do the following:

 

double[] myArray = (double[]) myArrayVariable.GetValVariant("", 0);

 

For more help with accessing arrays from .NET see the example: <TestStandPublic>\Examples\AccessingArraysUsingAPI\UsingDotNet\

 

-Doug

0 Kudos
Message 2 of 3
(3,877 Views)

It working perfectly

Tnx a lot

0 Kudos
Message 3 of 3
(3,856 Views)