-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp.py
More file actions
94 lines (84 loc) · 1.91 KB
/
exp.py
File metadata and controls
94 lines (84 loc) · 1.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import paho.mqtt.client as mqtt
import json
import time
brok = "mqtt-dashboard.com"
port = 1883
# Keys
ts = 'timestamp'
topic = 'Topic'
d = 'data'
aId = 'areaId'
v = 'value'
v2 = 'value2'
mqttc = mqtt.Client()
mqttc.connect(brok, port)
def exp(filename, expName = "test", velo = 0):
filename = './Jsons/' + filename + '.json'
sceneFile = open(filename, 'r')
scene = json.load(sceneFile)
t = 0
for i, e in enumerate(scene['data']):
print(e)
if (e[topic] == 'Fire'):
e[d]['messageId'] = expName
if (e[topic] == 'Test-mW'):
e[d]['value2'] = velo
if (e[topic] == 'Test-Target'):
e[d]['value'] = velo
if t >= e[ts]:
# play
mqttc.publish(e[topic], str(e[d]))
else:
time.sleep(e[ts] - t)
# play
mqttc.publish(e[topic], str(e[d]))
t = e[ts]
def exp2(test, sub = None):
global mqttc
mqttc = mqtt.Client()
mqttc.connect(brok, port)
#kin-A-2
# 19km/h = 5.3m/s
testVelo = 5.3 # 4.2m/s ~= 15km/h
d = test.split('-')
building = d[0]
exp(building + '-init',None,testVelo)
statName = d[0]
for i, e in enumerate(d[1:]):
exp(building + '-' + e,None,testVelo)
statName += '-' + e
if sub != None:
statName += sub
exp('Fire', statName)
def t(f):
global mqttc
mqttc = mqtt.Client()
mqttc.connect(brok, port)
exp('settarget',None, f)
#exp2('kin-A-1')
# t(1)
# exp2('etri-A-1','first')
# input()
# exp2('etri-A-2','first')
# input()
# exp2('etri-A-3','first')
# input()
# exp2('etri-B-1','first')
# input()
# exp2('etri-B-2','first')
# input()
# exp2('etri-B-3','first')
# input()
# t(6)
# exp2('etri-A-1','last')
# input()
# exp2('etri-A-2','last')
# input()
# exp2('etri-A-3','last')
# input()
# exp2('etri-B-1','last')
# input()
# exp2('etri-B-2','last')
# input()
# exp2('etri-B-3','last')
# input()