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
Tammo Jan Dijkema
HPIB
Commits
1510fc28
Commit
1510fc28
authored
Feb 16, 2018
by
auke.klazema
Browse files
Removed uneeded member variable usage
parent
3c29bfc8
Changes
2
Show whitespace changes
Inline
Side-by-side
hpib.py
View file @
1510fc28
...
@@ -38,7 +38,6 @@ class PrologixGpibUsb(PortDevice):
...
@@ -38,7 +38,6 @@ class PrologixGpibUsb(PortDevice):
self
.
_find_devices
()
self
.
_find_devices
()
else
:
else
:
self
.
_devices
=
"Not scanned."
self
.
_devices
=
"Not scanned."
self
.
_hpib_address
=
-
1
def
_set_default_platform_values
(
self
):
def
_set_default_platform_values
(
self
):
if
platform
.
system
()
==
"Linux"
:
if
platform
.
system
()
==
"Linux"
:
...
@@ -82,14 +81,14 @@ class PrologixGpibUsb(PortDevice):
...
@@ -82,14 +81,14 @@ class PrologixGpibUsb(PortDevice):
def
_find_devices
(
self
):
def
_find_devices
(
self
):
self
.
_devices
=
[]
self
.
_devices
=
[]
for
self
.
_hpib_
address
in
range
(
0
,
31
):
for
address
in
range
(
0
,
31
):
commandStr
=
"++addr "
+
str
(
self
.
_hpib_
address
)
+
chr
(
10
)
+
\
commandStr
=
"++addr "
+
str
(
address
)
+
chr
(
10
)
+
\
"*idn?"
+
chr
(
10
)
+
\
"*idn?"
+
chr
(
10
)
+
\
"++read"
+
chr
(
10
)
"++read"
+
chr
(
10
)
self
.
_serialPort
.
write
(
commandStr
)
self
.
_serialPort
.
write
(
commandStr
)
returnStr
=
self
.
_serialPort
.
readline
()
returnStr
=
self
.
_serialPort
.
readline
()
if
returnStr
!=
""
:
if
returnStr
!=
""
:
self
.
_devices
+=
[
self
.
_hpib_
address
,
returnStr
]
self
.
_devices
+=
[
address
,
returnStr
]
def
command
(
self
,
hpib_address
,
command
):
def
command
(
self
,
hpib_address
,
command
):
if
hpib_address
!=
self
.
_hpib_address
:
if
hpib_address
!=
self
.
_hpib_address
:
...
...
test/test_hpib.py
View file @
1510fc28
...
@@ -99,7 +99,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
...
@@ -99,7 +99,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
hpib
.
PrologixGpibUsb
(
port
=
"device"
)
hpib
.
PrologixGpibUsb
(
port
=
"device"
)
def
test_command_prepend_plusplus_addr_if_new_address
(
self
):
def
test_command_prepend_plusplus_addr_if_new_address
(
self
):
address
=
2
address
=
0
command
=
"command"
command
=
"command"
write_mock
=
self
.
serial_mock
.
return_value
.
write
write_mock
=
self
.
serial_mock
.
return_value
.
write
...
@@ -110,7 +110,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
...
@@ -110,7 +110,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
write_mock
.
assert_called_with
(
"++addr "
+
str
(
address
)
+
chr
(
10
)
+
command
+
chr
(
10
))
write_mock
.
assert_called_with
(
"++addr "
+
str
(
address
)
+
chr
(
10
)
+
command
+
chr
(
10
))
def
test_command_no_prepend_plusplus_addr_if_address_already_used
(
self
):
def
test_command_no_prepend_plusplus_addr_if_address_already_used
(
self
):
address
=
2
address
=
0
command
=
"command"
command
=
"command"
write_mock
=
self
.
serial_mock
.
return_value
.
write
write_mock
=
self
.
serial_mock
.
return_value
.
write
...
@@ -122,7 +122,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
...
@@ -122,7 +122,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
write_mock
.
assert_called_with
(
command
+
chr
(
10
))
write_mock
.
assert_called_with
(
command
+
chr
(
10
))
def
test_query_prepend_plusplus_addr_if_new_address
(
self
):
def
test_query_prepend_plusplus_addr_if_new_address
(
self
):
address
=
2
address
=
0
query
=
"query"
query
=
"query"
write_mock
=
self
.
serial_mock
.
return_value
.
write
write_mock
=
self
.
serial_mock
.
return_value
.
write
...
@@ -135,7 +135,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
...
@@ -135,7 +135,7 @@ class PrologixGpibUsbTest(unittest.TestCase):
"++read eoi"
+
chr
(
10
))
"++read eoi"
+
chr
(
10
))
def
test_query_no_prepend_plusplus_addr_if_address_already_used
(
self
):
def
test_query_no_prepend_plusplus_addr_if_address_already_used
(
self
):
address
=
2
address
=
0
query
=
"query"
query
=
"query"
write_mock
=
self
.
serial_mock
.
return_value
.
write
write_mock
=
self
.
serial_mock
.
return_value
.
write
...
...
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