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

Fix: Keithley 2000 modes #334

Merged
merged 11 commits into from
Sep 20, 2016
Merged

Fix: Keithley 2000 modes #334

merged 11 commits into from
Sep 20, 2016

Conversation

Rubenknex
Copy link
Contributor

Fixes #333 by @damazter

Changes proposed in this pull request:

@alexcjohnson @giulioungaretti

Copy link
Contributor

@damazter damazter left a comment

Choose a reason for hiding this comment

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

We had to make two changes to make the code work,
I think those are two typos

@@ -142,25 +164,32 @@ def __init__(self, name, address, reset=False, **kwargs):
self.connect_message()

def trigger(self):
if self.trigger_continuous() == 'off':
if self.trigger_continuous():
Copy link
Contributor

Choose a reason for hiding this comment

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

should be
if not self.trigger_continuous()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I forgot to add that, also the other one

self.write('INIT')
self._trigger_sent = True

def _read_next_value(self):
# Prevent a timeout when no trigger has been sent
if self.trigger_continuous() == 'off' and not self._trigger_sent:
if self.trigger_continuous() and not self._trigger_sent:
Copy link
Contributor

Choose a reason for hiding this comment

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

should be
if not self.trigger_continuous() and not self._trigger_sent

@Rubenknex
Copy link
Contributor Author

@alexcjohnson @giulioungaretti I think this can be merged?

super().__init__(name, address, **kwargs)

self._trigger_sent = False

# Unfortunately the strings have to contain quotation marks and a
# newline character, as this is how the instrument returns it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Pass the terminator='\n' along to super().__init__ (in fact, perhaps only there, there's probably no reason to put it in the K2000 constructor is there?) and pyvisa will take out the newlines for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this is expected behavior, but when using a val_mapping the newline doesn't get chopped off. As evidenced by the usage in the constructor and the fact that the current _mode_map works.

Copy link
Contributor

Choose a reason for hiding this comment

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

it's in the signature of this constructor, but you don't do anything with it after that. But if you instead put it in the super().__init__ call, it really should take the newlines out.

Copy link
Contributor

Choose a reason for hiding this comment

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

See for example the K2600 driver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see... didn't think of adding it to the super() call.


return parser(self.ask(cmd))

def _set_mode_param(self, parameter, value):
cmd = '{}:{} {}'.format(self.mode(), parameter, value)
""" Read the current Keithley mode and set a parameter """
if type(value) is bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

not blocking, but it's usually preferable to use isinstance(value, bool)

@alexcjohnson
Copy link
Contributor

Looks good to me - my comments are nonblocking bits of cleanup. Thanks for the pep🎱 fixes!

Looks like @damazter needs to approve his review with your changes before you can merge, but it's a💃 from my standpoint.

@Rubenknex
Copy link
Contributor Author

@alexcjohnson Apparently I am not authorized to merge this PR, did something change recently?

@alexcjohnson
Copy link
Contributor

@Rubenknex I'm not entirely sure what restrictions @giulioungaretti put in place, but now that tests pass (the failure before was stochastic unrelated to your changes) are you allowed to merge?

@Rubenknex
Copy link
Contributor Author

@alexcjohnson Nope, it refers me to this page https://help.github.com/articles/about-protected-branches/

@alexcjohnson alexcjohnson merged commit e80f019 into master Sep 20, 2016
@alexcjohnson alexcjohnson deleted the fix/keithley_2000_modes branch September 20, 2016 17:00
@alexcjohnson
Copy link
Contributor

Alright, merged. That article implies that since tests and reviews all passed you should have been able to merge too... dunno.

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.

3 participants