aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/scpi.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-02 13:10:51 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-02 13:10:51 -0500
commit4035e1dfd9cc16fc4eb730cb51adf6a5963269bf (patch)
treebee7c779950a1cb0defa431644d5a53063594bdf /qolab/hardware/scpi.py
parente30d8525409aa4d6554ff64485decc1be25d31c1 (diff)
downloadqolab-4035e1dfd9cc16fc4eb730cb51adf6a5963269bf.tar.gz
qolab-4035e1dfd9cc16fc4eb730cb51adf6a5963269bf.zip
create a root package qolab
Diffstat (limited to 'qolab/hardware/scpi.py')
-rw-r--r--qolab/hardware/scpi.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/qolab/hardware/scpi.py b/qolab/hardware/scpi.py
new file mode 100644
index 0000000..279ef24
--- /dev/null
+++ b/qolab/hardware/scpi.py
@@ -0,0 +1,63 @@
+"""
+provide basic class to operate SCPI capable instruments
+"""
+
+class SCPIinstr:
+ """ Basic class which support SCPI commands """
+ """
+ Do not instantiate directly, use
+ rm = pyvisa.ResourceManager()
+ SCPIinstr(rm.open_resource('TCPIP::192.168.0.2::INSTR'))
+ """
+ def __init__(self, resource):
+ self.resource = resource
+
+ # convenience pyvisa functions
+ self.write = self.resource.write
+ self.read = self.resource.read
+ self.query = self.resource.query
+ self.read_bytes = self.resource.read_bytes
+ self.read_binary_values = self.resource.read_binary_values
+ self.query_binary_values = self.resource.query_binary_values
+
+ @property
+ def idn(self):
+ return self.query("*IDN?")
+
+ def clear_status(self):
+ self.write("*CLS")
+
+ def set_event_status_enable(self):
+ self.write("*ESE")
+
+ def query_event_status_enable(self):
+ self.query("*ESE?")
+
+ def query_event_status_register(self):
+ self.query("*ESR?")
+
+ def set_wait_until_finished(self):
+ self.query("*OPC")
+
+ def wait_until_finished(self):
+ self.query("*OPC?")
+
+ def reset(self):
+ self.write("*RST")
+
+ def set_service_request_enable(self):
+ self.write("*SRE")
+
+ def query_service_request_enable(self):
+ self.query("*SRE?")
+
+ def query_status_byte(self):
+ self.query("*STB?")
+
+ def self_test_result(self):
+ self.query("*TST?")
+
+ def wait(self):
+ self.write("*WAI")
+
+