add select_experiment
This commit is contained in:
@ -5,7 +5,7 @@ import io
|
||||
import uuid
|
||||
from configparser import ConfigParser
|
||||
from math import ceil
|
||||
from sehistory.influx import InfluxDBWrapper
|
||||
from sehistory.seinflux import SEHistory
|
||||
from colors import assign_colors_to_curves
|
||||
from chart_config import ChartConfig
|
||||
from base import Instrument, get_abs_time
|
||||
@ -84,8 +84,10 @@ class InfluxGraph:
|
||||
logging.info('LIVE %g %g %d %d', end, now, end >= now, self.livemode)
|
||||
if interval:
|
||||
interval = float(interval)
|
||||
print('CURVES', start - now, end - now, self.tags)
|
||||
result = self.db.curves(start, end, queried_variables, merge='_measurement',
|
||||
interval=interval or None, **self.tags)
|
||||
print('LEN', len(result))
|
||||
self.update_last(result)
|
||||
self.db.complete(result, self.last_time, 'stream')
|
||||
self.last_minute = now // 60
|
||||
@ -145,19 +147,19 @@ class InfluxGraph:
|
||||
|
||||
self.tags = split_tags(tags)
|
||||
if instrument:
|
||||
tags['stream'] = list(self.db.get_streams(instrument))
|
||||
print('GETAV', self.tags)
|
||||
self.tags['stream'] = list(self.db.get_streams(instrument))
|
||||
print('TAGS', self.tags)
|
||||
blocks = self.get_available_variables(start_time, end_time, self.chart_configs, userconfiguration)
|
||||
device_name = tags.get('device', '<unknown>')
|
||||
device_name = self.tags.get('device', '<unknown>')
|
||||
# initialize self.last_values to keep track of the available variables
|
||||
self.last_values = {var["name"]: [0, None] for block in blocks for var in block["curves"]}
|
||||
assign_colors_to_curves(blocks)
|
||||
result = dict(type='var_list')
|
||||
result['blocks'] = blocks
|
||||
result['device'] = device_name
|
||||
print('DEVICE', device_name, tags)
|
||||
for block in blocks:
|
||||
print(block['tag'], [c['name'] for c in block['curves']])
|
||||
# print('DEVICE', device_name, tags)
|
||||
# for block in blocks:
|
||||
# print(block['tag'], [c['name'] for c in block['curves']])
|
||||
return result
|
||||
|
||||
def get_available_variables(self, start_time, end_time, chart_configs=None, user_config=None):
|
||||
@ -307,7 +309,7 @@ class InfluxGraph:
|
||||
# the server is only waiting after a None return
|
||||
# this avoids to many queries with expected empty result
|
||||
return None
|
||||
last_time = int(min(self.last_time.values()))
|
||||
last_time = int(min(self.last_time.values(), default=now-3600))
|
||||
# if len(self.last_time) > 1:
|
||||
# print('time_poll_jitter', max(self.last_time.values()) - min(self.last_time.values()))
|
||||
prev_minute, self.last_minute = self.last_minute, now // 60
|
||||
@ -416,7 +418,7 @@ class SecopInfluxInstrument(SecopInstrument):
|
||||
config.optionxform = str
|
||||
config.read("./config/influx.ini")
|
||||
section = config["INFLUX"]
|
||||
self.db = InfluxDBWrapper('linse-c')
|
||||
self.db = SEHistory()
|
||||
# self.db = InfluxDBWrapper(uri=section["url"], token=section["token"],
|
||||
# org=section["org"], bucket=section['bucket'])
|
||||
# self.influx_data_getter = InfluxDataGetter(self.db, inst_name)
|
||||
@ -425,7 +427,9 @@ class SecopInfluxInstrument(SecopInstrument):
|
||||
def new_client(self):
|
||||
return self.register(SecopInfluxClient(self))
|
||||
|
||||
def get_stream_tags(self, timestamp=None):
|
||||
def get_streams(self, timestamp=None):
|
||||
return self.db.get_streams(None, timestamp)
|
||||
|
||||
def get_experiments(self, start=None, stop=None):
|
||||
return self.db.get_experiments(start, stop)
|
||||
|
||||
|
Reference in New Issue
Block a user