05-11-2016 12:05 PM
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.
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.
Solved! Go to Solution.
05-12-2016 03:40 AM
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
05-12-2016 12:06 PM
Charlie,
Thanks for this. I poked around the Step.Module API but didn't see AsLabViewModule. I just needed to scroll to the bottom.
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!
05-13-2016 03:22 AM
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
05-13-2016 03:59 PM
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
05-13-2016 05:21 PM
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
05-13-2016 05:23 PM
Haha! I missed the Evaluate in your second reply. I should have had my coffee before reading your reply.