NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically add measurements and data sources to test step??? LV TS API

Hello!  I am trying to, via LabVIEW using the TestStand API, programmatically add measurements and datasources for those measurements to my test steps.

 

Currently I have figured out how to modify measurements (i.e. Step.Results.Measurements[x].Limit.Low).  I just can't figure out how to add new measurements.  I've tried using the NewSubProperty and InsertSubProperty methods, but with no luck.  Essentially, what I am trying to do is allow for a dynamic number of measurements in a test step (i.e. for an array of data that may change in size).

 

Does anyone have an example of how to do this?  I have found nothing specific in NI's documentation nor by searching their site.

 

I'm using LV2010 and TestStand 4.2.1.

CLA, CCVID, Certified Instructor
0 Kudos
Message 1 of 16
(4,317 Views)

I have an example but it's in TestStand.

 

So I'm assuming you are using the MultiNumericStep type correct?

 

The trick is 4 properties:

Step.Result.Measurement (Array of NI_LimitMeasurement)

Step.NumericArray (Arry of Numbers, gets filled with measurement)

Step.DataSourceArray (Array of Expression, leave blank for default behavior)

Step.ExpectedNumMeas (needs to be the size of the arrays)

 

All the arrays need to be the same size. Step.ExpectedNumMeas needs to be the size of the arrays.

 

If you want to see how it works then just add some limits in TestStand and then go look at those properties in the Property Browser and see what they get filled with.

 

My example is at home.  If this doesn't get you going then let me know and I'll modify and send it to you.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 16
(4,310 Views)

I do understand how these properties are all related, and for what they are used, however I am not having any luck at creating them programmatically with the TestStand API.

 

What do you mean by an example in TestStand?  I can easily generate all of this using the TestStand IDE, but I am trying to programmatically generate it all via the test step itself, since the number of results and the limits themselves will vary.

 

If you have example code of setting these programmatically I'd love to take a look at it (doesn't have to be labview, i can trasnlate C/CVI).  Thanks!!!  Smiley Happy

CLA, CCVID, Certified Instructor
0 Kudos
Message 3 of 16
(4,308 Views)

I dynamically create steps and set these properties within TestStand through the TS API.  So it would be what you are doing but just in TestStand instead of LV.  I just use Statement steps.  I will send you a modified version later tonight.

 

Thanks,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 16
(4,305 Views)

Enjoy at your own risk.  Let me know if you have any questions.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 5 of 16
(4,294 Views)

Hi Jeramy,

 

just as an addtion to Jiggs pretty good example.

 

In this thread you will find links some more examples.

http://forums.ni.com/t5/NI-TestStand/Build-a-test-sequence-from-a-script/m-p/1305696/highlight/true#...

 

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 6 of 16
(4,287 Views)

Very nice example, however I am still stuck on this because the method names do not seem to match what is exposed through propery and invoke nodes.

 

In your example you use a method called "InsertElement", to which object does this belong?  Is this the same method as InsertSubProperty?  It does not appear that the way you access the TestStand API from TestStand expressions is the same as how it is accessed via LabVIEW.  For now I'll try to use the same flow of calls you use in your TestStand example as a guide and take my best guess as to the corresponding methods in LabVIEW.  I'll keep you posted as to how it goes.

 

Dear NI, it would help to have some consistancy.  Thanks.  Smiley Wink

 

Anyone else have an example of how to create limits in TestStand via LabVIEW or CVI?

CLA, CCVID, Certified Instructor
0 Kudos
Message 7 of 16
(4,283 Views)

 

InsertElements would be similar to Build Array or Insert Into Array in LV.  That step is called malloc (named because of the old memory allocation in C).  Basically in any language you have to define how many elements are in an array before you start setting those elements (in Set Limits step).

 

InsertElements isn't in the TS help so it's kinda tricky to find more info.  However, if you click on the f(x) button next to that expression then you get the Expression Browser.  In there you'll see a tab called Operators/Functions (common functions available to assist in development in TS). 

 

So you probably shouldn't accuse NI of too much wrongdoing... 😉

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 8 of 16
(4,268 Views)

Thanks for clarifying where the InsertElement function comes from in TestStand.  I see what he's doing here now, however, it is not much help for what I am trying to accomplish since you cannot manipulate TestStand objects in LabVIEW the same way as primitive LabVIEW datatypes.  I could make an array of limits in LabVIEW, but they would be LabVIEW doubles or a cluster for example, not Step.Result.Measurement containers.  In the TestStand IDE you can create an array of that native type because you're in TestStand, not LabVIEW which canonly access TestStand via the API.  Thus, again, the missing link is what method of what object is appropriate for creating and inserting measurements into a TestStep.

 

In the Expression Browser window of TestStand there is a tab for "TestStand API."  This is what I am limited to for manipulating TestStand types within LabVIEW.  This is the only set of methods I can use for putting things into or getting things from TestStand via LabVIEW.

 

The InsertSupProperty method requires a reference to an existing Propery Object (in this case I would want a Measurement object)...but how do I create one?

 

The NewSubProperty method creates a new generic Property Object, but will not specifically be a Measurement object and will not appear in the Measurements array when created in a new index (it doesn't work like an add or insert function) and nor does it return the reference to the object I just supposedly created.

 

If you have expertise in this API I would greatly appreciate your help.  Thanks for your time so far, both of you, it is highly valued.

CLA, CCVID, Certified Instructor
0 Kudos
Message 9 of 16
(4,258 Views)

A measurement object really just is a PropertyObject.  You can create one with this type from the Engine.NewPropertyObject with passing the name of the type.

0 Kudos
Message 10 of 16
(4,246 Views)