NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

What array type need to be passed for array of structures in CA_VariantSet1DArray

Hi,

 

I am using TestStand4.2.1 and Labwindows/CVI 8.5.

 

I am updating an array of station global variables which are of type structure. I have seen the example for updating array of double using CA_VariantSet1DArray, TS_PropertySetValVariant. In this example, for the API CA_VariantSet1DArray API we are passing CAVT_DOUBLE as array type.

 

For my array of structures what type I need to pass to get the array of structures are updated to TestStand Variables.

 

Regards,

Ramjee V

0 Kudos
Message 1 of 7
(3,947 Views)

Hello Ramjee,

 

You can refer to the following document for further information on this:

 

Using LabWindows/CVI with TestStand

 

 

It would help if you elaborate your query a little more.

 

Regards,

Navjodh

0 Kudos
Message 2 of 7
(3,935 Views)

It's simpler in the case of arrays of objects to set each element with a separate call. For example:

 

int i;

myarray.SetNumElements(0, 0);

for(i = 0; i < numElements; i++)

{

     myarray.SetPropertyObjectByOffset(i, myNewObjects[i], PropOption_InsertElement);

}

 

Hope this helps,

-Doug

PropOption_InsertElemen
0 Kudos
Message 3 of 7
(3,929 Views)

Hi Doug,

 

Could you please elaborate a bit in detail using a sample code if you have any?

 

Regards,

Ramjee V

0 Kudos
Message 4 of 7
(3,921 Views)

I was assuming you already had a C array of CAObjHandles for the objects you wanted to add. If not then you can just create the elements as needed using the Engine.NewPropertyObject() API.

 

Let me know specifically what you are trying to do in more detail or what you are not sure how to do and I will elaborate if needed.

-Doug

0 Kudos
Message 5 of 7
(3,916 Views)

Hi Doug,

 

Thank you for your time in responding to my query.

 

My problem is as follows:

 

1. I am having a structure in labWindows/CVI as

 

    struct study

    {

          int no;

          char name[5];

    };

 

2. I have created a array of structure variable in Labwindows/CVI as struct

 

        study studies[3];

 

3. I have created Type container in TestStand station globals to match with the above CVI structure.

4. Created an array of the above type of size 3 in TestStand station globals.

5. Now my question is, I am trying to update the TestStand Station global array with the values of the CVI array in Simple operator interface executable not using dll.

 

I hope you understood my problem. Could you please suggest me, how to go on this?

 

Regards,

Ramjee V

0 Kudos
Message 6 of 7
(3,910 Views)

For this use case, I'd do something like the following (note that this is C# syntax more than CVI, but the idea is similar, just use the CVI version of the API functions):

 

// NOTE: This assumes the C array and TestStand array are already the same size,

// and that the field names in the TestStand array are the same as the names in the C array.

int i;

for(i = 0; i < numElements; i++)

{

     PropertyObject myElement = myTestStandArray.GetPropertyObjectByOffset(i, 0);

     myElement.SetValNumber("no", 0, studies[i].no);

     myElement.SetValString("name", 0, studies[i].name);

}

 

Hope this helps,

-Doug

0 Kudos
Message 7 of 7
(3,900 Views)