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

Added AbstractClass to clearly define the shared interface

parent fe75724e
......@@ -4,7 +4,18 @@ import re
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,
findDevices=False):
if port == "":
......@@ -80,7 +91,7 @@ class PrologixGpibUsb():
self._returnStr = self._serialPort.readline()
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._commandCount = self._serialPort.write(self._commandStr)
return
......@@ -89,7 +100,7 @@ class PrologixGpibUsb():
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,
parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, interCharTimeout=None,
pause=0, timeout=10):
......@@ -113,7 +124,7 @@ class GPIB_232_485CT_A():
self._returnCnt = int(self._serialPort.readline())
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._commandCount = self._serialPort.write(self._commandStr)
......@@ -130,7 +141,7 @@ class HpibDevice():
def setLocal(self, set2Local=True):
if set2Local:
self._port.setLocal(self._hpib_address)
self._port.set_local(self._hpib_address)
def command(self, commandStr):
self._port.command(self._hpib_address, commandStr)
......
Markdown is supported
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