Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Power Meter HP437B #979

Merged
merged 19 commits into from
Feb 9, 2024

Conversation

neuschs
Copy link
Contributor

@neuschs neuschs commented Oct 14, 2023

No description provided.

Copy link
Contributor

@LongnoseRob LongnoseRob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution,

i left some comments in addition to the points found by the CI.

On the actual device, have you had a look inot it how much difference there is to the HP43 (with HPIB/GPIB option) and or the dual-channel 438?

pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
@neuschs
Copy link
Contributor Author

neuschs commented Oct 15, 2023

Thank you for the contribution,

i left some comments in addition to the points found by the CI.

On the actual device, have you had a look inot it how much difference there is to the HP43 (with HPIB/GPIB option) and or the dual-channel 438?

I had a short look over the HP438A because it got mentioned in the manual of the 437B.
And indeed they do share a lot of common commands, but I so far have no good idea on how to combine these two.
The HP438A is two-channel where you have to send a message in before every other command to determine which channel you want to configure or measure.
But on the 437B this issues doesn't exist.
And additionally implementing a device without being able to test it even once feels wrong.

What do you mean with "HP43 (with HPIB/GPIB)" ? The 437B as well as the 438A have GPIB options.

@LongnoseRob
Copy link
Contributor

LongnoseRob commented Oct 15, 2023

Thank you for the contribution,
i left some comments in addition to the points found by the CI.
On the actual device, have you had a look inot it how much difference there is to the HP43 (with HPIB/GPIB option) and or the dual-channel 438?

I had a short look over the HP438A because it got mentioned in the manual of the 437B. And indeed they do share a lot of common commands, but I so far have no good idea on how to combine these two. The HP438A is two-channel where you have to send a message in before every other command to determine which channel you want to configure or measure. But on the 437B this issues doesn't exist. And additionally implementing a device without being able to test it even once feels wrong.

Yes, without access to the hardware for testing it makes little sense.

What do you mean with "HP43 (with HPIB/GPIB)" ? The 437B as well as the 438A have GPIB options.

Sorry, I ment the HP436..

@neuschs
Copy link
Contributor Author

neuschs commented Oct 16, 2023

Yes, without access to the hardware for testing it makes little sense.

I can pack the common commands into a base class so someone can later reuse them for the HP438A. But that would only make sense if it makes sense to inherit from the Channel and the BaseClass for the 438A because that one has the two channels.

I checked, the HP436A shares nothing in common with the HP437B.

@LongnoseRob
Copy link
Contributor

Yes, without access to the hardware for testing it makes little sense.

I can pack the common commands into a base class so someone can later reuse them for the HP438A. But that would only make sense if it makes sense to inherit from the Channel and the BaseClass for the 438A because that one has the two channels.

I checked, the HP436A shares nothing in common with the HP437B.

It was just an idea but if it is too much work for the 438, then continue with your initial approach,
If someone then wants to interface the 438, they can then think abiut the channel stuff at that time.

* added real device tests
* added getters to some functions which had none in before
@neuschs
Copy link
Contributor Author

neuschs commented Oct 17, 2023

@LongnoseRob

I created a mockup up of how a 438A combination could be implemented. What do you think ? The multi inherence is kind of awkward.

from pymeasure.instruments import Instrument, Channel
from pymeasure.adapters import ProtocolAdapter
 

class HP43XXGeneralStuff:

    @property
    def test_general(self):
        return "value"

 
    @test_general.setter
    def test_general(self, value):
        self.write(value)


class HP43XXChannelStuff:

    @property
    def test_property(self):
        return "value"

 
    @test_property.setter
    def test_property(self, value):
        self.write(value)
 

class HP438AChannel(Channel, HP43XXChannelStuff):


    @HP43XXChannelStuff.test_property.setter
    def test_property(self, value):
        self.write(f"SET{self.id}")
        HP43XXChannelStuff.test_property.fset(self, value)


class HP438A(Instrument, HP43XXGeneralStuff):
    a = Instrument.ChannelCreator(HP438AChannel, "A")
    b = Instrument.ChannelCreator(HP438AChannel, "B")
 

class HP437B(Instrument, HP43XXGeneralStuff, HP43XXChannelStuff):
    pass


hp438a = HP438A(ProtocolAdapter(), name="Test")
hp438a.a.test_property = "Value"
hp438a.test_general = "other value"
 
hp437b = HP437B(ProtocolAdapter(), name="Test")
hp437b.test_property = "Value"
hp437b.test_general = "other value"

* implemented last functions
* fixed documentation
@BenediktBurger
Copy link
Member

A few, quick comments regarding inheritance without looking at the code in detail:
In your mockup, the xx channel / instrument could already inherit from Channel / Instrument, which would make multiple inheritance superfluous.
Would it be feasible to make the 437 (which has those additional commands) inherit from the 438?

A comment regarding testing without a device: for that reason we have protocol tests.
I do not know whether the instrument has tests. If not, you could write tests, before you touch the instrument. After changing it, the tests have to pass again. That ensures, that the communication did not change during code refactoring.

@neuschs
Copy link
Contributor Author

neuschs commented Oct 18, 2023

In your mockup, the xx channel / instrument could already inherit from Channel / Instrument, which would make multiple inheritance superfluous.

Sadly no, because the 437B is no multiple channel device. It has only one power sensor connector and therefore shouldn't offer the channel namespace.
But the 438A has two channels.

Would it be feasible to make the 437 (which has those additional commands) inherit from the 438?

The 438 has additional commands and has two channs.

I do not know whether the instrument has tests. If not, you could write tests, before you touch the instrument. After changing it, the tests have to pass again. That ensures, that the communication did not change during code refactoring.

I agree !

Copy link
Contributor

@LongnoseRob LongnoseRob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, in gerneral it looks good to me.
I left some comments on certain points where iimprovement could be discussed.

pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
Copy link
Contributor

@LongnoseRob LongnoseRob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the latest changes, LGTM

Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, I commented on a few points to improve.

tests/instruments/hp/test_hp437b.py Outdated Show resolved Hide resolved
tests/instruments/hp/test_hp437b_with_device.py Outdated Show resolved Hide resolved
tests/instruments/hp/test_hp437b.py Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
@neuschs
Copy link
Contributor Author

neuschs commented Jan 20, 2024

@BenediktBurger Can you have a look why that Python 3.8 macos-latest test fails ?

@BenediktBurger
Copy link
Member

@BenediktBurger Can you have a look why that Python 3.8 macos-latest test fails ?

The test succeeded.

Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more small changes, please.

pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp437b.py Outdated Show resolved Hide resolved
@BenediktBurger
Copy link
Member

May I merge?

@neuschs
Copy link
Contributor Author

neuschs commented Feb 9, 2024

Sure go on

@BenediktBurger BenediktBurger merged commit 0dad3bb into pymeasure:master Feb 9, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants