Skip to content
Snippets Groups Projects
Commit 63e6f56e authored by Daniele Nicolodi's avatar Daniele Nicolodi
Browse files

dummy: Dummy data producer used for testing

parent 0cd9a941
No related branches found
No related tags found
No related merge requests found
dummy.py 0 → 100644
import click
import random
from datetime import datetime
from ptblab import datalogger, terminal, utils, win32time
@click.command()
@click.option('--interval', metavar='SEC', type=float, default=1.0, help='Recoding interval.')
@click.option('--datadir', type=click.Path(), help='Data folder for datalogger mode.')
@click.option('--dataname', default='dummy', metavar='STRING', help='Data name in datalogger mode.')
def main(interval, datadir, dataname):
store = datalogger.open_data_file(datadir, dataname, None)
win32time.set_resolution(win32time.get_resolution().max)
terminal.setup()
for timestamp in utils.tick(interval):
r = random.random()
t = datetime.fromtimestamp(timestamp).isoformat(' ', 'milliseconds')
print(f'{timestamp:.3f} {t:s} {r:.6f}', end='\033[0K\r')
store.write(timestamp, r)
print()
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment