Exemple #1
0
        private void RunTest()
        {
            Logger          logger   = eventLogControl.Logger;
            MetaDictionary  globals  = new MetaDictionary();
            EventWaitHandle endEvent = new EventWaitHandle(false, EventResetMode.ManualReset);

            try
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource();
                using (TestDocument.TestGraphContainer testGraph = Document.CreateTestGraph(logger, globals))
                {
                    testGraph.Graph.LogPacketEvent  += new EventHandler <LogPacketEventArgs>(log_AddLogPacket);
                    testGraph.Graph.EditPacketEvent += new EventHandler <EditPacketEventArgs>(Graph_EditPacketEvent);

                    LogPacket[] packets = Document.GetInputPackets();

                    using (QueuedDataAdapter inputAdapter = new QueuedDataAdapter(tokenSource.Token))
                    {
                        foreach (LogPacket p in packets)
                        {
                            inputAdapter.Enqueue(p.Frame.CloneFrame());
                        }

                        inputAdapter.StopEnqueue();

                        testGraph.Graph.BindEndpoint(testGraph.Output.Uuid, new EventDataAdapter(endEvent));
                        testGraph.Graph.BindEndpoint(testGraph.Input.Uuid, inputAdapter);

                        IPipelineEndpoint inputEndpoint = testGraph.Input as IPipelineEndpoint;
                        inputEndpoint.Start();

                        // Sleep up to 100 seconds
                        if (!endEvent.WaitOne(100000))
                        {
                            logger.LogError("Test did not finish after 100 seconds");
                            tokenSource.Cancel();
                        }
                    }
                }
            }
            catch (EndOfStreamException)
            {
                // End of stream
            }
            catch (ThreadAbortException)
            {
            }
            catch (ObjectDisposedException)
            {
            }
            finally
            {
                if (endEvent != null)
                {
                    endEvent.Dispose();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Method to bind an endpoint
        /// </summary>
        /// <param name="id"></param>
        /// <param name="adapter"></param>
        public void BindEndpoint(Guid id, IDataAdapter adapter)
        {
            if (Nodes.ContainsKey(id) && (Nodes[id] is IPipelineEndpoint))
            {
                IPipelineEndpoint ep = Nodes[id] as IPipelineEndpoint;

                ep.Adapter = adapter;
            }
            else
            {
                throw new ArgumentException(String.Format(CANAPE.Properties.Resources.NetGraph_InvalidEndpointId, id));
            }
        }
Exemple #3
0
            public ConnectionEntry(ProxyNetworkService service, NetGraph graph, int timeout, bool afterData)
            {
                _service = service;
                Graph    = graph;

                if (timeout > 0)
                {
                    SetTimeout(timeout, afterData);
                }

                foreach (KeyValuePair <Guid, BasePipelineNode> node in graph.Nodes)
                {
                    IPipelineEndpoint ep = node.Value as IPipelineEndpoint;

                    if (ep != null)
                    {
                        ep.DataRecieved += ep_DataRecieved;
                    }
                }
            }