// // ViewController.m // Test_scan // // Created by Ray on 12/22/15. // Copyright © 2015 United Software Applications, Inc. All rights reserved. // //#define USE_SOFTSCAN 1 #import "ScannerSettingViewController.h" #import "AppDelegate.h" @interface ScannerSettingViewController () @end @implementation ScannerSettingViewController { #ifdef USE_SOFTSCAN DeviceInfo* _softScanDeviceInfo; #endif DeviceInfo* _deviceInfoToTrigger; // DeviceInfo* _deviceInfoToTrigger; // NSDate* _lastCheck; // NSInteger _sameSecondCount; } //@synthesize flipsidePopoverController = _flipsidePopoverController; @synthesize Entry = _Entry; @synthesize Status = _Status; //@synthesize ScanApi; //@synthesize ScanApiConsumer; //@synthesize scanApiVersion; #pragma mark - View lifecycle - (void)onCloseClick:(UIButton *)sender { if(self.onDismissVC) self.onDismissVC(); [self dismissViewControllerAnimated:true completion:nil]; } - (void)viewDidLoad { [super viewDidLoad]; self.support_scanner = true; self.edgesForExtendedLayout = UIRectEdgeNone ; UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic] style:UIBarButtonItemStylePlain target:self action:@selector( onCloseClick:)]; self.navigationItem.rightBarButtonItem = closeButton; // NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; // // CFShow(infoDictionary); // // app名称 // NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"]; // // app版本 // NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; // // app build版本 // NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"]; // // // NSString* appinfo =[NSString stringWithFormat:@"App info: %@ %@ build%@",app_Name,app_Version,app_build]; // self.appinfoLabel.text = appinfo; self.tv_info.layer.borderWidth=1 ; //边框粗细 self.tv_info.layer.borderColor=[UIColor darkGrayColor].CGColor; //边框颜色 UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; switch (appDelegate.api_Status) { case API_START: self.scan_switch.enabled = true; self.scan_switch.on = true; break; case API_INIT: self.scan_switch.enabled = false; break; case API_STOP: self.scan_switch.enabled = true; self.scan_switch.on=false; break; case API_CLOSING: self.scan_switch.enabled = false; break; default: break; } _Status.text = appDelegate.Status_Text; self.tv_info.text = appDelegate.log; // [appDelegate enableScanner:self.scan_switch.isOn]; // _devices=[[NSMutableArray alloc]init]; // change this to YES if you want SingleEntry to // confirm the decoded data // _doAppDataConfirmation=NO; // if(ScanApi==nil){ //#ifdef USE_SOFTSCAN // // this is useful for SoftScan to keep a handle // // that is used in the trigger button // _softScanDeviceInfo=nil; //#endif // // ScanApi=[[ScanApiHelper alloc]init]; // [ScanApi setDelegate:self]; // } // Do any additional setup after loading the view, typically from a nib. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; bool autolaunch = [defaults boolForKey:@"EnableScannerOnLaunch"] ; self.auto_launch_switch.on = autolaunch; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } //-(void)onTimer: (NSTimer*)theTimer{ // if(theTimer==ScanApiConsumer){ // // // [self addlog:@"ScanApi::doScanApiReceive:"]; // [ScanApi doScanApiReceive]; // } //} //-(void)addlog:(NSString*) newtext //{ // // // UIApplication * app = [UIApplication sharedApplication]; // AppDelegate *appDelegate = (AppDelegate *)[app delegate]; // // [appDelegate addlog:newtext]; // dispatch_async(dispatch_get_main_queue(), ^{ // self.tv_info.text = appDelegate.log; // // [self.tv_info scrollRangeToVisible:NSMakeRange(appDelegate.log.length-1,0)]; // }); // //} #pragma mark -control events //- (IBAction)onScannerClick:(id)sender { //} - (IBAction)onChangeAutolaunch:(id)sender { NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:@"EnableScannerOnLaunch"]; [defaults setBool:self.auto_launch_switch.isOn forKey:@"EnableScannerOnLaunch"]; [defaults synchronize]; } -(void) alert_view :(NSString*) msg title:(NSString*) title { if(title==nil) title = @"Message"; if(msg.length>0) { title=[NSString stringWithFormat:@"%@\n\n%@",title,msg]; } UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } - (IBAction)onEmailClicked:(id)sender { AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; [appDelegate test_onDecodedDataResult:@"SCANNER TEST"]; return; // UIApplication * app = [UIApplication sharedApplication]; // AppDelegate *appDelegate = (AppDelegate *)[app delegate]; if(appDelegate.log.length==0) { [self alert_view:nil title:@"Log is empty sending canceled."]; return; } if(self.scan_switch.isOn) { [self alert_view:nil title:@"Disable scanner first."]; return; } // NSString *path = NSTemporaryDirectory(); // CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault); // Get the string representation of CFUUID object. NSString* filename =[[NSUUID UUID] UUIDString]; // NSString *filePath = [path stringByAppendingPathComponent:filename]; MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; if(mc==nil) return; mc.mailComposeDelegate = self; [mc setSubject:@"scaner test log"]; [mc setToRecipients:@[@"ray.zhang@united-cn.net",@"RedAntSupport@united-us.net"]]; NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; // CFShow(infoDictionary); // app名称 NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"]; // app版本 NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; // app build版本 NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"]; NSString* appinfo =[NSString stringWithFormat:@"App info: %@ %@ build%@",app_Name,app_Version,app_build]; // if(self.mail_content==nil) // self.mail_content=@""; NSString* htmlbody = [NSString stringWithFormat:@"
%@
%@",@"Process description:",appinfo]; [mc setMessageBody:htmlbody isHTML:YES]; NSData *data = [appDelegate.log dataUsingEncoding:NSUTF8StringEncoding];//[NSData dataWithContentsOfFile:filePath]; // if(self.attachment_name.length>0) // filename = self.attachment_name; [mc addAttachmentData:data mimeType:@"text/plain" fileName:filename]; [self presentModalViewController:mc animated:YES]; return; } //- (IBAction)onConnectClick:(id)sender { // // //} - (IBAction)onSwitchChanged:(id)sender { // [self addlog:@"onSwitchChanged:"]; UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; [appDelegate enableScanner:self.scan_switch.isOn]; // if(self.scan_switch.isOn) // { // [self addlog:@"switch on"]; // // //// [ScanApi open]; //// [self addlog:@"ScanApi open"]; //// //// ScanApiConsumer=[NSTimer scheduledTimerWithTimeInterval:.2 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES]; //// [self addlog:@"ScanApiConsumer init"]; // // //// [ScanApi close]; //// [self addlog:@"ScanApi opent"]; // } // else // { // [self addlog:@"switch off"]; // // //// [ScanApiConsumer invalidate]; //// ScanApiConsumer= nil; //// [self addlog:@"ScanApiConsumer invalidate"]; // // // // [ScanApi close]; // [self addlog:@"ScanApi close"]; // // // } } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: DebugLog(@"Mail send canceled..."); break; case MFMailComposeResultSaved: DebugLog(@"Mail saved..."); break; case MFMailComposeResultSent: DebugLog(@"Mail sent..."); break; case MFMailComposeResultFailed: DebugLog(@"Mail send errored: %@...", [error localizedDescription]); break; default: break; } [self dismissModalViewControllerAnimated:YES]; } #pragma mark -UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; return appDelegate.devices.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString* CellIdentifier = @"device_cell"; UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; DeviceInfo* info = appDelegate.devices[indexPath.row]; cell.textLabel.text = [info getName]; cell.detailTextLabel.text = info.getTypeString; return cell; } #pragma mark -UITableViewDelegate //- (void)tableView:(UITableView *)tableView //didSelectRowAtIndexPath:(NSIndexPath *)indexPath //{ // // [self addlog:@"tableView didSelectRowAtIndexPath:"]; // // DeviceInfo* deviceInfo = _devices[indexPath.row]; // // if(_doAppDataConfirmation==YES){ // // switch the comment between the 2 following lines for handling the // // data confirmation beep from the scanner (local) // // if none is set, the scanner will beep only once when SingleEntry actually // // confirm the decoded data, otherwise the scanner will beep twice, one locally, // // and one when SingleEntry will confirm the decoded data // [ScanApi postSetDecodeAction:deviceInfo DecodeAction:kSktScanLocalDecodeActionNone Target:self Response:@selector(onSetLocalDecodeAction:)]; // // // [ScanApi postSetDecodeAction:deviceInfo DecodeAction:kSktScanLocalDecodeActionBeep|kSktScanLocalDecodeActionFlash|kSktScanLocalDecodeActionRumble Target:self Response:@selector(onSetLocalDecodeAction:)]; // } // // // for demonstration only, let's make sure the DPM is enabled // // first interrogate the scanner to see if it's already enabled // // and in the onGetSymbologyDpm callback, if the DPM is not already set // // then we send a Symbology property to enable it. // [ScanApi postGetSymbologyInfo:deviceInfo SymbologyId:kSktScanSymbologyDirectPartMarking Target:self Response:@selector(onGetSymbologyDpm:)]; //} //#pragma mark - UI Handlers //// Trigger button handler mostly use for //// trigger a SoftScan read. //// This postSetTriggerDevice will fail if the //// postSetOverlayView is not done before. //// THIS CODE CAN BE IGNORED IF SOFTSCAN IS NOT NEEDED //- (IBAction)triggerSoftScan:(id)sender { //#ifdef USE_SOFTSCAN // [ScanApi postSetTriggerDevice:_deviceInfoToTrigger Action:kSktScanTriggerStart Target:self Response:@selector(onSetTrigger:)]; //#endif //} //#pragma mark - Device Info List management //-(void) updateDevicesList:(DeviceInfo*) deviceInfo Add:(BOOL)add{ // // [self addlog:@"updateDevicesList:"]; // // if(add==YES){ // [_devices addObject:deviceInfo]; // } // else{ // [_devices removeObject:deviceInfo]; // } // // NSMutableString* temp=[[NSMutableString alloc]init]; // for (DeviceInfo* info in _devices) { // [temp appendString:[info getName]]; // [temp appendString:@"\n"]; // } // if(_devices.count>0) // [temp appendString:@"ready to scan"]; // else // [temp appendString:@"Waiting for Scanner..."]; // // _Status.text=temp ; // [self addlog:temp]; // [self.dev_table reloadData]; // //} // // //#pragma mark - ScanApiHelper complete delegates //// THE 2 FOLLOWING CALLBACKS ARE FOR DEMO ONLY FOR SHOWING HOW //// TO CHECK IF A SYMBOLOGY IS ALREADY ENABLED AND IF NOT IT ENABLES //// IT RIGHT THERE. THE GOAL IS TO CONFIGURE ONCE THE SCANNER WHEN IT //// CONNECTS TO THE DEVICE. IF THERE IS NO SPECIFIC NEED TO CONFIGURE //// THE SCANNER, THESE CALLBACKS CAN BE REMOVED // //// callback received when the Get Symbology Status is completed //-(void)onGetSymbologyDpm:(ISktScanObject*)scanObj{ // [self addlog:@"onGetSymbologyDpm:"]; // // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // DeviceInfo* deviceInfo=[ScanApi getDeviceInfoFromScanObject:scanObj]; // if(deviceInfo!=nil){ // ISktScanSymbology* symbology=[[scanObj Property]Symbology]; // if([symbology getStatus]==kSktScanSymbologyStatusDisable){ // [ScanApi postSetSymbologyInfo:deviceInfo SymbologyId:kSktScanSymbologyDirectPartMarking Status:TRUE Target:self Response:@selector(onSetSymbology:)]; // } // } // } // else{ // // an error message should be displayed here // // indicating that the DPM symbology status cannot be retrieved // } //} // //// callback received when the Set Symbology Status is completed //-(void)onSetSymbology:(ISktScanObject*)scanObj{ // [self addlog:@"onSetSymbology:"]; // // SKTRESULT result=[[scanObj Msg]Result]; // if(!SKTSUCCESS(result)){ // // display an error message saying a symbology cannot be set // } //} // ///** // * // */ //-(void) onSetDataConfirmationMode:(ISktScanObject*)scanObj{ // // [self addlog:@"onSetDataConfirmationMode:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // // [self addlog:@"DataConfirmation Mode OK"]; // // } // else{ // [self addlog:[NSString stringWithFormat:@"DataConfirmation Mode Error %ld",result]]; // } //} // // ///** // * // */ //-(void) onDataConfirmation:(ISktScanObject*)scanObj{ // [self addlog:@"onDataConfirmation:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // [self addlog:@"Data Confirmed OK"]; // } // else{ // [self addlog:[NSString stringWithFormat:@"Data Confirmed Error %ld",result]]; // } //} // ///** // * // */ //-(void) onSetLocalDecodeAction:(ISktScanObject*)scanObj{ // [self addlog:@"onSetLocalDecodeAction:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // [self addlog:@"Local Decode Action OK"]; // } // else{ // [self addlog:[NSString stringWithFormat:@"Local Decode Action Error %ld",result]]; // } //} // ///** // * // */ //-(void) onGetSoftScanStatus:(ISktScanObject*)scanObj{ // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // ISktScanProperty* property=[scanObj Property]; // // [self addlog:@"SoftScan status:"]; // if([property getByte]==kSktScanEnableSoftScan){ // [self addlog:@"SoftScan is ENABLED"]; // _softScannerEnabled=TRUE; // } // else{ // _softScannerEnabled=FALSE; // [self addlog:@"SoftScan is DISABLED"]; // } // // // } // else{ // [self addlog:[ NSString stringWithFormat:@"getting SoftScanStatus returned the error %ld",result]]; // } //} // ///** // * // */ //-(void) onSetSoftScanStatus:(ISktScanObject*)scanObj{ // [self addlog:@"onSetSoftScanStatus:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // [self addlog:@"SoftScan set status success"]; // } // else{ // [self addlog:[NSString stringWithFormat:@"SoftScan set status returned the error %ld",result]]; // } //} // ///** // * // */ //-(void) onSetTrigger:(ISktScanObject*)scanObj{ // [self addlog:@"onSetTrigger:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // [self addlog:@"Trigger set success"]; // } // else{ // // // [self addlog:[NSString stringWithFormat:@"Trigger set returned the error %ld",result]]; // } //} // ///** // * // */ //-(void) onGetScanApiVersion:(ISktScanObject*)scanObj{ // [self addlog:@"onGetScanApiVersion:"]; // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)) // { // ISktScanProperty*property=[scanObj Property]; // if([property getType]==kSktScanPropTypeVersion) // { // scanApiVersion=[NSString stringWithFormat:@"%lx.%lx.%lx.%ld", // [[property Version]getMajor], // [[property Version]getMiddle], // [[property Version]getMinor], // [[property Version]getBuild]]; // } // } // else{ // scanApiVersion=[NSString stringWithFormat:@"Get ScanAPI version Error: %ld",result]; // } // // // [self addlog:[NSString stringWithFormat:@"ver: %@",scanApiVersion]]; //} // ///** // * // */ //#ifdef USE_SOFTSCAN //-(void) onSetOverlayView:(ISktScanObject*)scanObj{ // SKTRESULT result=[[scanObj Msg]Result]; // if(SKTSUCCESS(result)){ // [self addlog:@"Overlay view set success"]; // } // else{ // [self addlog:[NSString stringWithFormat:@"Overlay view set returned the error %ld",result]]; // // // } //} //#endif ///** // * called each time a device connects to the host // * @param result contains the result of the connection // * @param newDevice contains the device information // */ //-(void)onDeviceArrival:(SKTRESULT)result device:(DeviceInfo*)deviceInfo{ // [self addlog:@"onDeviceArrival:"]; // // [self updateDevicesList:deviceInfo Add:YES]; // // //#ifdef USE_SOFTSCAN // // if the scanner is a SoftScan scanner // if([deviceInfo.getTypeString compare:@"SoftScan"]==NSOrderedSame){ // // _softScannerTriggerBtn.hidden=NO; // _softScanDeviceInfo=deviceInfo; // if(_deviceInfoToTrigger==nil) // _deviceInfoToTrigger=deviceInfo; // NSMutableDictionary* overlayParameter=[[NSMutableDictionary alloc]init]; // [overlayParameter setValue:self forKey:[NSString stringWithCString:kSktScanSoftScanContext encoding:NSASCIIStringEncoding]]; // [ScanApi postSetOverlayView:deviceInfo OverlayView:overlayParameter Target:self Response:@selector(onSetOverlayView:)]; // } // else //#endif // { // if([deviceInfo.getTypeString compare:@"CHS 8Ci Scanner"]==NSOrderedSame){ //// _softScannerTriggerBtn.hidden=NO; // _deviceInfoToTrigger=deviceInfo; // } // if(_doAppDataConfirmation==YES){ // // switch the comment between the 2 following lines for handling the // // data confirmation beep from the scanner (local) // // if none is set, the scanner will beep only once when SingleEntry actually // // confirm the decoded data, otherwise the scanner will beep twice, one locally, // // and one when SingleEntry will confirm the decoded data // [ScanApi postSetDecodeAction:deviceInfo DecodeAction:kSktScanLocalDecodeActionNone Target:self Response:@selector(onSetLocalDecodeAction:)]; // // // [ScanApi postSetDecodeAction:deviceInfo DecodeAction:kSktScanLocalDecodeActionBeep|kSktScanLocalDecodeActionFlash|kSktScanLocalDecodeActionRumble Target:self Response:@selector(onSetLocalDecodeAction:)]; // } // // // for demonstration only, let's make sure the DPM is enabled // // first interrogate the scanner to see if it's already enabled // // and in the onGetSymbologyDpm callback, if the DPM is not already set // // then we send a Symbology property to enable it. // [ScanApi postGetSymbologyInfo:deviceInfo SymbologyId:kSktScanSymbologyDirectPartMarking Target:self Response:@selector(onGetSymbologyDpm:)]; // } // // //} // // ///** // * called each time a device disconnect from the host // * @param deviceRemoved contains the device information // */ //-(void) onDeviceRemoval:(DeviceInfo*) deviceRemoved{ // // [self addlog:@"onDeviceRemoval:"]; // [self updateDevicesList:deviceRemoved Add:NO]; // if(_deviceInfoToTrigger==deviceRemoved){ // _deviceInfoToTrigger=nil; // } //#ifdef USE_SOFTSCAN // if(_softScanDeviceInfo==deviceRemoved){ // _softScanDeviceInfo=nil; // } // if(_deviceInfoToTrigger==nil) // _deviceInfoToTrigger=_softScanDeviceInfo; //#endif // if(_deviceInfoToTrigger==nil){ //// _softScannerTriggerBtn.hidden=YES; // } //} // ///** // * called each time ScanAPI is reporting an error // * @param result contains the error code // */ //-(void) onError:(SKTRESULT) result{ // [self addlog:@"onError:"]; // // [self addlog:[NSString stringWithFormat:@"ScanAPI is reporting an error: %ld",result]]; // _Status.text=[NSString stringWithFormat:@"ScanAPI is reporting an error: %ld",result]; // //} // ///** // * called each time ScanAPI receives decoded data from scanner // * @param deviceInfo contains the device information from which // * the data has been decoded // * @param decodedData contains the decoded data information // */ //-(void) onDecodedDataResult:(long)result device:(DeviceInfo *)device decodedData:(ISktScanDecodedData*)decodedData{ // // [self addlog:@"onDecodedDataResult:"]; // //-(void) onDecodedData:(DeviceInfo *)device decodedData:(ISktScanDecodedData*)decodedData{ // if(SKTSUCCESS(result)){ // _Entry.text=[NSString stringWithUTF8String:(const char *)[decodedData getData]]; // [self addlog:[NSString stringWithUTF8String:(const char *)[decodedData getData]]]; // if(_doAppDataConfirmation==YES){ // [ScanApi postSetDataConfirmation:device Target:self Response:@selector(onDataConfirmation:)]; // } // } //} // // // // // ///** // * called when ScanAPI initialization has been completed // * @param result contains the initialization result // */ //-(void) onScanApiInitializeComplete:(SKTRESULT) result{ // // [self addlog:@"onScanApiInitializeComplete:"]; // // if(SKTSUCCESS(result)){ // NSString* strlog =[NSString stringWithFormat:@"onScanApiInitialize SUCCESS result:%ld",result]; // [self addlog:strlog]; // //#ifdef USE_SOFTSCAN // // make sure we support SoftScan // [ScanApi postSetSoftScanStatus:kSktScanSoftScanSupported Target:self Response:@selector(onSetSoftScanStatus:)]; // // // check if SoftScan is enabled // [ScanApi postGetSoftScanStatus:self Response:@selector(onGetSoftScanStatus:)]; //#else // // disable support SoftScan (Default, not really needed if it was never activated) // [ScanApi postSetSoftScanStatus:kSktScanSoftScanNotSupported Target:self Response:@selector(onSetSoftScanStatus:)]; //#endif // // // ask for ScanAPI version (not a requirement but always nice to know) // [ScanApi postGetScanApiVersion:self Response:@selector(onGetScanApiVersion:)]; // // // configure ScanAPI for doing App Data confirmation, // // if TRUE then SingleEntry will confirm the decoded data // if(_doAppDataConfirmation==YES){ // [ScanApi postSetConfirmationMode:kSktScanDataConfirmationModeApp Target:self Response:@selector(onSetDataConfirmationMode:)]; // } // // _Status.text=@"Waiting for scanner..."; // } // else{ // _Status.text=[NSString stringWithFormat:@"Error initializing ScanAPI:%ld",result]; // NSString* strlog =[NSString stringWithFormat:@"Error initializing ScanAPI:%ld",result]; // [self addlog:strlog]; // } //} // ///** // * called when ScanAPI has been terminated. This will be // * the last message received from ScanAPI // */ //-(void) onScanApiTerminated{ // // [self addlog:@"onScanApiTerminated:"]; // // // [ScanApiConsumer invalidate]; // ScanApiConsumer= nil; // [self addlog:@"ScanApiConsumer invalidate"]; // // _Status.text = @"Off"; // //} // ///** // * called when an error occurs during the retrieval // * of a ScanObject from ScanAPI. // * @param result contains the retrieval error code // */ //-(void) onErrorRetrievingScanObject:(SKTRESULT) result{ // // [self addlog:@"onErrorRetrievingScanObject:"]; // [self addlog:[NSString stringWithFormat:@"Error retrieving ScanObject:%ld",result]]; // _Status.text=[NSString stringWithFormat:@"Error retrieving ScanObject:%ld",result]; //} // // #pragma mark - Support scanner -(void) OnUpdateDevicesList { [self.dev_table reloadData]; } -(void) onDecodedData:(NSString*) value { _Entry.text= value; } -(void) onErrorInfo:(NSString*) errorInfo { } -(void) onStatusChanged:(NSString*) status { UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; switch (appDelegate.api_Status) { case API_START: self.scan_switch.enabled = true; self.scan_switch.on = true; break; case API_INIT: self.scan_switch.enabled = false; break; case API_STOP: self.scan_switch.enabled = true; self.scan_switch.on=false; break; case API_CLOSING: self.scan_switch.enabled = false; break; default: break; } _Status.text = status; } -(void) onLogUpdate { UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; dispatch_async(dispatch_get_main_queue(), ^{ self.tv_info.text = appDelegate.log; [self.tv_info scrollRangeToVisible:NSMakeRange(appDelegate.log.length-1,0)]; }); } - (void)reRefreshView { [self.dev_table reloadData]; } @end