-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/SiLab-Bonn/basil int…
…o development
- Loading branch information
Showing
8 changed files
with
315 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,5 @@ deploy: | |
on: | ||
tags: true | ||
repo: SiLab-Bonn/basil | ||
skip_existing: true | ||
distributions: sdist bdist_wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.0.0 | ||
3.0.1.dev0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
# | ||
# ------------------------------------------------------------ | ||
# Copyright (c) All rights reserved | ||
# SiLab, Institute of Physics, University of Bonn | ||
# ------------------------------------------------------------ | ||
# | ||
|
||
from basil.HL.RegisterHardwareLayer import HardwareLayer | ||
import logging | ||
|
||
|
||
class debyeflex3003(HardwareLayer): | ||
|
||
"""Driver for the ISO-DEBYEFLEX 3003 X-Ray tube. | ||
A simple protocol via RS 232 serial port is used with 9600 baud rate. | ||
""" | ||
|
||
def __init__(self, intf, conf): | ||
super(debyeflex3003, self).__init__(intf, conf) | ||
|
||
def init(self): | ||
super(debyeflex3003, self).init() | ||
|
||
def read(self): | ||
ret = self._intf.read() | ||
if ret[-1:] != "\r": | ||
print("debyeflex3003.read() terminator error") | ||
return ret[1:-1] | ||
|
||
def write(self, cmd): | ||
self._intf.write(str(cmd)) | ||
|
||
def get_nominal_current(self): | ||
"""Read nominal current in mA. | ||
""" | ||
self.write("CN") | ||
curr = self.read() | ||
return int(curr) / 1000. | ||
|
||
def get_actual_current(self): | ||
"""Read actual current in mA. | ||
""" | ||
self.write("CA") | ||
curr = self.read() | ||
return int(curr) / 1000. | ||
|
||
def set_current(self, curr): | ||
"""Set current in mA | ||
""" | ||
if curr > 80 or curr < 0: | ||
raise ValueError("Illegal value for tube current (0 - 80 mA)") | ||
else: | ||
self.write("SC:{:02d}".format(int(curr))) | ||
logging.info("Set tube current to {:.1f} mA".format(self.get_nominal_current())) | ||
|
||
def get_nominal_voltage(self): | ||
"""Read nominal voltage in kV. | ||
""" | ||
self.write("VN") | ||
vol = self.read() | ||
return int(vol) / 1000. | ||
|
||
def get_actual_voltage(self): | ||
"""Read actual voltage in kV. | ||
""" | ||
self.write("VA") | ||
vol = self.read() | ||
return int(vol) / 1000. | ||
|
||
def set_voltage(self, vol): | ||
"""Set high voltage in kV | ||
""" | ||
if vol > 60 or vol < 0: | ||
raise ValueError("Illegal value for tube voltage (0 - 60 kV)") | ||
else: | ||
self.write("SV:{:02d}".format(vol)) | ||
logging.info("Set tube voltage to {:.1f} kV".format(self.get_nominal_voltage())) | ||
|
||
def set_highvoltage_on(self): | ||
self.write("HV:1") | ||
|
||
def set_highvoltage_off(self): | ||
self.write("HV:0") | ||
|
||
def open_shutter(self, shutter=1): | ||
"""Open the shutter with given number. Only shuttter=1 supported from hardware currently | ||
""" | ||
if not isinstance(shutter, int): | ||
raise TypeError("Invalid type for shutter number") | ||
elif shutter > 4 or shutter < 1: | ||
raise ValueError("Invalid value for shutter number") | ||
else: | ||
self.write("OS:{:1d}".format(shutter)) | ||
logging.info("Opened shutter number {:1d}".format(shutter)) | ||
|
||
def close_shutter(self, shutter=1): | ||
"""Close the shutter with given number. Only shuttter=1 supported from hardware currently | ||
""" | ||
if not isinstance(shutter, int): | ||
raise TypeError("Invalid type for shutter number") | ||
elif shutter > 4 or shutter < 1: | ||
raise ValueError("Invalid value for shutter number") | ||
else: | ||
self.write("CS:{:1d}".format(shutter)) | ||
logging.info("Closed shutter number {:1d}".format(shutter)) | ||
|
||
def start_timer(self, timer=1): | ||
"""Start the timer with the given number (corresponds to shutter number) | ||
""" | ||
if not isinstance(timer, int): | ||
raise TypeError("Invalid type for timer number") | ||
elif timer > 4 or timer < 1: | ||
raise ValueError("Invalid value for timer number") | ||
else: | ||
self.write("TS:{:1d}".format(timer)) | ||
logging.info("Started timer number {:1d}".format(timer)) | ||
|
||
def stop_timer(self, timer=1): | ||
"""Stop the timer with the given number (corresponds to shutter number) | ||
""" | ||
if not isinstance(timer, int): | ||
raise TypeError("Invalid type for timer number") | ||
elif timer > 4 or timer < 1: | ||
raise ValueError("Invalid value for timer number") | ||
else: | ||
self.write("TE:{:1d}".format(timer)) | ||
logging.info("Stopped timer number {:1d}".format(timer)) | ||
|
||
def set_timer(self, timer=1, dur=3600): | ||
"""Set the timer with the given number (corresponds to shutter number) to the given duration (in s) | ||
""" | ||
if not isinstance(timer, int): | ||
raise TypeError("Invalid type for timer number") | ||
elif not isinstance(dur, int): | ||
raise TypeError("Illegal type for duration") | ||
elif timer > 4 or timer < 1: | ||
raise ValueError("Invalid value for timer number") | ||
else: | ||
h = dur // 3600 | ||
m = (dur % 3600) // 60 | ||
s = (dur % 3600) % 60 | ||
self.write("TP:{:1d},{:02d},{:02d},{:02d}".format(timer, h, m, s)) | ||
time = self.get_nominal_time(timer) | ||
logging.info("Set timer number {:1d} to {:02d}:{:02d}:{:02d} (HH:MM:SS)".format( | ||
timer, time // 3600, (time % 3600) // 60, (time % 3600) % 60) | ||
) | ||
|
||
def get_actual_time(self, timer=1): | ||
"""Get the actual time of the given timer in s | ||
""" | ||
if not isinstance(timer, int): | ||
raise TypeError("Invalid type for timer number") | ||
elif timer > 4 or timer < 1: | ||
raise ValueError("Invalid value for timer number (1, 2, 3, 4)") | ||
else: | ||
self.write("TA:{:1d}".format(timer)) | ||
time = self.read() | ||
return int(time) | ||
|
||
def get_nominal_time(self, timer=1): | ||
"""Get the nominal time of the given timer in s | ||
""" | ||
if not isinstance(timer, int): | ||
raise TypeError("Invalid type for timer number") | ||
elif timer > 4 or timer < 1: | ||
raise ValueError("Invalid value for timer number (1, 2, 3, 4)") | ||
else: | ||
self.write("TN:{:1d}".format(timer)) | ||
time = self.read() | ||
return int(time) | ||
|
||
def lock_keyboard(self): | ||
"""Locks the hardware keyboard on the device. Only STOP key still works. | ||
""" | ||
self.write("KB:0") | ||
|
||
def unlock_keyboard(self): | ||
self.write("KB:1") | ||
|
||
def get_status(self, status_word): | ||
""" Get a pre-selected range of status parameters | ||
""" | ||
self.write("SR:{:02d}".format(status_word)) | ||
response = self.read() | ||
status = bin(int(response[7:10]))[2:].zfill(8) # Convert response to 8 char long string of binary values | ||
logging.info("Status word {:02d}: {:8s}".format(status_word, status)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# ------------------------------------------------------------ | ||
# Copyright (c) All rights reserved | ||
# SiLab, Institute of Physics, University of Bonn | ||
# ------------------------------------------------------------ | ||
# | ||
|
||
from basil.HL.RegisterHardwareLayer import HardwareLayer | ||
import logging | ||
import time | ||
import string | ||
|
||
class julaboF32HD(HardwareLayer): | ||
|
||
"""Driver for the Julabo F32-HD tillar. | ||
A simple protocol via RS 232 serial port is used with 4800 baud rate. | ||
""" | ||
|
||
def __init__(self, intf, conf): | ||
super(julaboF32HD, self).__init__(intf, conf) | ||
self.pre_time=time.time() | ||
|
||
def init(self): | ||
super(julaboF32HD, self).init() | ||
|
||
def read(self): | ||
ret = self._intf.read() | ||
if len(ret)<2 or ret[-2:] != "\r\n": | ||
print("julabo.read() terminator error") | ||
return ret[:-2] | ||
|
||
def write(self, cmd): | ||
if time.time()-self.pre_time<1.0: | ||
time.sleep(1.0) | ||
self._intf.write(str(cmd)) | ||
self.pre_time=time.time() | ||
|
||
def get_identifier(self): | ||
"""Read identifier | ||
""" | ||
self.write("version") | ||
ret = self.read() | ||
return ret | ||
|
||
def start_thermostat(self,start=True): | ||
""" start tiller | ||
""" | ||
if start==True: | ||
self.write("out_mode_05 1") | ||
else: | ||
self.write("out_mode_05 0") | ||
|
||
def stop_thermostat(self): | ||
""" stop tiller | ||
""" | ||
self.start_thermostat(False) | ||
|
||
def get_status(self): | ||
""" Get status | ||
""" | ||
self.write("status") | ||
ret = self.read() | ||
logging.debug("status:{:s}".format(ret)) | ||
try: | ||
tmp=ret.split(" ", 1) | ||
status=int(tmp[0]) | ||
status_str=tmp[1:] | ||
except: | ||
print("julabo.get_status() wrong format ".format(repr(ret))) | ||
status=-99 | ||
status_str=ret | ||
return status,status_str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# ------------------------------------------------------------ | ||
# Copyright (c) All rights reserved | ||
# SiLab, Institute of Physics, University of Bonn | ||
# ------------------------------------------------------------ | ||
# | ||
|
||
''' Example how to use the tiller. | ||
''' | ||
|
||
import time | ||
|
||
from basil.dut import Dut | ||
|
||
dut = Dut('julaboF32HD.yaml') | ||
dev.init() | ||
print "ID",dev["tiller"].get_identifier() | ||
print "status",dev["tiller"].get_status() | ||
|
||
### start | ||
### set menu->confiuration->setpoint->rs232 | ||
dev["tiller"].start_thermostat() | ||
dev["tiller"].get_status() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
transfer_layer: | ||
- name : Serial | ||
type : Serial | ||
init : | ||
port : /dev/ttyUSB5 | ||
read_termination : "\r\n" | ||
write_termination : "\r" | ||
baudrate : 4800 | ||
timeout : 2.0 | ||
parity : "N" ### serial.PARITY_NONE | ||
xonxoff : True ### software handshake on | ||
rtscts : False | ||
dsrdtr : False | ||
|
||
|
||
hw_drivers: | ||
- name : tiller | ||
type : julaboF32HD | ||
interface : Serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters