07-14-2011 04:10 PM
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.
07-14-2011 04:54 PM
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.
07-14-2011 05:11 PM - edited 07-14-2011 05:14 PM
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!!!
07-14-2011 05:24 PM
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.
07-15-2011 12:29 AM
07-15-2011 12:55 AM
just as an addtion to Jiggs pretty good example.
In this thread you will find links some more examples.
07-15-2011 07:54 AM
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.
Anyone else have an example of how to create limits in TestStand via LabVIEW or CVI?
07-15-2011 11:02 AM
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...
07-15-2011 12:44 PM
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.
07-15-2011 01:58 PM
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.