NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Loading a particular array's elements using property loader

This question has kind-of been asked before, but I can't find a good answer.  I have a configuration file that has, say, two arrays in it.  I want to load in all the elements from one of the arrays (I don't know how big the array will be, so let's assume that the local the elements are going in to is big enough for all the elements in the file) - how do I define that in a property loader?  I know I can list out all the elements separately (eg: arrayOfStrings[0], arrayOfStrings[1] ... arrayOfStrings[n]), but as I said, I have no idea on how many elements there will be.

 

I've attached an example - the config file has two arrays in it (arrayOfStrings and arrayOfNumbers).  I'd like the first property loader to load in only the arrayOfStrings elements.  (The second property loader loads in all the elements, just to make sure that my file is okay 🙂 )

 

I know that there are methods using XML and XLS, but I need this to work with tab-delimited files (it's what my client is used to, and moving away from them isn't an option right now).





Copyright © 2004-2021 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 1 of 10
(3,859 Views)

Crelf,

 

Since it will successfully import all values from a given
file, what is your use case for not wanting certain values? If you are trying
to import separate data sets, i would recommend separate files. Otherwise there
is a goodbit of data missing from the .dat file included in your zip file. I
tried this again after using TestStand to export values to a .txt tab delimited
file and it works correctly. 

 


Richard S -- National Instruments --Applications Engineer -- Data Acquisition with TestStand

0 Kudos
Message 2 of 10
(3,837 Views)

Snowman 6008 wrote:

what is your use case for not wanting certain values? If you are trying
to import separate data sets, i would recommend separate files.


It's a pretty long story to describe the use case - just trust me: I need the properties to be in one file, I need the file to be in tab-delimted format, and I need the property loader to load properties selectively.


Snowman 6008 wrote:

Otherwise there
is a goodbit of data missing from the .dat file included in your zip file.


Like what?  I know that the XML format works, but, as I already said, I need to use the tab-delimited format.  What I'm asking is if it's possible to include the information about array sizes that exists in the XML format in the tab-delimited format?  If so, how?  If not, then mark it as a feature suggestion, as a lot of people have asked for this funcitonality in the forums.





Copyright © 2004-2021 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 3 of 10
(3,821 Views)

Crelf,

 

The reason your text file seems to work is because locals.arrayOfStrings[0] can be addressed directly, and written to. So when you are using property loader to import all your values, TestStand will gladly write to  locals.arrayOfStrings[0]. But when you only tell it to import locals.arrayOfStrings it will evaluate locals.arrayOfStrings[0] == locals.arrayOfStrings to be false. 

 

This is why the "XML" version works, because the left most value is still  arrayOfString. 

 

 

Feel free to make a product suggestion at http://digital.ni.com/applications/psc.nsf/default?OpenForm&temp1=&node= . If you like you can also modify the property loader using the TSDBComponents.cws in C:\Program Files\National Instruments\TestStand 4.2\Components\StepTypes\Database .

 

 

 

Richard S -- National Instruments --Applications Engineer -- Data Acquisition with TestStand

0 Kudos
Message 4 of 10
(3,796 Views)

Crelf,

 

As you probably already know, you can import an array property with the property loader step using the XML string format. When you import the XML string, your array property dimensions will be overwritten with the dimensions specified in the XML string. According to your post you can not use this solution and you are looking for an alternative way for importing all the individual array elements specified in your source file. Unfortunately currently there is no way for the property loader step to accomplish this because the property loader step only imports the properties specified in the selected properties list that is configured at edit time.I have reported this suggestion to the development team.

As an alternative you can accomplish what you want by using two property loader steps and the TestStand API as showed the attached example.

In the example I am trying to import the element for Locals.MyArray. In order to specify the desired dimensions of the array I am importing Locals.LowerBound and Locals.UpperBound first from the source file. Once I have the dimensions, I use them to update the dimensions of Locals.MyArray and to specify  what properties should be imported by the "Import Array Elements" step.

Finally the "Import Array Elements" step imports all the array elements specified in the source file.Notice that you can easily specify the array dimensions and the array elements to import by modifying your source file. Let me know if it helps.

The sequence file was saved using TestStand 4.0 format.

 

Download All
Message 5 of 10
(3,787 Views)
Thanks for your help gents - it is as I expected 🙂  I appreciate you taking the time.




Copyright © 2004-2021 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 6 of 10
(3,764 Views)
Thanks for the example, I'm working with crelf on this issue and would like to add a wrinkle.  I would like to make this a sequence call so that I can use it throughout the project.  I have passed the array reference to the subsequence and think I have setup the property loader parameters to be similar, but I'm not having any luck with the actual property loader call.  Any help would be appreciated.  Thanks.
0 Kudos
Message 7 of 10
(3,610 Views)
You may find this thread interesting or useful: http://forums.ni.com/ni/board/message?board.id=330&message.id=27332#M27332
Richard S -- National Instruments --Applications Engineer -- Data Acquisition with TestStand

0 Kudos
Message 8 of 10
(3,577 Views)
Hi Antonio, Your code is what I was looking for, as I prefer having a table defined with 1 line per value instead of the XML notation. Unfortuneatly, I have an error: "Error Message: The post-expression for the step 'Set number of elements to import in array property' could not be evaluated. Unknown variable or property name 'Locals.MyArray.Type'. [Error Code: -17306] " Any idea why ? I am using TestStand 4.0.1. Thanks
0 Kudos
Message 9 of 10
(2,719 Views)

Hi,

 

I have updated failing step "Set number of elements to import in array property" with

Locals.MyArray.SetDimensions("", 0, "["+Str(Locals.LowerBound)+"]","["+Str(Locals.UpperBound)+"]")

 

and it now works in TestStand 4.0.

0 Kudos
Message 10 of 10
(2,709 Views)