コード例 #1
0
        public void send_nice_data_and_test_if_all_stopped_and_empty_also_unconnected_nodes()
        {
            var graph  = new Graph();
            var source = new SourceNode(graph);
            var sink   = new SinkNode(graph);
            var sink2  = new SinkNode(graph);
            var pass1  = new PassThroughNode(graph);
            var pass2  = new PassThroughNode(graph);

            graph.Connect(source.OutputPorts[0], pass1.InputPorts[0]);
            graph.Connect(pass1.OutputPorts[0], sink.InputPorts[0]);

            // pass2 is not connected a source
            graph.Connect(pass2.OutputPorts[0], sink2.InputPorts[0]);
            ((DataInputPort)pass2.InputPorts[0]).Samplerate = 100;

            Assert.IsTrue(graph.Run(),
                          "Graph.Run() must succeed");

            const int PaketsPerSecond = 4;
            const int Seconds         = 1;

            for (int i = 0; i < Seconds * PaketsPerSecond; i++)
            {
                System.Threading.Thread.Sleep(1000 / PaketsPerSecond);
                source.SendData(source.Samplerate / PaketsPerSecond);
            }

            System.Diagnostics.Debug.WriteLine("Graph Stop");
            graph.Stop();
            System.Diagnostics.Debug.WriteLine("All Done");

            foreach (var node in graph.Nodes)
            {
                Assert.IsTrue(node.State == Node.ProcessingState.Stopped, "All nodes must stop");
            }

            Assert.IsTrue((sink.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((sink2.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((pass1.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((pass2.InputPorts[0] as DataInputPort).Queue.Length == 0);
        }
コード例 #2
0
        public void send_nice_data_and_test_if_all_stopped_and_empty_multi_way()
        {
            var graph   = new Graph();
            var source1 = new SourceNode(graph);
            var source2 = new SourceNode(graph);
            var sink    = new SinkNode(graph);
            var pass    = new PassThroughNode(graph);
            var adder   = new MetricAdder.Adder(graph);

            graph.Connect(source1.OutputPorts[0], adder.InputPorts[0]);
            graph.Connect(source2.OutputPorts[0], adder.InputPorts[1]);
            graph.Connect(adder.OutputPorts[0], pass.InputPorts[0]);
            graph.Connect(pass.OutputPorts[0], sink.InputPorts[0]);

            Assert.IsTrue(graph.Run(),
                          "Graph.Run() must succeed");

            const int PaketsPerSecond = 4;
            const int Seconds         = 1;

            for (int i = 0; i < Seconds * PaketsPerSecond; i++)
            {
                System.Threading.Thread.Sleep(1000 / PaketsPerSecond);
                source1.SendData(source1.Samplerate / PaketsPerSecond);
                source2.SendData(source2.Samplerate / PaketsPerSecond);
            }

            System.Diagnostics.Debug.WriteLine("Graph Stop");
            graph.Stop();
            System.Diagnostics.Debug.WriteLine("All Done");

            foreach (var node in graph.Nodes)
            {
                Assert.IsTrue(node.State == Node.ProcessingState.Stopped, "All nodes must stop");
            }

            Assert.IsTrue((sink.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((pass.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((adder.InputPorts[0] as DataInputPort).Queue.Length == 0);
            Assert.IsTrue((adder.InputPorts[1] as DataInputPort).Queue.Length == 0);
        }