NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass String parameter from Test Stand to Java API and from Java API back to Test Stand?

Greeting!
 
I want to pass parameters between Test Stand and Java API. I tried the java example Computer.java in TestStand 3.5\Examples\Java. It seems in this example, there are Numeric Limit Test used. However, I searched through all the static method step and can not fine a proper one supporting String paramer passing.
 
Can any experts give me suggestions on how to do this and how to set configuration in the Test Stand?
 
Thank you very much!
0 Kudos
Message 1 of 6
(4,220 Views)
Lilyli,

This example is just a basic example in using Java with TestStand, passing parameters as strings is not very different from passing ints or other data types. The String Value Test step type and method show how to do this in those specific cases as well. Were you getting some sort of error when trying this? Also, have you looked at the ReadMe for this example? The ReadMe has a lot of useful information about this example and how to use step types.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 2 of 6
(4,191 Views)
Hola Brandon,
 
I just added the following code to computer.java and recompiled computer.class:
 
public String LiliTest(String TestString) {
  return TestString;
  }
 
The call to the step is shown in the ni2.jpg picture. I added two string variables Locals.InputString and Locals.OutputString. I set the Expressions->Status Expression to "Passed" with no preconditions and I am getting the error shown in the picture ni.jpg, do I need to do else with the class?
 
Download All
0 Kudos
Message 3 of 6
(4,186 Views)
Are you sure you're pointing to the correct .class file? This error means there is no method by this name located in that .class file. I added your code and recompiled and could not replicate this error.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 4 of 6
(4,141 Views)
Yes, I am sure I pointed to the correct .class file. I also use the find in TestStand to make sure that I have changed all the occurence of "Java Class to load".
 
The error dialog said:
 
Details: Error executing substep 'Post'
Cannot find class
 
Error Code: -1500; User-defined error code
 
Location: Step 'Get Power On' of sequence 'MainSequence' in 'Computer3.seq'
 
It is interesting that I do not meet any error dialog when I run the Computer.java example. I changed some code in the Computer.java as I described in the previous messages and recomplie the class. I also point to the updated .class file in TestStand. Then I will see the error dialog. This problem is not solved even after I close down and restart TestStand. (I guess there might be memeory leaking problem since I saw memory leaking warning when closing TestStand).
 
 
Could this problem relate to the class loader issue? if so, how should I config the TestStand to load the class properly?
 
I appreciate your help and looking forward to your suggestion.
0 Kudos
Message 5 of 6
(4,125 Views)
Hi Lilyli,

Are you still receiving this error?  I tested this out making the exact changes you did and was able to pass a string in and out of a java code module with no problem.  If you are still getting this error, double check to make sure that you are calling the new .class that was created.
0 Kudos
Message 6 of 6
(4,076 Views)