/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { this.oposBarcodeScanner = new OPOSScanner(); // Open this.oposBarcodeScanner.Open(peripheralName); OposHelper.CheckResultCode(this, this.oposBarcodeScanner.ResultCode); // Claim this.oposBarcodeScanner.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposBarcodeScanner.ResultCode); // Enable/Configure this.oposBarcodeScanner.DeviceEnabled = true; // Plug in handlers for data eevents this.oposBarcodeScanner.DataEvent += this.OnBarcodeScannerDataEvent; this.oposBarcodeScanner.ErrorEvent += this.OnBarcodeScannerErrorEvent; // Set autodisable to false this.oposBarcodeScanner.AutoDisable = false; // Enable data events this.oposBarcodeScanner.DataEventEnabled = true; }
/// <summary> /// Closes a connection with Barcode Scanner. /// </summary> public void Close() { if (this.oposBarcodeScanner != null) { this.oposBarcodeScanner.DataEvent -= this.OnBarcodeScannerDataEvent; this.oposBarcodeScanner.ErrorEvent -= this.OnBarcodeScannerErrorEvent; this.oposBarcodeScanner.ReleaseDevice(); this.oposBarcodeScanner.Close(); this.oposBarcodeScanner = null; } this.scannedBarcodesBufferBlock = null; }