Exemplo n.º 1
0
        public void DataQueueTest()
        {
            var au = new AutoResetEvent(false);
            var i = new TestInterface();
            var d = new DataQueue(i);
            d.Error += (a, b) => au.Set();
            d.QueueEmpty += (a, b) => au.Set();
            d.Run();

            for (int x = 0; x < 100; x++)
            {
                var z = new TestPw();
                d.EnqueData(z);
                au.WaitOne();
                Assert.IsTrue(z.ModuleDataCheckOk);
            }
        }
Exemplo n.º 2
0
        private void Connect(Tuple<string, ConnectType> specs)
        {
            try
            {
                _interface = ConnectionFactory(specs.Item2);

                _interface.DataReceived += (sender, bytes) => _mcucomm.Fire(Cevts.ReceiveCompleted, bytes);
                _interface.ErrorOccured += (sender, s) => _mcucomm.Fire(Cevts.Error, s.Exception.ToString());
                _interface.ModeChanged += (sender, b) => _mcucomm.Fire(b.Connected ? Cevts.Connected : Cevts.Disconnect);
                _interface.Connect(specs.Item1);

                _dataQueue = new DataQueue(_interface);

                _dataQueue.Error += (sender, exception) => _mcucomm.Fire(Cevts.Error, exception.Exception.Message);
                _dataQueue.QueueEmpty += (sender, args) => _mcucomm.Fire(Cevts.QueueEmtpy);

                _dataQueue.Run();
            }
            catch (Exception e)
            {
                _mcucomm.Fire(Cevts.Error, e.Message);
            }
        }