mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 10:30:48 +00:00
levels reworked
comp generator function added to util. patch bump
This commit is contained in:
parent
845ef2441e
commit
a1d6cf1042
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "vban-cmd"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||
license = "MIT"
|
||||
|
@ -14,7 +14,7 @@ from .packet import (
|
||||
VBAN_VMRT_Packet_Header,
|
||||
)
|
||||
from .subject import Subject
|
||||
from .util import script
|
||||
from .util import comp, script
|
||||
|
||||
Socket = IntEnum("Socket", "register request response", start=0)
|
||||
|
||||
@ -170,14 +170,8 @@ class VbanCmd(metaclass=ABCMeta):
|
||||
def ldirty(self):
|
||||
"""True iff a level value has changed."""
|
||||
self._strip_comp, self._bus_comp = (
|
||||
tuple(
|
||||
not a == b
|
||||
for a, b in zip(self._public_packet.inputlevels, self._strip_buf)
|
||||
),
|
||||
tuple(
|
||||
not a == b
|
||||
for a, b in zip(self._public_packet.outputlevels, self._bus_buf)
|
||||
),
|
||||
tuple(not x for x in comp(self.cache["strip_level"], self._strip_buf)),
|
||||
tuple(not x for x in comp(self.cache["bus_level"], self._bus_buf)),
|
||||
)
|
||||
return any(any(l) for l in (self._strip_comp, self._bus_comp))
|
||||
|
||||
@ -201,8 +195,8 @@ class VbanCmd(metaclass=ABCMeta):
|
||||
self._pdirty = self._pp.pdirty(self.public_packet)
|
||||
|
||||
if self.ldirty:
|
||||
self.cache["strip_level"] = tuple(self._strip_buf)
|
||||
self.cache["bus_level"] = tuple(self._bus_buf)
|
||||
self.cache["strip_level"] = self._strip_buf
|
||||
self.cache["bus_level"] = self._bus_buf
|
||||
self.subject.notify("ldirty")
|
||||
if self.public_packet != self._pp:
|
||||
self._public_packet = self._pp
|
||||
@ -219,8 +213,8 @@ class VbanCmd(metaclass=ABCMeta):
|
||||
strip levels in PREFADER mode.
|
||||
"""
|
||||
return (
|
||||
[val for val in packet.inputlevels],
|
||||
[val for val in packet.outputlevels],
|
||||
tuple(val for val in packet.inputlevels),
|
||||
tuple(val for val in packet.outputlevels),
|
||||
)
|
||||
|
||||
def apply(self, data: dict):
|
||||
|
@ -71,7 +71,6 @@ class BusLevel(IRemote):
|
||||
def getter(self):
|
||||
"""Returns a tuple of level values for the channel."""
|
||||
|
||||
range_ = self.level_map[self.index]
|
||||
return tuple(
|
||||
round(-i * 0.01, 1)
|
||||
for i in self._remote.cache["bus_level"][self.range[0] : self.range[-1]]
|
||||
|
@ -1,3 +1,6 @@
|
||||
from typing import Iterator
|
||||
|
||||
|
||||
def cache_bool(func, param):
|
||||
"""Check cache for a bool prop"""
|
||||
|
||||
@ -49,3 +52,15 @@ def script(func):
|
||||
return func(remote, script)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def comp(t0: tuple, t1: tuple) -> Iterator[bool]:
|
||||
"""
|
||||
Generator function, accepts two tuples.
|
||||
|
||||
Evaluates equality of each member in both tuples.
|
||||
"""
|
||||
for a, b in zip(t0, t1):
|
||||
if b <= 9500:
|
||||
yield a == b
|
||||
yield True
|
||||
|
Loading…
Reference in New Issue
Block a user