add make_strip_level_map and make_bus_level_map

This commit is contained in:
onyx-and-iris 2022-07-21 22:55:49 +01:00
parent 6bcdd0f6a2
commit 7506fb0737
2 changed files with 31 additions and 19 deletions

View File

@ -155,11 +155,7 @@ class VirtualBus(Bus):
class BusLevel(IRemote): class BusLevel(IRemote):
def __init__(self, remote, index): def __init__(self, remote, index):
super().__init__(remote, index) super().__init__(remote, index)
self.level_map = tuple( self.range = _make_bus_level_maps[remote.kind.name][self.index]
(i, i + 8)
for i in range(0, (remote.kind.phys_out + remote.kind.virt_out) * 8, 8)
)
self.range = self.level_map[self.index]
def getter(self, mode): def getter(self, mode):
""" """
@ -187,7 +183,7 @@ class BusLevel(IRemote):
return self.getter(3) return self.getter(3)
@property @property
def is_updated(self) -> bool: def isdirty(self) -> bool:
""" """
Returns dirty status for this specific channel. Returns dirty status for this specific channel.
@ -196,6 +192,15 @@ class BusLevel(IRemote):
if self._remote.running: if self._remote.running:
return any(self._remote._bus_comp[self.range[0] : self.range[-1]]) return any(self._remote._bus_comp[self.range[0] : self.range[-1]])
is_updated = isdirty
def make_bus_level_map(kind):
return tuple((i, i + 8) for i in range(0, (kind.phys_out + kind.virt_out) * 8, 8))
_make_bus_level_maps = {kind.name: make_bus_level_map(kind) for kind in kinds_all}
def _make_bus_mode_mixin(): def _make_bus_mode_mixin():
"""Creates a mixin of Bus Modes.""" """Creates a mixin of Bus Modes."""

View File

@ -3,7 +3,6 @@ from abc import abstractmethod
from math import log from math import log
from typing import Union from typing import Union
from .error import VMError
from .iremote import IRemote from .iremote import IRemote
from .kinds import kinds_all from .kinds import kinds_all
from .meta import bool_prop, float_prop from .meta import bool_prop, float_prop
@ -188,17 +187,7 @@ class VirtualStrip(Strip):
class StripLevel(IRemote): class StripLevel(IRemote):
def __init__(self, remote, index): def __init__(self, remote, index):
super().__init__(remote, index) super().__init__(remote, index)
phys_map = tuple((i, i + 2) for i in range(0, remote.kind.phys_in * 2, 2)) self.range = _make_strip_level_maps[remote.kind.name][self.index]
virt_map = tuple(
(i, i + 8)
for i in range(
remote.kind.phys_in * 2,
remote.kind.phys_in * 2 + remote.kind.virt_in * 8,
8,
)
)
self.level_map = phys_map + virt_map
self.range = self.level_map[self.index]
def getter(self, mode): def getter(self, mode):
""" """
@ -237,7 +226,7 @@ class StripLevel(IRemote):
return self.getter(2) return self.getter(2)
@property @property
def is_updated(self) -> bool: def isdirty(self) -> bool:
""" """
Returns dirty status for this specific channel. Returns dirty status for this specific channel.
@ -246,6 +235,24 @@ class StripLevel(IRemote):
if self._remote.running: if self._remote.running:
return any(self._remote._strip_comp[self.range[0] : self.range[-1]]) return any(self._remote._strip_comp[self.range[0] : self.range[-1]])
is_updated = isdirty
def make_strip_level_map(kind):
phys_map = tuple((i, i + 2) for i in range(0, kind.phys_in * 2, 2))
virt_map = tuple(
(i, i + 8)
for i in range(
kind.phys_in * 2,
kind.phys_in * 2 + kind.virt_in * 8,
8,
)
)
return phys_map + virt_map
_make_strip_level_maps = {kind.name: make_strip_level_map(kind) for kind in kinds_all}
class GainLayer(IRemote): class GainLayer(IRemote):
def __init__(self, remote, index, i): def __init__(self, remote, index, i):