Mercurial > hg > soniczoomios
comparison eventLogger.h @ 29:fabb3a5cdfc9
Timed session improvements. Desperate pathetic attempts to send a simple HTTP POST.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 22 Feb 2013 17:41:38 +0000 |
parents | e2c62db1e265 |
children | c0a6f7c66719 |
comparison
equal
deleted
inserted
replaced
28:e2c62db1e265 | 29:fabb3a5cdfc9 |
---|---|
23 #include <map> | 23 #include <map> |
24 #include "2dvector.h" | 24 #include "2dvector.h" |
25 #include "json.h" | 25 #include "json.h" |
26 #include "testApp.h" | 26 #include "testApp.h" |
27 | 27 |
28 | 28 #import "ServerComms.h" |
29 | 29 |
30 | |
31 #define EVENT_THIN_FACTOR 10 | 30 #define EVENT_THIN_FACTOR 10 |
32 #define EVENT_LOG_FILENAME "log.json" | 31 #define EVENT_LOG_FILENAME "log.json" |
33 #define SERVER_URL "http://127.0.0.1:8080/testservice/" | 32 //#define LOGGING_SERVER_URL "http://www.isophonics.net/datacollector/" |
34 #define UPLOAD_CHUNK_SIZE 500 | 33 #define LOGGING_SERVER_URL "http://127.0.0.1:8080/testservice/" |
34 #define UPLOAD_CHUNK_SIZE 100 | |
35 | |
35 #define QUESTIONNAIRE_ENABLE_TIME 100000 // milliseconds | 36 #define QUESTIONNAIRE_ENABLE_TIME 100000 // milliseconds |
36 #define APP_CREATION_TIME 381429000000 // milliseconds to the time i wrote this wee blighter | 37 #define APP_CREATION_TIME 381429000000 // milliseconds to the time i wrote this wee blighter saves digits |
37 | 38 |
38 #define PROGRAM_VERSION 1.0 // IMPORTANT TOCHNAGE! | 39 #define PROGRAM_VERSION 0.1 // IMPORTANT TOCHNAGE! |
39 | 40 |
40 // can add but don't change ordering - this will invalidate logs | 41 // can add but don't change ordering - this will invalidate logs |
41 enum leventType {SAVE_PRESET, // 0 | 42 enum leventType {SAVE_PRESET, // 0 |
42 SAVE_DESET, // 1 | 43 SAVE_DESET, // 1 |
43 SCROLL, // 2 | 44 SCROLL, // 2 |
126 os << e.eventType << ',' << e.val1 << ',' << e.val2 << ',' << e.sliderID << '\n'; | 127 os << e.eventType << ',' << e.val1 << ',' << e.val2 << ',' << e.sliderID << '\n'; |
127 | 128 |
128 return os; | 129 return os; |
129 } | 130 } |
130 //--------------------------------------------------------------------------- | 131 //--------------------------------------------------------------------------- |
131 | 132 |
133 class ThreadedObject: ofThread{ | |
134 int i; | |
135 int threadedFunc(int i){ | |
136 return i + 10; | |
137 }; | |
138 }; | |
139 | |
140 | |
132 class EventLogger{ | 141 class EventLogger{ |
133 public: | 142 public: |
134 int nextUploadNumber; | 143 int nextUploadNumber; |
135 bool loggingEnabled; | 144 bool loggingEnabled; |
136 bool logUploadInProgress; | 145 bool logUploadInProgress; |
137 bool serverConnectionOK; | 146 bool serverConnectionOK; |
138 bool consentGiven; | 147 bool consentGiven; |
139 unsigned int deviceID; // unique get something from hardware?? | 148 bool questionnaireCompleted; |
149 bool questionnaireUploaded; | |
150 unsigned int deviceID; | |
140 unsigned int totalInteractionTime, savedInteractionTime, sessionTime, sessionStartTime; | 151 unsigned int totalInteractionTime, savedInteractionTime, sessionTime, sessionStartTime; |
141 string userName; // not unique | 152 string userName; // not unique |
142 | 153 |
143 EventLogger(); | 154 EventLogger(); |
144 void init(); | 155 void init(); |
147 void newUser(); | 158 void newUser(); |
148 void logEvent(const leventType& evtType,const TwoVector& centre = TwoVector(), const double& scale = 1.0, const int& sliderID = -1, const double& sliderVal = 0.0); | 159 void logEvent(const leventType& evtType,const TwoVector& centre = TwoVector(), const double& scale = 1.0, const int& sliderID = -1, const double& sliderVal = 0.0); |
149 void questionnaireAnswersObtained(vector<int> answers, const char* userComments); | 160 void questionnaireAnswersObtained(vector<int> answers, const char* userComments); |
150 void urlResponse(ofHttpResponse & response); | 161 void urlResponse(ofHttpResponse & response); |
151 private: | 162 private: |
152 // what we need... | |
153 /* | |
154 time, type, value | |
155 */ | |
156 | 163 |
157 int currentHTTPRequestID; | 164 int currentHTTPRequestID; |
165 | |
166 | |
158 vector<lEvent> theEvents; | 167 vector<lEvent> theEvents; |
159 | 168 |
160 void thinnedLogEvent(lEvent nextEvent); | 169 void thinnedLogEvent(lEvent nextEvent); |
161 | |
162 // values applicable to all events | |
163 | |
164 unsigned int nextUploadQty; | 170 unsigned int nextUploadQty; |
165 | 171 |
166 string questionnaireComments; | 172 string questionnaireComments; |
167 | 173 |
168 ofxiPhoneDeviceType iOSdeviceType; | 174 ofxiPhoneDeviceType iOSdeviceType; |
169 | 175 |
170 bool testConnection(); | 176 bool testConnection(); |
171 vector<int> questionnaireAnswers; | 177 vector<int> questionnaireAnswers; |
172 bool questionnaireCompleted; | |
173 bool questionnaireUploaded; | |
174 int interfaceOrder; | 178 int interfaceOrder; |
175 | 179 |
176 | 180 |
177 void checkLogFile(); | 181 void checkLogFile(); |
182 void deleteLogs(); // new user | |
178 bool uploadEventLog(bool async); | 183 bool uploadEventLog(bool async); |
179 void firstEverAppOpen(); | 184 void firstEverAppOpen(); |
180 void readJsonToLog(const string &jsonFile); | 185 void readJsonToLog(const string &jsonFile); |
181 void uploadQuestionnaire(); | 186 void uploadQuestionnaire(); |
182 bool sendToServer(string functionName, Json::Value jsonData, bool async); | 187 bool sendToServer(string functionName, Json::Value jsonData, bool async); |
188 for(evIter = theEvents.begin(); evIter < theEvents.end(); evIter++){ | 193 for(evIter = theEvents.begin(); evIter < theEvents.end(); evIter++){ |
189 cout << *evIter; | 194 cout << *evIter; |
190 | 195 |
191 } | 196 } |
192 }; | 197 }; |
198 | |
199 // | |
200 ServerComms *serverComms; | |
201 | |
193 }; | 202 }; |
194 | 203 |
195 | 204 |
196 //--------------------------------------------------------------------------- | 205 //--------------------------------------------------------------------------- |
197 | 206 |