NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a test that has multiple return values

Is there a way to create a test step that would check multiple returned parameters. The parameters would be packed into a structure or object like this:

public struct Packet
    {
        public string state;
        public double pressure;
        public double temperature;
       // more vars to be added....
    }

Testing the returned parameters:
  1. A String value "state" that must be == "storage";
  2. A Numeric value "pressure" that must be between 300 and 330
  3. A Numeric value "temperature" that must be between 20 and 30
The test only passes if packet meets the requirements.
 
example of code:

C# code compiled into test.examples.dll to be called from .net step type
#####################################################
using System;


namespace test.examples
{
    public struct Packet
    {
        public string state;
        public double pressure;
        public double temperature;
       // more vars to be added....
    }
  
    public class PacketTest
    {
        public PacketTest()
        {}

        public Packet runTest()
        {
            // simulate a packet returned from a real test.
            Packet myPacket = new Packet();
            // populate the packet structure
            myPacket.state = "Storage";
            myPacket.pressure = 321.1;
            myPacket.temperature = 25.6;
            // return the packet
            return myPacket;
        }
    }
}

###################################################


This seems like it might have been covered already, if so, please point me to the post. Perhaps I am not searching for the right topic.

best regards,
Bryan


Message Edited by bryanthomas on 07-07-2006 08:49 AM

0 Kudos
Message 1 of 5
(3,473 Views)
There are two options that I can think of off of the top of my head:
 
1)  Create an action step that gets the information and stores it in a local variable.  Create three steps afterwards (a string value test, and two numeric limit tests) that use the 'None Adapter' and tests the information this way.
-Advantages: very easy
-Disadvantages: Shows up as 4 steps, may not be as obvious.
 
2)  Create a custom step type that has step properties and a Post-Step that will test these values. 
-Advantages: Possibly cleaner, easier to understand in a sequence execution
-Disadvantages: much more complicated, may not be flexible enough
 
Unless you are going to have many of these types of tests, I would recommend the first approach.
 
Allen P.
NI
Message 2 of 5
(3,464 Views)
Allen,
Thanks for the quick response. I figured out something very simular to option one, but I think what I really want is option two. I created a sequence with an action and then 3 no adapter steps,  but the 4 steps don't seem to
I have a total of 12 tests and they all follow this same format where multiple parameters are tested in the test.
Action returns a packet and then need to test the parts of the packet.

A few questions for clarifications
When I create the custom step type and add post-step actions it asks for a module that I want to run.
do I create all the steps as post-steps? Do I specify the module in the custom step or do I specifiy it after I add the step to mysequnce?
Should I be saving the custom step type in the MyTypes.ini or in the NI_Types.ini?

thanks,
Bryan

0 Kudos
Message 3 of 5
(3,457 Views)
To make a generic custom step type, you will need to have the limits associated with step properties.  For example, the Numeric Limit Step uses Step.Limits.Low and Step.Limits.High to determine if a value passes or not.
 
For your test, you will need properties for each limit you plan on testing.  For example, you could set-
 
Step.PressureLimits.Low, Step.PressureLimits.High, Step.TemperatureLimits.Low, Step.TemperatureLimits.High, and Step.ExpectedState.
 
I would also add properties Step.Result.Pressure, Step.Result.Temperature, Step.Result.State.
 
Your Post Substep would compare the limits to these properties.  I would also recommend making an Edit Substep that will allow an interface to set these values (otherwise you will have to use the Tree View to set your limits).
 
I would recommend using MyTypes.ini to store your types.  For more information, I would recommend reading Chapter 13 in the TestStand Reference Manual.  It talks a great deal more about custom step types.
 
Allen P.
NI
0 Kudos
Message 4 of 5
(3,427 Views)
Allen,
thanks for the explanation, this was exactly the guidance I needed.
best regards,
Bryan
 
0 Kudos
Message 5 of 5
(3,422 Views)