private void scanner_Status(object sender, Scanner.StatusEventArgs e)
        {
            StatusData statusData = e.P0;

            StatusData.ScannerStates state = e.P0.State;
            new AsyncStatusUpdate().Execute(state.ToString());

            /*if (state == StatusData.ScannerStates.Idle)
             * {
             *  statusString = "Status: " + statusData.FriendlyName + " is enabled and idle...";
             *  RunOnUiThread(() => textViewStatus.Text = statusString);
             *
             *
             *  if (state == StatusData.ScannerStates.Waiting)
             *  {
             *      statusString = "Status: Scanner is waiting for trigger press...";
             *      RunOnUiThread(() =>
             *      {
             *          textViewStatus.Text = statusString;
             *      });
             *  }
             *
             *  if (state == StatusData.ScannerStates.Scanning)
             *  {
             *      statusString = "Status: Scanning...";
             *      RunOnUiThread(() =>
             *      {
             *          textViewStatus.Text = statusString;
             *
             *      });
             *  }
             *
             *  if (state == StatusData.ScannerStates.Disabled)
             *  {
             *      statusString = "Status: " + statusData.FriendlyName + " is disabled.";
             *      RunOnUiThread(() =>
             *      {
             *          textViewStatus.Text = statusString;
             *
             *      });
             *  }
             *
             *  if (state == StatusData.ScannerStates.Error)
             *  {
             *      statusString = "Status: An error has occurred.";
             *      RunOnUiThread(() =>
             *      {
             *          textViewStatus.Text = statusString;
             *
             *      });
             *  }
             *
             * }*/
        }
Exemplo n.º 2
0
 private void OnStatusChanged(object sender, Scanner.StatusEventArgs args)
 {
     StatusData.ScannerStates state = args?.P0?.State;
     if (state == StatusData.ScannerStates.Idle)
     {
         //Task.Delay(100);
         SetScannerConfig();
         _scanner.Read();
     }
     else if (state == StatusData.ScannerStates.Scanning)
     {
     }
 }
Exemplo n.º 3
0
        private void StatusChanged(object sender, Scanner.StatusEventArgs e)
        {
            string status = String.Empty;

            StatusData.ScannerStates state = e.P0.State;

            if (state == StatusData.ScannerStates.Idle)
            {
                OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"Gotowy."));

                try
                {
                    if (m_Scanner.IsEnabled && !m_Scanner.IsReadPending)
                    {
                        if (ConfigChange)
                        {
                            SetConfig();
                            ConfigChange = false;
                        }

                        m_Scanner.Read();
                    }
                }
                catch (ScannerException ex)
                {
                    status = ex.Message;
                    OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"{status}"));
                }
            }

            if (state == StatusData.ScannerStates.Waiting)
            {
                status = "Oczekiwanie..";
                OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"{status}"));
            }
            if (state == StatusData.ScannerStates.Scanning)
            {
                status = "Skanowanie...";
                OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"{status}"));
            }
            if (state == StatusData.ScannerStates.Disabled)
            {
                status = "Scanner disabled";
                OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"{status}"));
            }
            if (state == StatusData.ScannerStates.Error)
            {
                status = "Error occurred during scanning";
                OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"{status}"));
            }
        }
Exemplo n.º 4
0
 void _scanner_Status(object sender, Scanner.StatusEventArgs e)
 {
     StatusData.ScannerStates state = e.P0.State;
     if (state == StatusData.ScannerStates.Idle)
     {
         try
         {
             if (_scanner.IsEnabled && !_scanner.IsReadPending)
             {
                 _scanner.Read();
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Exemplo n.º 5
0
        void scanner_Status(object sender, Scanner.StatusEventArgs e)
        {
            String statusStr = "";

            //EMDK: The status will be returned on multiple cases. Check the state and take the action.
            StatusData.ScannerStates state = e.P0.State;

            if (state == StatusData.ScannerStates.Idle)
            {
                statusStr = "Scanner is idle and ready to submit read.";
                try
                {
                    if (scanner.IsEnabled && !scanner.IsReadPending)
                    {
                        scanner.Read();
                    }
                }
                catch (ScannerException e1)
                {
                    statusStr = e1.Message;
                }
            }
            if (state == StatusData.ScannerStates.Waiting)
            {
                statusStr = "Waiting for Trigger Press to scan";
            }
            if (state == StatusData.ScannerStates.Scanning)
            {
                statusStr = "Scanning in progress...";
            }
            if (state == StatusData.ScannerStates.Disabled)
            {
                statusStr = "Scanner disabled";
            }
            if (state == StatusData.ScannerStates.Error)
            {
                statusStr = "Error occurred during scanning";
            }
            displayStatus(statusStr);
        }
        private void Scanner_Status(object sender, Scanner.StatusEventArgs e)
        {
            StatusData statusData = e.P0;

            StatusData.ScannerStates state = e.P0.State;

            if (state == StatusData.ScannerStates.Idle)
            {
                var statusString = "Status: " + statusData.FriendlyName + " is enabled and idle...";
                //RunOnUiThread(() => textViewStatus.Text = statusString);

                if (true)
                {
                    try
                    {
                        // An attempt to use the scanner continuously and rapidly (with a delay < 100 ms between scans)
                        // may cause the scanner to pause momentarily before resuming the scanning.
                        // Hence add some delay (>= 100ms) before submitting the next read.
                        try
                        {
                            Thread.Sleep(1000);
                        }
                        catch (System.Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        // Submit another read to keep the continuation
                        scanner.Read();
                    }
                    catch (ScannerException ex)
                    {
                        statusString = "Status: " + ex.Message;
                        //RunOnUiThread(() => textViewStatus.Text = statusString);
                        Console.WriteLine(ex.StackTrace);
                    }
                    catch (NullReferenceException ex)
                    {
                        statusString = "Status: An error has occurred.";
                        //RunOnUiThread(() => textViewStatus.Text = statusString);
                        Console.WriteLine(ex.StackTrace);
                    }
                }
            }

            if (state == StatusData.ScannerStates.Waiting)
            {
                Console.WriteLine("Status: Scanner is waiting for trigger press...");
            }

            if (state == StatusData.ScannerStates.Scanning)
            {
                Console.WriteLine("Status: Scanning...");
            }

            if (state == StatusData.ScannerStates.Disabled)
            {
                Console.WriteLine("Status: " + statusData.FriendlyName + " is disabled.");
            }

            if (state == StatusData.ScannerStates.Error)
            {
                Console.WriteLine("Status: An error has occurred.");
            }
        }