/// <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) { if (this.oposPinpad == null) { this.oposPinpad = new OPOSPINPadClass(); this.oposPinpad.DataEvent += this.OnPinPadDataEvent; // _IOPOSPINPadEvents_DataEventEventHandler this.oposPinpad.ErrorEvent += this.OnPinPadErrorEvent; // _IOPOSPINPadEvents_ErrorEventEventHandler try { // Open Task.Run(() => this.oposPinpad.Open(peripheralName)).Wait(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposPinpad.ResultCode); // Claim this.oposPinpad.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposPinpad.ResultCode); } catch { this.Close(); throw; } } }
/// <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> /// 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) { if (this.oposSigCap == null) { this.oposSigCap = new OPOSSigCap(); this.oposSigCap.DataEvent += this.OnSigCapDataEvent; this.oposSigCap.ErrorEvent += this.OnSigCapErrorEvent; try { // Open Task.Run(() => this.oposSigCap.Open(peripheralName)).Wait(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposSigCap.ResultCode); // Claim this.oposSigCap.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposSigCap.ResultCode); // Configure this.CapUserTerminated = this.oposSigCap.CapUserTerminated; this.MaximumX = this.oposSigCap.MaximumY; this.MaximumY = this.oposSigCap.MaximumY; } catch { this.Close(); throw; } } // NOTE: Hardware station does not support "ReatlTimeDataEnabled" property. }
/// <summary> /// Opens a rambler device. /// </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.StartReader(); lock (SyncLock) { this.isCardReaderEnabled = true; } }
/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="peripheralConfig">The peripheral configuration.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { this.CashDispenserName = peripheralName; // Open the cash dispenser. NetTracer.Information("Cash dispenser is opened for device '{0}'.", peripheralName); return; }
/// <summary> /// Establishes a connection to the specified cash drawer. /// </summary> /// <param name="peripheralName">Name of cash drawer device to open.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { this.oposCashDrawer = new OPOSCashDrawer(); // Open this.oposCashDrawer.Open(peripheralName); OposHelper.CheckResultCode(this, this.oposCashDrawer.ResultCode); // Claim this.oposCashDrawer.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposCashDrawer.ResultCode); // Enable this.oposCashDrawer.DeviceEnabled = true; OposHelper.CheckResultCode(this, this.oposCashDrawer.ResultCode); }
/// <summary> /// Establishes a connection to the specified scale. /// </summary> /// <param name="peripheralName">Name of scale device to open.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { this.oposScale = new OPOSScale(); // Open this.oposScale.Open(peripheralName); OposHelper.CheckResultCode(this, this.oposScale.ResultCode); // Claim this.oposScale.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposScale.ResultCode); // Enable/Configure this.oposScale.DeviceEnabled = true; this.oposScale.PowerNotify = (int)OPOS_Constants.OPOS_PN_ENABLED; }
/// <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.oposMsr = new OPOSMSR(); // Open this.oposMsr.Open(peripheralName); OposHelper.CheckResultCode(this, this.oposMsr.ResultCode); // Claim this.oposMsr.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposMsr.ResultCode); // Enable/Configure this.oposMsr.DeviceEnabled = true; // Set the decode data - so that the device decodes the scanned data this.oposMsr.DecodeData = true; // Note: there are two properties that look similar // ParseDecodedData and ParseDecodeData // Both do the same as per the OPOS spec. // Setting this property makes the device return data // in individual fields. this.oposMsr.ParseDecodedData = true; // Set Transmit Sentinels to true // so that when the data is sent, we can get the sentenels // and can parse the data of the tracks. this.oposMsr.TransmitSentinels = true; // Plug in handlers for data eevents this.oposMsr.DataEvent += this.OnMsrDataEvent; this.oposMsr.ErrorEvent += this.OnMsrErrorEvent; // Set autodisable to false this.oposMsr.AutoDisable = false; // Enable data events this.oposMsr.DataEventEnabled = true; }
/// <summary> /// Establishes a connection to the specified cash drawer. /// </summary> /// <param name="peripheralName">Name of cash drawer device to open.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { ThrowIf.NullOrWhiteSpace(peripheralName, "peripheralName"); ThrowIf.Null(peripheralConfig, "peripheralConfig"); ThrowIf.Null(peripheralConfig.ExtensionProperties, "peripheralConfig.ExtensionProperties"); IDictionary <string, object> configurations = peripheralConfig.ExtensionProperties.ToObjectDictionary(); string ip = configurations[PeripheralConfigKey.IpAddress] as string; int? port = configurations[PeripheralConfigKey.Port] as int?; if (string.IsNullOrWhiteSpace(ip)) { throw new ArgumentException(string.Format("Peripheral configuration parameter is missing: {0}.", PeripheralConfigKey.IpAddress)); } if (port == null) { throw new ArgumentException(string.Format("Peripheral configuration parameter is missing: {0}.", PeripheralConfigKey.Port)); } this.tcpClient = new TcpClient(); this.tcpClient.Connect(ip, (int)port); }
/// <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.Open(peripheralName, 0, false, peripheralConfig); }
/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="characterSet">The character set.</param> /// <param name="binaryConversion">If set to <c>true</c> [binary conversion].</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, int characterSet, bool binaryConversion, PeripheralConfiguration peripheralConfig) { this.oposPrinter = new OPOSPOSPrinter(); // Open this.oposPrinter.Open(peripheralName); OposHelper.CheckResultCode(this, this.oposPrinter.ResultCode); // Claim this.oposPrinter.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, this.oposPrinter.ResultCode); // Enable/Configure this.oposPrinter.DeviceEnabled = true; this.oposPrinter.AsyncMode = false; this.oposPrinter.CharacterSet = characterSet; this.oposPrinter.RecLineChars = 56; this.oposPrinter.SlpLineChars = 60; this.binaryConversionEnabled = binaryConversion; }
/// <summary> /// Construct the Payment Device class and open the connection from it. /// </summary> /// <param name="peripheralName">Name of peripheral device.</param> /// <param name="terminalSettings">The terminal settings for the peripheral device.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> /// <returns>A task that can be awaited until the connection is opened.</returns> public virtual async Task OpenAsync(string peripheralName, SettingsInfo terminalSettings, PeripheralConfiguration peripheralConfig) { this.executionLock = new SemaphoreSlim(1, 1); this.paymentDevice = CompositionManager.Instance.GetComponent <IPaymentDevice>(peripheralName); if (this.paymentDevice == null) { throw new PeripheralException(PeripheralException.PaymentTerminalError, "Payment terminal '{0}' is not available.\n\nPossible issues:\n1. Payment terminal device assembly not installed in DLLHost or IIS Hardware Station bin directory.\n2. Payment terminal device assembly not in hardwareStation->composition of the configuration file in above directory.", peripheralName); } IDictionary <string, string> peripheralConfigDictionary = new Dictionary <string, string>(); if (peripheralConfig != null && peripheralConfig.ExtensionProperties != null) { peripheralConfigDictionary = peripheralConfig.ExtensionProperties.ToStringDictionary(); } await this.paymentDevice.OpenAsync(peripheralName, terminalSettings, peripheralConfigDictionary); }
/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="characterSet">The character set.</param> /// <param name="binaryConversion">If set to <c>true</c> [binary conversion].</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, int characterSet, bool binaryConversion, PeripheralConfiguration peripheralConfig) { ThrowIf.NullOrWhiteSpace(peripheralName, "peripheralName"); ThrowIf.Null(peripheralConfig, "peripheralConfig"); IDictionary <string, object> configurations = peripheralConfig.ExtensionProperties.ToObjectDictionary(); string ip = configurations[PeripheralConfigKey.IpAddress] as string; if (string.IsNullOrWhiteSpace(ip)) { throw new ArgumentException(string.Format("Peripheral configuration parameter is missing: {0}.", PeripheralConfigKey.IpAddress)); } int?port = configurations[PeripheralConfigKey.Port] as int?; if (port == null) { throw new ArgumentException(string.Format("Peripheral configuration parameter is missing: {0}.", PeripheralConfigKey.Port)); } this.ip = ip.Trim(); this.port = (int)port; // Get code page attribute this.codePage = characterSet; if (this.codePage > 0) { this.codePageAttribute = string.Format(CodePageFormat, this.codePage); } else { this.codePageAttribute = string.Empty; // Use printer setting } }
private async Task OpenAsync(string peripheralName, SettingsInfo terminalSettings, PeripheralConfiguration deviceConfig) { // Open the device for payments await Task.Delay(500).ConfigureAwait(false); }
/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="characterSet">The character set.</param> /// <param name="binaryConversion">If set to <c>true</c> [binary conversion].</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, int characterSet, bool binaryConversion, PeripheralConfiguration peripheralConfig) { this.PrinterName = peripheralName; }
/// <summary> /// Establishes a connection to the specified cash drawer. /// </summary> /// <param name="peripheralName">Name of cash drawer device to open.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { this.PortName = peripheralName; }
/// <summary> /// Establishes a connection to the specified line display. /// </summary> /// <param name="peripheralName">Name of scale device to open.</param> /// <param name="characterSet">The character set.</param> /// <param name="binaryConversion">If set to <c>true</c> [binary conversion].</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public void Open(string peripheralName, int characterSet, bool binaryConversion, PeripheralConfiguration peripheralConfig) { this.oposLineDisplayWorker = new WorkerThread <IOPOSLineDisplay>(() => { IOPOSLineDisplay oposLineDisplay = new OPOSLineDisplay(); // Open oposLineDisplay.Open(peripheralName); OposHelper.CheckResultCode(this, oposLineDisplay.ResultCode); // Claim oposLineDisplay.ClaimDevice(OposHelper.ClaimTimeOut); OposHelper.CheckResultCode(this, oposLineDisplay.ResultCode); // Enable/Configure oposLineDisplay.DeviceEnabled = true; binaryConversionEnabled = binaryConversion; if (characterSet != 0) { // If character set is not supported by device, then disable and error out. if (!oposLineDisplay.CharacterSetList.Split(CharacterSetListSeparator).Any(p => p.Equals(characterSet.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))) { oposLineDisplay.ReleaseDevice(); oposLineDisplay.Close(); throw new PeripheralException(PeripheralException.LineDisplayCharacterSetNotSupported); } oposLineDisplay.CharacterSet = characterSet; } this.numberOfColumns = oposLineDisplay.Columns; return(oposLineDisplay); }); }
/// <summary> /// Opens a peripheral. /// </summary> /// <param name="peripheralName">Name of the peripheral.</param> /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param> public virtual void Open(string peripheralName, PeripheralConfiguration peripheralConfig) { }