コード例 #1
0
 public BillCassetteEventArgs(BillCassetteStatus status)
 {
     this.Status = status;
 }
コード例 #2
0
        /// <summary>
        /// Timer for accepting payments
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Stop();

            try
            {
                lock (_locker)
                {
                    List <byte> bytesResult = null;

                    bytesResult = SendCommand(BillValidatorCommands.POLL).ToList();

                    if (bytesResult[3] != 0x14)
                    {
                        switch (bytesResult[3])
                        {
                        // Accepting
                        case 0x15:
                            SendCommand(BillValidatorCommands.ACK);
                            break;

                        // Escrow position - Rejecting
                        case 0x1C:
                            SendCommand(BillValidatorCommands.ACK);
                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Rejected, 0, ""));
                            break;

                        // Escrow position
                        case 0x80:
                            SendCommand(BillValidatorCommands.ACK);
                            OnBillStacking(new BillStackedEventArgs(CashCodeTable(bytesResult[4])));

                            if (this._returnBill)
                            {
                                bytesResult = this.SendCommand(BillValidatorCommands.RETURN).ToList();
                                _returnBill = false;
                            }
                            else
                            {
                                bytesResult = this.SendCommand(BillValidatorCommands.STACK).ToList();
                            }

                            break;

                        // Stacking
                        case 0x17:
                            SendCommand(BillValidatorCommands.ACK);
                            break;

                        // Bill stacked
                        case 0x81:
                            SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable(bytesResult[4]), ""));

                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine(string.Format("Banknote - {0} was obtained.", CashCodeTable(bytesResult[4])));
                            Console.ResetColor();
                            break;

                        // Returning
                        case 0x18:
                            SendCommand(BillValidatorCommands.ACK);

                            break;

                        // Bill returning
                        case 0x82:
                            SendCommand(BillValidatorCommands.ACK);

                            break;

                        // Drop cassette out of position
                        case 0x42:
                            if (_cassetteStatus != BillCassetteStatus.Removed)
                            {
                                _cassetteStatus = BillCassetteStatus.Removed;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassetteStatus));
                            }
                            break;

                        // Initialize
                        case 0x13:
                            if (_cassetteStatus == BillCassetteStatus.Removed)
                            {
                                _cassetteStatus = BillCassetteStatus.Inplace;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassetteStatus));
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Log(exception);
            }
            finally
            {
                if (!_timer.Enabled && _isListening)
                {
                    _timer.Start();
                }
            }
        }
コード例 #3
0
        // Таймер прослушки купюроприемника
        private void _Listener_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            this._Listener.Stop();

            try
            {
                lock (_Locker)
                {
                    List <byte> ByteResult = null;

                    // отпавить команду POLL
                    ByteResult = this.SendCommand(BillValidatorCommands.POLL).ToList();

                    // Если четвертый бит не Idling (незанятый), то идем дальше
                    if (ByteResult[3] != 0x14)
                    {
                        // ACCEPTING
                        //Если получили ответ 15H (Accepting)
                        if (ByteResult[3] == 0x15)
                        {
                            // Подтверждаем
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // ESCROW POSITION
                        // Если четвертый бит 1Сh (Rejecting), то купюроприемник не распознал купюру
                        else if (ByteResult[3] == 0x1C)
                        {
                            // Принялии какую-то купюру
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Rejected, 0, this._ErrorList.Errors[ByteResult[4]]));
                        }

                        // ESCROW POSITION
                        // купюра распознана
                        else if (ByteResult[3] == 0x80)
                        {
                            // Подтветждаем
                            this.SendCommand(BillValidatorCommands.ACK);

                            // Событие, что купюра в процессе отправки в стек
                            OnBillStacking(new BillStackedEventArgs(CashCodeTable(ByteResult[4])));

                            // Если программа отвечает возвратом, то на возврат
                            if (this._ReturnBill)
                            {
                                // RETURN
                                // Если программа отказывает принимать купюру, отправим RETURN
                                ByteResult       = this.SendCommand(BillValidatorCommands.RETURN).ToList();
                                this._ReturnBill = false;
                            }
                            else
                            {
                                // STACK
                                // Если равпознали, отправим купюру в стек (STACK)
                                ByteResult = this.SendCommand(BillValidatorCommands.STACK).ToList();
                            }
                        }

                        // STACKING
                        // Если четвертый бит 17h, следовательно идет процесс отправки купюры в стек (STACKING)
                        else if (ByteResult[3] == 0x17)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Bill stacked
                        // Если четвертый бит 81h, следовательно, купюра попала в стек
                        else if (ByteResult[3] == 0x81)
                        {
                            // Подтветждаем
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable(ByteResult[4]), ""));
                        }

                        // RETURNING
                        // Если четвертый бит 18h, следовательно идет процесс возврата
                        else if (ByteResult[3] == 0x18)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // BILL RETURNING
                        // Если четвертый бит 82h, следовательно купюра возвращена
                        else if (ByteResult[3] == 0x82)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Drop Cassette out of position
                        // Снят купюроотстойник
                        else if (ByteResult[3] == 0x42)
                        {
                            if (_cassettestatus != BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Removed;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }

                        // Initialize
                        // Кассета вставлена обратно на место
                        else if (ByteResult[3] == 0x13)
                        {
                            if (_cassettestatus == BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Inplace;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }
                    }
                }
            }
            catch
            {}
            finally
            {
                // Если таймер выключен, то запускаем
                if (!this._Listener.Enabled && this._IsListening)
                {
                    this._Listener.Start();
                }
            }
        }
コード例 #4
0
        // Timer of wiretapping bill acceptor
        private void _Listener_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            this._Listener.Stop();

            try
            {
                lock (_Locker)
                {
                    List <byte> ByteResult = null;

                    // send a POLL command
                    ByteResult = this.SendCommand(BillValidatorCommands.POLL).ToList();

                    // If the fourth bit is not Idling (idle), then go ahead
                    if (ByteResult[3] != 0x14)
                    {
                        // ACCEPTING
                        //If your recieved answer 15H (Accepting)
                        if (ByteResult[3] == 0x15)
                        {
                            // We confirm
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // ESCROW POSITION
                        // If the fourth bit is 1Сh (Rejecting), then the bill acceptor did not recognize the bill
                        else if (ByteResult[3] == 0x1C)
                        {
                            // Accept some kind of bill
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Rejected, 0, this._ErrorList.Errors[ByteResult[4]]));
                        }

                        // ESCROW POSITION
                        // bill recognized
                        else if (ByteResult[3] == 0x80)
                        {
                            // Welcome
                            this.SendCommand(BillValidatorCommands.ACK);

                            // The event that the bill in the process of sending to the stack
                            OnBillStacking(new BillStackedEventArgs(CashCodeTable(ByteResult[4])));

                            // If the program responds with a return, then the return
                            if (this._ReturnBill)
                            {
                                // RETURN
                                // If the program refuses to accept the bill, send RETURN
                                ByteResult       = this.SendCommand(BillValidatorCommands.RETURN).ToList();
                                this._ReturnBill = false;
                            }
                            else
                            {
                                // STACK
                                // If you have recognized, send the bill to the stack (STACK)
                                ByteResult = this.SendCommand(BillValidatorCommands.STACK).ToList();
                            }
                        }

                        // STACKING
                        // If the fourth bit is 17h, hence the process of sending the note to the stack is going on (STACKING)
                        else if (ByteResult[3] == 0x17)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Bill stacked
                        // If the fourth bit is 81h, therefore, the bill hit the stack
                        else if (ByteResult[3] == 0x81)
                        {
                            // Welcome
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable(ByteResult[4]), ""));
                        }

                        // RETURNING
                        // If the fourth bit is 18h, hence the return process is in progress.
                        else if (ByteResult[3] == 0x18)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // BILL RETURNING
                        // If the fourth bit is 82h, hence the bill is returned.
                        else if (ByteResult[3] == 0x82)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Drop Cassette out of position
                        // Banknote withdrawn
                        else if (ByteResult[3] == 0x42)
                        {
                            if (_cassettestatus != BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Removed;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }

                        // Initialize
                        // The cassette is inserted back into place.
                        else if (ByteResult[3] == 0x13)
                        {
                            if (_cassettestatus == BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Inplace;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            { }
            finally
            {
                // If the timer is off, then run
                if (!this._Listener.Enabled && this._IsListening)
                {
                    this._Listener.Start();
                }
            }
        }
コード例 #5
0
        // Таймер прослушки купюроприемника
        private void _Listener_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            this._Listener.Stop();

            try
            {
                lock (_Locker)
                {
                    List<byte> ByteResult = null;

                    // отпавить команду POLL
                    ByteResult = this.SendCommand(BillValidatorCommands.POLL).ToList();

                    // Если четвертый бит не Idling (незанятый), то идем дальше
                    if (ByteResult[3] != 0x14)
                    {
                        // ACCEPTING
                        //Если получили ответ 15H (Accepting)
                        if (ByteResult[3] == 0x15)
                        {
                            // Подтверждаем
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // ESCROW POSITION
                        // Если четвертый бит 1Сh (Rejecting), то купюроприемник не распознал купюру
                        else if (ByteResult[3] == 0x1C)
                        {
                            // Принялии какую-то купюру
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Rejected, 0, this._ErrorList.Errors[ByteResult[4]]));
                        }

                        // ESCROW POSITION
                        // купюра распознана
                        else if (ByteResult[3] == 0x80)
                        {
                            // Подтветждаем
                            this.SendCommand(BillValidatorCommands.ACK);

                            // Событие, что купюра в процессе отправки в стек
                            OnBillStacking(new BillStackedEventArgs(CashCodeTable(ByteResult[4])));

                            // Если программа отвечает возвратом, то на возврат
                            if (this._ReturnBill)
                            {
                                // RETURN
                                // Если программа отказывает принимать купюру, отправим RETURN
                                ByteResult = this.SendCommand(BillValidatorCommands.RETURN).ToList();
                                this._ReturnBill = false;
                            }
                            else
                            {
                                // STACK
                                // Если равпознали, отправим купюру в стек (STACK)
                                ByteResult = this.SendCommand(BillValidatorCommands.STACK).ToList();
                            }
                        }

                        // STACKING
                        // Если четвертый бит 17h, следовательно идет процесс отправки купюры в стек (STACKING)
                        else if (ByteResult[3] == 0x17)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Bill stacked
                        // Если четвертый бит 81h, следовательно, купюра попала в стек
                        else if (ByteResult[3] == 0x81)
                        {
                            // Подтветждаем
                            this.SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable(ByteResult[4]), ""));
                        }

                        // RETURNING
                        // Если четвертый бит 18h, следовательно идет процесс возврата
                        else if (ByteResult[3] == 0x18)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // BILL RETURNING
                        // Если четвертый бит 82h, следовательно купюра возвращена
                        else if (ByteResult[3] == 0x82)
                        {
                            this.SendCommand(BillValidatorCommands.ACK);
                        }

                        // Drop Cassette out of position
                        // Снят купюроотстойник
                        else if (ByteResult[3] == 0x42)
                        {
                            if (_cassettestatus != BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Removed;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));

                            }
                        }

                        // Initialize
                        // Кассета вставлена обратно на место
                        else if (ByteResult[3] == 0x13)
                        {
                            if (_cassettestatus == BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Inplace;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }
                    }
                }
            }
            catch
            {}
            finally
            {
                // Если таймер выключен, то запускаем
                if (!this._Listener.Enabled && this._IsListening)
                    this._Listener.Start();
            }
        }
コード例 #6
0
 public BillCassetteEventArgs(BillCassetteStatus status)
 {
     this.Status = status;
 }
        // The timer of wiretapping of the bill acceptor
        private void _Listener_Elapsed(object sender, ElapsedEventArgs e)
        {
            _listener.Stop();

            try
            {
                lock (_Locker)
                {
                    // Omit the POLL command
                    var byteResult = SendCommand(BillValidatorCommands.POLL).ToList();

                    // If the fourth bit is not Idling (unoccupied), then go further
                    if (byteResult[3] != 0x14)
                    {
                        // ACCEPTING
                        // If you receive a response 15H (Accepting)
                        if (byteResult[3] == 0x15)
                        {
                            // Confirm
                            SendCommand(BillValidatorCommands.ACK);
                        }

                        // ESCROW POSITION
                        // If the fourth bit is 1Ch(Rejecting), then the bill acceptor did not recognize the bill
                        else if (byteResult[3] == 0x1C)
                        {
                            // Accepted some bill
                            SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Rejected, _billsDefinition.InvalidBill,
                                                                     _errorList.GetErrorByCode(byteResult[4])));
                        }

                        // ESCROW POSITION
                        // Bill recognized
                        else if (byteResult[3] == 0x80)
                        {
                            // Acknowledging
                            SendCommand(BillValidatorCommands.ACK);

                            // The event that the bill is in the process of sending to the stack
                            OnBillStacking(new BillStackedEventArgs(CashCodeTable(byteResult[4])));

                            // If the program responds with a refund, then the return
                            if (_returnBill)
                            {
                                // RETURN
                                // If the program refuses to accept the bill, we will send RETURN
                                byteResult  = SendCommand(BillValidatorCommands.RETURN).ToList();
                                _returnBill = false;
                            }
                            else
                            {
                                // STACK
                                // If you are equal, we will send the note to the stack(STACK)
                                byteResult = SendCommand(BillValidatorCommands.STACK).ToList();
                            }
                        }

                        // STACKING
                        // If the fourth bit is 17h, then the process of sending a note to the stack(STACKING)
                        else if (byteResult[3] == 0x17)
                        {
                            SendCommand(BillValidatorCommands.ACK);
                        }

                        // Bill stacked
                        // If the fourth bit is 81h, therefore, the bill hit the stack
                        else if (byteResult[3] == 0x81)
                        {
                            // Acknowledging
                            SendCommand(BillValidatorCommands.ACK);

                            OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted,
                                                                     CashCodeTable(byteResult[4]), null));
                        }

                        // RETURNING
                        // If the fourth bit is 18h, then the process returns
                        else if (byteResult[3] == 0x18)
                        {
                            SendCommand(BillValidatorCommands.ACK);
                        }

                        // BILL RETURNING
                        // If the fourth bit is 82h, then the note is returned
                        else if (byteResult[3] == 0x82)
                        {
                            SendCommand(BillValidatorCommands.ACK);
                        }

                        // Drop Cassette out of position
                        // The bills are removed
                        else if (byteResult[3] == 0x42)
                        {
                            if (_cassettestatus != BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Removed;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }

                        // Initialize
                        // The cassette is inserted back into place
                        else if (byteResult[3] == 0x13)
                        {
                            if (_cassettestatus == BillCassetteStatus.Removed)
                            {
                                // fire event
                                _cassettestatus = BillCassetteStatus.Inplace;
                                OnBillCassetteStatus(new BillCassetteEventArgs(_cassettestatus));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // ignored
            }
            finally
            {
                // If the timer is off, then we start
                if (!_listener.Enabled && _isListening)
                {
                    _listener.Start();
                }
            }
        }
コード例 #8
0
 public BillCassetteEventArgs(BillCassetteStatus billCassetteStatus)
 {
     Status = billCassetteStatus;
 }