Skip to content

Commit

Permalink
Expand changes to new instruments. Fix wrong conflict resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktBurger committed Nov 15, 2022
1 parent 17da3f4 commit f411648
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 50 deletions.
4 changes: 2 additions & 2 deletions pymeasure/instruments/agilent/agilentB1500.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def read_channels(self, nchannels):
:return: Measurement data
:rtype: tuple
"""
data = self.adapter.read_bytes(self._data_format.size * nchannels)
data = self.read_bytes(self._data_format.size * nchannels)
data = data.decode("ASCII")
data = data.rstrip('\r,')
# ',' if more data in buffer, '\r' if last data point
Expand Down Expand Up @@ -1810,7 +1810,7 @@ def to_dict(parameters, names, *args):
def _get_smu(key, smu_references):
# command without channel
command = re.findall(r'(?P<command>[A-Z]+)', key)[0]
channel = key[len(command):]
channel = key[len(command) :] # noqa: E203
return smu_references[int(channel)]

# SMU Modes
Expand Down
4 changes: 2 additions & 2 deletions pymeasure/instruments/ametek/ametek7270.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,6 @@ def auto_gain(self, setval):

def shutdown(self):
""" Ensures the instrument in a safe state """
self.voltage = 0.
self.isShutdown = True
log.info("Shutting down %s" % self.name)
self.voltage = 0.
super().shutdown()
1 change: 1 addition & 0 deletions pymeasure/instruments/ami/ami430.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,4 @@ def shutdown(self, ramp_rate=0.0357):
self.zero()
self.wait_for_holding()
self.disable_persistent_switch()
super().shutdown()
1 change: 1 addition & 0 deletions pymeasure/instruments/anritsu/anritsuMG3692C.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ def shutdown(self):
# TODO: Implement modulation
self.modulation = False
self.disable()
super().shutdown()
1 change: 1 addition & 0 deletions pymeasure/instruments/deltaelektronika/sm7045d.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ def shutdown(self):
"""
self.ramp_to_zero()
self.disable()
super().shutdown()
3 changes: 1 addition & 2 deletions pymeasure/instruments/eurotest/eurotestHPP120256.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ def __init__(self,
write_delay=0.4,
timeout=5000,
**kwargs):

kwargs.setdefault('name', "Euro Test High Voltage DC Source model HPP-120-256")
super().__init__(
adapter,
"Euro Test High Voltage DC Source model HPP-120-256",
write_termination="\n",
read_termination="",
send_end=True,
Expand Down
8 changes: 4 additions & 4 deletions pymeasure/instruments/heidenhain/nd287.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def __init__(self, adapter, units="mm", **kwargs):
def id(self):
""" String identification property for the device.
"""
self.adapter.connection.write("\x1BA0000")
id_str = self.adapter.connection.read_bytes(37).decode("utf-8")
self.write("\x1BA0000")
id_str = self.read_bytes(37).decode("utf-8")
return id_str

@property
Expand All @@ -101,9 +101,9 @@ def check_errors(self):
:return: String with the error message as its contents.
"""
self.adapter.connection.write("\x1BA0301")
self.write("\x1BA0301")
try:
err_str = self.adapter.connection.read_bytes(36).decode("utf-8")
err_str = self.read_bytes(36).decode("utf-8")
except VisaIOError:
err_str = None

Expand Down
2 changes: 1 addition & 1 deletion pymeasure/instruments/hp/hp3437A.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class HP3437A(HPLegacyInstrument):
pb_desc = PackedBits

def __init__(self, adapter, **kwargs):
kwargs.setdefault('name', "Hewlett-Packard HP3437A")
super().__init__(
adapter,
"Hewlett-Packard HP3437A",
**kwargs,
)
log.info("Initialized HP3437A")
Expand Down
35 changes: 4 additions & 31 deletions pymeasure/instruments/hp/hp8116a.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,12 @@ def _boolean_control(identifier, state_index, docs, inverted=False, **kwargs):

def write(self, command):
""" Write a command to the instrument and wait until the 8116A has interpreted it. """
self.adapter.write(command)
super().write(command)

# We need to read the status byte and wait until the buffer_not_empty bit
# is cleared because some older units lock up if we don't.
self._wait_for_commands_processed()

def read(self):
""" Some units of the 8116A don't use the EOI line (see service note 8116A-07A).
Therefore reads with automatic end-of-transmission detection will timeout.
Instead, :code:`adapter.read_bytes()` has to be used.
"""
raise NotImplementedError('Not supported, use adapter.read_bytes() instead')

def ask(self, command, num_bytes=None):
""" Write a command to the instrument, read the response, and return the response as ASCII text.
Expand All @@ -257,30 +250,9 @@ def ask(self, command, num_bytes=None):

# The first character is always a space or a leftover character from the previous command,
# when the number of bytes read was too large or too small.
bytes = self.adapter.read_bytes(num_bytes)[1:]
bytes = self.read_bytes(num_bytes)[1:]
return bytes.decode('ascii').strip(' ,\r\n')

def values(self, command, separator=',', cast=float, preprocess_reply=None, **kwargs):
# I had to copy the values method from the adapter class since we need to call
# our own ask() method instead of the adapter's default one.
results = str(self.ask(command))
if callable(preprocess_reply):
results = preprocess_reply(results)
elif callable(self.adapter.preprocess_reply):
results = self.adapter.preprocess_reply(results)
results = results.split(separator)
for i, result in enumerate(results):
try:
if cast == bool:
# Need to cast to float first since results are usually
# strings and bool of a non-empty string is always True
results[i] = bool(float(result))
else:
results[i] = cast(result)
except Exception:
pass # Keep as string
return results

# Instrument controls #

operating_mode = Instrument.control(
Expand Down Expand Up @@ -379,7 +351,8 @@ def values(self, command, separator=',', cast=float, preprocess_reply=None, **kw
""",
validator=strict_range,
values=[10, 90.0001],
get_process=lambda x: int(x[6:8])
cast=int,
# get_process=lambda x: int(x[6:8])
)

pulse_width = Instrument.control(
Expand Down
2 changes: 1 addition & 1 deletion pymeasure/instruments/hp/hp8657b.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class HP8657B(Instrument):
"""

def __init__(self, adapter, **kwargs):
kwargs.setdefault('name', "Hewlett-Packard HP8657B")
super().__init__(
adapter,
"Hewlett-Packard HP8657B",
includeSCPI=False,
send_end=True,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion pymeasure/instruments/hp/hpsystempsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class HP6632A(HPLegacyInstrument):
def __init__(self, adapter, **kwargs):
kwargs.setdefault('read_termination', '\r\n')
kwargs.setdefault('send_end', True)
kwargs.setdefault('name', "Hewlett-Packard HP6632A")
super().__init__(
adapter,
"Hewlett-Packard HP6632A",
**kwargs,
)

Expand Down
21 changes: 21 additions & 0 deletions pymeasure/instruments/keithley/keithley2306.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ class BatteryChannel(Channel):
)

def pulse_current_step(self, step_number):
"""Create a new current step point for this instrument.
:param: step_number:
int: the number of the step to be created
:type: :class:`.Step`
"""
return Step(self.instrument, step_number)


Expand Down Expand Up @@ -663,6 +670,13 @@ def __init__(self, adapter, **kwargs):
)

def ch(self, channel_number):
"""Get a channel from this instrument.
:param: channel_number:
int: the number of the channel to be selected
:type: :class:`.Channel`
"""
if channel_number == 1:
return self.ch1
elif channel_number == 2:
Expand All @@ -671,6 +685,13 @@ def ch(self, channel_number):
raise ValueError("Invalid channel number. Must be 1 or 2.")

def relay(self, relay_number):
"""Get a relay channel from this instrument.
:param: relay_number:
int: the number of the relay to be selected
:type: :class:`.Relay`
"""
if relay_number == 1:
return self.relay1
elif relay_number == 2:
Expand Down
1 change: 1 addition & 0 deletions pymeasure/instruments/newport/esp300.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,4 @@ def shutdown(self):
""" Shuts down the controller by disabling all of the axes.
"""
self.disable()
super().shutdown()
2 changes: 1 addition & 1 deletion pymeasure/instruments/signalrecovery/dsp7265.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,4 +588,4 @@ def convert_if_present(keys, multiply_by=1):
def shutdown(self):
log.info("Shutting down %s." % self.name)
self.voltage = 0.
self.isShutdown = True
super().shutdown()
4 changes: 2 additions & 2 deletions pymeasure/instruments/srs/sr830.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ def fill_buffer(self, count, has_aborted=lambda: False, delay=0.001):
self.pause_buffer()
return ch1, ch2
self.pauseBuffer()
ch1[index:count + 1] = self.buffer_data(1, index, count)
ch2[index:count + 1] = self.buffer_data(2, index, count)
ch1[index : count + 1] = self.buffer_data(1, index, count) # noqa: E203
ch2[index : count + 1] = self.buffer_data(2, index, count) # noqa: E203
return ch1, ch2

def buffer_measure(self, count, stopRequest=None, delay=1e-3):
Expand Down
4 changes: 2 additions & 2 deletions pymeasure/instruments/srs/sr860.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,13 @@ def snap(self, val1="X", val2="Y", val3=None):
val3 = None
"""
if val3 is None:
return self.adapter.values(
return self.values(
command=f"SNAP? {val1}, {val2}",
separator=",",
cast=float,
)
else:
return self.adapter.values(
return self.values(
command=f"SNAP? {val1}, {val2}, {val3}",
separator=",",
cast=float,
Expand Down
2 changes: 1 addition & 1 deletion pymeasure/instruments/temptronic/temptronic_eco560.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class ECO560(ATSBase):

def __init__(self, adapter, **kwargs):
kwargs.setdefault('timeout', 3000)
kwargs.setdefault('name', "Temptronic ECO-560 Thermostream")
super().__init__(
adapter,
name="Temptronic ECO-560 Thermostream",
tcpip={'write_termination': '\n',
'read_termination': '\n'},
**kwargs
Expand Down

0 comments on commit f411648

Please sign in to comment.