NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using TS Expressions or LabVIEW API to map VI Call controls and indicators to Test Stand variables and report

Hey all,

 

Short story: how to map inputs and outputs of a VI Call to TestStand variables using expressions or LabVIEW API?

 

Long story:

I wish to create sequences from XML, which are capable of calling VIs and doing stuff with their IOs.

My strategy is to expand the XML Sequence Translator Example to also call LabVIEW VIs and map their IOs to TS variables and/or to the TS report.

 

For example, this part of the XML creates an action step with a VI call:

<Step Name="Open VI" Type="Action" Adapter="G Flexible VI Adapter">
     <Expr>Module.AsLabVIEWModule.VIPath="test_popup_transl.vi"</Expr>
     <Prop LookupString="Module.LoadPrototype(0)"></Prop>
</Step>

 

With additional expressions, how can I map the VI controls and indicators to test stand variables and report?

 

Which expressions / properties to modify? I would be happy using expressions or equivalent LabVIEW API calls, but I'm currently lost as to which properties to setup or which methods to call.

 

Any ideas?

0 Kudos
Message 1 of 8
(1,523 Views)

Not sure if you know about the set and get XML methods for a property object: 

GetXML: https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/propertyobject_getxml_m/

SetXML: https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/propertyobject_setxml_m/

 

And since everything (except the engine) inherits from PropertyObject in TestStand then you can essentially convert anything into XML (including Steps, Sequences, Sequence Files, Etc....).  Then you can just manipulate the exact values you want and then read it back in.  It gets a little ugly though because it is flattening every little piece of information needed to recreate the object.

 

Basically think of a step as a large data type with a whole bunch of nested sub properties.  In the Sequence Editor you are simply defining the "attributes" of that data type.  So by making a step a LabVIEW step it will automatically have a Step.TS.SData.ViCall container.  the TS.SData container is used for when you change the adapter of a step.  The ViCall property has a sub property called Parms, which is basically an array of containers, each representing an input/output to your VI.  So if you had an error cluster going into your VI and wanted to see if it had an error then you could use Step.TS.SData.ViCall.Parms["error out"].ArrayClusterEls["status"].ArgDisplayVal. 

 

As you can see this gets very complex and ugly and is very STATIC.  So TestStand has created a nice API to do all of this.  You can find more about the API here: https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/labviewadapter/  

 

Personally, I think you could accomplish what you want by simply using the property loader step and just use local variables and pass those into your LabVIEW step.  Assuming your goal is to have someone edit certain values in a text editor.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 8
(1,486 Views)

Hi jiggawax, thanks a lot for your reply!

 

you're right, editing the large XML is a pain and actually, I am trying to use the LabVIEW API*. But I'm getting stuck...

 

And you calling LabVIEW API simple makes me curious 😄

In hope for you shedding even more light, here's some more context:

 

I wish to create a tool, which takes a list of VIs and creates a TS sequence. So far, my best bet is to use the LabVIEW API to create a TS sequence of mainly VI Call Action steps and already map each VI's inputs and outputs to TS variables (for passing among VIs) and the TS report. Then I'd run the resulting sequence in TS and get a report from it.

 

So far, I've been able to use expressions in LV Invoke Nodes (Step.asPropertyObject.EvaluateEx(exprString)) in the translator to configure a VI call step. When I open the resulting sequence in TS, it successfully calls the VI I specified.

 

However, looking at the Variables Pane in TS, my call's Step.TS.SData.ViCall.Parms is empty, although the VI has a string indicator. 

 

Seems like I'm stuck here:

 - how can I use the LabVIEW API to determine the VI prototype in the programmatic construction of the VI Call step?

 - how can I use the LabVIEW API to map something to those parameters in the VI prototype?

 - ... I'll also need to create sequence variables and probalby types and such, but baby steps.

 

Hope you have some tips,

Rok

 

*The XML part of my strategy is secondary and we can ignore it for simplicity - it's just a way to input instuctions to the XML Translator Example [1], which I'm using as the basis of the tool that I'm describing. At the moment, I'm using XML to define steps and set their properties and pass expressions to the tool, but I'm happy to just perform these same steps in the tool directly.

[1] https://zone.ni.com/reference/en-XX/help/370052AA-01/tsexamples/infotopics/sequencefiletranslators/

0 Kudos
Message 3 of 8
(1,482 Views)

For posterity, my colleague found these useful instructions and example, which solves my wishes above:

https://forums.ni.com/t5/NI-TestStand/Setting-VI-Parameters-in-LabView-Action-Module-with-TestStand/...

https://forums.ni.com/t5/Example-Code/Creating-a-Sequence-File-with-a-LabVIEW-Module-Step-Using-the/...

 

Some comments:

 - Invoke Node of LabVIEWModule does not show its parent's methods :(. The trick is to first configure the Invoke Node on Module reference, then wire a LabVIEWModule reference to it.

 - Generally, making this work with the LV API has involved a lot of reverse engineering, trial&error and looking for examples & tricks, even after referring to the TS developer and TS architect online courses.

 

For all TestStand w. LabVIEW API experts out there, what was the most useful to you when learning how to navigate the TS API, its classes and methods? Which is the best way to debug your expressions and function calls?

 

Thanxx,

Rok

0 Kudos
Message 4 of 8
(1,439 Views)

Sorry for the slow response.  I forgot to send this out the other day.

 

I've thrown together a simple example demonstrating this.

 

test.vi just needs to be in a valid search directory for this to work.

 

All you need to do is run the sequence called Add Step (no process model).  It should inject a LV step into MainSequence and set the report text parameter.

 

Obviously this is a very simplified version of what you are looking for.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Download All
Message 5 of 8
(1,434 Views)

@tavta wrote:

 

For all TestStand w. LabVIEW API experts out there, what was the most useful to you when learning how to navigate the TS API, its classes and methods? Which is the best way to debug your expressions and function calls?

 


For me I tried in in TS first and then got it working in LabVIEW.  The TestStand help is very well written, in my opinion, for the APIs.

 

The other lightbulb moment for doing TS API calls in LV was understanding the different APIs (adapter api vs teststand api) and typecasting is done through the data to variant node.

 

Glad you are on your way.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 6 of 8
(1,433 Views)


The other lightbulb moment for doing TS API calls in LV was understanding the different APIs (adapter api vs teststand api) and typecasting is done through the data to variant node.

Yuup, this is a big one, thanks! It's hard to discern these two and I'll need some time to understand clearly the boundary between them and the proper way to traverse the two APIs.

 

@jiggawax, how did you dispel this confusion? Which resource was the most valuable? 

 

I've attached an example project, could be useful for someone for posterity:

 

Top VI:

 - creates a sequence with some fileglobal vars

 - finds 2 module VIs in Modules/ subfolder

 - for each VI, calls AddStep.vi and maps their IOs to global vars (will result in passing data from one module to the other)

    ... the VI IOs must be known when AddStep.vi is called.

 - closes the references 

AddStep.vi:

 - for every LabVIEWParameter being mapped, configure its corresponding AdditionalResult such that it's included in the report. NOTE: the LabVIEWParameter stuff belongs to LV Adapter API, the AdditionalResult stuff belongs to TS API.

 

Some useful links:

 

Original example: https://forums.ni.com/t5/Example-Code/Creating-a-Sequence-File-with-a-LabVIEW-Module-Step-Using-the/...

 

Class overview & such:

https://www.ni.com/pdf/manuals/372844d.pdf

https://www.ni.com/cs-cz/support/documentation/supplemental/08/teststand-report-generation-and-custo...

 

Message 7 of 8
(1,400 Views)

@tavta wrote:


@jiggawax, how did you dispel this confusion? Which resource was the most valuable? 


For me it was just trial and error, the TestStand help, the forums and asking the TestStand R&D team at NI Week.

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