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

Rigol dg1062 #1082

Merged
merged 35 commits into from
Jul 23, 2018
Merged

Rigol dg1062 #1082

merged 35 commits into from
Jul 23, 2018

Conversation

sohailc
Copy link
Member

@sohailc sohailc commented May 4, 2018

A driver for the Rigol DG1062

@codecov
Copy link

codecov bot commented May 4, 2018

Codecov Report

Merging #1082 into master will decrease coverage by <.01%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master    #1082      +/-   ##
==========================================
- Coverage   79.78%   79.77%   -0.01%     
==========================================
  Files          48       48              
  Lines        6657     6664       +7     
==========================================
+ Hits         5311     5316       +5     
- Misses       1346     1348       +2

@sohailc sohailc requested a review from jenshnielsen May 4, 2018 14:16
Copy link
Collaborator

@jenshnielsen jenshnielsen left a comment

Choose a reason for hiding this comment

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

Left a few minor inline comments but looks fine otherwise

super().__init__(name, address, terminator="\n", **kwargs)

channels = ChannelList(self, "channel", DG1062Channel,
snapshotable=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You may want to set this false? I think as it is the channels will be in the snapshot twice


super().__init__(parent, name)

self.parent = parent
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks redundant to me. I would prefer to add a parent property to the baseclass. We should have done that a long time ago to not have to call _parent

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, you can remove line 29.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now it seems we do need both lines. Line 27 does not automatically add parent to self.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It adds it but only as _parent which IMHO is a bug in the Channel class. There should be a non private way to get the parent so I would add a parent property to the Channel clase

    @property
    def parent(self):
        return self.parent

Note that we already have a root instrument property. Perhaps we can use that here


Example:
>>> gd = DG1062("gd", "TCPIP0::169.254.187.99::inst0::INSTR")
>>> gd.channels[0].apply(waveform="SIN", freq=1E3, ampl=1.0, offset=0, phase=0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a good way to know the valid arguments. Perhaps even just a ref to the relevant page in a manual

Copy link
Member Author

Choose a reason for hiding this comment

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

The valid arguments depend on the waveform, which makes this a bit tricky. If you give wrong arguments I raise a ValueError and list the arguments expected. See the example notebook.

Perhaps I can build an alternate interface which looks something like:

gd.channel[0].apply.sin(freq, ampl, offset, phase)

The advantage of that is that we can then have proper doc strings which the user can refer to.

Copy link
Member Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

sweet!

@sohailc
Copy link
Member Author

sohailc commented Jul 20, 2018

@jenshnielsen can you have another look at this, please?

log = logging.getLogger(__name__)


def sane_partial(func, docstring, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

shall this reside in "helpers" somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that could be helpful. Where exactly would you propose to put this?

Copy link
Contributor

Choose a reason for hiding this comment

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

qcodes/utils/helpers.py should be an OK place. Although that file is already huge...

self.add_parameter(
"polarity",
get_cmd=f":SOUR{channel}:BURS:GATE:POL?",
set_cmd=f":SOUR{channel}:BURS:GATE:POL {{}}",
Copy link
Contributor

Choose a reason for hiding this comment

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

just for my understanding, why are double brackets needed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

that i know, just haven't seen visa commands which contain brackets for the values ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nor do you see that here, it's a string to be formatted later by Command. See https://github.com/QCoDeS/Qcodes/blob/master/qcodes/utils/command.py

So here we want to have set_cmd=":SOUR1:BURS:GATE:POL {}" etc.


def trigger(self) ->None:
"""
Send a soft trigger to the instrument. This only works if the trigger
Copy link
Contributor

Choose a reason for hiding this comment

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

"soft" means "from software"/"from the driver"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I will make this more clear

@@ -581,3 +582,32 @@ def attribute_set_to(object_: Any, attribute_name: str, new_value: Any):
setattr(object_, attribute_name, new_value)
yield
setattr(object_, attribute_name, old_value)


def sane_partial(func, docstring, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you give this a more descriptive name. Sane_partial tells very little about why this is more sane

@jenshnielsen
Copy link
Collaborator

@sohailc Looks good but I think we should find a better name for sane_partial

@WilliamHPNielsen
Copy link
Contributor

partial_with_docstring? That's at least immediately understandable.

@sohailc
Copy link
Member Author

sohailc commented Jul 23, 2018

Ok, I will change it to partial_with_docstring and merge the code

@sohailc sohailc merged commit 8c009af into microsoft:master Jul 23, 2018
giulioungaretti pushed a commit that referenced this pull request Jul 23, 2018
Merge: cad7e14 7c0571e
Author: sohail chatoor <schatoor@gmail.com>

    Merge pull request #1082 from sohailc/rigol_dg1062
@sohailc sohailc deleted the rigol_dg1062 branch October 3, 2018 18:42
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

4 participants