From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

C# teststep: How to pass Visa reference to correct instrument?

Solved!
Go to solution

Hello,

in C# i created a DLL for an instrument with functions like Initialize, SetVoltage, Close.

In the Initialize function i create the object for this session with:

            RM = new ResourceManager();
            Instrument = new FormattedIO488();

 

Now i put the Initialize function in TestStand 2014SP1 as a .Net-Module-NumericLimitTest.

When opening the properties of my new step in the Type-Editor then there is a button "Default Module" where i can select the function of the C#-DLL.

 

All paramaters are shown (like VISA-Address) and also an additional parameter "Return Value" Object Reference" OUT which was added by TestStand.

-> I save this value in a StationGlobal.

 

Question is now:

If i have more than one instrument of the same type (means two or more Initialize-calls) how can i pass the saved references to the next function (SetVoltage) so that is executed on the correct instrument?

 

Thanks for help

0 Kudos
Message 1 of 3
(3,644 Views)

When i do this in C# then i have to execute a "new" to the object.

Like

MyDMM.MyDMM INST_A = new MyDMM.MyDMM();

MyDMM.MyDMM INST_B = new MyDMM.MyDMM();

MyDMM.MyDMM INST_C = new MyDMM.MyDMM();

...

...

INST_A.Initialize(IPaddress,..)

INST_B.Initialize(IPaddress,..)

INST_B.Initialize(IPaddress,..)

 

How can i do this "new" in TestStand? And how would i pass the object-names to the teststeps?

 

Thanks

0 Kudos
Message 2 of 3
(3,640 Views)
Solution
Accepted by topic author OnlyOne

Solved:

Select "Use Existing Object" un -Net Invocation and pass the saved reference in there.

0 Kudos
Message 3 of 3
(3,634 Views)