-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataHandler.py
61 lines (38 loc) · 1.96 KB
/
DataHandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
sys.path.insert(0, '../')
from Handler.DatabaseHandlers import SqliteHandler
from Handler.JsonHandlers import ConfigHandler
class DataHandler():
def __init__(self):
self.__configHandler = ConfigHandler()
self.__sqliteHandler = SqliteHandler()
def setupDataStack(self,name:str,structure:dict):
return self.__sqliteHandler.setupTable(name,structure)
def getPin(self,pinID):
return self.__configHandler.getPin(pinID)
def getAllPins(self, mode="all"):
return self.__configHandler.getAllPins(mode)
def safeData(self,dest:str,data:dict):
return self.__sqliteHandler.writeToTable(table=dest,data=data)
def readData(self,stack,length):
return self.__sqliteHandler.getDataFromTable(table=stack,length=length)
def readDataByTimeSpan(self,stack,startTime,endTime):
return self.__sqliteHandler.getDataByTimeSpan(stack,startTime,endTime)
def getSensors(self,onlyActive = True):
return self.__configHandler.getSensors(onlyActive)
def addSensor(self, name: str, pinID: int, className: str, active: bool=True):
return self.__configHandler.addSensor(name, pinID, className, active)
def getActuators(self,onlyActive = True):
return self.__configHandler.getActuators(onlyActive)
def addActuator(self, name: str, type: str, collection: str, config: dict, active: bool=True,configIsUnique=True):
return self.__configHandler.addActuator(name, type, collection, config, active,configIsUnique)
def getLogics(self,onlyActive = True):
return self.__configHandler.getLogics(onlyActive)
def listDataStacks(self):
return self.__sqliteHandler.listTables()
def getDataStackSize(self,collection):
return self.__sqliteHandler.getTableSize(table=collection)
def getMainConfig(self):
return self.__configHandler.getMainConfig()
if __name__ == "__main__":
dataHander = DataHandler()