mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-04-06 23:53:31 +00:00
BusModes IntEnum added to bus
get() added to bus mode mixin, returns the current bus mode. added support for setting bus mode by dict fixed bug in apply where bool parameters weren't being applied. bus modes added to all 3 example configs. test_config added to unit tests.
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import time
|
||||
from abc import abstractmethod
|
||||
from enum import IntEnum
|
||||
from typing import Union
|
||||
|
||||
from .error import VMCMDErrors
|
||||
from .iremote import IRemote
|
||||
from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop
|
||||
|
||||
BusModes = IntEnum(
|
||||
"BusModes",
|
||||
"normal amix bmix repeat composite tvmix upmix21 upmix41 upmix61 centeronly lfeonly rearonly",
|
||||
start=0,
|
||||
)
|
||||
|
||||
|
||||
class Bus(IRemote):
|
||||
"""
|
||||
@@ -95,28 +104,34 @@ def _make_bus_mode_mixin():
|
||||
def identifier(self) -> str:
|
||||
return f"Bus[{self.index}].mode"
|
||||
|
||||
def get(self):
|
||||
time.sleep(0.01)
|
||||
for i, val in enumerate(
|
||||
[
|
||||
self.amix,
|
||||
self.bmix,
|
||||
self.repeat,
|
||||
self.composite,
|
||||
self.tvmix,
|
||||
self.upmix21,
|
||||
self.upmix41,
|
||||
self.upmix61,
|
||||
self.centeronly,
|
||||
self.lfeonly,
|
||||
self.rearonly,
|
||||
]
|
||||
):
|
||||
if val:
|
||||
return BusModes(i + 1).name
|
||||
return "normal"
|
||||
|
||||
return type(
|
||||
"BusModeMixin",
|
||||
(IRemote,),
|
||||
{
|
||||
"identifier": property(identifier),
|
||||
**{
|
||||
mode: bus_mode_prop(mode)
|
||||
for mode in [
|
||||
"normal",
|
||||
"amix",
|
||||
"bmix",
|
||||
"repeat",
|
||||
"composite",
|
||||
"tvmix",
|
||||
"upmix21",
|
||||
"upmix41",
|
||||
"upmix61",
|
||||
"centeronly",
|
||||
"lfeonly",
|
||||
"rearonly",
|
||||
]
|
||||
},
|
||||
**{mode.name: bus_mode_prop(mode.name) for mode in BusModes},
|
||||
"get": get,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -107,9 +107,19 @@ class IRemote(metaclass=ABCMeta):
|
||||
|
||||
def apply(self, data):
|
||||
"""Sets all parameters of a dict for the channel."""
|
||||
script = ""
|
||||
|
||||
def fget(attr, val):
|
||||
if attr == "mode":
|
||||
return (f"mode.{val}", 1)
|
||||
return (attr, val)
|
||||
|
||||
script = str()
|
||||
for attr, val in data.items():
|
||||
if hasattr(self, attr):
|
||||
attr, val = fget(attr, val)
|
||||
if isinstance(val, bool):
|
||||
val = 1 if val else 0
|
||||
|
||||
self._remote.cache[f"{self.identifier}[{self.index}].{attr}"] = val
|
||||
script += f"{self.identifier}[{self.index}].{attr}={val};"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user