Multiple Instruments as same type- Comport messing up(Pyhon plugin)

Hi All
We have developed a python plugin for handling our power supply. The plugin shall be able to handle multiple plugins.
For know it can adjust the voltage and power on/off. Its using the comports.
The way we have implemented is:
The instrument itself we have a property input for the comport. We use the property in open() to open connection and Close() for closing the connection. Then we have a few methods to handle the functions like power on/off etc.
Then the plugin part simply use these functions.
In terms of use, we have in the Bench setup 4 power supplies. As we need different voltages to simulate a test.
When we use just one of the power supplies it work fine. no matter what power supply we chose in the test.
When we need to use multiple power supplies something is going wrong:
in the testplan/teststep we assign the input parameter to the instrument(Power supply).
When running the testplan with multiple power supplies it simply not using the right power supply. and that’s a bummer as then we sent wrong voltage to the DUT. The pattern I see is that opentap not making a new object for each power supply so it will just send commands to the last initialized comport.
To prove my findings and quick fix our issue, I have moved the open/close comport to each method. As then I am sure we link it to the right comport. This actually work but it really slow down the tests.
Anyone that have seen the same problem and having an idea to solve this?
Its not easy to explain but I have tried… I can of course share an example if my explanation doesn’t make sense:)

br
Martin

Hi @mschmidt,

You should be able to define 4 power supplies in your test bench settings and use them concurrently with 4 different voltage settings. I imaging it looks somewhat like this:

I wonder what you mean by this though: The pattern I see is that opentap not making a new object for each power supply....

When do you expect opentap to be making a new object?

Glad to hear it should be possible, So we are probably doing something wrong.
We created 4 PSU. just like you shown.
And I did a test exactly this way and I could not rely on that I was communicating with the correct PSU. It seemed like it was talking to the same comport even if I had defined different instruments in the test step.
What I mean by object is I assume each instrument is an Object where it have been defined a Comport.
we did solve the issue by open/close comport on each teststep. I have atteched part of the code where I have comment out the open port etc. and added open/close in the function. I hope it makes a bit more sense?

This is the problem:

image

in this case the PSU is created as a ‘static’ variable on the class(not the instance). To fix it, move it inside the __init__ like this:

    def __init__(self):
        #...
        self.psu = TenmaPowerSupply()       
        #...

Sounds right. We will try. Thank you

Follow up.
Its working. Thank you @rolf_madsen