public void FiresStimulusOutputEvents()
        {
            var c         = new TestDAQController();
            var srate     = new Measurement(10, "Hz");
            var outStream = new DAQOutputStream("out")
            {
                MeasurementConversionTarget = "V",
                SampleRate = srate
            };
            var inStream = new DAQInputStream("in")
            {
                MeasurementConversionTarget = "V",
                SampleRate = srate
            };

            var outputData   = new Dictionary <IDAQOutputStream, Queue <IOutputData> >();
            var dataQueue    = new Queue <IOutputData>();
            var outputIOData = new OutputData(
                Enumerable.Range(0, 100).Select(i => new Measurement(i, "V")),
                new Measurement(10, "Hz")
                );

            dataQueue.Enqueue(outputIOData);

            outputData[outStream] = dataQueue;

            var dev = new TestDevice("test", outputData)
            {
                MeasurementConversionTarget = "V"
            };

            dev.BindStream(outStream);

            bool fired = false;

            c.StimulusOutput += (daq, args) =>
            {
                Assert.That(args.Stream == outStream);
                Assert.That(args.Data != null);
                Assert.That(args.Data.Configuration.Count() > 0);
                fired = true;
            };
            c.ProcessIteration += (daq, args) => ((IDAQController)daq).RequestStop();

            c.AddStreamMapping(outStream, inStream);

            c.Start(false);

            while (c.Running)
            {
                ;
            }

            Assert.That(fired, Is.True.After(1000, 10));
        }
Ejemplo n.º 2
0
        public void FiresOnStoppedEvent()
        {
            var controller = new TestDAQController();
            controller.Clock = controller;

            bool fired = false;

            controller.Stopped += (c, args) => fired = true;
            controller.ExceptionalStop += (c, ex) => Assert.Fail(ex.Exception.ToString());

            controller.Start(false);
            controller.Stop();

            Assert.IsTrue(fired);
        }
        public void FiresOnStoppedEvent()
        {
            var controller = new TestDAQController();

            controller.Clock = controller;

            bool fired = false;

            controller.Stopped         += (c, args) => fired = true;
            controller.ExceptionalStop += (c, ex) => Assert.Fail(ex.Exception.ToString());

            controller.Start(false);
            controller.Stop();

            Assert.IsTrue(fired);
        }
        public void FiresStimulusOutputEvents()
        {
            var c = new TestDAQController();
            var srate = new Measurement(10, "Hz");
            var outStream = new DAQOutputStream("out")
                                {
                                    MeasurementConversionTarget = "V",
                                    SampleRate = srate
                                };
            var inStream = new DAQInputStream("in")
                               {
                                   MeasurementConversionTarget = "V",
                                   SampleRate = srate
                               };

            var outputData = new Dictionary<IDAQOutputStream, Queue<IOutputData>>();
            var dataQueue = new Queue<IOutputData>();
            var outputIOData = new OutputData(
                Enumerable.Range(0, 100).Select(i => new Measurement(i, "V")),
                new Measurement(10, "Hz")
                );

            dataQueue.Enqueue(outputIOData);

            outputData[outStream] = dataQueue;

            var dev = new TestDevice("test", outputData) { MeasurementConversionTarget = "V" };

            dev.BindStream(outStream);

            bool fired = false;
            c.StimulusOutput += (daq, args) =>
                                    {
                                        Assert.That(args.Stream == outStream);
                                        Assert.That(args.Data != null);
                                        Assert.That(args.Data.Configuration.Count() > 0);
                                        fired = true;

                                        ((IDAQController) daq).RequestStop();
                                    };

            c.AddStreamMapping(outStream, inStream);

            c.Start(false);

            while (c.IsRunning)
            {
                Thread.Sleep(1);
            }

            Assert.That(fired, Is.True);
        }