NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Property loading an empty array

I have an array that I want to initialize from text file using a property loader step.  I want the number of elements of the initialized array to be equal to the number of elements in  the array in the text file.  I tried to accomplish this by defining the TestStand array empty and importing all properties from the text file.  This resulted in an error message for each property in the array - here's a snippet of the error messages:

 

 

Error evaluating expression:FileGlobals.Arinc629.Limits.Label[0].Address = (0xE90)

Property does not exist.

 

 

The text file I'm loading the properties from is attached.  The properties are loaded successfully if I define the TestStand array with a size bigger or equal to the number of elements in the text file.  But I want to have the text file to dictate how many elements are in the TestStand array.  Is there a good way to do that?

 

Thanks,

Hans

Message Edited by hans17 on 11-05-2008 06:28 PM
0 Kudos
Message 1 of 12
(4,946 Views)

Here's the limit file for the property loader step.

 

Hans 

0 Kudos
Message 2 of 12
(4,942 Views)

Hi,

 

The easiest way would be to have two property loads steps 

One to load the size of the array.

Then set your array size using the SetNumberElements()

Then call the property loader again to load your data.

 

Regards

Ray Farmer

 

 

 

Regards
Ray Farmer
0 Kudos
Message 3 of 12
(4,905 Views)

Thanks for the reply, Ray.  I had thought of doing exactly that.  There's a couple drawbacks though.  First, I need a couple extra TestStand steps, not a huge deal.  Second, whenever someone adds or deletes an array element in the limit file, they have to remember to update the array size.  Seems like it could all be handled automatically by TestStand, which would make the user's code simpler and easier to maintain.

 

Hans 

0 Kudos
Message 4 of 12
(4,891 Views)

Sorry, I accidently posted the same reply again.

 

Hans 

Message Edited by hans17 on 11-10-2008 03:53 PM
Message Edited by hans17 on 11-10-2008 03:53 PM
0 Kudos
Message 5 of 12
(4,886 Views)

No problem.

 

The other alternative would be to modify the PropertyLoader step type or generate a step type based on the PropertyLoader.

 

Regards

Ray

Regards
Ray Farmer
0 Kudos
Message 6 of 12
(4,880 Views)

Thanks again for the reply Ray.  You're on your way to 4000!

 

I could make my own step type, but it makes more sense for TestStand to automatically handle property loading a variable length array.  Otherwise every user that wants to do that has to investigate and implement their own workaround.  Better to have NI solve the problem once for everyone.  Perhaps I'll submit a suggestion to NI.

 

Hans 

Message 7 of 12
(4,853 Views)
Hans,

This was reported to R&D (132872) for further investigation.  The workaround you have now (presizing the arrays) is good, but TestStand should be able to load variable sized arrays.  Therefore this information has been passed to R&D so that hopefully this can be added as a future funcitonality in TestStand.  Thanks for the feedback.
John B.
Applications Engineer
National Instruments
Message 8 of 12
(4,848 Views)

Thank you John!  I really appreciate NI looking into this enhancement and I bet other TestStand users will appreciate it as well.

 

Thanks again,

Hans 

0 Kudos
Message 9 of 12
(4,845 Views)

Hans,

 

What version of TestStand are you using?

Starting with TestStand 3.1 you can import/export arrays and containers as XML strings.

If you want to be able to set the array bounds in the text file all you have to do is to modify the LBound and HBound attributes in the corresponding XML Prop tag and add the Value tags corresponding to the elements you want to add.

For example.

 

Let's assume I have an numeric array local variable named MyArray (Locals.MyArray).

The first thing I would do is to use the Import/Export Properties tool to generate my text file.

1. Make sure that the Locals.MyArray variable is not empty (In my case Lower Bound =0 and Upper Bound= 9)

2.  Go to Tools>>Import/Export Properties

3. Go to the Source/Destination tab and  specify your text file location

4.  Go to the properties tab and add Locals.MyArray to the selected properties list

5. Click the Export  button

6. Open your text file and verify it looks as follows:

<Step Name>

<Locals>    Variable Value
MyArray    <Prop Name='MyArray' Type='Array' LBound='[0]' HBound='[9]' ElementType='Number'><Value ID='[0]'>0</Value><Value ID='[1]'>0</Value><Value ID='[2]'>0</Value><Value ID='[3]'>0</Value><Value ID='[4]'>0</Value><Value ID='[5]'>0</Value><Value ID='[6]'>0</Value><Value ID='[7]'>0</Value><Value ID='[8]'>0</Value><Value ID='[9]'>0</Value></Prop>

<FileGlobals>    Variable Value

<StationGlobals>    Variable Value

7. In my case I only exported the Locals.MyArray variable

8. Notice that the Value of the Locals.MyArray variable is a XML string that contains a Value tag for each element in the array.

9.  If I want to change the number of elements in the array next time I import the text file, I only have tp modify the LBound and HBound attributes and add or remove the value tags for the array elements.

10. Let's say that I want my array to have only one element, then I need to set the value of HBound to 0 and get rid of the Value tags corresponding to the rest of the elements.

 <Step Name>

<Locals>    Variable Value
MyArray    <Prop Name='MyArray' Type='Array' LBound='[0]' HBound='[0]' ElementType='Number'><Value ID='[0]'>0</Value></Prop>

<FileGlobals>    Variable Value

<StationGlobals>    Variable Value

11.  Modify your text file and use the Import/Export Properties tool or the property loader step to import the text file

12 . Verify that the array bounds are modified

 

You could use this technique to initialize an empty array using the property loader.

Hope it helps.

 

Regards.
Message 10 of 12
(4,822 Views)