| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845 |
- //
- // 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"
- #import "RAUtils.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 {
-
- [self dismissViewControllerAnimated:true completion:^{
- if(self.onDismissVC)
- self.onDismissVC();
- }];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- #ifdef RA_NOTIFICATION
- self.support_scanner = true;
- #endif
- // 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];
- }
-
- [RAUtils message_box:title message:nil completion:nil];
- }
- - (IBAction)onEmailClicked:(id)sender {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] 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* 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:@"<p>%@</p></br>%@",@"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];
- [self presentViewController:mc animated:YES completion:nil];
-
- 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];
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #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
- {
- dispatch_async(dispatch_get_main_queue(), ^{
- 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;
- }
- self.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
|