-
Notifications
You must be signed in to change notification settings - Fork 0
/
devicemanager.py
32 lines (25 loc) · 1014 Bytes
/
devicemanager.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
from device_haspscreen import DeviceHaspScreen
from device_vyria import DeviceVyria
from device_socorel import DeviceSocorel
import logging
import logprefix
class DeviceManager ():
__manager = None
def __init__(self):
self.route = {
"hasp":DeviceHaspScreen (__name__),
"viriya":DeviceVyria(__name__),
"Socorel":DeviceSocorel(__name__)
}
self.logger = logprefix.LogPrefix(__name__, logging.getLogger())
def incomingMessage (self, mqtt, devicetype, device, topic, payload):
if devicetype in self.route:
self.route[devicetype].incomingMessage (mqtt, devicetype, device, topic, payload)
else:
self.logger.warning("unknow device type:{0}".format(devicetype))
def outgoingMessage(self):
pass
def get_manager ():
if DeviceManager.__manager is None:
DeviceManager.__manager = DeviceManager ()
return DeviceManager.__manager