Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
auke.klazema
HPIB
Commits
054a8d21
Commit
054a8d21
authored
Feb 16, 2018
by
auke.klazema
Browse files
Added AbstractClass to clearly define the shared interface
parent
fe75724e
Changes
1
Show whitespace changes
Inline
Side-by-side
hpib.py
View file @
054a8d21
...
...
@@ -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
set
L
ocal
(
self
,
hpib_address
):
def
set
_l
ocal
(
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
set
L
ocal
(
self
,
hpib_address
):
def
set
_l
ocal
(
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
.
set
L
ocal
(
self
.
_hpib_address
)
self
.
_port
.
set
_l
ocal
(
self
.
_hpib_address
)
def
command
(
self
,
commandStr
):
self
.
_port
.
command
(
self
.
_hpib_address
,
commandStr
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment