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

Dev/sds1072cml #1080

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Dev/sds1072cml #1080

wants to merge 9 commits into from

Conversation

fthouin
Copy link

@fthouin fthouin commented Mar 29, 2024

First draft of a module to control the Siglent SDS1072CML oscilloscope

_ Unit tests are still lacking
_ the module is usable but awkward (especially the trigger setting)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding tests. However, please see the writing tests section of our documentation.

The test_instrument.py file contains protocol tests (without a device), while test_instrument_with_device contains tests with an actual device. For a device test, we have a fixture, which allows to define the resource name as a command line parameter.

@BenediktBurger
Copy link
Member

Thanks @fthouin for your contribution and welcome to the contributors.

Two small comments during a first quick view.

@fthouin
Copy link
Author

fthouin commented Apr 13, 2024

Hi Benedict,

Thanks for the feedback, I have finalized the control of the instrument (trigger and all)

I would now like to add tests using the test generator. However, when invoking from pymeasure.generator import Generator I get a ModuleNotFoundError: No module named 'pymeasure.generator' error.

Is this feature still supported or have I forgotten to configure something?

Thanks for your help!

@BenediktBurger
Copy link
Member

BenediktBurger commented Apr 15, 2024

I would now like to add tests using the test generator. However, when invoking from pymeasure.generator import Generator I get a ModuleNotFoundError: No module named 'pymeasure.generator' error.

I do not know by heart, whether the test generator is already part of the latest release or not. Do you have pymeasure installed as a release or from github?
The test generator is already part of the master branch for some time, but not very long.
Do you find the file pymeasure.generator.py in your branch?
If not, you can merge the current master branch into your branch (which you have to do anyways, in order to resolve the authors.txt conflict).
Here is a link to the file in the master branch: https://github.com/pymeasure/pymeasure/blob/master/pymeasure/generator.py, to verify the path and content.

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.

A few comments how to improve your code, which is mainly code style according to python standards.
For more information see https://peps.python.org/pep-0257/

Comment on lines +1 to +3
#############################
Siglent SDS1072CML Oscilloscope
#############################
Copy link
Member

Choose a reason for hiding this comment

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

The marks have to be as long as the text itself:

Suggested change
#############################
Siglent SDS1072CML Oscilloscope
#############################
###############################
Siglent SDS1072CML Oscilloscope
###############################

"""
vertical_division=Channel.control(
"C{ch}:VDIV?","C{ch}:VDIV %s",
"Sets or gets the vertical sensitivity of a channel.",
Copy link
Member

Choose a reason for hiding this comment

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

Docstrings in general should be in imperative mode (so "Set or Get"...)

We in pymeasure use "Control" for "Set or get" as the first word of a control. For a measurement it is "Measure" or "Get" and for a setting it is "Set".

Suggested change
"Sets or gets the vertical sensitivity of a channel.",
"Control the vertical sensitivity of a channel.",

)
coupling=Channel.control(
"C{ch}:CPL?","C{ch}:CPL %s1M",
"Sets and gets the channel coupling mode. (see UM p. 35)",
Copy link
Member

Choose a reason for hiding this comment

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

The reference to the user manual is not as useful for those, who do not have it. It is better, if you add the options ("DC" and "AC").

Suggested change
"Sets and gets the channel coupling mode. (see UM p. 35)",
"Sets and gets the channel coupling mode to "AC" or "DC". (see UM p. 35)",

Comment on lines +52 to +53
Returns the waveforms displayed in the channel.
return:
Copy link
Member

Choose a reason for hiding this comment

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

A docstring should be in imperative mode. The first sentence should be separated by the rest by an empty line:

Suggested change
Returns the waveforms displayed in the channel.
return:
Return the waveforms displayed in the channel.
return:

map_values=True,
get_process= lambda v : v.split(" ",1)[-1][0],
)
def getWaveform(self):
Copy link
Member

Choose a reason for hiding this comment

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

normally for python the style is get_waveform for methods.

timetags=[i*descriptorDictionnary["horizInterval"]+descriptorDictionnary["horizOffset"] for i in range(len(rawWaveform))]
return timetags,waveform

def getDesc(self):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def getDesc(self):
def get_desc(self):

"descriptorOffset":descriptorOffset
}
return descriptorDictionnary
class TriggerChannel(Channel):
Copy link
Member

Choose a reason for hiding this comment

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

Two empty lines between definitions outside of classes, please.

Suggested change
class TriggerChannel(Channel):
class TriggerChannel(Channel):

}
triggerSetupDict=get_process(self.ask("TRSE?"))
return triggerSetupDict
def getLevel(self):
Copy link
Member

Choose a reason for hiding this comment

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

One empty line between class definitions, please.

Suggested change
def getLevel(self):
def getLevel(self):

Comment on lines +244 to +252
class SDS1072CML(Instrument):
""" Represents the SIGLENT SDS1072CML Oscilloscope
and provides a high-level for interacting with the instrument
"""
def __init__(self, adapter, name="Siglent SDS1072CML Oscilloscope", **kwargs):
super().__init__(
adapter,
name,
**kwargs
Copy link
Member

Choose a reason for hiding this comment

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

Please state, whether the device supports SCPI (in this case inherit SCPIMixin before Instrument) or not (in this case set includeSCPI=False).

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

2 participants