Skip to content

Commit

Permalink
Merge ea4f159 into 767536c
Browse files Browse the repository at this point in the history
  • Loading branch information
CatherineH committed Jan 19, 2016
2 parents 767536c + ea4f159 commit d7bc69f
Show file tree
Hide file tree
Showing 16 changed files with 1,866 additions and 274 deletions.
41 changes: 41 additions & 0 deletions instruments/doc/examples/ex_thorlabstc200.py
@@ -0,0 +1,41 @@
#Thorlabs Temperature Controller example

import instruments as ik
import quantities
tc = ik.thorlabs.TC200.open_serial('/dev/tc200', 115200)


tc.temperature = 70*quantities.degF
print("The current temperature is: ", tc.temperature)

tc.mode = tc.Mode.normal
print("The current mode is: ", tc.mode)

tc.enable = True
print("The current enabled state is: ", tc.enable)

tc.p = 200
print("The current p gain is: ", tc.p)

tc.i = 2
print("The current i gain is: ", tc.i)

tc.d = 2
print("The current d gain is: ", tc.d)

tc.degrees = quantities.degF
print("The current degrees settings is: ", tc.degrees)

tc.sensor = tc.Sensor.ptc100
print("The current sensor setting is: ", tc.sensor)

tc.beta = 3900
print("The current beta settings is: ", tc.beta)

tc.max_temperature = 150*quantities.degC
print("The current max temperature setting is: ", tc.max_temperature)

tc.max_power = 1000*quantities.mW
print("The current max power setting is: ", tc.max_power)


41 changes: 41 additions & 0 deletions instruments/doc/examples/ex_topticatopmode.py
@@ -0,0 +1,41 @@
#Thorlabs Temperature Controller example

import instruments as ik
import quantities
tm = ik.toptica.TopMode.open_serial('/dev/ttyACM0', 115200)


print("The current emission state is: ", tm.enable)
print("The current lock state is: ", tm.locked)
print("The current interlock state is: ", tm.interlock)
print("The current fpga state is: ", tm.fpga_status)
print("The current temperature state is: ", tm.temperature_status)
print("The current current state is: ", tm.current_status)

print("The laser1's serial number is: ", tm.laser1.serial_number)
print("The laser1's model number is: ", tm.laser1.model)
print("The laser1's wavelength is: ", tm.laser1.wavelength)
print("The laser1's production date is: ", tm.laser1.production_date)
print("The laser1's enable state is: ", tm.laser1.enable)
print("The laser1's up time is: ", tm.laser1.on_time)
print("The laser1's charm state is: ", tm.laser1.charm_status)
print("The laser1's temperature controller state is: ", tm.laser1.temperature_control_status)
print("The laser1's current controller state is: ", tm.laser1.current_control_status)
print("The laser1's tec state is: ", tm.laser1.tec_status)
print("The laser1's intensity is: ", tm.laser1.intensity)
print("The laser1's mode hop state is: ", tm.laser1.mode_hop)
print("The laser1's lock start time is: ", tm.laser1.lock_start)
print("The laser1's first mode hop time is: ", tm.laser1.first_mode_hop_time)
print("The laser1's latest mode hop time is: ", tm.laser1.latest_mode_hop_time)
print("The laser1's correction status is: ", tm.laser1.correction_status)











1 change: 1 addition & 0 deletions instruments/instruments/__init__.py
Expand Up @@ -63,6 +63,7 @@ def __check_versions():
import instruments.rigol
import instruments.srs
import instruments.tektronix
import instruments.toptica
import instruments.thorlabs
import instruments.qubitekk
import instruments.hp
Expand Down
Expand Up @@ -104,10 +104,10 @@ def close(self):
self._conn.close()

def read(self, size):
if (size >= 0):
if size >= 0:
resp = self._conn.read(size)
return resp
elif (size == -1):
elif size == -1:
result = bytearray()
c = 0
while c != self._terminator:
Expand Down
60 changes: 57 additions & 3 deletions instruments/instruments/abstract_instruments/instrument.py
Expand Up @@ -83,7 +83,15 @@ class Instrument(object):
# This can and should be overriden in subclasses for instruments
# that use different terminators.
_terminator = "\n"


# some instruments issue prompt characters to indicate that it is ready for input. This must be eliminated from
# the response
_prompt = ""

# Certain instruments (such as those produced by Thorlabs) echo the command back before producing the response.
# this boolean handles that change.
_echo = False

def __init__(self, filelike):
# Check to make sure filelike is a subclass of AbstractCommunicator
if isinstance(filelike, AbstractCommunicator):
Expand Down Expand Up @@ -115,7 +123,12 @@ def query(self, cmd, size=-1):
connected instrument.
:rtype: `str`
"""
return self._file.query(cmd, size)
if not self._echo:
return self._file.query(cmd, size).replace(self.prompt, "")
else:
response = self._file.query(cmd, size)
response = self.readline().replace(self.prompt, "").replace(cmd, "").replace(self.terminator, "")
return response

def read(self, size=-1):
"""
Expand All @@ -129,6 +142,13 @@ def read(self, size=-1):
"""
return self._file.read(size)

def readline(self):
"""
Read a full line
:return: the read line
:rtype: `str`
"""
return self._file.readline()

## PROPERTIES ##

Expand All @@ -142,6 +162,7 @@ def timeout(self):
:type: `int`
'''
return self._file.timeout

@timeout.setter
def timeout(self, newval):
self._file.timeout = newval
Expand All @@ -159,6 +180,7 @@ def address(self):
:type: `int` for GPIB address, `str` for other
'''
return self._file.address

@address.setter
def address(self, newval):
self._file.address = newval
Expand All @@ -175,10 +197,42 @@ def terminator(self):
:type: `int`, or `str` for GPIB adapters.
'''
return self._file.terminator

@terminator.setter
def terminator(self, newval):
self._file.terminator = newval


@property
def prompt(self):
'''
Gets/sets the prompt used for communication.
For communication options where this is applicable, the value
corresponds to the character used for prompt
:type: `int`, or `str` for GPIB adapters.
'''
if not hasattr(self._file, 'prompt'):
self._file.prompt = self._prompt
return self._file.prompt

@prompt.setter
def prompt(self, newval):
self._file.prompt = newval

@property
def echo(self):
'''
Gets/sets the echo setting
:type: `bool`
'''

return self._echo

@echo.setter
def echo(self, newval):
self._echo = newval

## BASIC I/O METHODS ##

def write(self, msg):
Expand Down

0 comments on commit d7bc69f

Please sign in to comment.