fix bus mode prop

add spacing for clarity in Modes dataclass.

bus mode prop now returning correct mode
This commit is contained in:
onyx-and-iris 2022-03-18 07:42:25 +00:00
parent b9d45948f3
commit 6aeef19d38
3 changed files with 64 additions and 51 deletions

View File

@ -133,7 +133,7 @@ _bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}
def _make_bus_mode_mixin(cls): def _make_bus_mode_mixin(cls):
""" Creates a mixin of Bus Modes. """ """ Creates a mixin of Bus Modes. """
return type('BusModeMixin', (cls,), { return type('BusModeMixin', (cls,), {
**{f'{mode.lower()}': bus_mode_prop(f'mode.{mode}') for mode in **{f'{mode.lower()}': bus_mode_prop(mode) for mode in
['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21', ['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21',
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']}, 'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']},
}) })

View File

@ -5,53 +5,54 @@ from dataclasses import dataclass
@dataclass @dataclass
class Modes: class Modes:
""" Channel Modes """ """ Channel Modes """
_mute: hex=0x00000001 _mute: hex=0x00000001
_solo: hex=0x00000002 _solo: hex=0x00000002
_mono: hex=0x00000004 _mono: hex=0x00000004
_mutec: hex=0x00000008 _mutec: hex=0x00000008
_amix: hex=0x00000010 _normal: hex=0x00000000
_repeat: hex=0x00000020 _amix: hex=0x00000010
_bmix: hex=0x00000030 _repeat: hex=0x00000020
_bmix: hex=0x00000030
_composite: hex=0x00000040 _composite: hex=0x00000040
_tvmix: hex=0x00000050 _tvmix: hex=0x00000050
_upmix21: hex=0x00000060 _upmix21: hex=0x00000060
_upmix41: hex=0x00000070 _upmix41: hex=0x00000070
_upmix61: hex=0x00000080 _upmix61: hex=0x00000080
_centeronly: hex=0x00000090 _centeronly:hex=0x00000090
_lfeonly: hex=0x000000A0 _lfeonly: hex=0x000000A0
_rearonly: hex=0x000000B0 _rearonly: hex=0x000000B0
_mask: hex=0x000000F0 _mask: hex=0x000000F0
_eq: hex=0x00000100 _eq: hex=0x00000100
_cross: hex=0x00000200 _cross: hex=0x00000200
_eqb: hex=0x00000800 _eqb: hex=0x00000800
_busa: hex=0x00001000 _busa: hex=0x00001000
_busa1: hex=0x00001000 _busa1: hex=0x00001000
_busa2: hex=0x00002000 _busa2: hex=0x00002000
_busa3: hex=0x00004000 _busa3: hex=0x00004000
_busa4: hex=0x00008000 _busa4: hex=0x00008000
_busa5: hex=0x00080000 _busa5: hex=0x00080000
_busb: hex=0x00010000 _busb: hex=0x00010000
_busb1: hex=0x00010000 _busb1: hex=0x00010000
_busb2: hex=0x00020000 _busb2: hex=0x00020000
_busb3: hex=0x00040000 _busb3: hex=0x00040000
_pan0: hex=0x00000000 _pan0: hex=0x00000000
_pancolor: hex=0x00100000 _pancolor: hex=0x00100000
_panmod: hex=0x00200000 _panmod: hex=0x00200000
_panmask: hex=0x00F00000 _panmask: hex=0x00F00000
_postfx_r: hex=0x01000000 _postfx_r: hex=0x01000000
_postfx_d: hex=0x02000000 _postfx_d: hex=0x02000000
_postfx1: hex=0x04000000 _postfx1: hex=0x04000000
_postfx2: hex=0x08000000 _postfx2: hex=0x08000000
_sel: hex=0x10000000 _sel: hex=0x10000000
_monitor: hex=0x20000000 _monitor: hex=0x20000000
class Channel(abc.ABC): class Channel(abc.ABC):

View File

@ -1,10 +1,10 @@
from .errors import VMCMDErrors from .errors import VMCMDErrors
from time import sleep
def strip_output_prop(param): def strip_output_prop(param):
""" A strip output prop. """ """ A strip output prop. """
def fget(self): def fget(self):
data = self._remote.public_packet return not int.from_bytes(self.public_packet.stripstate[self.index], 'little') & getattr(self._modes, f'_bus{param.lower()}') == 0
return not int.from_bytes(data.stripstate[self.index], 'little') & getattr(self._modes, f'_bus{param.lower()}') == 0
def fset(self, val): def fset(self, val):
if not isinstance(val, bool) and val not in (0, 1): if not isinstance(val, bool) and val not in (0, 1):
raise VMCMDErrors(f'{param} is a boolean parameter') raise VMCMDErrors(f'{param} is a boolean parameter')
@ -14,18 +14,30 @@ def strip_output_prop(param):
def bus_mode_prop(param): def bus_mode_prop(param):
""" A strip output prop. """ """ A strip output prop. """
def fget(self): def fget(self):
data = self._remote.public_packet data = self.public_packet
if param == 'mode.normal': modes = {
vals = [ 'normal': (False,False,False,False,False,False,False,False,False,False,False,False),
not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower()}') == 0 'amix': (False,True,True,False,False,True,False,True,False,True,False,True),
for param in ['Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21', 'bmix': (False,True,True,True,False,True,True,True,False,True,True,True),
'repeat': (False,False,True,True,False,False,True,True,False,False,True,True),
'composite': (False,False,False,False,True,True,True,True,False,False,False,False),
'tvmix': (False,True,True,False,True,True,True,True,False,True,False,True),
'upmix21': (False,False,True,True,True,True,True,True,False,False,True,True),
'upmix41': (False,True,True,True,True,True,True,True,False,True,True,True),
'upmix61': (False,False,False,False,False,False,False,False,True,True,True,True),
'centeronly': (False,True,True,False,False,True,False,True,True,True,True,True),
'lfeonly': (False,False,True,True,False,False,True,True,True,True,True,True),
'rearonly': (False,True,True,True,False,True,True,True,True,True,True,True),
}
vals = tuple(
not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower()}') == 0
for param in ['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21',
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly'] 'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']
] )
return not True in vals return vals == modes[param.lower()]
return not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower().split(".")[1]}') == 0
def fset(self, val): def fset(self, val):
if not isinstance(val, bool) and val not in (0, 1): if not isinstance(val, bool) and val not in (0, 1):
raise VMCMDErrors(f'{param} is a boolean parameter') raise VMCMDErrors(f'mode.{param} is a boolean parameter')
self.setter(param, 1 if val else 0) self.setter(f'mode.{param}', 1 if val else 0)
return property(fget, fset) return property(fget, fset)