示例#1
0
        /// <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&lt;string, object&gt; settings = new Dictionary&lt;string, object&gt;();
        ///     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;
            }));
        }
示例#2
0
        protected Dictionary <string, object> GetDefaultProperties(Com.Honeywell.Aidc.BarcodeReader reader)
        {
            var result = new Dictionary <string, object>();

            foreach (var pair in reader.AllDefaultProperties)
            {
                result.Add(pair.Key, ObjectTypeHelper.ConvertJavaObjectToSettingValue(pair.Value));
            }

            return(result);
        }