Once calibration data is taken, the user can scan. The following code sample takes a scan:
__weak typeof(&*self)weakSelf = self;
[[CPScioDevice sharedInstance] isCalibrationValid:^(BOOL success) {
if (!success) {
[weakSelf alertWithTitle:@"Calibration is invalid" message:@"Calibrate before scan"];
return;
}
[weakSelf toastWithTitle:@"scanAPI" message:@"Scanning"];
[[CPScioDevice sharedInstance] scanWithCompletion:^(BOOL success, CPScioReading *reading, NSError *error) {
NSLog(@"Scan: %i",success);
if (!success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self alertWithTitle:error.userInfo[NSLocalizedDescriptionKey] message:error.userInfo[NSLocalizedFailureReasonErrorKey]];
});
return;
}
weakSelf.scanReading = reading;
if (![SASampleFileUtils storeToDisk:reading fileName:SALastScanFileName]) {
[self alertWithTitle:@"Failure" message:@"Failed to save last scan"];
}
[self toastWithTitle:@"Scan Completed" message:@"You can analyze a model now."];
}];
}];
__weak typeof(&*self)weakSelf = self;
[[CPScioDevice sharedInstance] isCalibrationValid:^(BOOL success) {
if (!success) {
[weakSelf alertWithTitle:@"Calibration is invalid" message:@"Calibrate before scan"];
return;
}
[weakSelf toastWithTitle:@"scanAPI" message:@"Scanning"];
[[CPScioDevice sharedInstance] scanWithCompletion:^(BOOL success, CPScioReading *reading, NSError *error) {
NSLog(@"Scan: %i",success);
if (!success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self alertWithTitle:error.userInfo[NSLocalizedDescriptionKey] message:error.userInfo[NSLocalizedFailureReasonErrorKey]];
});
return;
}
weakSelf.scanReading = reading;
if (![SASampleFileUtils storeToDisk:reading fileName:SALastScanFileName]) {
[self alertWithTitle:@"Failure" message:@"Failed to save last scan"];
}
[self toastWithTitle:@"Scan Completed" message:@"You can analyze a model now."];
}];
}];
__weak typeof(&*self)weakSelf = self; [[CPScioDevice sharedInstance] isCalibrationValid:^(BOOL success) { if (!success) { [weakSelf alertWithTitle:@"Calibration is invalid" message:@"Calibrate before scan"]; return; } [weakSelf toastWithTitle:@"scanAPI" message:@"Scanning"]; [[CPScioDevice sharedInstance] scanWithCompletion:^(BOOL success, CPScioReading *reading, NSError *error) { NSLog(@"Scan: %i",success); if (!success) { dispatch_async(dispatch_get_main_queue(), ^{ [self alertWithTitle:error.userInfo[NSLocalizedDescriptionKey] message:error.userInfo[NSLocalizedFailureReasonErrorKey]]; }); return; } weakSelf.scanReading = reading; if (![SASampleFileUtils storeToDisk:reading fileName:SALastScanFileName]) { [self alertWithTitle:@"Failure" message:@"Failed to save last scan"]; } [self toastWithTitle:@"Scan Completed" message:@"You can analyze a model now."]; }]; }];