refactor gainlayers and bus gains

This commit is contained in:
onyx-and-iris 2026-01-17 13:19:43 +00:00
parent ad88286509
commit efdcfce387
3 changed files with 29 additions and 67 deletions

View File

@ -24,14 +24,11 @@ class Bus(IRemote):
@property @property
def gain(self) -> float: def gain(self) -> float:
def fget():
val = self.public_packets[NBS.zero].busgain[self.index]
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter('gain') val = self.getter('gain')
return round(val if val else fget(), 1) if val:
return round(val, 2)
else:
return self.public_packets[NBS.zero].busgain[self.index]
@gain.setter @gain.setter
def gain(self, val: float): def gain(self, val: float):

View File

@ -169,66 +169,33 @@ class VbanRtPacketNBS0(VbanRtPacket):
""" """
@property @property
def stripgainlayer1(self) -> tuple: def gainlayers(self) -> tuple:
"""returns tuple of all strip gain layers as tuples"""
return tuple( return tuple(
int.from_bytes(self._stripGaindB100Layer1[i : i + 2], 'little') tuple(
for i in range(0, 16, 2) round(
) int.from_bytes(
getattr(self, f'_stripGaindB100Layer{layer}')[i : i + 2],
@property 'little',
def stripgainlayer2(self) -> tuple: signed=True,
return tuple( )
int.from_bytes(self._stripGaindB100Layer2[i : i + 2], 'little') * 0.01,
for i in range(0, 16, 2) 2,
) )
for i in range(0, 16, 2)
@property )
def stripgainlayer3(self) -> tuple: for layer in range(1, 9)
return tuple(
int.from_bytes(self._stripGaindB100Layer3[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer4(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer4[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer5(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer5[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer6(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer6[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer7(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer7[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer8(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer8[i : i + 2], 'little')
for i in range(0, 16, 2)
) )
@property @property
def busgain(self) -> tuple: def busgain(self) -> tuple:
"""returns tuple of bus gains""" """returns tuple of bus gains"""
return tuple( return tuple(
int.from_bytes(self._busGaindB100[i : i + 2], 'little') round(
int.from_bytes(self._busGaindB100[i : i + 2], 'little', signed=True)
* 0.01,
2,
)
for i in range(0, 16, 2) for i in range(0, 16, 2)
) )

View File

@ -408,15 +408,13 @@ class GainLayer(IRemote):
@property @property
def gain(self) -> float: def gain(self) -> float:
def fget(): def fget():
val = getattr( return self.public_packets[NBS.zero].gainlayers[self._i][self.index]
self.public_packets[NBS.zero], f'stripgainlayer{self._i + 1}'
)[self.index]
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter(f'GainLayer[{self._i}]') val = self.getter(f'GainLayer[{self._i}]')
return round(val if val else fget(), 1) if val:
return round(val, 2)
else:
return self.public_packets[NBS.zero].gainlayers[self._i][self.index]
@gain.setter @gain.setter
def gain(self, val: float): def gain(self, val: float):