Test steps OUTPUT -> INPUT binding

Hello,

I need the community help understanding how to bind an output from one step to an input of another step (I have experience with LabVIEW, but I’m new to OpenTAP and C#). I would like to know how to create this binding programmatically in a C# console application, not with TestStepAutomation, since we plan to develop our own custom UI later.

Below are two steps between which I’m trying to transfer data:

using OpenTap;

namespace openTapHelloWorld
{
[Display(“Measure MyDAQ Voltage”, Group: “openTapHelloWorld”)]
public class MeasureMyDAQStep : TestStep
{

public MyDAQ MyDAQ { get; set; }
public MyDut Dut { get; set; }

    [Output]
    [Unit("V")]
    public double Voltage { get; private set; }

    public override void Run()
    {
        Voltage = MyDAQ.MeasureVoltage();
        Results.Publish(Voltage);
        Log.Info("Measured voltage: {0:F3} V", Voltage);
    }
}

}

using OpenTap;

namespace openTapHelloWorld
{
[Display(“Check Voltage Limits”, Group: “openTapHelloWorld”)]
public class CheckVoltageLimitsStep : TestStep
{
public double LowLimit { get; set; } = 0.0;
public double HighLimit { get; set; } = 5.0;

    public Input<double> Voltage { get; set; } = new Input<double>();

    public override void Run()
    {
        double v = Voltage.Value;

        Log.Info("Checking voltage {0:F3} V", v);

        if (v < LowLimit || v > HighLimit)
            UpgradeVerdict(Verdict.Fail);
        else
            UpgradeVerdict(Verdict.Pass);
    }
}

}

The console output complains that” Step input requires reference to a TestStep”

40] [TestPlan] PrePlanRun Methods completed [2.36 ms]

[30] [MyDAQ] myDAQ opened on myDAQ1/ai0

[30] [MyDAQ] Resource “MyDAQ” opened. [197 ms]

[30] [TestPlan] “Measure MyDAQ Voltage” started.

[30] [TestStep] Measured voltage: 0.051 V

[30] [TestPlan] “Measure MyDAQ Voltage” completed. [213 ms]

[30] [TestPlan] “Check Voltage Limits” started.

[10] [TestPlan] Error running “Check Voltage Limits”: Step input requires reference to a TestStep output..

[40] [TestPlan] Exception: Step input requires reference to a TestStep output.

[40] [TestPlan] at OpenTap.Input1.get_Value()

[40] [TestPlan] at openTapHelloWorld.TestSteps.CheckVoltageLimitsStep.Run()

[40] [TestPlan] at OpenTap.TestStepExtensions.DoRun(ITestStep Step, TestPlanRun planRun, TestRun parentRun, IEnumerable1 attachedParameters)

Thank you.

hi @t_marius and welcome to the forum.

For the Input class, you need to set the Step and Property which are properties on the Input object.

You can also connect properties not of a type deriving from Input by using the InputOutputRelation class.

1 Like

Thank you @rolf_madsen, your suggestion worked.
The only issue I ran into was a compiler error when setting the Input property. The compiler was trying to convert a double into an IMemberData, which caused the error. The solution you posted in another thread on the forum, to use TypeData.GetTypeData(Step).GetMember(“StepMember”) fixed it.

After setting both the source step instance and the output property, everything worked as expected.

Thanks!

1 Like