remove unused files
This commit is contained in:
parent
2c4c4bcd95
commit
2ba8a1ec08
1 changed files with 0 additions and 65 deletions
65
Client.py
65
Client.py
|
@ -1,65 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
import queue
|
|
||||||
import time
|
|
||||||
|
|
||||||
class Client:
|
|
||||||
def __init__(self, id_c, type_c="default"):
|
|
||||||
self.type_c = type_c
|
|
||||||
self.id_c = id_c
|
|
||||||
self.ts = time.time()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
self.ts = time.time()
|
|
||||||
|
|
||||||
def get_info(self):
|
|
||||||
return {"id": self.id_c, "type": self.type_c, "ts": self.ts}
|
|
||||||
|
|
||||||
class Sensor(Client):
|
|
||||||
def __init__(self, id_s, type_s, num_values):
|
|
||||||
self.num_values = num_values
|
|
||||||
self.values = {}
|
|
||||||
super().__init__(id_s, type_s)
|
|
||||||
|
|
||||||
def get_values(self, single=False):
|
|
||||||
ret = {}
|
|
||||||
ret["id"] = self.id_c
|
|
||||||
ret["type"] = self.type_c
|
|
||||||
if single:
|
|
||||||
ret["values"] = self.values[next(iter(self.values))]
|
|
||||||
else:
|
|
||||||
ret["values"] = self.values
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def add_value(self, value):
|
|
||||||
ts = time.time()
|
|
||||||
self.values[ts] = value
|
|
||||||
|
|
||||||
while len(self.values) > self.num_values:
|
|
||||||
self.values.pop(next(iter(self.values)))
|
|
||||||
|
|
||||||
return len(self.values)
|
|
||||||
|
|
||||||
class Actor(Client):
|
|
||||||
def __init__(self, id_a, type_a, levels):
|
|
||||||
self.type_a = type_a
|
|
||||||
self.levels = levels
|
|
||||||
self.queue = queue.Queue()
|
|
||||||
super().__init__(id_a, type_a)
|
|
||||||
|
|
||||||
|
|
||||||
def get_info(self):
|
|
||||||
return {"id": self.id_c, "type": self.type_a, "ts": self.ts,
|
|
||||||
"levels": self.levels, "level": self.level}
|
|
||||||
|
|
||||||
def add_queue(self, command, data):
|
|
||||||
# print("add_queue: {\"command\": %s, \"data\": %s}" % (command, data))
|
|
||||||
self.queue.put({"command": command, "data": data})
|
|
||||||
|
|
||||||
def get_queue(self):
|
|
||||||
ret = {}
|
|
||||||
if not self.queue.empty():
|
|
||||||
ret = self.queue.get()
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def get_level(self):
|
|
||||||
return(self.level)
|
|
Loading…
Reference in a new issue