NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Display current Step with API

Solved!
Go to solution

Hello,

I am using LabVIEW 2009 AP1, and I am calling a TestStand 4.2 Sequence using the API. I am not using the Operator interface, as this is not a GUI, but a module that will just run a sequence.

 

I essentially replicated the .NET calls listed here:

http://forums.ni.com/t5/NI-TestStand/Calling-user-created-Teststand-sequence-from-NET/m-p/703125?que...

Only with the LabVIEW activeX engine, properties and methods. Therefore I have references to the TS Engine, sequence file, process model and execution.

 

What I need is access to the current step name. I don't need the whole sequence viewer, essentially just access to the "Step.Name" property at any specific time.I would guess this would be accessable through the execution reference, but I am unable to track it down. I am suspecting it will be getting a reference to a subproperty of the execution and then acting on that in someway, but I can't get there from here.

Any ideas?

 

Thanks,

Tim

 


Data Science Automation

CTA, CLA, CLED
SHAZAM!
0 Kudos
Message 1 of 5
(4,736 Views)

Tim,

 

You need to setup a UI Message Handler so that you can handle Trace Events which will give you the means of getting the Step details.

 

http://zone.ni.com/reference/en-XX/help/370052J-01/TOC28.htm

http://zone.ni.com/reference/en-XX/help/370052J-01/tsapiref/infotopics/app_exe_events/ (for Tracing Events)

 

 

Regards
Ray Farmer
Message 2 of 5
(4,720 Views)
Solution
Accepted by Mellobuck

Hi Tim,

 

Just two other solutions:

 

If you have a handle to your execution

you could use Execution.GetThread() Note: You have check with property Execution.NumThreads how many there are present.

lets hope there is only one!

Access the thread, and get context with Thread.GetSequenceContext

Now you should be able to access the name with SequenceContext.Step.Name

 

Another solution to this stuff might be found there:

http://forums.ni.com/t5/NI-TestStand/Is-is-possible-to-retrieve-a-sequence-context-through-a-new/m-p...

linked to this: http://forums.ni.com/t5/NI-TestStand/Marshalling-the-IEngine-object/m-p/666852

 

Hope this also helps

 

Juergen

 

 

 

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 3 of 5
(4,713 Views)

Thanks Juergen,

I checked the documentation on the API and discovered that Executions contain Threads which then contain the Sequence context. Once I connected the Sequence context I was able to monitor the Step properties, including name.

Like you said, once the execution completes, the threads disappear, so I had to make sure I wasn't trying to read it after that.

 

Thanks,

Tim


Data Science Automation

CTA, CLA, CLED
SHAZAM!
0 Kudos
Message 4 of 5
(4,704 Views)

It is not safe to access the threads/sequence contexts of an execution from your UI thread while it is actively running. There are race conditions with accessing these properties if the thread or threads are not suspended for a trace or break event. UI messages are a more robust way to do what you are trying to do because the thread or threads involved are suspended until you are done handling the UI message. If you are accessing threads using GetThread or properties of a sequence context in a different thread than the one which it represents while the execution is actively running, you risk the possibility of crashing your application.

 

-Doug

Message 5 of 5
(4,684 Views)