コード例 #1
0
ファイル: NordicMerlin.cs プロジェクト: TabVV/GeneralTerminal
        private void SetScanResultText(String message, String sAIMSI)
        {
            BCId
                bcID = BCId.Unknown;

            //if (base.BCInvoker.InvokeRequired)
            //{
            //    // we were called on a worker thread
            //    // marshal the call to the user interface thread
            //    base.BCInvoker.Invoke(new SetScanResultTextDelegate(SetScanResultText), new object[] { message });
            //    return;
            //}
            //this code can only be reached
            //by the user interface thread

            //this.Scan_Text.Text = message;


            if (message.Length > 0)
            {
                //if (message[message.Length - 1] == '\0')
                //    message = message.Remove(message.Length - 1, 1);

                if (dicAIMs.ContainsKey(sAIMSI))
                {
                    bcID = dicAIMs[sAIMSI];
                }
                else if (dicAIMs.ContainsKey(sAIMSI.Substring(0, 1)))
                {
                    bcID = dicAIMs[sAIMSI.Substring(0, 1)];
                }
            }

            OnBarcodeScan(new BarcodeScannerEventArgs(bcID, message));
        }
コード例 #2
0
 public BarcodeScannerEventArgs(BCId nBarcodeID, string s, byte[] bData, int nLen)
 {
     this.nBCId   = nBarcodeID;
     this.binData = bData;
     this.nBinLen = nLen;
     this.data    = s;
 }
コード例 #3
0
        // приведение типа штрихкода к своему стандарту
        // для терминалов Honeywell
        protected virtual BCId SetBarcodeType(string sT)
        {
            BCId ret = BCId.NoData;

            switch (sT)
            {
            case "d":
            case "D":
                ret = BCId.EAN13;
                break;

            case "e":
                ret = BCId.Interleaved25;
                break;

            case "I":
            case "j":
                ret = BCId.Code128;
                break;

            case "w":
                ret = BCId.DataMatrix;
                break;

            default:
                break;
            }
            return(ret);
        }
コード例 #4
0
        private void ScanMessage(object sender)
        {
            int
                nR,
                nMaxLen;          // Maximum length of a 1-D Barcode
            string
                sSymID,
                sBarCode = string.Empty;

            Scanner.CODE_ID
                scID;
            BCId
                nCodeID = BCId.NoData;
            BarcodeScannerEventArgs
                ba;

            try
            {
                //--- Was the Decode Attempt Successful? ---
                if (HX2Scan.GetStatus() == ManagedLXEAPI.Scanner.SCAN_COMPLETE)
                {
                    nMaxLen  = 128;
                    sBarCode = HX2Scan.GetData(ref nMaxLen);
                    //nR = HX2Scan.PutData(sBarCode, nMaxLen);
                    //scID = HX2Scan.GetCodeID();
                    if (nMaxLen > 1)
                    {
                        if (Char.IsLetter(sBarCode, 0))
                        {
                            sSymID   = sBarCode.Substring(0, 1);
                            sBarCode = sBarCode.Substring(1);
                            nCodeID  = SetBarcodeType(sSymID);
                        }
                        else
                        {
                            nCodeID = (nMaxLen > 13) ? BCId.Code128 : BCId.EAN13;
                        }

                        ba = new BarcodeScannerEventArgs(nCodeID, sBarCode);
                        OnBarcodeScan(ba);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return;
        }
コード例 #5
0
        void xEng_DecodeEvent(object sender, DecodeBase.DecodeEventArgs e)
        {
            BCId   nCodeID  = BCId.NoData;
            string sBarCode = string.Empty;
            BarcodeScannerEventArgs ba;

            // Obtain the string and code id.
            try
            {
                if ((e.DecodeResults.nLength > 0) && (e.DecodeResults.rResult == Result.RESULT_SUCCESS))
                {
                    //switch (e.DecodeResults.chCodeID)
                    //{
                    //    case "d":
                    //    case "D":
                    //        nCodeID = BCId.EAN13;
                    //        break;
                    //    case "e":
                    //        nCodeID = BCId.Interleaved25;
                    //        break;
                    //    case "I":
                    //    case "j":
                    //        nCodeID = BCId.Code128;
                    //        break;
                    //    case "w":
                    //        nCodeID = BCId.DataMatrix;
                    //        break;
                    //    default:
                    //        break;
                    //}
                    nCodeID  = SetBarcodeType(e.DecodeResults.chCodeID);
                    sBarCode = e.DecodeResults.pchMessage;
                }
            }
            catch (Exception)
            {
                //MessageBox.Show("Error reading string!");
            }

            ba = new BarcodeScannerEventArgs(nCodeID, e.DecodeResults.pchMessage, e.DecodeResults.binaryData,
                                             e.DecodeResults.nLength);

            OnBarcodeScan(ba);
            return;
        }
コード例 #6
0
        protected override BCId SetBarcodeType(string sT)
        {
            BCId ret = BCId.NoData;

            switch (sT)
            {
            case "A":
                ret = BCId.EAN13;
                break;

            case "B":
                ret = BCId.Code39;
                break;

            case "C":
                ret = BCId.Codabar;
                break;

            case "D":
            case "K":
                ret = BCId.Code128;
                break;

            case "E":
                ret = BCId.Code93;
                break;

            case "F":
                ret = BCId.Interleaved25;
                break;

            default:
                break;
            }
            return(ret);
        }
コード例 #7
0
        void xEng_DecodeEvent(object sender, DecodeBase.DecodeEventArgs e)
        {
            BCId   nCodeID  = BCId.NoData;
            string sBarCode = string.Empty;
            BarcodeScannerEventArgs ba;

            try
            {
                //RightLEDOff();
                //--- Was the Decode Attempt Successful? ---
                if (e.DecodeResults.rResult == Result.RESULT_SUCCESS)
                {
                    //xEng.Device.SetLEDs(Device.LedSelect.RightGreen, Device.LedState.On, 0, 0);

                    //sBarCode = e.DecodeResults.chCodeID;
                    //switch (sBarCode)
                    //{
                    //    case "d":
                    //    case "D":
                    //        nCodeID = BCId.EAN13;
                    //        break;
                    //    case "j":
                    //        nCodeID = BCId.Code128;
                    //        break;
                    //    case "w":
                    //        nCodeID = BCId.DataMatrix;
                    //        break;
                    //    default:
                    //        break;
                    //}

                    nCodeID  = base.SetBarcodeType(e.DecodeResults.chCodeID);
                    sBarCode = e.DecodeResults.pchMessage;

                    //--- Play an SDK Provided Audible Sound ---
                    //xEng.so..Sound.Play(Sound.SoundTypes.Success);
                    ba = new BarcodeScannerEventArgs(nCodeID, sBarCode, e.DecodeResults.binaryData, e.DecodeResults.binaryData.Length);
                    OnBarcodeScan(ba);
                }
                else
                {
                    //--- Async Decode Exception ---
                    switch (e.DecodeResults.rResult)
                    {
                    case Result.RESULT_ERR_CANCEL:                    // Async Decode was Canceled
                        return;

                    case Result.RESULT_ERR_NODECODE:                  // Scan Timeout
                        //MessageBox.Show("Scan Timeout Exceeded");
                        break;

                    default:
                        //MessageBox.Show(e.DecodeException.Message);
                        break;
                    }

                    //if (e.DecodeResults.rResult..DecodeException != null)
                    //{



                    //}
                    //else
                    //{
                    //    //--- Generic Async Exception ---
                    //    //MessageBox.Show(e.Exception.Message);
                    //}
                    //xEng.Sound.Play(Sound.SoundTypes.Failure);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }

            return;
        }
コード例 #8
0
        //private void dcdEvent_Scanned_X4(object sender, DecodeEventArgs e)
        //{
        //    CodeId cID = CodeId.NoData;
        //    string dcdData = string.Empty;
        //    byte[]
        //        byteData;
        //    BCId nCodeID  = BCId.NoData;

        //    // Obtain the string and code id.
        //    try
        //    {
        //        dcdData = hDcd.ReadString(e.RequestID, ref cID);
        //    }
        //    catch (Exception)
        //    {
        //        MessageBox.Show("Error reading string!");
        //        return;
        //    }

        //        switch (cID)
        //        {
        //            case CodeId.EAN13:
        //            case CodeId.EAN8:
        //                nCodeID = BCId.EAN13;
        //                break;
        //            case CodeId.Code128:
        //                nCodeID = BCId.Code128;
        //                break;
        //            case CodeId.Interleaved25:
        //                nCodeID = BCId.Interleaved25;
        //                break;
        //            case CodeId.Code39:
        //                nCodeID = BCId.Code39;
        //                break;
        //            case CodeId.GS1Expanded:
        //                nCodeID = BCId.GS1DataBar;
        //                break;
        //            default:
        //                nCodeID = BCId.Unknown;
        //                break;
        //        }

        //    // убрать форматирование для AtlasWMS
        //    int nL = dcdData.Length;
        //            byteData = System.Text.Encoding.UTF8.GetBytes(dcdData);
        //    if (byteData.Length >= 5)
        //    {
        //        if ((byteData[0] == '\x2') &&                       // STX
        //            (byteData[byteData.Length - 1] == '\x3') &&     // ETX
        //            (byteData[1] == ']'))                           // AIM
        //        {
        //            dcdData = dcdData.Substring(4, nL - 5);
        //            dcdData = dcdData.Replace('$', '\x1D');       // $ -> FNC1
        //            byteData = System.Text.Encoding.UTF8.GetBytes(dcdData);
        //        }
        //    }
        //    OnBarcodeScan(new BarcodeScannerEventArgs(nCodeID, dcdData, byteData, byteData.Length));
        //}



        /// <summary>
        /// Event that fires when a PSC scanner has performed a scan.
        /// </summary>
        private void dcdEvent_Scanned(ScannerEngine sender)
        {
            BCId   nCodeID  = BCId.NoData;
            string sBarCode = string.Empty;

            byte[] byteData = sender.BarcodeDataAsByteArray;

            // Obtain the string and code id.
            try
            {
                sBarCode = sender.BarcodeDataAsText;
                baDat    = sender.BarcodeDataAsByteArray;
                string sAIM = sender.BarcodeTypeAsAIMIdentifier;

                BARCODE_Identifier bi = sender.BarcodeTypeAsIdentifier;
                switch (bi)
                {
                case BARCODE_Identifier.BARCODE_ID_EAN_13:
                case BARCODE_Identifier.BARCODE_ID_EAN_13_ADDON_2:
                case BARCODE_Identifier.BARCODE_ID_EAN_13_ADDON_5:
                    nCodeID = BCId.EAN13;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_128_STANDARD:
                    nCodeID = BCId.Code128;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_EAN_128:
                    nCodeID = BCId.Code128;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_ISBT_128:
                    nCodeID = BCId.Code128;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_ISBT_128_CON:
                    nCodeID = BCId.Code128;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_25_INTERLEAVED:
                    nCodeID = BCId.Interleaved25;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_25_MATRIX:
                    nCodeID = BCId.Matrix25;
                    break;

                case BARCODE_Identifier.BARCODE_ID_CODE_39_STANDARD:
                    nCodeID = BCId.Code39;
                    break;

                case (BARCODE_Identifier)8804:
                    nCodeID = BCId.GS1DataBar;
                    break;

                default:
                    nCodeID = BCId.Unknown;
                    break;
                }
            }
            catch (Exception)
            {
                //MessageBox.Show("Error reading string!");
            }

            //OnBarcodeScan(new BarcodeScannerEventArgs( nCodeID, sBarCode ));

            // убрать форматирование для AtlasWMS
            int nL = sBarCode.Length;

            if (byteData.Length >= 5)
            {
                if ((byteData[0] == '\x2') &&                       // STX
                    (byteData[byteData.Length - 1] == '\x3') &&     // ETX
                    (byteData[1] == ']'))                           // AIM
                {
                    sBarCode = sBarCode.Substring(4, nL - 5);
                    sBarCode = sBarCode.Replace('$', '\x1D');       // $ -> FNC1
                    byteData = System.Text.Encoding.UTF8.GetBytes(sBarCode);
                }
            }

            OnBarcodeScan(new BarcodeScannerEventArgs(nCodeID, sBarCode, byteData, byteData.Length));
            return;
        }
コード例 #9
0
        /// <summary>
        /// Event that fires when a Symbol scanner has performed a scan.
        /// </summary>
        private void symbolReader_ReadNotify(object sender,EventArgs e)
        {
            ReaderData readerData = symbolReader.GetNextReaderData();

            // If it is a successful scan (as opposed to a failed one)
            if (readerData.Result == Results.SUCCESS)
            {
                BCId nType = BCId.NoData;

                // Преобразовать Symbol-тип штрихкода к моему
                switch (readerData.Type)
                {
                case DecoderTypes.EAN128:
                case DecoderTypes.CODE128:
                    nType = BCId.Code128;
                    break;

                case DecoderTypes.EAN13:
                    nType = BCId.EAN13;
                    break;

                case DecoderTypes.EAN8:
                    nType = BCId.EAN8;
                    break;

                case DecoderTypes.I2OF5:
                case DecoderTypes.D2OF5:
                case DecoderTypes.IATA2OF5:
                case DecoderTypes.CHINESE_2OF5:
                    nType = BCId.Interleaved25;
                    break;

                case DecoderTypes.IMAGE:
                    nType = BCId.Image;
                    break;

                case DecoderTypes.CODE11:
                    nType = BCId.Code11;
                    break;

                case DecoderTypes.CODE39:
                    nType = BCId.Code39;
                    break;

                case DecoderTypes.RSS14:
                case DecoderTypes.RSSEXP:
                case DecoderTypes.RSSLIM:
                    nType = BCId.GS1DataBar;
                    break;

                default:
                    nType = BCId.Unknown;
                    break;
                }

                // Raise scan event to caller (with data)
                BarcodeScannerEventArgs xBCA = new BarcodeScannerEventArgs(nType,readerData.Text);
                OnBarcodeScan(xBCA);

                // Start the next scan
                Start();
            }
        }
コード例 #10
0
        void xEng_DecodeEvent(object sender, DecodeAssembly.DecodeEventArgs e)
        {
            BCId   nCodeID  = BCId.NoData;
            string sBarCode = string.Empty;
            BarcodeScannerEventArgs ba;

            try
            {
                RightLEDOff();
                //--- Was the Decode Attempt Successful? ---
                if (e.ResultCode == DecodeAssembly.ResultCodes.Success)
                {
                    xEng.Device.SetLEDs(Device.LedSelect.RightGreen, Device.LedState.On, 0, 0);
                    //sBarCode = e.CodeId;
                    //switch (sBarCode)
                    //{
                    //    case "d":
                    //    case "D":
                    //        nCodeID = BCId.EAN13;
                    //        break;
                    //    case "j":
                    //        nCodeID = BCId.Code128;
                    //        break;
                    //    case "w":
                    //        nCodeID = BCId.DataMatrix;
                    //        break;
                    //    default:
                    //        break;
                    //}
                    nCodeID  = base.SetBarcodeType(e.CodeId);
                    sBarCode = e.Message;

                    //--- Play an SDK Provided Audible Sound ---
                    xEng.Sound.Play(Sound.SoundTypes.Success);
                }
                else
                {
                    if (e.DecodeException != null)
                    {
                        //--- Async Decode Exception ---
                        switch (e.DecodeException.ResultCode)
                        {
                        case DecodeAssembly.ResultCodes.Cancel:                // Async Decode was Canceled
                            return;

                        case DecodeAssembly.ResultCodes.NoDecode:              // Scan Timeout
                            //MessageBox.Show("Scan Timeout Exceeded");
                            break;

                        default:
                            //MessageBox.Show(e.DecodeException.Message);
                            break;
                        }
                    }
                    else
                    {
                        //--- Generic Async Exception ---
                        //MessageBox.Show(e.Exception.Message);
                    }
                    //xEng.Sound.Play(Sound.SoundTypes.Failure);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }

            ba = new BarcodeScannerEventArgs(nCodeID, sBarCode, e.RawData, e.Length);
            OnBarcodeScan(ba);
            return;
        }
コード例 #11
0
 public BarcodeScannerEventArgs(BCId nBarcodeID, string data) : this(nBarcodeID, data, null, 0)
 {
 }