Hi connospp,
It sounds like OpenTAP already supports your use-case. What you need to to is to implement an Instrument for your power supply. OpenTAP will call the Open method on any configured instrument (or resource) before the test plan starts, and Close after the test plan stops (whether it was aborted or completed normally).
I don’t think you actually need SetUp / TearDown in this instance, but it can be achieved by implementing the ITestPlanRunMonitor interface. The methods EnterTestPlanRun and ExitTestPlanRun will be executed immediately before and after a test plan. I would however advise against it because OpenTAP knows how to handle IResource / IInstrument implementations properly.
For example if you implement
public class MyPowerSupply : Instrument {
// implementation
}
...
public class MyTestStep : TestStep {
public MyPowerSupply PSU { get; set; }
}
then the test plan GUI will let you easily choose between all configured instances of MyPowerSupply in your current bench settings, whereas you would need to create a hardcoded solution for your particular instrument in both the PrePlanRun / PostPlanRun and ITestPlanRunMonitor scenarios.
I hope this makes sense. If not, there are some example implementations of instruments and DUTs in the SDK Examples