jondoesntgit / hardware

Python Wrappers for Hardware used in the Digonnet Lab at Stanford
MIT License
1 stars 0 forks source link

Create an `instrument` base class that various instruments extend #12

Open jondoesntgit opened 6 years ago

jondoesntgit commented 6 years ago

Each instrument should have a base class that it inherits methods like identify and log_state from.

Furthermore, instruments should be divided into categories, like function generators, lock-in amplifiers

jondoesntgit commented 6 years ago
# An example to get you started
class Instrument():

    def __init__(self):
        self._name = None

    def identify(self):
        print(self._name)

class FunctionGenerator(Instrument):

    def __init__(self):
        super().__init__()
        self._frequency = None

    @property
    def frequency(self):
        raise NotImplementedError

    @frequency.setter
    def frequency(self, val):
        raise NotImplementedError

class WheelerInstruments2000(FunctionGenerator):

    def __init__(self):
        super().__init__()
        self._frequency = 10
        self._name = "Wheeler Instruments 2000, Serial Number 3.14159"

    @property
    def frequency(self):
        return self._frequency

    @frequency.setter
    def frequency(self, val):
        self._frequency = val

class WheelerInstruments3000(FunctionGenerator):

    def __init__(self):
        super().__init__()
        self._name = "Wheeler Instruments 3000, Serial Number 2.718281828"