NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Data from a MainSequence to a Callback

Solved!
Go to solution

I'm just trying to learn TestStand so bear with me.

 

I'm using the default sequential model. I've added some steps and local variables to my MainSequence. I've copied the TestReport callback from the default sequential model and added that to my list of sequences as a callback. I have since added some steps to personalize the TestReport sequence callback.

 

My issue is figuring out how to pass a LocalVariable from my MainSequence to my TestReport callback. What's the best method? How can I use an Expression statement in my TestReport callback to retrieve the data from the MainSequence Local? Is that the best method?

 

I've spent 8 years doing dataflow programming with wires. This disconnected passing of data is very frustrating.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 1 of 7
(3,916 Views)

I like your method of thought.  In general it is best to pass data back and forth using parameters.  Unfortunately with callbacks you cannot change the parameter lists (because they are called from the Process Model).

 

So you will have to use FileGlobals.

 

In general I hate Globals but this is the correct use for them.  Avoid StationGlobals though... 🙂

 

The other way is using: RunState.SequenceFile.Data.Seq["MainSequence"].Locals.MyVar  This is bad for obvious reasons but should still work.

 

Good Luck,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 7
(3,846 Views)

Thx for the reply ~jiggawax~, but why would using the expression be a bad thing? (not so obvious to me)

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 3 of 7
(3,844 Views)
Solution
Accepted by topic author B.Settles

Not sure how familiar you are with the RunState variable?  RunState basically holds information describing the state of execution.  At that point in your callback the state of execution in MainSequence is unknown (although you have a pretty good idea).  In your case you are probably safe but there are cases when it could cause issues.  It's just not safe to get in the habit of accessing data through RunState.  Plus it makes maintenance harder because now you have stronger coupling (not in your case though).

 

In my opinion FileGlobals seems to be more stable.

 

There are times when accessing RunState is necessary but I like to use it in moderation.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 7
(3,840 Views)

Hi,

What you are talking about is passing values from one sequence to another. In your case from MainSequence to TestReport.

It is true that the most maintainable and readable way to pass the variables to a subsequence (TestReport) is through parameters. The other solutions are like using LabVIEW Globals and Locals 🙂 In this case you would have to modify your process model file to do this.

Fileglobals are visible to all sequences in a sequence file, you'll have to replace your locals of interest with FileGlobals, or copy the Local values to the FileGlobals just before the Report sequence call. I think jigg has a good recommendation here.

I don't think you can use the Runstate expressions in this case because at the time TestReport executes, your MainSequence execution is completed and it is out of memory (including the Locals). That's what jigg means by, "...the state of execution in MainSequence is unknown..."

If you are doing this for the file header or footer I think this is ok. But if it is data you could use Additional Results steps in your sequence to get the data into the ResultList. It's like using dummy steps just to host the data. This would be more scalable, it would automatically show up in the report, database and everywhere else.

I also wanted to say that many LabVIEW people have been frustrated by TestStand, join the club! If you stick with it, it is very rewarding, a great product, and you can move up from maintaining boring, low level test executive code. If you feel frustrated call tech support or use the forums. There is always an answer and it is safer to stick with NI's recommendations even if they sound wierd at times.

 

cc

Message 5 of 7
(3,828 Views)

thanks to everyone for the replies. They actually helped me understand why, instead of just telling me what to do. I'm going with the File Globals until I get the courage to start my own process model (heavily based on the defaults), but I was wondering if any of you have taken the NI TestStand courses and what you thought.

 

I had a good experience with the LabVIEW courses, and I'm thinking the TestStand courses would be very helpful in trying to understand "Why", if I can get the money pinchers to open up their wallets a little.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 6 of 7
(3,797 Views)

I used to teach the TestStand courses as well as the LV courses.  In my experience the best students were the ones that had played around with the product for a few months before attending the course (which it sounds like you are doing).  It seems that they got the most out of the course because they came with real life questions and problems and kind of knew where they were headed with the application.  The course was able to solidify their understanding of the product as well as opened their eyes to some tips and tricks that made their life easier.  If you go in green then you will most likely be focused on trying to understand what LV or TS does and navigating them as opposed to picking up on the tips and tricks and solidifying your understanding.

 

A friend of mine said there are 3 types of students in the NI courses:

Those that are forced (Boss decided to use LV/TS and made them go to learn)

Those that are vacationing (Conned boss into thinking this was necessary so they could get out of a week of work)

Those that are there to learn (Actually want to be there and have real problems they want to solve with the knowledge)

 

If you go in as the 3rd type of student then the courses are awesome and you can get a lot out of them.  Otherwise they are a waste of time and money.

 

Hope this helps,

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 7
(3,791 Views)