Mercurial > hg > soniczoomios
comparison eventLogger.h @ 25:f42a00e3f22d
Logs condensed slightly. Questionnaire button enable.
double precision location!!!
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 01 Feb 2013 17:39:19 +0000 |
parents | a4908ad8c78e |
children | ae4d2c3ce5e0 |
comparison
equal
deleted
inserted
replaced
24:a4908ad8c78e | 25:f42a00e3f22d |
---|---|
9 // uploading logs to server, and storing locally if not uploaded | 9 // uploading logs to server, and storing locally if not uploaded |
10 | 10 |
11 #ifndef __oscSenderExample__eventLogger__ | 11 #ifndef __oscSenderExample__eventLogger__ |
12 #define __oscSenderExample__eventLogger__ | 12 #define __oscSenderExample__eventLogger__ |
13 | 13 |
14 #define EVENT_LOG_FILENAME "log.json" | |
15 #define SERVER_URL "http://127.0.0.1:8080/testservice/" | |
16 | 14 |
17 #include "ofMain.h" | 15 #include "ofMain.h" |
18 #include "ofxiPhone.h" | 16 #include "ofxiPhone.h" |
19 #include "2dvector.h" | 17 #include "2dvector.h" |
20 #include "ofxiPhoneExtras.h" | 18 #include "ofxiPhoneExtras.h" |
25 #include <map> | 23 #include <map> |
26 #include "2dvector.h" | 24 #include "2dvector.h" |
27 #include "json.h" | 25 #include "json.h" |
28 #include "testApp.h" | 26 #include "testApp.h" |
29 | 27 |
30 #import "usernameAlertViewController.h" | |
31 | 28 |
32 | 29 |
30 | |
31 | |
32 #define EVENT_LOG_FILENAME "log.json" | |
33 #define SERVER_URL "http://127.0.0.1:8080/testservice/" | |
34 #define UPLOAD_CHUNK_SIZE 500 | |
35 #define QUESTIONNAIRE_ENABLE_TIME 100000 // milliseconds | |
36 #define APP_CREATION_TIME 381429000000 // milliseconds to the time i wrote this wee blighter | |
37 | |
38 #define PROGRAM_VERSION 1.0 // IMPORTANT TOCHNAGE! | |
39 | |
33 // can add but don't change ordering - this will invalidate logs | 40 // can add but don't change ordering - this will invalidate logs |
34 #define PROGRAM_VERSION 1.0 | 41 enum leventType {SAVE_PRESET, // 0 |
35 enum leventType {SAVE_PRESET, | 42 SAVE_DESET, // 1 |
36 SAVE_DESET, | 43 SCROLL, // 2 |
37 SCROLL, | 44 ZOOM, // 3 |
38 ZOOM, | 45 SCROLL_STOPPED, // 4 |
39 SCROLL_STOPPED, | 46 ZOOM_STOPPED, // 5 |
40 ZOOM_STOPPED, | 47 SNAPPED_TO_PRESET, // 6 |
41 SNAPPED_TO_PRESET, | 48 CHANGE_SLIDER, // 7 |
42 CHANGE_SLIDER, | 49 SWAP_VIEW, // 8 |
43 SWAP_VIEW, | 50 SET_MIN_ZOOM, // 9 |
44 SET_MIN_ZOOM, | 51 SET_MAX_ZOOM, // 10 |
45 SET_MAX_ZOOM}; | 52 RANDOMISE, // 11 |
53 APP_STARTED, // 12 | |
54 APP_EXITED, // 13 | |
55 CONSENT_DENIED, // 14 | |
56 SEQ_LOCKED, // 15 | |
57 SYNTH_LOCKED, // 16 | |
58 PLAY_PRESSED, // 17 | |
59 PAUSE_PRESSED}; // 18 | |
46 | 60 |
47 //--------------------------------------------------------------------------- | 61 //--------------------------------------------------------------------------- |
48 | 62 |
49 class lEvent{ | 63 class lEvent{ |
50 public: | 64 public: |
51 // try and make this as compact as possible. | 65 // try and make this as compact as possible. |
52 leventType eventType; | 66 leventType eventType; |
53 double val1; // x coord, scale if zoom | 67 double val1; // x coord, scale if zoom |
54 double val2; // y coord, 0 if zoom | 68 double val2; // y coord, 0 if zoom |
55 int sliderID; | 69 int sliderID; // xtra int |
56 long long eventTime; | 70 long long eventTime; |
57 lEvent(leventType eType, double v1 = 0.0, double v2 = 0.0,int sID = 0){ | 71 lEvent(leventType eType, double v1 = 0.0, double v2 = 0.0,int sID = 0){ |
58 eventType = eType; | 72 eventType = eType; |
59 val1 = v1; | 73 val1 = v1; |
60 val2 = v2; | 74 val2 = v2; |
61 sliderID = sID; | 75 sliderID = sID; |
62 | 76 |
63 double timemsd = [NSDate timeIntervalSinceReferenceDate]; | 77 double timemsd = [NSDate timeIntervalSinceReferenceDate]; |
64 eventTime = (unsigned long long)(timemsd*1000); | 78 eventTime = (unsigned long long)(timemsd*1000) - APP_CREATION_TIME; |
65 | 79 |
66 } | 80 } |
81 | |
67 lEvent(const Json::Value &jevt){ | 82 lEvent(const Json::Value &jevt){ |
68 // constructor takes "jsonToEvent" readfile function role | 83 // constructor takes "jsonToEvent" readfile function role |
69 eventType = (leventType)jevt["eventType"].asInt(); | 84 eventType = (leventType)jevt["eType"].asInt(); |
70 val1 = jevt["val1"].asFloat(); | 85 val1 = jevt["v1"].asDouble(); |
71 val2 = jevt["val2"].asFloat(); | 86 val2 = jevt["v2"].asDouble(); |
72 sliderID = jevt["sliderID"].asInt(); | 87 sliderID = jevt["sID"].asInt(); |
73 eventTime = jevt["eventTime"].asLargestInt(); | 88 eventTime = jevt["eTime"].asLargestInt(); |
74 | 89 |
75 // TODO what happens if we try to read one that isn't there? | 90 // TODO what happens if we try to read one that isn't there? |
76 | 91 |
77 } | 92 } |
78 Json::Value eventToJson(){ | 93 Json::Value eventToJson(){ |
79 Json::Value jevt; | 94 Json::Value jevt; |
80 jevt["eventType"] = eventType; | 95 jevt["eType"] = eventType; |
81 jevt["val1"] = val1; | 96 // here: should give a certain number of sig figs? |
82 jevt["val2"] = val2; | 97 jevt["v1"] = val1; |
83 jevt["sliderID"] = sliderID; | 98 jevt["v2"] = val2; |
84 jevt["eventTime"] = eventTime; | 99 jevt["sID"] = sliderID; |
100 jevt["eTime"] = eventTime; | |
85 return jevt; | 101 return jevt; |
86 } | 102 } |
87 }; | 103 }; |
88 //--------------------------------------------------------------------------- | 104 //--------------------------------------------------------------------------- |
89 // streams no longer used | 105 // streams no longer used |
112 } | 128 } |
113 //--------------------------------------------------------------------------- | 129 //--------------------------------------------------------------------------- |
114 | 130 |
115 class EventLogger{ | 131 class EventLogger{ |
116 public: | 132 public: |
133 int nextUploadNumber; | |
117 bool loggingEnabled; | 134 bool loggingEnabled; |
118 bool serverConnectionOK; | 135 bool serverConnectionOK; |
136 bool consentGiven; | |
119 unsigned int deviceID; // unique get something from hardware?? | 137 unsigned int deviceID; // unique get something from hardware?? |
120 unsigned int totalInteractionTime, sessionTime, sessionStartTime; | 138 unsigned int totalInteractionTime, savedInteractionTime, sessionTime, sessionStartTime; |
121 string userName; // not unique | 139 string userName; // not unique |
122 | 140 |
123 EventLogger(); | 141 EventLogger(); |
124 void init(); | 142 void init(); |
125 void exitAndSave(); | 143 void exitAndSave(); |