Commit 054a8d21 authored by auke.klazema's avatar auke.klazema
Browse files

Added AbstractClass to clearly define the shared interface

parent fe75724e
...@@ -4,7 +4,18 @@ import re ...@@ -4,7 +4,18 @@ import re
import platform import platform
class PrologixGpibUsb(): class PortDevice(object):
def command(self, hpib_address, command):
raise NotImplementedError
def query(self, hpib_address, queryStr, count=80):
raise NotImplementedError
def set_local(self, hpib_address):
raise NotImplementedError
class PrologixGpibUsb(PortDevice):
def __init__(self, port="", timeout=1, portFormat="%d", maxDeviceNum=9, verbose=False, def __init__(self, port="", timeout=1, portFormat="%d", maxDeviceNum=9, verbose=False,
findDevices=False): findDevices=False):
if port == "": if port == "":
...@@ -80,7 +91,7 @@ class PrologixGpibUsb(): ...@@ -80,7 +91,7 @@ class PrologixGpibUsb():
self._returnStr = self._serialPort.readline() self._returnStr = self._serialPort.readline()
return self._returnStr[:-1] return self._returnStr[:-1]
def setLocal(self, hpib_address): def set_local(self, hpib_address):
#self._commandStr = "++addr "+str(hpib_address)+chr(10)+"loc "+str(hpib_address)+chr(10) #self._commandStr = "++addr "+str(hpib_address)+chr(10)+"loc "+str(hpib_address)+chr(10)
#self._commandCount = self._serialPort.write(self._commandStr) #self._commandCount = self._serialPort.write(self._commandStr)
return return
...@@ -89,7 +100,7 @@ class PrologixGpibUsb(): ...@@ -89,7 +100,7 @@ class PrologixGpibUsb():
return self._devices return self._devices
class GPIB_232_485CT_A(): class GPIB_232_485CT_A(PortDevice):
def __init__(self, port="/dev/ttyS0", baudrate=9600, bytesize=serial.EIGHTBITS, def __init__(self, port="/dev/ttyS0", baudrate=9600, bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, interCharTimeout=None, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, interCharTimeout=None,
pause=0, timeout=10): pause=0, timeout=10):
...@@ -113,7 +124,7 @@ class GPIB_232_485CT_A(): ...@@ -113,7 +124,7 @@ class GPIB_232_485CT_A():
self._returnCnt = int(self._serialPort.readline()) self._returnCnt = int(self._serialPort.readline())
return self._returnStr[:self._returnCnt-1] return self._returnStr[:self._returnCnt-1]
def setLocal(self, hpib_address): def set_local(self, hpib_address):
self._commandStr = "loc "+str(hpib_address)+chr(13) self._commandStr = "loc "+str(hpib_address)+chr(13)
self._commandCount = self._serialPort.write(self._commandStr) self._commandCount = self._serialPort.write(self._commandStr)
...@@ -130,7 +141,7 @@ class HpibDevice(): ...@@ -130,7 +141,7 @@ class HpibDevice():
def setLocal(self, set2Local=True): def setLocal(self, set2Local=True):
if set2Local: if set2Local:
self._port.setLocal(self._hpib_address) self._port.set_local(self._hpib_address)
def command(self, commandStr): def command(self, commandStr):
self._port.command(self._hpib_address, commandStr) self._port.command(self._hpib_address, commandStr)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment