You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stowellm edited this page Sep 30, 2014
·
1 revision
// initialize a project
int p = 828;
// after initializing dm = [[DataManager alloc] init], set the project ID
[dm setProjectID:p];
// now retrieve the fields for this project
[dm retrieveProjectFields];
// create an array to store data
NSMutableArray *data = [[NSMutableArray alloc] init];
// allocate a data container object for each data point
DataContainer *dc = [[DataContainer alloc] init];
// populate the data container using the key constants defined in DataContainer.h
[dc addData:[NSNumber numberWithInt:100] forKey:sACCEL_X];
[dc addData:[NSNumber numberWithInt:200] forKey:sACCEL_Y];
[dc addData:[NSNumber numberWithInt:300] forKey:sACCEL_Z];
// write the data container to an NSDictionary with the data manager's writeDataToJSONObject
// method, then save it to your local array
[data addObject:[dm writeDataToJSONObject:dc]];
// repeat for the next data point
dc = [[DataContainer alloc] init];
[dc addData:[NSNumber numberWithInt:400] forKey:sACCEL_X];
[dc addData:[NSNumber numberWithInt:500] forKey:sACCEL_Y];
[dc addData:[NSNumber numberWithInt:600] forKey:sACCEL_Z];
[data addObject:[dm writeDataToJSONObject:dc]];
// login to isense
[api createSessionWithEmail:@"YOUR_EMAIL_HERE" andPassword:@"YOUR_PW_HERE"];
// convert the data from row-major to column-major format with the data manager
NSMutableDictionary *colData = [DataManager convertDataToColumnMajor:data forProjectID:p andRecognizedFields:nil];
// upload the data to isense
[api uploadDataToProject:p withData:colData andName:@"Data set"];