05-02-2011 06:13 AM
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
05-04-2011 08:15 AM - edited 05-04-2011 08:19 AM
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
05-05-2011 09:50 AM - edited 05-05-2011 09:50 AM
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
05-06-2011 12:22 AM
Hi Doug,
Could you please elaborate a bit in detail using a sample code if you have any?
Regards,
Ramjee V
05-06-2011 11:19 AM
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
05-07-2011 04:42 AM
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
05-09-2011 09:48 AM - edited 05-09-2011 09:49 AM
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