/// <summary> /// Sets a collection of decoder or symbology settings. The settings parameter /// contains a collection of key-value pairs where the key identifies the setting. /// <para>You may use <see cref="P:DevFromDownUnder.Honeywell.DataCollection.SettingKeys" /> to get the /// predefined setting keys. The setting value type may be any built-in C# types /// such as bool, int, string, etc. You may use <see cref="P:DevFromDownUnder.Honeywell.DataCollection.SettingValues" /> /// to get the predefined values for certain settings. Please reference the API /// documentation of the <see cref="T:DevFromDownUnder.Honeywell.DataCollection.BarcodeReaderSettingKeys" /> class for the /// expected setting value types.</para> /// <para>Note: This method may not return error result if the setting is not /// supported by the decoder or the setting value is not accepted by the decoder.</para> /// </summary> /// <param name="settings">A Dictionary object containing setting key-value pairs.</param> /// <returns>A <see cref="T:DevFromDownUnder.Honeywell.DataCollection.Result" /> object containing the success or /// failure result of the operation.</returns> /// <example> /// <code> /// using DevFromDownUnder.Honeywell.DataCollection.BarcodeReader; /// BarcodeReader mBarcodeReader = new BarcodeReader(); /// BarcodeReader.Result result = await mBarcodeReader.OpenAsync(); /// if (result.Code == BarcodeReader.Result.Codes.SUCCESS || /// result.Code == BarcodeReader.Result.Codes.READER_ALREADY_OPENED) /// { /// Dictionary<string, object> settings = new Dictionary<string, object>(); /// settings.Add(mBarcodeReader.SettingKeys.Code39Enabled, true); /// settings.Add(mBarcodeReader.SettingKeys.Code39CheckDigitMode, /// mBarcodeReader.SettingValues.Code39CheckDigitMode_NoCheck); /// result = await mBarcodeReader.SetAsync(settings); /// } /// </code> /// </example> /// <seealso cref="T:DevFromDownUnder.Honeywell.DataCollection.BarcodeReaderSettingKeys" /> /// <seealso cref="T:DevFromDownUnder.Honeywell.DataCollection.BarcodeReaderSettingValues" /> public override async Task <Result> SetAsync(Dictionary <string, object> settings) { Logger.Debug($"BarcodeReader {ID}", "SetAsync entry"); return(await Task.Run(() => { Result result = new Result(Result.Codes.SUCCESS, "Success"); lock (mProfileFixLock) { if (mReaderOpened) { try { var dictionary = new Dictionary <string, Java.Lang.Object>(); foreach (KeyValuePair <string, object> setting in settings) { try { dictionary.Add(setting.Key, ObjectTypeHelper.ConvertSettingValueToJavaObject(setting.Value)); } catch (ArgumentException ex) { result = new Result(Result.Codes.INVALID_PARAMETER, ex.Message); } } if (result.Code == Result.Codes.SUCCESS) { mAidcBarcodeReader.SetProperties(dictionary); //Needed for loadprofile rebind mLoadProfileRebindLastSetProperties = dictionary; result = new Result(Result.Codes.SUCCESS, "Set method completed."); } } catch (Java.Lang.Exception ex) { result = new Result(Result.Codes.EXCEPTION, ex.Message); } catch (Exception ex) { result = new Result(Result.Codes.EXCEPTION, ex.Message); } } else { result = new Result(Result.Codes.NO_ACTIVE_CONNECTION, "No active scanner connection."); } } return result; })); }
/// <summary> /// This call is needed if you are going to be using LoadProfileAsync with nested readers /// </summary> /// <returns>Success status and may result in closed readers if not SUCCESS</returns> public Task <Result> OnResumeAsync() { Logger.Debug($"BarcodeReader {ID}", "OnResume entry"); return(Task.Run(() => { Result result = new Result(Result.Codes.SUCCESS, "Success"); try { if (mLoadProfileRebindPending) { lock (mProfileFixLock) { //Fix the current reader //Don't need to check if we have an open reader as we made it only // subscribe and unsubscribe on open and close //Reset the reader as loadProfile is broken and kills readers result = ResetReader(); //Set the properties if we are using the same profile and scanner if (result?.Code == Result.Codes.SUCCESS) { if (mLoadProfileRebindProperties != null) { mAidcBarcodeReader?.SetProperties(mLoadProfileRebindProperties); } else if (mLoadProfileRebindLastSetProperties != null) { //Fallback to last non-profile properties mAidcBarcodeReader?.SetProperties(mLoadProfileRebindLastSetProperties); } } } } } catch (Java.Lang.Exception ex) { result = new Result(Result.Codes.EXCEPTION, ex.Message); } catch (Exception ex) { result = new Result(Result.Codes.EXCEPTION, ex.Message); } Logger.Debug($"BarcodeReader {ID}", "OnResume exit"); return result; })); }