Skip to content

Commit

Permalink
Streaming: Remove config bits from streaming data
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Aug 28, 2024
1 parent 305562f commit 48a5205
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
2 changes: 0 additions & 2 deletions mytoolit/can/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from mytoolit.can.streaming import (
AsyncStreamBuffer,
StreamingConfiguration,
StreamingConfigBits,
StreamingData,
StreamingFormat,
StreamingFormatVoltage,
Expand Down Expand Up @@ -1923,7 +1922,6 @@ async def read_streaming_data_single(self) -> StreamingData:
values=values,
timestamp=response.timestamp,
counter=response.data[1],
channels=StreamingConfigBits(first=True, second=True, third=True),
)

return data
Expand Down
22 changes: 3 additions & 19 deletions mytoolit/can/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ def on_message_received(self, msg: Message) -> None:
timestamp=timestamp,
counter=counter,
values=values,
channels=self.configuration.channels,
)

# Calculate amount of lost messages
Expand Down Expand Up @@ -612,11 +611,7 @@ class StreamingData:
"""Support for storing data of a streaming message"""

def __init__(
self,
counter: int,
timestamp: float,
values: Sequence[float],
channels: StreamingConfigBits,
self, counter: int, timestamp: float, values: Sequence[float]
) -> None:
"""Initialize the streaming data with the given arguments
Expand All @@ -632,16 +627,11 @@ def __init__(
values:
The streaming values
channels:
A bitfield specifying which of the measurement channels was enabled
when the measurement took place
"""

self.counter = counter
self.timestamp = timestamp
self.values = values
self.channels = channels

def apply(
self,
Expand All @@ -658,10 +648,7 @@ def apply(
Examples
--------
>>> channel3 = StreamingConfigBits(
... first=False, second=False, third=True)
>>> data = StreamingData(
... values=[1, 2, 3], counter=21, timestamp=1, channels=channel3)
>>> data = StreamingData(values=[1, 2, 3], counter=21, timestamp=1)
>>> data.apply(lambda value: value + 10)
>>> data.values
[11, 12, 13]
Expand All @@ -678,10 +665,7 @@ def __repr__(self):
Examples
--------
>>> all = StreamingConfigBits(
... first=True, second=True, third=True)
>>> StreamingData(
... values=[1, 2, 3], counter=21, timestamp=1, channels=all)
>>> StreamingData(values=[1, 2, 3], counter=21, timestamp=1)
[1, 2, 3]@1 #21
"""
Expand Down
14 changes: 4 additions & 10 deletions mytoolit/measurement/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,8 @@ def add_streaming_data(
>>> channel3 = StreamingConfiguration(first=False, second=False,
... third=True)
>>> bits3 = channel3.channels
>>> data1 = StreamingData(
... values=[1, 2, 3], counter=21, timestamp=1, channels=bits3)
>>> data2 = StreamingData(
... values=[4, 5, 6], counter=22, timestamp=2, channels=bits3)
>>> data1 = StreamingData(values=[1, 2, 3], counter=21, timestamp=1)
>>> data2 = StreamingData(values=[4, 5, 6], counter=22, timestamp=2)
>>> filepath = Path("test.hdf5")
>>> with Storage(filepath, channel3) as storage:
... storage.add_streaming_data(data1)
Expand All @@ -326,11 +323,8 @@ def add_streaming_data(
Store streaming data for three channels
>>> all = StreamingConfiguration(first=True, second=True, third=True)
>>> bits_all = all.channels
>>> data1 = StreamingData(
... values=[1, 2, 3], counter=21, timestamp=1, channels=bits_all)
>>> data2 = StreamingData(
... values=[4, 5, 6], counter=22, timestamp=2, channels=bits_all)
>>> data1 = StreamingData(values=[1, 2, 3], counter=21, timestamp=1)
>>> data2 = StreamingData(values=[4, 5, 6], counter=22, timestamp=2)
>>> with Storage(filepath, all) as storage:
... storage.add_streaming_data(data1)
... storage.add_streaming_data(data2)
Expand Down

0 comments on commit 48a5205

Please sign in to comment.