NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create an instance of TestStand Engine from .Net

How can I create an Instance of the TestStand Engine without the ApplicationManager in C# or .Net?

engine = new NationalInstruments.TestStand.Interop.API.EngineClass();

is that all?
0 Kudos
Message 1 of 11
(5,954 Views)
Does nobody knows how to start the engine?
0 Kudos
Message 2 of 11
(5,930 Views)
Hi,
 
Have a look at the Operator Interface code (the old style) as this doesn't use the Application Manager.
 
Regards
Ray Farmer
Regards
Ray Farmer
Message 3 of 11
(5,927 Views)
Yes there is an example for C++:
m_engine.CreateInstance("TestStand.Engine");

but the method "CreateInstance" doesn't exists in .Net or I didn't found it.

with
engine = new NationalInstruments.TestStand.Interop.API.Engine()
there is no error but I think the engine don't run because no execution runns.
0 Kudos
Message 4 of 11
(5,926 Views)
Eddy,

i do not understand your point "no execution runs". Just getting the reference to the engine object does not cause TestStand to start any executions. This is at least what i understand by your statement. On the other hand, maybe you wanted to state: If i try to start an execution by using this engine-reference,  nothing happens. I get no error but i also dont see any running executions.
So please let us know which one's the correct 🙂

Norbert B.
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 11
(5,913 Views)

I want to create an insance of the TestStand engine to work with TestStand. without using the ApplicationManager.

I'm using .Net 2.0 with C#. The reason is that I don't have a Userinterface to place the control on it. So there must be a way to start TestSand without the Manager classes

0 Kudos
Message 6 of 11
(5,607 Views)
Not sure I understand either, but after you get a reference to the Engine, you need to do some other things to get an execution to run.  In a nutshell, you need to get the SequenceFile and then you can create an Execution (which is the running of the sequence).  Here's some pseudocode for you:

Engine eng = new Engine();  // gets the engine
SequenceFile seqFile = eng.GetSequenceFileEx( fullfilenameofsequencetoload, 0, TypeConflictHandlerTypes.ConflictHandler_Error);  // loads up the sequence file
Execution exc = eng.NewExecution (seqFile, "Single Pass", null, false, 0, System.Type.Missing, System.Type.Missing, System.Type.Missing);  // runs the entry point sequence

The help file has all the details for these calls and there's some subtleties in there, but hopefully that will point you in the right direction.


0 Kudos
Message 7 of 11
(5,592 Views)

yes that's right. the problem was that I have to call

msg.Acknowledge(); in the Eventhandler

engine_UIMessageEvent(UIMessage msg)

otherwise the engine do not send messages any more. And I have to set engine.CurrentUser.

Now the problem is to ReleaseSequenceFileEx(..) after an execution. The return value is false. I'll check if there is somthing loaded or not released.

0 Kudos
Message 8 of 11
(5,586 Views)
As for having problems during the ReleaseSequenceFileEx, my only advice is to remember that all the TestStand API objects are COM-based.  Thus, follow a very strict creation/releasing of objects regime.  Liberal use of Marshal.ReleaseComObject(obj); and obj = null; goes a long way in helping keep eveything tidy.
0 Kudos
Message 9 of 11
(5,578 Views)

re: "I'm using .Net 2.0 with C#. The reason is that I don't have a Userinterface to place the control on it. So there must be a way to start TestSand without the Manager classes"

Just put the manager controls on a form that you load but don't display. Programming with the manager controls is much easier than without.

 

re: "Liberal use of Marshal.ReleaseComObject(obj); and obj = null; goes a long way in helping keep eveything tidy."

The .net UI examples work fine without any calls to Marshal.ReleaseComObject(obj). They do this with a couple of strategically placed calls to GCCollect. In fact, ReleaseComObject can't be used to ensure all TestStand objects are released before engine shutdown because the .Net/COM interop layer creates temporary wrappers for event parameters that your code never sees when it processes ActiveX events for which you do not provide handlers.

In general, TestStand only expects that all TestStand references are released by engine shutdown time and that sequence files are released in a timely manner in order to trigger their unload callbacks (I can't recall at the moment whether this is purely triggered by ReleaseSequenceFileEx, or if holding a plain COM reference could prevent an unload callback from firing). Note that the explicit releasing of sequence files is a special case that communicates to the engine how the file is being used. In .net, you have no need to explicitly null out a TestStand object variable as long as your application variables no longer reference the object by the time shutdown occurs. This means, that you shouldn't ever need to set a local or parameter that holds teststand object to null.

0 Kudos
Message 10 of 11
(5,575 Views)