01-26-2011 12:27 PM
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:
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
Solved! Go to Solution.
01-27-2011 03:05 AM
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)
01-27-2011 04:18 AM
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:
linked to this: http://forums.ni.com/t5/NI-TestStand/Marshalling-the-IEngine-object/m-p/666852
Hope this also helps
Juergen
01-27-2011 06:32 AM
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
01-27-2011 10:01 AM - edited 01-27-2011 10:03 AM
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