public static void CheckBarcodeReaderStatus(IPort port)
        {
            // Create IPeripheralConnectParser object.
            IPeripheralConnectParser parser = StarIoExt.CreateBcrConnectParser(BcrModel.POP1);

            // Usage of parser sample is "Communication.ParseDoNotCheckCondition(IPeripheralCommandParser parser, IPort port)".
            CommunicationResult result = Communication.ParseDoNotCheckCondition(parser, port);

            // Check peripheral status.
            barcodeReaderStatus = PeripheralStatus.Invalid;
            if (result.Result == Result.Success)
            {
                // Check parser property value.
                if (parser.IsConnected) // connect
                {
                    barcodeReaderStatus = PeripheralStatus.Connect;
                }
                else // disconnect
                {
                    barcodeReaderStatus = PeripheralStatus.Disconnect;
                }
            }
            else // communication error
            {
                barcodeReaderStatus = PeripheralStatus.Impossible;
            }

            //switch (barcodeReaderStatus)
            //{
            //    default:
            //    case PeripheralStatus.Impossible:
            //        OnBarcodeReaderImpossible();
            //        break;

            //    case PeripheralStatus.Connect:
            //        OnBarcodeReaderConnect();
            //        break;

            //    case PeripheralStatus.Disconnect:
            //        OnBarcodeReaderDisconnect();
            //        break;
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// Sample : Checking barcode reader status.
        /// </summary>
        private void CheckBarcodeReaderStatus()
        {
            // Create IPeripheralConnectParser object.
            IPeripheralConnectParser parser = StarIoExt.CreateBcrConnectParser(BcrModel.POP1);

            // Usage of parser sample is "Communication.ParseDoNotCheckCondition(IPeripheralCommandParser parser, IPort port)".
            Communication.CommunicationResult result = Communication.ParseDoNotCheckCondition(parser, port);

            // Check peripheral status.
            currentBarcodeReaderStatus = Communication.PeripheralStatus.Invalid;
            if (result == Communication.CommunicationResult.Success)
            {
                // Check parser property value.
                if (parser.IsConnected) // connect
                {
                    currentBarcodeReaderStatus = Communication.PeripheralStatus.Connect;
                }
                else // disconnect
                {
                    currentBarcodeReaderStatus = Communication.PeripheralStatus.Disconnect;
                }
            }
            else // communication error
            {
                currentBarcodeReaderStatus = Communication.PeripheralStatus.Impossible;
            }

            switch (currentBarcodeReaderStatus)
            {
            default:
            case Communication.PeripheralStatus.Impossible:
                OnPrinterImpossible();
                break;

            case Communication.PeripheralStatus.Connect:
                OnBarcodeReaderConnect();
                break;

            case Communication.PeripheralStatus.Disconnect:
                OnBarcodeReaderDisconnect();
                break;
            }
        }
        public static string MonitoringBarcodeReader(IPort port)
        {
            var result = string.Empty;

            // Create IPeripheralConnectParser object.
            IPeripheralConnectParser parser = StarIoExt.CreateBcrConnectParser(BcrModel.POP1);

            // Usage of parser sample is "Communication.ParseDoNotCheckCondition(IPeripheralCommandParser parser, IPort port)".
            CommunicationResult comResult = Communication.ParseDoNotCheckCondition(parser, port);

            CheckBarcodeReaderStatus(port);

            //Console.WriteLine(barcodeReaderStatus);

            if (barcodeReaderStatus == PeripheralStatus.Connect) // Barcode reader is connected.
            {
                result = ReadBarcodeReaderData(port);            // Read barcode reader data.
            }
            return(result);
        }