1 from datetime import datetime
4 path = "/scratch/July-2018/training/"
6 #device = "dlink-plug/self-test"
7 #fileExperiment = "dlink-plug-oct-17-2018.timestamps"
8 #fileDetection = "detection-on-training-device-side"
9 #fileDetection = "detection-on-training-phone-side"
11 #device = "arlo-camera/self-test"
12 #fileExperiment = "arlo-camera-aug-10-2018.timestamps"
13 #fileDetection = "detection-on-training-phone-side"
15 #device = "blossom-sprinkler/self-test"
16 #fileExperiment = "blossom-sprinkler-aug-13-2018.timestamps"
17 #fileDetection = "detection-on-training-device-side"
19 device = "nest-thermostat/self-test"
20 fileExperiment = "nest-aug-15-2018.timestamps"
21 fileDetection = "detection-on-training-phone-side"
23 #device = "hue-bulb/self-test"
24 #fileExperiment = "hue-bulb-aug-7-2018.timestamps"
25 #fileDetection = "detection-on-training-phone-side"
27 #device = "tplink-bulb/self-test"
28 #fileExperiment = "tplink-bulb-aug-3-2018.timestamps"
29 #fileDetection = "detection-on-training-phone-side"
31 #device = "wemo-insight-plug/self-test"
32 #fileExperiment = "wemo-insight-july-31-2018.timestamps"
33 #fileDetection = "detection-on-training-device-side"
35 TIME_WINDOW = 15 # detection/signature window of 15 seconds
36 #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds
38 # Open training timestamps file and store into a list
39 with open(path + device + "/" + fileExperiment, "r") as experiment:
41 for line in experiment:
42 # Format "%m/%d/%Y %I:%M:%S %p"
43 tsE = datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p\n")
44 tsExperimentList.append(tsE)
46 # Open detection timestamps file and store into a list
47 with open(path + device + "/" + fileDetection, "r") as detection:
49 for line in detection:
50 # Format "%b %d, %Y %I:%M:%S %p"
51 tsD = datetime.strptime(line, "%b %d, %Y %I:%M:%S %p\n")
52 tsDetectionList.append(tsD)
54 if (len(tsExperimentList) > len(tsDetectionList)):
55 maxTimestamps = len(tsExperimentList)
57 maxTimestamps = len(tsDetectionList)
61 while i < maxTimestamps:
62 if(len(tsExperimentList) <= i or len(tsDetectionList) <= j):
65 tsE = tsExperimentList[i]
66 tsD = tsDetectionList[j]
67 # Detection is always a bit later than training trigger
70 #print("tsE: " + str(tsE) + " - tsD: " + str(tsD) + " - delta1: " + str(delta1.seconds) + " - delta2: " + str(delta2.seconds))
71 # The following happens when we could detect less triggers than the experiment
72 if (delta1.seconds > TIME_WINDOW and delta2.seconds > TIME_WINDOW):
73 print("Missing trigger at line: " + str(i) + ", t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
76 # The following should not happen (we have more detected triggers than the experiment)
77 #elif (delta.seconds < NEG_TIME_WINDOW):
78 # print("Mismatch at t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
83 print("Done parsing: " + str(i) + " lines")