/// <summary>
        /// Get's a generic input.
        /// </summary>
        /// <param name="numericInput">Numeric input code.</param>
        /// <param name="textInput">Text input code.</param>
        /// <param name="firstLine">First line label.</param>
        /// <param name="secondLine">Second line label.</param>
        /// <param name="minimumLength">Minimum number of characters typed.</param>
        /// <param name="maximumLength">Maximum number of characters typed (up to 32 chars).</param>
        /// <param name="timeOut">Time out.</param>
        /// <returns>Text typed.</returns>
        public string GetInput(KeyboardNumberFormat numericInput, KeyboardTextFormat textInput, FirstLineLabelCode firstLine, SecondLineLabelCode secondLine, int minimumLength, int maximumLength, int timeOut)
        {
            if (GciGertecRequest.IsSupported(this.Informations.ManufacturerName, this.Informations.Model, this.Informations.ManufacturerVersion) == false)
            {
                return(null);
            }

            if (minimumLength < 0)
            {
                minimumLength = 0;
            }

            if (maximumLength > 32)
            {
                throw new InvalidOperationException("Invalid maximumLength. The maximum length is up to 32 characters.");
            }

            GciGertecRequest request = new GciGertecRequest();

            request.NumericInputType.Value       = numericInput;
            request.TextInputType.Value          = textInput;
            request.LabelFirstLine.Value         = firstLine;
            request.LabelSecondLine.Value        = secondLine;
            request.MaximumCharacterLength.Value = minimumLength;
            request.MinimumCharacterLength.Value = maximumLength;
            request.TimeOut.Value  = timeOut;
            request.TimeIdle.Value = 0;

            GertecEx07Response response = this.Communication.SendRequestAndReceiveResponse <GertecEx07Response>(request);

            if (response == null || response.RSP_STAT.Value != AbecsResponseStatus.ST_OK)
            {
                return(null);
            }

            if (response.RSP_RESULT.HasValue == true)
            {
                return(response.RSP_RESULT.Value);
            }

            return(null);
        }
        /// <summary>
        /// Gets a decimal amount.
        /// The amount shall be typed in the followed format:
        ///    - "1,99"
        ///    - "0,00"
        /// Containing always at least 4 chars.
        /// </summary>
        /// <param name="currency">Amount currency, i. e. R$, US$.</param>
        /// <returns>The amount if a valid amount was typed. Null if: timeout, user cancelled, amount was typed on an invalid format (example: 1.7,2).</returns>
        public Nullable <decimal> GetAmount(AmountCurrencyCode currency)
        {
            if (GciGertecRequest.IsSupported(this.Informations.ManufacturerName, this.Informations.Model, this.Informations.ManufacturerVersion) == false)
            {
                return(null);
            }

            if (currency == AmountCurrencyCode.Undefined || Enum.IsDefined(typeof(AmountCurrencyCode), (int)currency) == false)
            {
                throw new ArgumentException("currency has an invalid value.");
            }

            GciGertecRequest request = new GciGertecRequest();

            request.NumericInputType.Value       = KeyboardNumberFormat.Decimal;
            request.TextInputType.Value          = KeyboardTextFormat.Symbols;
            request.LabelFirstLine.Value         = FirstLineLabelCode.Type;
            request.LabelSecondLine.Value        = (SecondLineLabelCode)(currency + 30);
            request.MaximumCharacterLength.Value = 4;
            request.MinimumCharacterLength.Value = 10;
            request.TimeOut.Value  = 120;
            request.TimeIdle.Value = 0;

            GertecEx07Response response = this.Communication.SendRequestAndReceiveResponse <GertecEx07Response>(request);

            if (response == null || response.RSP_STAT.Value != AbecsResponseStatus.ST_OK)
            {
                return(null);
            }

            if (response.RSP_RESULT.HasValue == true)
            {
                return(this.GetAmount(response.RSP_RESULT.Value));
            }

            return(null);
        }
Exemplo n.º 3
0
        public void Gertec_EX07_test()
        {
            // testes:
            //this.mockedPinpadConnection = new MockedPinpadConnection();

            // prod:
            IPinpadConnection conn = PinpadConnectionProvider.GetFirst();

            PinpadCommunication comm = new PinpadCommunication(conn);

            GciGertecRequest request = new GciGertecRequest();

            request.NumericInputType.Value       = KeyboardNumberFormat.Decimal;
            request.TextInputType.Value          = KeyboardTextFormat.None;
            request.LabelFirstLine.Value         = FirstLineLabelCode.TypeNumber;
            request.LabelSecondLine.Value        = SecondLineLabelCode.GasPump;
            request.MaximumCharacterLength.Value = 1;
            request.MinimumCharacterLength.Value = 10;
            request.TimeOut.Value  = 60;
            request.TimeIdle.Value = 0;

            Debug.WriteLine(request.CommandString);

            GertecEx07Response response = comm
                                          .SendRequestAndReceiveResponse <GertecEx07Response>(request);

            if (response != null)
            {
                Debug.WriteLine("Response status: " + response.RSP_STAT.Value);
                Debug.WriteLine("Value typed: " + response.RSP_RESULT.Value);
            }
            else
            {
                Debug.WriteLine("Resposta nula. Cancelamento ou timeout.");
            }
        }