mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2024-11-15 17:10:46 +00:00
move channel props into factory function
sub apply func now using sendtext depth func added to util apply_profile now using sub apply (which uses sendtext)
This commit is contained in:
parent
2830299942
commit
ce48136cdb
@ -22,6 +22,9 @@ class OutputBus(Channel):
|
||||
"levels": BusLevel(remote, index),
|
||||
"mode": BusModeMixin(remote, index),
|
||||
**{param: channel_bool_prop(param) for param in ["mute", "mono"]},
|
||||
"eq": channel_bool_prop("eq.On"),
|
||||
"eq_ab": channel_bool_prop("eq.ab"),
|
||||
"label": channel_label_prop(),
|
||||
},
|
||||
)
|
||||
return OB_cls(remote, index, *args, **kwargs)
|
||||
@ -30,12 +33,6 @@ class OutputBus(Channel):
|
||||
def identifier(self):
|
||||
return "bus"
|
||||
|
||||
eq = channel_bool_prop("eq.On")
|
||||
|
||||
eq_ab = channel_bool_prop("eq.ab")
|
||||
|
||||
label = channel_label_prop()
|
||||
|
||||
@property
|
||||
def gain(self) -> float:
|
||||
def fget():
|
||||
|
@ -104,7 +104,11 @@ class Channel(abc.ABC):
|
||||
|
||||
def apply(self, mapping):
|
||||
"""Sets all parameters of a dict for the strip."""
|
||||
script = ""
|
||||
for key, val in mapping.items():
|
||||
if not hasattr(self, key):
|
||||
raise VMCMDErrors(f"Invalid {self.identifier} attribute: {key}")
|
||||
setattr(self, key, val)
|
||||
self._remote.cache[f"{self.identifier}[{self.index}].{key}"] = val
|
||||
script += f"{self.identifier}[{self.index}].{key}={val};"
|
||||
|
||||
self._remote.sendtext(script)
|
||||
|
@ -25,6 +25,7 @@ class InputStrip(Channel):
|
||||
param: channel_bool_prop(param)
|
||||
for param in ["mono", "solo", "mute"]
|
||||
},
|
||||
"label": channel_label_prop(),
|
||||
},
|
||||
)
|
||||
return IS_cls(remote, index, **kwargs)
|
||||
@ -33,8 +34,6 @@ class InputStrip(Channel):
|
||||
def identifier(self):
|
||||
return "strip"
|
||||
|
||||
label = channel_label_prop()
|
||||
|
||||
@property
|
||||
def limit(self) -> int:
|
||||
return
|
||||
|
@ -34,6 +34,12 @@ def cache_string(func, param):
|
||||
return wrapper
|
||||
|
||||
|
||||
def depth(d):
|
||||
if isinstance(d, dict):
|
||||
return 1 + (max(map(depth, d.values())) if d else 0)
|
||||
return 0
|
||||
|
||||
|
||||
def script(func):
|
||||
"""Convert dictionary to script"""
|
||||
|
||||
|
@ -67,7 +67,6 @@ class VbanCmd(abc.ABC):
|
||||
self.running = True
|
||||
self._pdirty = False
|
||||
self.cache = {}
|
||||
self.in_apply = False
|
||||
|
||||
def __enter__(self):
|
||||
self.login()
|
||||
@ -204,8 +203,6 @@ class VbanCmd(abc.ABC):
|
||||
self._text_header.framecounter = count.to_bytes(4, "little")
|
||||
if param:
|
||||
self.cache[f"{id_}.{param}"] = val
|
||||
if self._sync or self.in_apply:
|
||||
sleep(self._delay)
|
||||
|
||||
@script
|
||||
def sendtext(self, cmd):
|
||||
@ -241,7 +238,6 @@ class VbanCmd(abc.ABC):
|
||||
|
||||
def apply(self, mapping: dict):
|
||||
"""Sets all parameters of a di"""
|
||||
self.in_apply = True
|
||||
for key, submapping in mapping.items():
|
||||
obj, index = key.split("-")
|
||||
|
||||
@ -252,7 +248,6 @@ class VbanCmd(abc.ABC):
|
||||
else:
|
||||
raise ValueError(obj)
|
||||
target.apply(submapping)
|
||||
self.in_apply = False
|
||||
|
||||
def apply_profile(self, name: str):
|
||||
try:
|
||||
@ -266,7 +261,7 @@ class VbanCmd(abc.ABC):
|
||||
else:
|
||||
base[key] = profile[key]
|
||||
profile = base
|
||||
self.sendtext(profile)
|
||||
self.apply(profile)
|
||||
except KeyError:
|
||||
raise VMCMDErrors(f"Unknown profile: {self.kind.id}/{name}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user