NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically Assign Action Step Input Parameters

Solved!
Go to solution

I am hoping someone could indulge my laziness regarding passing variant data types from TestStand 2013f1 to LabView 2015 SP1.

 

Since the "Anything" data type in TS and the variant data type in LV don't play nice, I have to manually pass the data type from TS to LV.  I do this by adding an input to the VI that accepts a string description of the TS data type.  I then use the "TypeOf" function in TS to get this string descriptor.  This works well; however, I call this action many, many times with different data types.  I worry that I will forget to update the TypeOf input every time I instantiate this VI.  This would produce a run time error, which are annoying.

 

What I want is to autofill the TypeOf function with whatever Local, Parameter, etc I type into the variant (Anything) input of the VI.

Get Type Info.PNG

 

I'm not a TS architect but I've poked around the API trying to see if there's anything that can provide this functionality.  I am doubtful I can do this but I wanted to check with the community before I gave up.  

 

Thanks for your help in advance.

 

0 Kudos
Message 1 of 7
(5,330 Views)

Hi,

 

Good news - you can do this!

 

Using the API, you can programmatically access the parameter information of the step.

 

If you know the parameter index of your container (x) and the name of the element in the container that you want to obtain the type of ("Data"), you can use the following expression in the "Data Type" parameter:

 

Step.Module.AsLabVIEWModule.Parameters.Item(x).ArrayClusterEls["Data"].TypeDisplayString

 

I hope this helps,

 

Charlie

 

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 2 of 7
(5,318 Views)

Charlie,

Thanks for this.  I poked around the Step.Module API but didn't see AsLabViewModule.  I just needed to scroll to the bottom.Smiley Frustrated

 

I change the string you gave me to the following:

 

Step.Module.AsLabVIEWModule.Parameters.Item(1).ArrayClusterEls["[0]"].ArrayClusterEls["Data"].TypeDisplayString

 

This ended up returning "Anything," which is the TS type for the "Data" parameter so I changed it to the following:

 

Step.Module.AsLabVIEWModule.Parameters.Item(1).ArrayClusterEls["[0]"].ArrayClusterEls["Data"].ArgVal.Type.TypeName

No matter what I set "Data" to (number, string, etc.), this always evaluated to "Expression."

 

 

It looks like this isn't going to work.  The TypeName is literal.

 

Thanks for the help though!

Message 3 of 7
(5,305 Views)
Solution
Accepted by topic author jrasco

Ah - yes, I understand now.  My expression was getting the type of the LabVIEW parameter, whereas we want the type of the variable we are passing into LabVIEW!

 

This should work for you.

 

TypeOf(Evaluate(Step.Module.AsLabVIEWModule.Parameters.Item(1).ArrayClusterEls["[0]"].ArrayClusterEls["Data"].ArgVal))

 

Regards,

 

Charlie

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 4 of 7
(5,294 Views)

Yes, I tried this too but it always returns "Expression," which is useless.  I plan on submitting a request to the TS Idea Exchange.  Maybe Typeof can be updated to return more than "Expression."

 

I do know now how to achieve what I need using the TS API.  It invloves parsing the string entered into the "Data" paramter.  This parsed string will then be compare it against the list of variables used in the sequence to find the data type.  It gets complicated because variables aren't always entered into the "Data" parameter or there could a scalar multipled with a vector.

 

Jacob

0 Kudos
Message 5 of 7
(5,282 Views)

Charlie,

I figured it out!  I forgot that TS has an evaluate function.  The final expression should be:

 

TypeOf(Evaluate(Step.Module.AsLabVIEWModule.Parameters.Item(2).ArrayClusterEls["[0]"].ArrayClusterEls["Data"].ArgVal))

This gives me exactly what I'm looking for.

 

Thanks,

Jacob

0 Kudos
Message 6 of 7
(5,279 Views)

Haha!  I missed the Evaluate in your second reply.  I should have had my coffee before reading your reply.

0 Kudos
Message 7 of 7
(5,278 Views)