12-13-2010 04:19 PM
I have a 2D array in TestStand that I have populated using Labview and reading from an Excel spreadsheet. I have columns X, Y, and Z in the array stored as a Local in TestStand. What I am trying to do is iterate on this array using the ForEach function in TestStand. So for each row in the array I have parameters that I am using for my test. Each row again has a value from column X, Y, and Z. In Labview this is a breeze. I want to use the TestStand methods to perform this function. Is this possible and if so how? I would appreciate any help.
Thanks,
Troy
12-13-2010 06:58 PM
As you would in any other programming language, simply nest two for loops to iterate over the 2D array by index. If there's going to be a variable number of rows/columns, you can parse the return values of the GetArrayBounds() function to set the bounds of your iterations. Depending on how exactly you're retrieving the data, however, it may be more straightforward to store boundary information in additional locals while reading the data.
12-14-2010 07:00 AM
That is why I am asking the question. The NI s/w environment is the only programming language I use. So what I was looking for was maybe an example of how this is done in TestStand.
12-14-2010 08:13 AM
check out jigg's example, I haven't looked at it but as it's just a seq file it must be doing all the array indexing in TestStand.
http://forums.ni.com/t5/NI-TestStand/Foreach/m-p/1153817
Hope this help, otherwise I generate a simple example later on today
12-14-2010 08:52 AM
jigg's example is effective, but it may not be easy to reuse.
The attached demonstrates both a for loop and a foreach loop. Notice that the foreach uses fewer steps but iterates down a column; the for loop can iterate either across a row or down a column.
12-14-2010 01:11 PM
Thanks for taking the time to post. I see what is going on here although I have to admit the expression at the beginning is a little hazy to me as far as what it is doing and how. Non the less I put my array of data in place of what was in the example and it is working. I have to say that the ForEach is actually working better for me. I have an array of strings as follows:
Freq, Symrate, Modulation
1000, 512, QPSK
1001, 1024, QPSK
1010, 2048, QPSK
and so on. What I am trying to do is get the Freq, Symrate, and Modulation all at the same time and put them into variables that will be used for each step of the test. So I would want to get in the first instance 1000, 512, QPSK into their own variables to configure my test. Is there a way to do this using the example forwarded? Again, thanks for the help provided so far. One other thing, if there were another column added in the future would that make changes needed in the expression that is evaluating the array at first? An explanation of that expression in the beginning would also help. Thanks again.
12-14-2010 01:31 PM - edited 12-14-2010 01:34 PM
The expression is a tad hairy 😉 Try this on for size:
First, notice that there are three separate expression here, delimited by commas. The first (GetArrayBounds()) retrieves the upper and lower boundary sizes of the array and stores them to a local. Unfortunately, TestStand only uses string-based values to look up indicies, so this is why parsing is necessary.
As for integrating this method with your example, you should try to have another go at implementing this yourself. If you still get hung out, post what you've come up with and it'll be much easier to help.
12-14-2010 02:47 PM
12-14-2010 02:53 PM
I am currently working through the post from asbo. I now understand what is happening in the expression. However I am still open to ideas. Right now I am trying to access the data as explained earlier where I am loading my three elements/row into their respective variables. That is the part right now where I am stuck but working on. Can you explain or give an example of the method you are referring too?
12-14-2010 03:32 PM