NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Teststand Api GetNumElements

Hi,

 

have passed the Sequence Conetext (ThisContext) from Teststand to my C#-Dll (VS Studio 2005).

In the DLL I want to walk through the Sequence Context item by item (like the tree view in the Context tab of the sequence editor).

My idea was to ask the sequence context how many elements are existing in each level and then address each item by an index and ask for its type and do further processing.

(If it is an container, just ask how many items are contained and so on...)

 

I have tried this approach: 

  static public void MyFunc(ref SequenceContext MySequenceContext)

{

    int Index;

    string lb, ub;

    PropertyValueTypes type;     int NumOfSubproperties;

    MySequenceContext.AsPropertyObject().GetDimensions("", 0, out lb, out ub, out NumOfSubproperties, out type);

but I'm immediately getting this error:

    Exception has been thrown by the target of an invocation.
    Root Exception:Specified value does not have the expected type.
    Source: at NationalInstruments.TestStand.Interop.API.PropertyObject.GetDimensions(String lookupString, Int32 options, String& lowerBounds, String& upperBounds, Int32& numElements, PropertyValueTypes& elementType)
    at xxx.yyy.MyFunc(SequenceContext& MySequenceContext) in C:\\yalayalayala\\xxx.cs:line 38 [Error Code: -17500, Operation Failed.]

 

 

I alternatively tried this

  static public void MyFunc(ref SequenceContext MySequenceContext)

{

    int Index;

    string lb, ub;
    PropertyValueTypes type;

    int NumOfSubproperties;

    NumOfSubproperties = MySequenceContext.AsPropertyObject().GetNumElements();

This time the error was:

    Exception has been thrown by the target of an invocation.
    Root Exception:Specified value does not have the expected type.
    Source: at NationalInstruments.TestStand.Interop.API.PropertyObject.GetNumElements()
    at xxx.yyy.MyFunc(SequenceContext& MySequenceContext) in C:\\yalayalayala\\xxx.cs:line 38 [Error Code: -17500, Operation Failed.]

 

 

Isn't it possible to ask for each object, how many elements it has?

 

Many thanks

Thorsten

 

Sorry, I forgot to mention, that I'm using Teststand 3.1...

 

 

 

 

 

Message Edited by Tho_Wa on 09-29-2008 03:50 AM
0 Kudos
Message 1 of 2
(2,679 Views)

The Sequence Context is a container, not an Array.  The functions you are trying to use are meant for objects that are Arrays.

 

You should instead use the following function:

 

PropertyObject.GetNumSubProperties.

 

To access each individual subproperty, you can use the following functions:

 PropertyObject.GetNthSubProperty

and

PropertyObject.GetNthSubPropertyName

 

Allen P.

NI

0 Kudos
Message 2 of 2
(2,663 Views)