Example #1
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException"></exception>
        public void Load()
        {
            if (this.deviceType != DeviceTypes.OPOS)
            {
                return;
            }

            NetTracer.Information("Peripheral [Scanner] - OPOS device loading: {0}", this.DeviceName ?? "<Undefined>");

            oposScanner = new OPOSScannerClass();

            // Open
            oposScanner.Open(this.DeviceName);
            Peripherals.CheckResultCode(this, oposScanner.ResultCode);

            // Claim
            oposScanner.ClaimDevice(Peripherals.ClaimTimeOut);
            Peripherals.CheckResultCode(this, oposScanner.ResultCode);

            // Enable/Configure
            oposScanner.DataEvent       += new _IOPOSScannerEvents_DataEventEventHandler(posScanner_DataEvent);
            oposScanner.DeviceEnabled    = true;
            oposScanner.AutoDisable      = true;
            oposScanner.DecodeData       = true;
            oposScanner.DataEventEnabled = true;

            IsActive = true;
        }
Example #2
0
        public _BarcScan(Form1 _F1)
        {
            F1 = _F1;
            try
            {
                this.Scanner             = new OPOSScannerClass();
                this.Scanner.ErrorEvent += new _IOPOSScannerEvents_ErrorEventEventHandler(Scanner_ErrorEvent);
                this.Scanner.DataEvent  += new _IOPOSScannerEvents_DataEventEventHandler(Scanner_DataEvent);
                this.Scanner.Open("STI_SCANNER");
                //MessageBox.Show("1");
                ResultCodeH.Check(this.Scanner.ClaimDevice(7000));
                //MessageBox.Show("2");
                this.Scanner.DeviceEnabled = true;
                ResultCodeH.Check(this.Scanner.ResultCode);
                //MessageBox.Show("3");
                this.Scanner.AutoDisable = true;

                ResultCodeH.Check(this.Scanner.ResultCode);
                //MessageBox.Show("4");
                this.Scanner.DataEventEnabled = true;
                ResultCodeH.Check(this.Scanner.ResultCode);
                //MessageBox.Show("5");
            }
            catch (Exception _e)
            {
                MessageBox.Show(_e.Message.ToString());
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            // setup the console program to exit gracefully
            var exitEvent = new ManualResetEvent(false);

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                exitEvent.Set();
            };

            // create a scanner object
            scanner = new OPOSScannerClass();

            // subscribe to the delegate
            scanner.DataEvent += DataEvent;

            // attempt to open, claim, and enable a scanner
            // these functions are defined by OPOS
            scanner.Open(name);
            scanner.ClaimDevice(1000);
            if (scanner.Claimed)
            {
                Console.WriteLine("Connected to: " + name + " in C#");
                scanner.DeviceEnabled    = true;
                scanner.DataEventEnabled = true;
                scanner.DecodeData       = true;
            }
            else
            {
                scanner.Close();
                scanner.DataEvent -= DataEvent;
                return;
            }

            // wait for exit event
            Console.WriteLine("Press \'Ctrl + C\' to quit.");
            exitEvent.WaitOne();

            // unsubscribe to the delegate
            scanner.DataEvent -= DataEvent;

            // disable operation, release control, and close the scanner
            scanner.DataEventEnabled = false;
            scanner.ReleaseDevice();
            scanner.Close();
        }