camrasdevices.py 1.32 KB
Newer Older
1
2
3
import hpib
from hpib import HpibDevice

4
5
_port = hpib.PrologixGpibUsb()

6
7
8
class CamrasHpibDevice(HpibDevice):
    """Wrapper around HPIB commands"""
    def __init__(self, address):
9
        super(CamrasHpibDevice, self).__init__(address, _port)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
        self.__frequency = 0

    @property
    def frequency(self):
        """Returns the frequency (in Hz) of the receiver"""
        return int(float(self.query("freq?")))

    @frequency.setter
    def frequency(self, freq):
        """Set the receiver to the specified frequency. Throws a RuntimeError if failed"""
        self.command("freq {:d} Hz".format(int(freq)))
        new_freq = self.frequency
        if new_freq != freq:
            raise RuntimeError("Setting frequency failed: tried to set to {}, it is now {}".format(
                               freq, new_freq))

class Receiver(CamrasHpibDevice):
    """Wrapper around HPIB commands for the Rohde & Schwartz receiver"""

    def __init__(self):
        super(Receiver, self).__init__(1)

32
class LocalOscillator(CamrasHpibDevice):
33
34
35
36
37
38
39
40
41
42
    """Wrapper around HPIB commands for the local oscillator"""

    def __init__(self):
        super(LO, self).__init__(28)

class SignalGenerator(CamrasHpibDevice):
    """Wrapper around HPIB commands for the signal generator"""

    def __init__(self):
        super(SignalGenerator, self).__init__(14)