Ejemplo n.º 1
0
        public void FilterByKeyword_Test()
        {
            VisualRxSettings.ClearFilters();

            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create());

            VisualRxSettings.AddFilter((marble, channelKey) =>
                                       marble.Keywords.Contains("Key1"));

            VisualRxInitResult infos = info.Result;

            Trace.WriteLine(infos);

            var xs = Observable.Interval(TimeSpan.FromSeconds(0.5))
                     .Take(10);

            xs = xs.Monitor("Stream A", 1, "Key1", "Key3", "Key4");
            var ys = Observable.Interval(TimeSpan.FromSeconds(1))
                     .Take(10);

            ys = ys.Monitor("Stream B", 2, "Key2", "Key3");

            //xs.Subscribe();
            ys.Subscribe();
            xs.Wait();

            GC.KeepAlive(xs);
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Start");

            IObservable <PerformanceSample> performanceCounterObservable =
                PerfCounterObservable.FromRealTime(
                    TimeSpan.FromSeconds(1),
                    new[]
            {
                @"\Processor(_Total)\% Processor Time",
                @"\Memory(_Total)\% Committed Bytes In Use",
                @"\Memory(_Total)\Available MBytes"
            });

            VisualRxInitResult info = await VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create());

            Console.WriteLine(info);

            performanceCounterObservable
            .Monitor("Step 1", 1)
            .Where(v => v.CounterName == "% Processor Time")
            .Monitor("Step 2", 1)
            .Select(m => (int)(m.Value / 10))
            .Select(m => new string('-', m))
            .Subscribe(
                v => Console.WriteLine(v));

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create());

            Console.WriteLine(info.Result);


            Console.ReadKey();
        }
Ejemplo n.º 4
0
        static async Task Main(string[] args)
        {
            var info = await VisualRxSettings.Initialize(VisualRxWcfDiscoveryProxy.Create());

            Console.WriteLine(info);
            var xs = Observable.Interval(TimeSpan.FromSeconds(1))
                     .Monitor("Before", 1)
                     .Select(v => new string('*', (int)(v + 1)))
                     .Monitor("After", 2)
                     .Subscribe(v => Console.Write($"{v},"));

            Console.ReadKey();
        }
Ejemplo n.º 5
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            VisualRxSettings.ClearFilters();

            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create());

            VisualRxInitResult infos = info.Result;

            Trace.WriteLine(infos);
        }
Ejemplo n.º 6
0
        public virtual void TestInitialize()
        {
            VisualRxSettings.ClearFilters();

            ScopeFactory = new TestScopeFactory();
            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create(),
                //VisualRxWcfQueuedProxy.Create(),
                //VisualRxTraceSourceProxy.Create(),
                ScopeFactory);

            VisualRxInitResult infos = info.Result;

            Trace.WriteLine(infos);
        }
Ejemplo n.º 7
0
        public void SplitToDifferentChannel_ByDatumType_Test()
        {
            VisualRxSettings.ClearFilters();

            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create(),
                VisualRxWcfQueuedProxy.Create(),
                VisualRxTraceSourceProxy.Create());

            VisualRxSettings.AddFilter((marble, channelKey) =>
            {
                bool enable = false;
                switch (marble.Name)
                {
                case "Stream A":
                    enable = channelKey == VisualRxWcfDiscoveryProxy.KIND;
                    break;

                case "Stream B":
                    enable = channelKey == VisualRxTraceSourceProxy.KIND;
                    break;

                default:
                    enable = channelKey == VisualRxWcfQueuedProxy.KIND;
                    break;
                }
                return(enable);
            });

            VisualRxInitResult infos = info.Result;

            Trace.WriteLine(infos);

            var xs = Observable.Interval(TimeSpan.FromSeconds(0.5))
                     .Take(10);

            xs = xs.Monitor("Stream A", 1);
            var ys = Observable.Interval(TimeSpan.FromSeconds(1))
                     .Take(10);

            ys = ys.Monitor("Stream B", 2);

            xs.Subscribe();
            //ys.Subscribe();
            ys.Wait();

            GC.KeepAlive(xs);
        }
Ejemplo n.º 8
0
        private static void Main(string[] args)
        {
            TryToOpenViewer();

            var bc = new BlockingCollection <string>();

            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create()//,
                //MonitorWcfQueuedProxy.Create(),
                //VisualRxTraceSourceProxy.Create()
                );

            #region Loaded Proxies Log

            VisualRxInitResult infos = info.Result;
            Console.WriteLine(infos);

            #endregion Loaded Proxies Log

            var surrogate = new MonitorSurrogate <IList <double> >(MarbleSerializationOptions.Serializable);

            var xs = StockProvider()
                     .Buffer(2, 1)
                     .Monitor("Stock", 100, surrogate);

            for (int i = 0; i < 4; i++)
            {
                int local = i;
                var ys    = StockProvider(_rnd.Value.Next(50, 150))
                            .Buffer(2, 1)
                            .Monitor("StockGraph " + local, local, surrogate);
                xs = xs.Merge(ys);
            }
            xs.Subscribe(_ => bc.Add("."));

            foreach (var item in bc.GetConsumingEnumerable())
            {
                Console.Write(item);
            }
            GC.KeepAlive(xs);
        }
Ejemplo n.º 9
0
        public void EnableDisableTest()
        {
            var sync = new ManualResetEventSlim();

            VisualRxSettings.ClearFilters();

            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create());

            VisualRxInitResult infos = info.Result;

            Trace.WriteLine(infos);

            var xs = Observable.Interval(TimeSpan.FromSeconds(0.5))
                     .Take(10);

            xs = xs.Monitor("Enable / Disable", 1);
            xs.Subscribe(
                v => VisualRxSettings.Enable = v < 3 || v > 6,
                () => sync.Set());

            sync.Wait();
            GC.KeepAlive(xs);
        }
Ejemplo n.º 10
0
        private static void Main(string[] args)
        {
            TryToOpenViewer();

            Thread.Sleep(1200);
            Console.WriteLine("Initialize");
            /* Create a ConsoleTraceListener and add it to the trace listeners. */
            var testProxy = MonitorTestProxy.Create();

            VisualRxSettings.CollectMachineInfo = true;
            Task <VisualRxInitResult> info = VisualRxSettings.Initialize(
                VisualRxWcfDiscoveryProxy.Create(),
                //VisualRxWcfFixedAddressProxy.CreateDefaultHttp(Environment.MachineName),
                //VisualRxWcfQueuedProxy.Create(),
                //VisualRxTraceSourceProxy.Create(),
                testProxy);

            #region Loaded Proxies Log

            VisualRxInitResult infos = info.Result;
            Console.WriteLine(infos);

            #endregion Loaded Proxies Log

            // the test proxy will publish only items with "Interval" keyword
            VisualRxSettings.AddFilter((marble, proxyKind) =>
                                       proxyKind != MonitorTestProxy.KIND ||
                                       proxyKind == MonitorTestProxy.KIND &&
                                       marble.Keywords.Contains("Interval"));

            IObservable <string> stream1 = Observable.Return("** 42 **").Monitor("Return", 0.1);
            IObservable <string> stream2 = Observable.Empty <string>().Monitor("Empty", 0.2);
            IObservable <string> stream3 = Observable.Never <string>().Monitor("Never", 0.3);
            IObservable <string> stream4 = Observable.Throw <string>(new Exception()).Monitor("Throw", 0.4);
            IObservable <int>    stream5 = Observable.Generate(0, i => i < 5, i => i + 1, i => i, i => TimeSpan.FromSeconds(i))
                                           .Monitor("Generate", 0.4);

            stream1.Subscribe(Console.WriteLine);
            stream2.Subscribe(Console.WriteLine);
            stream3.Subscribe(Console.WriteLine);
            stream4.Subscribe(Console.WriteLine, ex => Console.WriteLine(ex));
            Thread.Sleep(3000);
            stream5.Subscribe(Console.WriteLine);

            #region Observable.Range

            var rengeStream = Observable.Range(1, 3)
                              .Monitor("Range 3", orderingIndex: 1);

            rengeStream.Subscribe(item => Console.Write("{0},", item), () => Console.WriteLine("Complete"));

            #endregion Observable.Range

            #region 1 sec Interval Take 50

            var srm1 = Observable.Interval(TimeSpan.FromSeconds(1)).Take(50)
                       .Monitor("Sec 1", 2, "Interval", "Merge");
            //srm1.Subscribe(Console.WriteLine);

            #endregion 1 sec Interval Take 50

            #region 3 sec Interval Take 14

            var srm2 = Observable.Interval(TimeSpan.FromSeconds(3))
                       .Take(14)
                       .Monitor("Sec 3", 2, "Interval", "Merge");
            //srm2.Subscribe(Console.WriteLine);

            #endregion 3 sec Interval Take 14

            #region 0.5 sec Interval With befor and after where

            var srm3 = Observable.Interval(TimeSpan.FromSeconds(0.5))
                       .Take(19)
                       .Monitor("Sec 0.5 Before Where", 4, "Interval", "Where")
                       .Where(v => v % 3 == 0)
                       .Monitor("After Where", 5, "Merge", "Where");
            //srm3.Subscribe(Console.WriteLine);

            #endregion 0.5 sec Interval With befor and after where

            #region Merge 1 sec, 3 sec and 0.5 sec Intervals

            Observable.Merge(srm1, srm2, srm3)
            .Monitor("After Merge", 6, "Merge")
            .Subscribe(Console.WriteLine);

            #endregion Merge 1 sec, 3 sec and 0.5 sec Intervals

            #region Observable.Throw

            var srm4 = Observable.Throw <NullReferenceException>(new NullReferenceException())
                       .Monitor("Error", 7);
            srm4.Subscribe(Console.WriteLine, ex => Console.WriteLine("Handle Error: {0}", ex.Message));

            #endregion Observable.Throw

            Thread.Sleep(8000);

            #region Filter test

            bool isIntervalOnly = !testProxy.Data.Any(
                marble => !marble.Keywords.Contains("Interval"));
            if (!isIntervalOnly)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            Console.WriteLine("Test proxy is interval only = {0} / Count = {1}",
                              isIntervalOnly, testProxy.Data.Count());
            Console.ResetColor();

            #endregion Filter test

            #region Stress Test

            for (int i = 0; i < STRESS_MILLISECOND_ITERATIONS; i++)
            {
                var srm5 = Observable.Interval(
                    TimeSpan.FromMilliseconds(STRESS_MILLISECOND),
                    NewThreadScheduler.Default)
                           .Take(STRESS_COUNT)
                           .Monitor("Stress " + i.ToString(), 100 + (i * 0.01), "Stress");
                srm5.Subscribe(Console.WriteLine);
            }

            #endregion Stress Test

            Console.ReadKey();
        }