2025-01-03 10:19:06 +00:00
|
|
|
import abc
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from . import util
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class IHeadAmp(abc.ABC):
|
|
|
|
"""Abstract Base Class for headamps"""
|
|
|
|
|
|
|
|
def __init__(self, remote, index: int):
|
|
|
|
self._remote = remote
|
|
|
|
self.index = index + 1
|
|
|
|
self.logger = logger.getChild(self.__class__.__name__)
|
|
|
|
|
|
|
|
def getter(self, param: str):
|
2025-01-15 10:54:52 +00:00
|
|
|
return self._remote.query(f'{self.address}/{param}')
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
def setter(self, param: str, val: int):
|
2025-01-15 10:54:52 +00:00
|
|
|
self._remote.send(f'{self.address}/{param}', val)
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def address(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class HeadAmp(IHeadAmp):
|
|
|
|
"""Concrete class for headamps"""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def address(self):
|
2025-01-15 10:54:52 +00:00
|
|
|
return f'/headamp/{str(self.index).zfill(2)}'
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def gain(self):
|
2025-01-15 10:54:52 +00:00
|
|
|
return round(util.lin_get(-12, 60, self.getter('gain')[0]), 1)
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
@gain.setter
|
|
|
|
def gain(self, val):
|
2025-01-15 10:54:52 +00:00
|
|
|
self.setter('gain', util.lin_set(-12, 60, val))
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def phantom(self):
|
2025-01-15 10:54:52 +00:00
|
|
|
return self.getter('phantom')[0] == 1
|
2025-01-03 10:19:06 +00:00
|
|
|
|
|
|
|
@phantom.setter
|
|
|
|
def phantom(self, val):
|
2025-01-15 10:54:52 +00:00
|
|
|
self.setter('phantom', 1 if val else 0)
|