-
Notifications
You must be signed in to change notification settings - Fork 3
/
status.py
29 lines (23 loc) · 940 Bytes
/
status.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
import time
#
# This is where we store the status of any connected peers/devices
#
Status = { 'peers' : {}, 'devices' : {} }
def getStatus():
return Status
def getPeerStatus(addr):
if addr not in Status['peers']:
Status['peers'][addr] = { 'devices' : set() }
return Status['peers'][addr]
def getDeviceStatus(deviceid):
if deviceid not in Status['devices']:
# cseq is control plane sequence number, 0..0xfd
# results is a dict holding the results from a request
# 'results' = { <sequence number of request sent> : { 'ev' : <threading.Event>, 'val' : <result of requested operation> }, ... }
Status['devices'][deviceid]={ 'rooms' : {}, 'cseq' : 0x0, 'results' : {} }
return Status['devices'][deviceid]
def getRoomStatus(deviceid,room):
deviceStatus = getDeviceStatus(deviceid)
if room not in deviceStatus['rooms']:
deviceStatus['rooms'][room] = { 'days' : {} }
return deviceStatus['rooms'][room]