hephy-dd / comet

COMET - Control and Measurement Toolkit
GNU General Public License v3.0
2 stars 2 forks source link

Driver actions and properties #44

Closed arnobaer closed 4 years ago

arnobaer commented 4 years ago

Add method decorator classes for actions and properties like Lantz or Slave do provide for convenient value mapping and list like item access.

class MyDriver(Driver):
    @Action()
    def init(self): ...
    @Property(values={False: 0, True: 1})
    def output(self):
        ...
    @output.setter
    def output(self, value: int):
        ...
    @Property(keys=(0, 1, 2, 3), minimum=-1000.0, maximum=1000.0)
    def channel(self, key):
        ...
    @channel.setter
    def channel(self, key, value):
        ...
>>> with MyDriver(...) as device:
...     device.output = True
...     device.channel[0] = 10.0