Skip to content

Commit

Permalink
Merge pull request #36 from iscoe/dev
Browse files Browse the repository at this point in the history
Dev updates
  • Loading branch information
griffinmilsap authored Sep 15, 2023
2 parents f985fc4 + 1b9168c commit ba1e310
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/ezmsg-sigproc/ezmsg/sigproc/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
3 changes: 3 additions & 0 deletions extensions/ezmsg-sigproc/ezmsg/sigproc/butterworthfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def design_filter(self) -> Optional[Tuple[np.ndarray, np.ndarray]]:

@ez.subscriber(INPUT_FILTER)
async def redesign(self, message: ButterworthFilterSettings) -> None:
if type(message) is not ButterworthFilterSettings:
return

if self.STATE.design.order != message.order:
self.STATE.zi = None
self.STATE.design = message
Expand Down
2 changes: 1 addition & 1 deletion extensions/ezmsg-sigproc/ezmsg/sigproc/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Optional, Any, Tuple, List, Dict, AsyncGenerator


@dataclass(frozen=True)
@dataclass(unsafe_hash = True)
class SampleTriggerMessage:
timestamp: float = field(default_factory=time.time)
period: Optional[Tuple[float, float]] = None
Expand Down
9 changes: 9 additions & 0 deletions ezmsg/util/messagequeue.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import asyncio
from typing import Any, AsyncGenerator, Optional
import ezmsg.core as ez
from ezmsg.util.rate import Rate


class MessageQueueSettings(ez.Settings):
maxsize: int = 0
leaky: bool = False
log_above_n: Optional[int] = None
output_hz: Optional[float] = None


class MessageQueueState(ez.State):
Expand Down Expand Up @@ -55,6 +57,13 @@ async def on_message(self, message: Any) -> None:

@ez.publisher(OUTPUT)
async def send_message(self) -> AsyncGenerator:
if self.SETTINGS.output_hz is not None:
rate = Rate(self.SETTINGS.output_hz)
else:
rate = None
while True:
msg = await self.STATE.msg_queue.get()
yield self.OUTPUT, msg
if rate is not None:
await rate.sleep()

1 change: 0 additions & 1 deletion ezmsg/util/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ async def sleep(self):
self.last_time = self.last_time + self.sleep_dur

if curr_time - self.last_time > self.sleep_dur * 2:
print("Time jumping forward detected")
self.last_time = curr_time
2 changes: 1 addition & 1 deletion ezmsg/version/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.3.2"
__version__ = "3.3.3"

0 comments on commit ba1e310

Please sign in to comment.