Пример #1
0
        public CashCodeBillValidator(string PortName, int BaudRate)
        {
            this._ErrorList = new CashCodeErroList();

            this._Disposed      = false;
            this._IsEnableBills = false;
            this._ComPortName   = "";
            this._Locker        = new object();
            this._IsConnected   = this._IsPowerUp = this._IsListening = this._ReturnBill = false;

            // Из спецификации:
            //      Baud Rate:	9600 bps/19200 bps (no negotiation, hardware selectable)
            //      Start bit:	1
            //      Data bit:	8 (bit 0 = LSB, bit 0 sent first)
            //      Parity:		Parity none
            //      Stop bit:	1
            this._ComPort               = new SerialPort();
            this._ComPort.PortName      = this._ComPortName = PortName;
            this._ComPort.BaudRate      = this._BaudRate = BaudRate;
            this._ComPort.DataBits      = 8;
            this._ComPort.Parity        = Parity.None;
            this._ComPort.StopBits      = StopBits.One;
            this._ComPort.DataReceived += new SerialDataReceivedEventHandler(_ComPort_DataReceived);

            this._ReceivedBytes = new List <byte>();
            this._SynchCom      = new EventWaitHandle(false, EventResetMode.AutoReset);

            this._Listener          = new System.Timers.Timer();
            this._Listener.Interval = POLL_TIMEOUT;
            this._Listener.Enabled  = false;
            this._Listener.Elapsed += new System.Timers.ElapsedEventHandler(_Listener_Elapsed);
        }
Пример #2
0
        private EventWaitHandle _SynchCom; // Переменная синхронизации отправки и считывания данных с ком порта

        #endregion Fields

        #region Constructors

        public CashCodeBillValidator(string PortName, int BaudRate)
        {
            this._ErrorList = new CashCodeErroList();

            this._Disposed = false;
            this._IsEnableBills = false;
            this._ComPortName = "";
            this._Locker = new object();
            this._IsConnected = this._IsPowerUp = this._IsListening = this._ReturnBill = false;

            // Из спецификации:
            //      Baud Rate:	9600 bps/19200 bps (no negotiation, hardware selectable)
            //      Start bit:	1
            //      Data bit:	8 (bit 0 = LSB, bit 0 sent first)
            //      Parity:		Parity none
            //      Stop bit:	1
            this._ComPort = new SerialPort();
            this._ComPort.PortName = this._ComPortName = PortName;
            this._ComPort.BaudRate = this._BaudRate = BaudRate;
            this._ComPort.DataBits = 8;
            this._ComPort.Parity = Parity.None;
            this._ComPort.StopBits = StopBits.One;
            this._ComPort.DataReceived += new SerialDataReceivedEventHandler(_ComPort_DataReceived);

            this._ReceivedBytes = new List<byte>();
            this._SynchCom = new EventWaitHandle(false, EventResetMode.AutoReset);

            this._Listener = new System.Timers.Timer();
            this._Listener.Interval = POLL_TIMEOUT;
            this._Listener.Enabled = false;
            this._Listener.Elapsed += new System.Timers.ElapsedEventHandler(_Listener_Elapsed);
        }