There are two CPScioCloud analyzeReading methods:
Single Model Analysis
This method has the following parameters:
- CPScioReading: The sample data retrieved after a successful scan.
- CPScioModelInfo identifier (NSString *): The predefined model identifier to compare the scan data with.
The method returns the following results:
- success: Whether the method returns a valid analysis of the sample.
- A CPScioModel: The model which match the sample scanned by the user.
- NSError: on failure the method returns the relevant error message.
The following code sample sends the CPScioReading to the cloud for single analysis, retrieves a CPScioModel and displays the information on the screen.
Note: In case of outlier detection, the attributeValue return “null”
weak typeof(&*self)weakSelf = self; [[CPScioCloud sharedInstance] analyzeReading:lastScan modelIdentifier:self.currentModel.identifier completion:^(BOOL success, CPScioModel *model, NSError *error) { NSLog(@"analyze succeded: %i",success); if (success) { NSString *message = [NSString stringWithFormat:@"Type: %@\nValue: %@\n%@", model.modelType == CPScioModelTypeClassification ? @"Classification" : @"Estimation", model.attributeValue, model.modelType == CPScioModelTypeClassification ? [NSString stringWithFormat:@"Confidence: %.2lf\n", model.confidence] : @""]; dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf alertWithTitle:@"Results" message:message]; }); } else { dispatch_async(dispatch_get_main_queue(), ^{ [self alertWithTitle:[error.userInfo objectForKey:NSLocalizedDescriptionKey] message:[error.userInfo objectForKey:NSLocalizedFailureReasonErrorKey]]; }); } }];
Multiple Model Analysis
This method has the following parameters:
- CPScioReading: The sample data retrieved after a successful scan.
- CPScioModelInfo identifiers list (NSArray of NSString): The predefined models identifiers to compare the scan data with.
The method returns the following results:
- success: Whether the method returns a valid analysis of the sample.
- A list of CPScioModels: The models which match the sample scanned by the user.
- NSError: on failure the method returns the relevant error message.
The following code sample sends the CPScioReading with a list of models identifiers to the cloud for multiple analysis and retrieves a list of CPScioModels.
Note: In case of outlier detection, the attributeValue return “null”
[CPScioCloud sharedInstance] analyzeReading:_reading modelIdentifiers:@[model1Identifier1, model2Identifier] completion:^(BOOL success, NSArray<CPScioModel *> *models, NSError *error) { if (success) { // models is an array of CPScioModel elements } }