Commit 7caaa6e7 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Throw error if device is off

parent abe68804
...@@ -11,12 +11,16 @@ class CamrasHpibDevice(HpibDevice): ...@@ -11,12 +11,16 @@ class CamrasHpibDevice(HpibDevice):
@property @property
def frequency(self): def frequency(self):
"""Returns the frequency (in Hz) of the receiver""" """Returns the frequency (in Hz) of the device. Throws a RuntimeError if no response"""
freq_str = self.query("freq?")
if len(freq_str)==0:
raise RuntimeError("Camras device at address {} is not responding".format(self._hpib_address))
return int(float(self.query("freq?"))) return int(float(self.query("freq?")))
@frequency.setter @frequency.setter
def frequency(self, freq): def frequency(self, freq):
"""Set the receiver to the specified frequency. Throws a RuntimeError if failed""" """Set the device to the specified frequency. Throws a RuntimeError if failed"""
print("setting frequency to", freq)
self.command("freq {:d} Hz".format(int(freq))) self.command("freq {:d} Hz".format(int(freq)))
new_freq = self.frequency new_freq = self.frequency
if new_freq != freq: if new_freq != freq:
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