NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

unable to save the file because a sequence file with that path is already loaded.

You need to load the prototype of the module to populate the DotNetParameters object.  You can do this by calling objDotNetModule.AsModule().LoadPrototype() in TestSTand 4.0.  Once the array is populated, you can access the individual elements of the DotNetParameters and set value expressions for each one.

Allen P.
NI
0 Kudos
Message 11 of 25
(2,340 Views)

hi Allen P,

Thanks for reply. I tried with your code but still problem persists. Please find attachment of code and kindly correct the wrong things.

regards

RKK

0 Kudos
Message 12 of 25
(2,335 Views)
My apologies, it is a bit more complicated than I initially thought.  You will need to do get the MetadataToken for the method.  The following solution is for TestStand 4.0.  If you are using 3.5 or prior, it will be different (and more complicated).  There are a few ways to do this, but I added the following code to yours to do this:

            Type typeClass = typeof(Class1);
            objDotNetModule.LoadPrototypeFromMetadataToken(typeClass.GetMethod("CPU").MetadataToken,0);

If you are creating the object, you also will need to do the following for the constructor:

            objDotNetModule.LoadConstructorPrototypeFromMetadataToken(typeClass.GetConstructors()[0].MetadataToken, 0);

In general, I would recommend that you trying to build the sequence file and saving it, then trying to open it in the Sequence Editor so that you can tell what you may have done wrong.

Allen P.
NI

0 Kudos
Message 13 of 25
(2,324 Views)
Hi AllenP,
 
      I sorry for late in reply. It's working greate. The next problem is how to assign the expression to the parameter?
Kindly find the attachment and suggest me accordingly.
 
Thank you
 
Regards
RKK
0 Kudos
Message 14 of 25
(2,289 Views)
It appears that you are setting Sequence Parameters instead of the module's parameters.  You need to set the module's parameters.  You have the Module object as objDotNetModule.

You need to access the parameters (objDotNetModule.Parameters), and set each of them.  For example:

            objDotNetModule.Parameters[0].ValueExpr = "9";
            objDotNetModule.Parameters[1].ValueExpr = "\"KPIT\"";
            objDotNetModule.Parameters[2].ValueExpr = "false";


Allen P.
NI
0 Kudos
Message 15 of 25
(2,274 Views)
Hi Allen P,
    It's working greate. I have one more problem how to pass object of propertyObject(TS 4.0) to Dll function?.
Thank you,
 
Regards
Rkk
0 Kudos
Message 16 of 25
(2,256 Views)

Hi,

I forget to add one more problem.

How to assign the function return value(of dll) to local variable?

Thank you,

Regards

RKK

0 Kudos
Message 17 of 25
(2,248 Views)
For each of the parameters, you need to set the ValueExpr to the proper lookup string.  For example, if you want to pass them to Locals.X, you would set the ValueExpr property of that parameter to "Locals.X".  In your example, you are doing this already, but have constants for your ValueExpr.

Allen P.
NI
0 Kudos
Message 18 of 25
(2,237 Views)

rkk,

The return function of your assembly (.dll) is the first parameter in the parameters list.  If you would like to get that return value and assign it to a variable, simply use the lookup string of the variable you would like to assign as Allen mentioned.

If you would like to pass an object reference into your assembly and operate on it there, you should create a parameter of the type 'NationalInstruments.TestStand.Interop.API.PropertyObject'.  This parameter will allow you to pass the object reference into your code. 

If you just need the value of a property object, you can create a parameter of the correct type, and assign a lookup string to that parameter.

For example, a function of the prototype:
int foo(NationalInstruments.TestStand.Interop.API.PropertyObject myProperty)

could have the parameter list:
DotNetModule.Parameters[0].ValueExpr = "locals.X";  //Assigning the return value of the function to locals.X
DotNetModule.Parameters[1].ValueExpr = "locals.Y";  //Passing the locals.Y object reference into your code

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 19 of 25
(2,232 Views)

Hi Josh W,

Thanks for reply. Actually I want to know how to use passed object reference into dll function?. My actual scenario is like :

1. Pass step variable to TestStand 4.0 and execute, store them into local variable.

2. dll function may have variable and return type value. The return type value should be stored into local variables.

Please answer to above 2 points with examples.

Thank you,

Regards

RKK

 

 

0 Kudos
Message 20 of 25
(2,224 Views)