Esempio n. 1
0
        // PnpEventArgs: there is no way of telling which scanner attached / detached
        private static void OnScannerAttached(object sender, PnpEventArgs e)
        {
            log.Debug("Scanner attached");
            Console.WriteLine("Scanner attached");

            // if cradle detaches, when it reattaches this event handler gets called once for cradle, once for scanner.
            // only want to configure one time.
            // this needs to be handled for more scanners. Can set 10 second timer to delete oldScanners
            if (BarcodeScannerManager.Instance.GetDevices().Count > 1)
            {
                oldScannerInfo = scannerInfo;
                // every time scanner is attached, reconfigure all scanners, because there is no guarantee that scanner that has
                // previously detached has the same id when it reattaches, and we don't have the id of the scanner that has attached.
                ConfigureScanners();
            }
        }
Esempio n. 2
0
        //set behaviour of scanners
        public static void ConfigureScanners()
        {
            //int asciiPrefix = 0x61;

            // no way to tell which scanner disconnects so reset everything whenever any scanner disconnects
            //prefixes = new Dictionary<int, int>();
            //scanners = new Dictionary<int, ScannerInfo>();

            List <IMotorolaBarcodeScanner> deviceList = BarcodeScannerManager.Instance.GetDevices();

            // Ensure scanners are attached
            if (deviceList.Count == 0)
            {
                log.Error("No scanners are attached.");
                Console.WriteLine("No scanners are attached.");
                return;
            }
            // want: multipoint-point, low volume, beep / flash green on good decode, mode IBMHID, assign prefix
            foreach (var scanner in deviceList)
            {
                // if cradle
                if (scanner.Info.ModelNumber == "CR0078-SC10007WR")
                {
                    scanner.SetHostMode(HostMode.USB_IBMHID);

                    // Set cradle to multipoint-to-point mode, so that up to 3 scanners can be linked to it.
//scanner.Actions.StoreIBMAttribute(538, DataType.Bool, true);

                    log.Debug("Setting hostmode=USB_IBMHID for scanner serial=" + scanner.Info.SerialNumber);
                    Console.WriteLine("Setting hostmode=USB_IBMHID for scanner serial=" + scanner.Info.SerialNumber);
                }
                // if scanner
                else
                {
                    // Set beeper volume low
                    scanner.Actions.StoreIBMAttribute(140, DataType.Byte, BeeperVolume.Low);
                    // Set beeper tone medium
                    scanner.Actions.StoreIBMAttribute(145, DataType.Byte, 2);

                    // Set beep on BarcodeScanEvent - LED also flashes green (unable to change)
                    scanner.Actions.StoreIBMAttribute(56, DataType.Bool, true);
                    // Disable laser flashing on BarcodeScanEvent
                    scanner.Actions.StoreIBMAttribute(859, DataType.Byte, 0);

                    //	Enable barcode prefix
                    //scanner.Actions.StoreIBMAttribute(235, DataType.Byte, 4);
                    //	scanner.Actions.StoreIBMAttribute(99, DataType.Array, 1);
                    //	assign letter prefix for identification

                    //   scanner.Actions.StoreIBMAttribute(105, DataType.Array, asciiPrefix);

                    //prefixes.Add(asciiPrefix, scanner.Info.ScannerId);

                    scannerInfo = new ScannerInfo
                    {
                        scanner = scanner,
                        //prefix = asciiPrefix,
                        timer    = null,
                        prevScan = null
                    };
                    // restore saved information for matching scanner
                    if (oldScannerInfo != null)
                    {
                        Console.WriteLine("old scanner detected");
                        scannerInfo.timer    = oldScannerInfo.timer;
                        scannerInfo.prevScan = oldScannerInfo.prevScan;
                    }
                    log.Debug("Setting default program attributes for scanner serial=" + scanner.Info.SerialNumber);
                    //log.Debug("Setting prefix=" + asciiPrefix + " for scanner serial=" + scanner.Info.SerialNumber);
                    Console.WriteLine("Setting default program attributes for scanner serial=" + scanner.Info.SerialNumber);
                    //Console.WriteLine("Setting prefix=" + asciiPrefix + " for scanner serial=" + scanner.Info.SerialNumber);
                    //asciiPrefix++;
                }
            }
            // assumes that only 1 scanner disconnected.
            oldScannerInfo = null;
        }