mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-01-24 17:27:48 +00:00
refactor gainlayers and bus gains
This commit is contained in:
parent
ad88286509
commit
efdcfce387
@ -24,14 +24,11 @@ class Bus(IRemote):
|
||||
|
||||
@property
|
||||
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')
|
||||
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
|
||||
def gain(self, val: float):
|
||||
|
||||
@ -169,66 +169,33 @@ class VbanRtPacketNBS0(VbanRtPacket):
|
||||
"""
|
||||
|
||||
@property
|
||||
def stripgainlayer1(self) -> tuple:
|
||||
def gainlayers(self) -> tuple:
|
||||
"""returns tuple of all strip gain layers as tuples"""
|
||||
return tuple(
|
||||
int.from_bytes(self._stripGaindB100Layer1[i : i + 2], 'little')
|
||||
tuple(
|
||||
round(
|
||||
int.from_bytes(
|
||||
getattr(self, f'_stripGaindB100Layer{layer}')[i : i + 2],
|
||||
'little',
|
||||
signed=True,
|
||||
)
|
||||
* 0.01,
|
||||
2,
|
||||
)
|
||||
for i in range(0, 16, 2)
|
||||
)
|
||||
|
||||
@property
|
||||
def stripgainlayer2(self) -> tuple:
|
||||
return tuple(
|
||||
int.from_bytes(self._stripGaindB100Layer2[i : i + 2], 'little')
|
||||
for i in range(0, 16, 2)
|
||||
)
|
||||
|
||||
@property
|
||||
def stripgainlayer3(self) -> tuple:
|
||||
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)
|
||||
for layer in range(1, 9)
|
||||
)
|
||||
|
||||
@property
|
||||
def busgain(self) -> tuple:
|
||||
"""returns tuple of bus gains"""
|
||||
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)
|
||||
)
|
||||
|
||||
|
||||
@ -408,15 +408,13 @@ class GainLayer(IRemote):
|
||||
@property
|
||||
def gain(self) -> float:
|
||||
def fget():
|
||||
val = getattr(
|
||||
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
|
||||
return self.public_packets[NBS.zero].gainlayers[self._i][self.index]
|
||||
|
||||
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
|
||||
def gain(self, val: float):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user