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),
|
"levels": BusLevel(remote, index),
|
||||||
"mode": BusModeMixin(remote, index),
|
"mode": BusModeMixin(remote, index),
|
||||||
**{param: channel_bool_prop(param) for param in ["mute", "mono"]},
|
**{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)
|
return OB_cls(remote, index, *args, **kwargs)
|
||||||
@ -30,12 +33,6 @@ class OutputBus(Channel):
|
|||||||
def identifier(self):
|
def identifier(self):
|
||||||
return "bus"
|
return "bus"
|
||||||
|
|
||||||
eq = channel_bool_prop("eq.On")
|
|
||||||
|
|
||||||
eq_ab = channel_bool_prop("eq.ab")
|
|
||||||
|
|
||||||
label = channel_label_prop()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gain(self) -> float:
|
def gain(self) -> float:
|
||||||
def fget():
|
def fget():
|
||||||
|
@ -104,7 +104,11 @@ class Channel(abc.ABC):
|
|||||||
|
|
||||||
def apply(self, mapping):
|
def apply(self, mapping):
|
||||||
"""Sets all parameters of a dict for the strip."""
|
"""Sets all parameters of a dict for the strip."""
|
||||||
|
script = ""
|
||||||
for key, val in mapping.items():
|
for key, val in mapping.items():
|
||||||
if not hasattr(self, key):
|
if not hasattr(self, key):
|
||||||
raise VMCMDErrors(f"Invalid {self.identifier} attribute: {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)
|
param: channel_bool_prop(param)
|
||||||
for param in ["mono", "solo", "mute"]
|
for param in ["mono", "solo", "mute"]
|
||||||
},
|
},
|
||||||
|
"label": channel_label_prop(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return IS_cls(remote, index, **kwargs)
|
return IS_cls(remote, index, **kwargs)
|
||||||
@ -33,8 +34,6 @@ class InputStrip(Channel):
|
|||||||
def identifier(self):
|
def identifier(self):
|
||||||
return "strip"
|
return "strip"
|
||||||
|
|
||||||
label = channel_label_prop()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def limit(self) -> int:
|
def limit(self) -> int:
|
||||||
return
|
return
|
||||||
|
@ -34,6 +34,12 @@ def cache_string(func, param):
|
|||||||
return wrapper
|
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):
|
def script(func):
|
||||||
"""Convert dictionary to script"""
|
"""Convert dictionary to script"""
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ class VbanCmd(abc.ABC):
|
|||||||
self.running = True
|
self.running = True
|
||||||
self._pdirty = False
|
self._pdirty = False
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
self.in_apply = False
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.login()
|
self.login()
|
||||||
@ -204,8 +203,6 @@ class VbanCmd(abc.ABC):
|
|||||||
self._text_header.framecounter = count.to_bytes(4, "little")
|
self._text_header.framecounter = count.to_bytes(4, "little")
|
||||||
if param:
|
if param:
|
||||||
self.cache[f"{id_}.{param}"] = val
|
self.cache[f"{id_}.{param}"] = val
|
||||||
if self._sync or self.in_apply:
|
|
||||||
sleep(self._delay)
|
|
||||||
|
|
||||||
@script
|
@script
|
||||||
def sendtext(self, cmd):
|
def sendtext(self, cmd):
|
||||||
@ -241,7 +238,6 @@ class VbanCmd(abc.ABC):
|
|||||||
|
|
||||||
def apply(self, mapping: dict):
|
def apply(self, mapping: dict):
|
||||||
"""Sets all parameters of a di"""
|
"""Sets all parameters of a di"""
|
||||||
self.in_apply = True
|
|
||||||
for key, submapping in mapping.items():
|
for key, submapping in mapping.items():
|
||||||
obj, index = key.split("-")
|
obj, index = key.split("-")
|
||||||
|
|
||||||
@ -252,7 +248,6 @@ class VbanCmd(abc.ABC):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(obj)
|
raise ValueError(obj)
|
||||||
target.apply(submapping)
|
target.apply(submapping)
|
||||||
self.in_apply = False
|
|
||||||
|
|
||||||
def apply_profile(self, name: str):
|
def apply_profile(self, name: str):
|
||||||
try:
|
try:
|
||||||
@ -266,7 +261,7 @@ class VbanCmd(abc.ABC):
|
|||||||
else:
|
else:
|
||||||
base[key] = profile[key]
|
base[key] = profile[key]
|
||||||
profile = base
|
profile = base
|
||||||
self.sendtext(profile)
|
self.apply(profile)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise VMCMDErrors(f"Unknown profile: {self.kind.id}/{name}")
|
raise VMCMDErrors(f"Unknown profile: {self.kind.id}/{name}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user