diff --git a/CashCode.Net/CashCode.Net/CashCodeBillValidator.cs b/CashCode.Net/CashCode.Net/CashCodeBillValidator.cs index 6fa91cd..4ebd816 100644 --- a/CashCode.Net/CashCode.Net/CashCodeBillValidator.cs +++ b/CashCode.Net/CashCode.Net/CashCodeBillValidator.cs @@ -52,13 +52,18 @@ public sealed class CashCodeBillValidator : IDisposable bool _ReturnBill; + private Dictionary CashCodeTable; + BillCassetteStatus _cassettestatus = BillCassetteStatus.Inplace; #endregion #region Конструкторы - public CashCodeBillValidator(string PortName, int BaudRate) + public CashCodeBillValidator(string PortName, int BaudRate, Dictionary cashCodeTable = null) { + if (cashCodeTable == null) + CashCodeTable = _defaultCashCodeTable; + this._ErrorList = new CashCodeErroList(); this._Disposed = false; @@ -494,21 +499,17 @@ private byte[] SendCommand(BillValidatorCommands cmd, byte[] Data = null) } // Таблица кодов валют - private int CashCodeTable(byte code) + private static Dictionary _defaultCashCodeTable = new Dictionary() { - int result = 0; - - if (code == 0x02) { result = 10; } // 10 р. - else if (code == 0x03) { result = 50; } // 50 р. - else if (code == 0x04) { result = 100; } // 100 р. - else if (code == 0x0c) { result = 200; } // 200 р. - else if (code == 0x05) { result = 500; } // 500 р. - else if (code == 0x06) { result = 1000; } // 1000 р. - else if (code == 0x0d) { result = 2000; } // 2000 р. - else if (code == 0x07) { result = 5000; } // 5000 р. - - return result; - } + { 0x02, 10 }, // 10 р. + { 0x03, 50 }, // 50 р. + { 0x04, 100 }, // 100 р. + { 0x0c, 200 }, // 200 р. + { 0x05, 500 }, // 500 р. + { 0x06, 1000 }, // 1000 р. + { 0x0d, 2000 }, // 2000 р. + { 0x07, 5000 } // 5000 р. + }; #endregion @@ -626,7 +627,7 @@ private void _Listener_Elapsed(object sender, System.Timers.ElapsedEventArgs e) this.SendCommand(BillValidatorCommands.ACK); // Событие, что купюра в процессе отправки в стек - OnBillStacking(new BillStackedEventArgs(CashCodeTable(ByteResult[4]))); + OnBillStacking(new BillStackedEventArgs(CashCodeTable[ByteResult[4]])); // Если программа отвечает возвратом, то на возврат if (this._ReturnBill) @@ -658,7 +659,7 @@ private void _Listener_Elapsed(object sender, System.Timers.ElapsedEventArgs e) // Подтветждаем this.SendCommand(BillValidatorCommands.ACK); - OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable(ByteResult[4]), "")); + OnBillReceived(new BillReceivedEventArgs(BillRecievedStatus.Accepted, CashCodeTable[ByteResult[4]], "")); } // RETURNING