NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand-only function?

Hi,

Is there a TestStand API function that I can use in CVI 5.5.1 that
performs the same function as the InsertElements() function that I can
use in a TestStand expression? I want to add elements to an array that I
have in stationglobals from a CVI function instead of making a TestStand
statement step to do it for me. For example, I want to create an empty
array and add elements as I go along to an array in StationGlobals from
CVI.

Thanks,
Emile Semmes
--
/---------------------------\
| Emile Semmes |
| Tellabs Operations, Inc. \------------\
| MTS 1 |
| BMG NPI Support |
\----------------------------------------/
0 Kudos
Message 1 of 10
(4,844 Views)
Hi,


To create an empty array you use the PropertyNewSubProperty function. To set the initial size or to adjust the size of the array you use the PropertySetDimensions. To write the data to an element use the PropertySetValNumber. Or to write the whole array use PropertySetValVariant.

There are some examples of using arrays in CVI in the TestStand example folders, plus look in the Resource Library | TestStand.

Hope this helps
Ray
Regards
Ray Farmer
0 Kudos
Message 2 of 10
(4,839 Views)
    Here I reported a problem when I tried to change the dimension of arrary(Step.Blocks[i]) in Teststand by using TS_PropertySetDimensions in CVI.Below is my codes. The problem is Teststand could not upgrade the array if I decrease array dimension. I'm wondering whether it's a Teststand bug or my fault?
 
Thanks!
Jacky
 
-------------------------------------------------------------------------------------- 
   sprintf(tempX,"[%d]",g_NoofBlocks-1);
   tsErrChk(TS_PropertySetDimensions (g_seqContextCVI,&errorInfo, "Step.Blocks", 0, "[0]", tempX));
   for (j=1; j<=g_NoofBlocks; j++)
    {
    
     sprintf(tempX1,"Step.Blocks[%d].TxStr",j-1);
     TS_PropertyNewSubProperty (g_seqContextCVI, &errorInfo, tempX1, TS_PropValType_Number, VTRUE, "", 0);
    
     sprintf(tempX2,"Step.Blocks[%d].Size",j-1);
     TS_PropertyNewSubProperty (g_seqContextCVI, &errorInfo, tempX2, TS_PropValType_Number, VFALSE, "", 0);
     
     sprintf(temp,"Step.Blocks[%d].Size",(j-1));
     tsErrChk(TS_PropertySetValNumber (g_seqContextCVI, &errorInfo, temp, 0,(double) (g_TxStr_Size[j-1])));
     
     size=g_TxStr_Size[j-1];
     
     strcat(tempX1,"");
     strcat(tempX2,"");
     sprintf(tempX1,"Step.Blocks[%d].TxStr",j-1);
     sprintf(tempX2,"[%d]",size-1);
 
     tsErrChk(TS_PropertySetDimensions (g_seqContextCVI, &errorInfo, tempX1, 0, "[0]", tempX2));
     
    
     for (i=0; i<size; i++)
     {       
      
      sprintf(temp,"Step.Blocks[%d].TxStr[%d]",(j-1),i);
      tsErrChk(TS_PropertySetValNumber (g_seqContextCVI, &errorInfo, temp, 0,(double) g_TxStr[j-1][i]));
     }
    
    }
0 Kudos
Message 3 of 10
(4,695 Views)

In order to better describe my issue, I attached a picture here

 

Thanks!

Jacky

0 Kudos
Message 4 of 10
(4,694 Views)
Hi Jacky,

Is the discrepancy between the "View Contents" and "Browse Sequence Contents" options occurring during run time? After the sequence has executed? Can you give us some more details surrounding the screen shot you've posted?

Also - the TestStand help recommends using the PropertySetNumElements function when changing the size of a single dimensional array. Try this function instead and see if it makes a difference.

Thanks Jacky,
Dan Weiland
0 Kudos
Message 5 of 10
(4,666 Views)

Hi Jacky,

Is this a typo

   sprintf(tempX1,"Step.Blocks[%d].TxStr",j-1);

Should it not read

   sprintf(tempX1,"Step.Blocks[%d].TxStr", ,j-1);

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 6 of 10
(4,652 Views)
Oh, Sorry
  Yes, this is a typo, in my code, I have "sprintf(tempX1,"Step.Blocks[%d].TxStr",,j-1)".
  At the very beginning, I had the plan to post the codes I have, but it seems that the code is quite complicated. So I would like to replace "PropertySetDimensions" with "PropertySetNumElements". However, I still have a question. You know I can specify LookupString when I use TS_PropertySetDimensions, but how to specify LookupString if I use TS_PropertySetNumElements?
 
a, TS_PropertySetDimensions (ObjHandle, NULL, "LookupString", 0, "LowBound", "Upperbounds");
b, TS_PropertySetNumElements (ObjHandle, NULL, NoofElements, 0);
 
 
I'm a new user of Labwindows and appreciate for your kindness and patience, which have given me more confidence to learn to the best
 
 
Thanks!
Jacky
0 Kudos
Message 7 of 10
(4,650 Views)

Hi,

If your reference to the object is the array then the lookup string will be "" (empty) therefore

a, TS_PropertySetDimensions (ObjHandle, NULL, "LookupString", 0, "LowBound", "Upperbounds");
b, TS_PropertySetNumElements (ObjHandle, NULL, NoofElements, 0);
 
will be
 
a, TS_PropertySetDimensions (ObjHandle, NULL, "", 0, "LowBound", "Upperbounds");
b, TS_PropertySetNumElements (ObjHandle, NULL, NoofElements, 0);
 
your ObjHandle will be obatined by using TS_PropertyGetPropertyObject(g_cviSeqContext, NULL, "LookupString", 0, &ObjHandle);
 
 
dont forget to discard ObjHandle by using CA_DiscardObjHandle before you return back to TestStand.
 
Hope this helps
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 8 of 10
(4,644 Views)

Hi,

I think your lookup string should have been "RunState.Step.Block" as you are using the SequenceContext as the reference

 tsErrChk(TS_PropertySetDimensions (g_seqContextCVI,&errorInfo, "Step.Blocks", 0, "[0]", tempX));

eg

 tsErrChk(TS_PropertySetDimensions (g_seqContextCVI,&errorInfo, "RunState.Step.Blocks", 0, "[0]", tempX));

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 9 of 10
(4,641 Views)
Hi,
I'm using "ThisContext" as the input parameter in the dialog of "Edit C/C++ DLL Call" when building step type. I want to save the values in Step.XXX after execution, not just runtime, so I'm sure that to use "Step.Blocks" as SequenceContext reference is correct.
I have replaced TS_PropertySetDimensions with TS_PropertySetNumElements. Now it's working fine.
As to the problem of using TS_PropertySetDimensions, I don't want to go far, but maybe, just maybe it could be real bug in Teststand, I hope NI could have an investigation on it.
Anyway, thanks for your help.You are always doing me big favors.


Thanks!
Jacky
0 Kudos
Message 10 of 10
(4,632 Views)