/// <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.
            }
Esempio n. 3
0
            /// <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;
                    }
                }
            }
Esempio n. 4
0
            /// <summary>
            /// Ends the electronic funds transaction.
            /// </summary>
            /// <param name="completionCode">The completionCode code.</param>
            public void EndElectronicFundsTransaction(int completionCode)
            {
                if (this.oposPinpad != null)
                {
                    int resultCode = this.oposPinpad.EndEFTTransaction(completionCode);
                    OposHelper.CheckResultCode(this, resultCode);

                    this.oposPinpad.DeviceEnabled    = false;
                    this.oposPinpad.DataEventEnabled = false;
                }
            }
Esempio n. 5
0
            /// <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;
            }
Esempio n. 6
0
            /// <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>
            /// Ends the capture.
            /// </summary>
            public void EndCapture()
            {
                SignatureCaptureResults results = null;

                if (this.oposSigCap != null)
                {
                    int resultCode = this.oposSigCap.EndCapture();
                    OposHelper.CheckResultCode(this, resultCode);

                    results = ParsePointArray(this.oposSigCap.PointArray);

                    this.oposSigCap.DeviceEnabled    = false;
                    this.oposSigCap.DataEventEnabled = false;
                }

                this.LastResult = results;
            }
            /// <summary>
            /// Enable device for capture.
            /// </summary>
            /// <param name="formName">Form name (null or empty string will use default).</param>
            public void BeginCapture(string formName)
            {
                this.LastResult = null;

                if (this.oposSigCap != null)
                {
                    if (string.IsNullOrEmpty(formName))
                    {   // Default to empty string if value is not provided.
                        formName = string.Empty;
                    }

                    this.oposSigCap.DeviceEnabled    = true;
                    this.oposSigCap.DataEventEnabled = true;

                    this.oposSigCap.BeginCapture(formName);
                    OposHelper.CheckResultCode(this, this.oposSigCap.ResultCode);
                }
            }
Esempio n. 9
0
            /// <summary>
            /// Print the text to the Printer.
            /// </summary>
            /// <param name="textToPrint">The text to print on the receipt.</param>
            private void PrintText(string textToPrint)
            {
                Match  barCodeMarkerMatch = Regex.Match(textToPrint, BarCodeRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                bool   printBarcode       = false;
                string receiptId          = string.Empty;

                if (barCodeMarkerMatch.Success)
                {
                    printBarcode = true;

                    // Get the receiptId
                    receiptId = barCodeMarkerMatch.Groups[1].ToString();

                    // Delete the barcode marker from the printed string
                    textToPrint = textToPrint.Remove(barCodeMarkerMatch.Index, barCodeMarkerMatch.Length);
                }

                // replace ESC with Char(27) and add a CRLF to the end
                textToPrint = textToPrint.Replace("ESC", ((char)27).ToString());

                if (this.binaryConversionEnabled == true)
                {
                    this.oposPrinter.BinaryConversion = 2; // OposBcDecimal
                    textToPrint = OposHelper.ConvertToBCD(textToPrint + "\r\n\r\n\r\n", this.oposPrinter.CharacterSet);
                }

                this.oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, textToPrint);
                this.oposPrinter.BinaryConversion = 0; // OposBcNone

                // Check if we should print the receipt id as a barcode on the receipt
                if (printBarcode == true)
                {
                    this.oposPrinter.PrintBarCode(
                        (int)OPOSPOSPrinterConstants.PTR_S_RECEIPT,
                        receiptId,
                        (int)OPOSPOSPrinterConstants.PTR_BCS_Code128,
                        80,
                        80,
                        (int)OPOSPOSPrinterConstants.PTR_BC_CENTER,
                        (int)OPOSPOSPrinterConstants.PTR_BC_TEXT_BELOW);
                    this.oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, "\r\n\r\n\r\n\r\n");
                }
            }
Esempio n. 10
0
            /// <summary>
            /// Method to print the raw bytes of a BMP-formatted image.
            /// </summary>
            /// <param name="image">Image bytes to print.</param>
            private void PrintLogoBytes(byte[] image)
            {
                if (this.oposPrinter.CapRecBitmap)
                {
                    if (null != image && image.Length > 0)
                    {
                        int conversion = this.oposPrinter.BinaryConversion; // save current conversion mode
                        this.oposPrinter.BinaryConversion = 2;              // OposBcDecimal

                        this.oposPrinter.PrintMemoryBitmap(
                            (int)OPOSPOSPrinterConstants.PTR_S_RECEIPT,
                            OposHelper.ConvertToBCD(image),
                            (int)OPOSPOSPrinterConstants.PTR_BMT_BMP,
                            (int)OPOSPOSPrinterConstants.PTR_BM_ASIS,
                            (int)OPOSPOSPrinterConstants.PTR_BM_CENTER);
                        this.oposPrinter.BinaryConversion = conversion; // restore previous conversion mode
                    }
                }
            }
Esempio n. 11
0
            /// <summary>
            /// Begins the electronic funds transaction.
            /// </summary>
            /// <param name="amount">The amount.</param>
            /// <param name="accountNumber">The account number.</param>
            public void BeginElectronicFundsTransaction(decimal amount, string accountNumber)
            {
                if (this.oposPinpad != null)
                {
                    this.oposPinpad.DeviceEnabled    = true;
                    this.oposPinpad.DataEventEnabled = true;

                    // Clear any all device input that has been buffered (for data events)
                    this.oposPinpad.ClearInput();

                    this.oposPinpad.Amount        = amount;
                    this.oposPinpad.AccountNumber = accountNumber;
                    this.oposPinpad.TerminalID    = "1"; // Note - we do not provide terminal ID for device on hardware station

                    if (amount < 0)
                    {   // Money is being refunded to the debit card - this is credit
                        this.oposPinpad.TransactionType = (int)Interop.OposConstants.OPOSPINPadConstants.PPAD_TRANS_CREDIT;
                    }
                    else
                    {   // Debit trans
                        this.oposPinpad.TransactionType = (int)Interop.OposConstants.OPOSPINPadConstants.PPAD_TRANS_DEBIT;
                    }

                    this.oposPinpad.Track1Data = string.Empty;
                    this.oposPinpad.Track2Data = string.Empty;
                    this.oposPinpad.Track3Data = string.Empty;
                    this.oposPinpad.Track4Data = string.Empty;

                    // hardcoded value for Hardware Station
                    int transactionHost = 1;

                    this.oposPinpad.BeginEFTTransaction(EncryptionAlgorithm, transactionHost);
                    OposHelper.CheckResultCode(this, this.oposPinpad.ResultCode);

                    this.oposPinpad.EnablePINEntry();
                    OposHelper.CheckResultCode(this, this.oposPinpad.ResultCode);
                }
                else
                {
                    this.AbortTransaction();
                }
            }
Esempio n. 12
0
            /// <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;
            }
Esempio n. 13
0
            /// <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;
            }
Esempio n. 14
0
            /// <summary>
            /// Displays the text.
            /// </summary>
            /// <param name="lines">The lines to display.</param>
            public void DisplayText(IEnumerable <string> lines)
            {
                ThrowIf.Null(lines, "lines");

                this.oposLineDisplayWorker.Execute((oposLineDisplay) =>
                {
                    var index = 0;

                    foreach (var line in lines)
                    {
                        var textToDisplay = line;

                        if (this.binaryConversionEnabled)
                        {
                            oposLineDisplay.BinaryConversion = 2;  // OposBcDecimal
                            textToDisplay = OposHelper.ConvertToBCD(textToDisplay, oposLineDisplay.CharacterSet);
                        }

                        oposLineDisplay.DisplayTextAt(index++, 0, textToDisplay, (int)OPOSLineDisplayConstants.DISP_DT_NORMAL);
                        oposLineDisplay.BinaryConversion = 0;   // OposBcNone
                    }
                });
            }
Esempio n. 15
0
            /// <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);
                });
            }