mirror of
https://github.com/OMGeeky/flucto-heisskleber.git
synced 2025-12-28 07:18:09 +01:00
* WIP: Added async file reader. * Async resampling and synchronization refactored. * Add async mqtt publisher. Remove queue from joint. * Add async zmq publisher and subscriber. * Modify integration tests for streaming. * Name refactoring resampler. * Added async source/sink to factory. * Refactor joint and add integration tests. * Add termcolor dev dependency * Add conosole source and sink * Add cli interface for different protocols * Removed files unfit for merge. * Fix review requests. * Restore use of $MSB_CONFIG_DIR for now. It seems that the default behaviour is not looking for .config/heisskleber * Remove version test, causing unnecessary failures.
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import asyncio
|
|
|
|
import numpy as np
|
|
|
|
from heisskleber.mqtt import AsyncMqttSubscriber, MqttConf
|
|
from heisskleber.stream.resampler import Resampler, ResamplerConf
|
|
|
|
|
|
async def main():
|
|
topic1 = "topic1"
|
|
topic2 = "topic2"
|
|
|
|
config = MqttConf(broker="localhost", port=1883, user="", password="") # not a real password
|
|
sub1 = AsyncMqttSubscriber(config, topic1)
|
|
sub2 = AsyncMqttSubscriber(config, topic2)
|
|
|
|
resampler_config = ResamplerConf(resample_rate=250)
|
|
|
|
resampler1 = Resampler(resampler_config, sub1)
|
|
resampler2 = Resampler(resampler_config, sub2)
|
|
|
|
while True:
|
|
m1, m2 = await asyncio.gather(resampler1.receive(), resampler2.receive())
|
|
|
|
print(f"epoch: {m1['epoch']}")
|
|
print(f"diff: {diff(m1, m2)}")
|
|
|
|
|
|
def diff(dict1, dict2):
|
|
return dict(
|
|
zip(
|
|
dict1.keys(),
|
|
np.array(list(dict1.values())) - np.array(list(dict2.values())),
|
|
)
|
|
)
|
|
|
|
|
|
# Run the event loop
|
|
if __name__ == "__main__":
|
|
try:
|
|
asyncio.run(main())
|
|
except KeyboardInterrupt:
|
|
print("Keyboard Interrupt")
|