Files
sehistory/t.py
Markus Zolliker ce205f47a2 further rework
- dump all every full hour
- finish all streams properly on exit
2025-02-11 10:51:37 +01:00

50 lines
1.3 KiB
Python

import time
import numpy as np
import pandas as pd
from influx import InfluxDBWrapper, NamedTuple, RegExp
DAY = 24 * 3600
token = "zqDbTcMv9UizfdTj15Fx_6vBetkM5mXN56EE9CiDaFsh7O2FFWZ2X4VwAAmdyqZr3HbpIr5ixRju07-oQmxpXw=="
db = InfluxDBWrapper('http://pc16392:8086', token, 'linse', 'curve-test')
print("""
qry([start], [stop], [interval=...,] [last=True,] [columns=[...],] [<tag>=<value>, ] ...)
crv([start], [stop], [mod.par], ['float'], [interval=...,] [add_prev=False,] [add_end=True,] [<tag>=<value>, ] ...)
""")
offset = (time.time() // 3600) * 3600
result = {}
def prt():
for i, (key, curve) in enumerate(result.items()):
if i > 5:
print('--- ...')
break
print('---', key, list(curve[0]._idx_by_name))
n = len(curve)
if n > 7:
curves = [curve[:3], None, curve[-3:]]
else:
curves = [curve]
for crv in curves:
if crv is None:
print('...')
else:
for row in crv:
print(round(row[0] - offset, db.timedig), row[1:])
def qry(*args, **kwds):
global result
result = db.query(*args, **kwds)
prt()
def crv(*args, **kwds):
global result
result = db.curves(*args, **kwds)
prt()