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: 

API testStand for ModuleAdpater DotNet

Once you've loaded the prototype, you can access the parameters by using the DotNetModule.Parameters property (returns DotNetParameters which is a collection of parameters for the member in question). You can then access the particular parameter you want using the DotNetParameters.Item() method (returns the DotNetParameter at the specified index). You can then set the value of the parameter using the DotNetParameter.ValueExpr property.

 

Hope this helps.

Manooch H.
National Instruments
0 Kudos
Message 11 of 42
(2,061 Views)
yes i used the method LoadProtoTypeFromMetDataToken(token,options).After that How to use the DotNetModule.Parameters exactly?
0 Kudos
Message 12 of 42
(2,047 Views)

Well, in order to use LoadPrototypeFromMetadataToken(), you must already have a DotNetModule reference to the step. Once LoadPrototypeFromMetadataToken() has been executed successfully, one approach you could take is the following:

 

for (int i = 0; i < DotNetModule.Parameters.Count; i++)

{

      if (DotNetModule.Parameters.Item(i).ParameterName == "name of parameter you want to set")

      {

                DotNetModule.Parameters.Item(i).UseDefaultValue = False;

                DotNetModule.Parameters.Item(i).ValueExpr = "value you would like to set the parameter to";

      }

}

 

Were the links that I provided to the TestStand Online Help for DotNetModule.Parameters and DotNetModule.Parameter in my previous post not helpful?

Manooch H.
National Instruments
0 Kudos
Message 13 of 42
(2,043 Views)

Hello and happy new year!

 

I think you need to use the function with LabwindowsCVI : setParameterValueExpr

 

But i have the same problem that you because i can't load correctly the DotNet Prototype and so i can't retrieve the list of parameters.

Please let me know if you have managed to set value for a parameter.

 

Manooch,

I haven't answered before because I haven't had enough time to try your solution. But i wonder if I can use this (deprecated function)

TS_DotNetModuleLoadMemberInfo (hTSStepModule, &errorInfo, VFALSE, &bHasMemberInfo);
because he seems this function worked previously with TestStand 3.0 ? Without have need of the Metadata Token. So i don't need to use

TS_DotNetModuleGetMetadataToken (hTSStepModule, &errorInfo, &metadata);
TS_DotNetModuleLoadPrototypeFromMetadataToken (hTSStepModule, &errorInfo, metadata, 0, &bHasMemberInfo);
 

Can you tell me more about this?

 

Anthony

0 Kudos
Message 14 of 42
(2,041 Views)

Anthony -

 

I tried the obsolete DotNetModule.LoadMemberInfo() method but was unable to use it successfully. You should be able to use DotNetModule.LoadPrototypeFromMetadataToken() successfully if you use one of my three mentioned methods of retrieving the Metadata Token.

Manooch H.
National Instruments
0 Kudos
Message 15 of 42
(2,039 Views)

Hi Manooch,

 

I have to do a challenge in an other thread and i like to use your wrapper.

But it is not working or better .net did a exception. I looked on your src

and found a little mistake why it is not working. 

 

Please fix it

 

Juergen

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 16 of 42
(2,014 Views)

Juergen -

 

The example that I posted to this thread was hard-coded to work with the files that I provided. It was merely an example of one method you might use. I call GetType in order to get the particular class whose member I am attempting to get the Metadata Token for. The particular implementation of GetType() that I use requires that you pass a string for the class in question represented by its full name. This includes both the namespace and the class name.

 

In my example, the namespace for my class is myTestAssembly and the name of my class is Class1, thus, I must pass "myTestAssembly.Class1" to the parameter of GetType to get the Type of my class. 

 

Are you simply trying to run my example or have you attempted to modify the files for your own use case?

Manooch H.
National Instruments
0 Kudos
Message 17 of 42
(2,006 Views)

Hi Manooch,

 

In your C# you are passing the the string "myTestAssembly.Class1" as parameter to GetType(). Thats well for your example. You have the agrument " string fullClassName " in ...MetaDataToken() which is never used in this code. I saw only the TS side where is a parameter fullClassName. But this one has no affect.

It should be GetType(fullClassName) so it can be controlled by TS.

 

What i like to do is to create a .net action step type.

To make it available to everybody it should be the member

ComputerSequenceSimulationDialog

of class

NationalInstruments.TestStand.Examples.ComputerMotherboard.Computer

in

Computer.dll

(the Hello World of TestStand)

 

Juergen 

 

  

 

 

  

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 18 of 42
(2,002 Views)

Juergen -

 

You are correct that I should be using the fullClassName parameter. I must have forgotten to make that modification after testing out the example. Thank you for pointing that out.

 

Are you having trouble with anything other than that? If so, please let me know and I will try to help out.

Manooch H.
National Instruments
0 Kudos
Message 19 of 42
(1,979 Views)

Hi Manooch,

 

Yes indeed, I have some other improvements idea of the GetConstructorMetadataToken, but i have to solution to it.

As you know, i am trying to use the computer class. But there is an other constructor parameter. Instead String, it is SequenceContext.

So i need some interchange abililty with the type array.

Is there a way to define a Type[] -class (Example: Type[SequenceContext,String,Int] if Constructor is MyClass::MyClass(SequenceContext,String,Int) ) in TS and give it as additional parameter to GetConstructorMetadataToken?

Have never done is in TS before. or are there other possibilities.

 

 

If with is possible other members here could use it as a very flexible wrapper.

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 20 of 42
(1,957 Views)