Influx graph part only + device name on jump and start + fixed dselect z-index

This commit is contained in:
l_samenv
2024-08-21 10:05:47 +02:00
parent 2ea1674991
commit 89dd427a22
8 changed files with 115 additions and 12 deletions

View File

@@ -11,7 +11,7 @@ import time
import pprint
import random
import time
from datetime import date
from datetime import date, datetime
from collections import deque
import sys
import socket
@@ -27,6 +27,7 @@ import signal
from influxgraph import InfluxGraph
from influxdb import InfluxDB, InfluxDataGetter
try: import simplejson as json
except ImportError: import json
@@ -498,11 +499,28 @@ class SeaInstrument(Instrument):
class SeaInfluxInstrument(SeaInstrument):
def __init__(self, inst_name, instrument_config):
super().__init__(inst_name, instrument_config)
self.db = InfluxDB()
self.influx_data_getter = InfluxDataGetter(self.db, json.load(open("./graphs/lab4.json", "r"))["influx"])
self.device = self.influx_data_getter.get_device_name(int(datetime.now().timestamp()))
def newClient(self):
if not self.seaspy.connected:
self.init()
return self.register(SeaInfluxClient())
class InfluxInstrument(Instrument):
def __init__(self, instr_name):
self.db = InfluxDB()
self.influx_data_getter = InfluxDataGetter(self.db, json.load(open("./graphs/lab4.json", "r"))["influx"])
self.clients = {}
self.title = instr_name
self.device = self.influx_data_getter.get_device_name(int(datetime.now().timestamp()))
def newClient(self):
return self.register(InfluxClient())
class SeaGraph:
HISTORICAL = 0
@@ -679,6 +697,36 @@ class SeaParams:
return dict(type='accept-command')
class InfluxParams:
"""Class with dummy routes, in case client side is started with the right part init commands"""
def __init__(self):
self.id = uuid.uuid4().hex[0:15]
self.queue = []
def poll(self):
messages = self.queue
self.queue = []
msg = self.graphpoll()
if msg:
messages.append(msg)
return messages
def info(self):
return ["na"]
def w_getblock(self, path):
return dict(type='draw', title="graph", path=path, components=[])
def w_updateblock(self, path):
return dict(type='accept-block')
def w_console(self):
return dict(type='accept-console')
def w_sendcommand(self, command):
return dict(type='accept-command')
class SeaClient(SeaParams, SeaGraph):
def __init__(self):
SeaParams.__init__(self)
@@ -688,7 +736,12 @@ class SeaClient(SeaParams, SeaGraph):
class SeaInfluxClient(SeaParams, InfluxGraph):
def __init__(self):
SeaParams.__init__(self)
InfluxGraph.__init__(self)
InfluxGraph.__init__(self, instrument.influx_data_getter)
class InfluxClient(InfluxParams, InfluxGraph):
def __init__(self):
InfluxParams.__init__(self)
InfluxGraph.__init__(self, instrument.influx_data_getter)
class DummyClient(SeaGraph):
@@ -1015,6 +1068,8 @@ if __name__ == '__main__':
instrument = SeaInstrument(inst_name, instrument_config)
elif type == 'influxsea':
instrument = SeaInfluxInstrument(inst_name, instrument_config)
elif type == 'influx':
instrument = InfluxInstrument(inst_name)
elif type == 'dummy':
instrument = DummyInstrument(inst_name, instrument_config)
elif type == 'secop':