restructure code and use frappy.client for SECoP

- separation of SECoP part from webserver
- use frappy client instead of own code for SECoP communication
This commit is contained in:
l_samenv
2024-10-23 11:10:04 +02:00
parent b708197d27
commit b07ca0bd4f
8 changed files with 597 additions and 1473 deletions

36
base.py Normal file
View File

@ -0,0 +1,36 @@
import time
import logging
class Logger(object):
def __init__(self, logpath):
self.terminal = sys.stdout
self.log = open(logpath, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
pass
class Instrument:
def __init__(self):
pass
def remove(self, client):
try:
del self.clients[client.id]
except KeyError:
logging.warning('client already removed %s', client.id)
def register(self, client):
self.clients[client.id] = client
return client
def get_abs_time(times):
now = int(time.time() + 0.999)
oneyear = 365 * 24 * 3600
return [t + now if t < oneyear else t for t in times]