Пример #1
0
        public static void SetSourceMapping(this ObservableDataSource <HistoryData> source, ITag currentTag)
        {
            if (currentTag != null)
            {
                switch (currentTag.Address.VarType)
                {
                case DataType.BOOL:
                    source.SetYMapping(Y => Y.Value.Boolean ? 1 : 0);
                    break;

                case DataType.BYTE:
                    source.SetYMapping(Y => Y.Value.Byte);
                    break;

                case DataType.WORD:
                case DataType.SHORT:
                    source.SetYMapping(Y => Y.Value.Int16);
                    break;

                case DataType.TIME:
                case DataType.INT:
                    source.SetYMapping(Y => Y.Value.Int32);
                    break;

                case DataType.FLOAT:
                    source.SetYMapping(Y => Y.Value.Single);
                    break;
                }
            }
        }
Пример #2
0
        public void EditGraph()
        {
            ObservableDataSource <Trade> source = new ObservableDataSource <Trade>(_listOfTrade);

            source.SetXMapping(c => c.Counter);
            source.SetYMapping(d => d.Price);

            ObservableDataSource <Trade> sourceMarker = new ObservableDataSource <Trade>(_listMarker);

            sourceMarker.SetXMapping(c => c.Counter);
            sourceMarker.SetYMapping(d => d.Price);

            plotter.AddLineGraph(source, new Pen(Brushes.Gold, 3), new PenDescription("chart"));

            LineAndMarker <MarkerPointsGraph> chartMarkerBuy = plotter.AddLineGraph(
                sourceMarker,
                new Pen(Brushes.Red, 3),
                new TrianglePointMarker {
                Size = 5, Fill = Brushes.Blue
            },
                new PenDescription("marker"));

            //chartMarkerBuy.LineGraph.DataSource = null;

            plotter.Viewport.FitToView();
        }
Пример #3
0
        public WellView()
        {
            InitializeComponent();
            DataContextChanged += new DependencyPropertyChangedEventHandler(WellView_DataContextChanged);
            Loaded             += new RoutedEventHandler(WellView_Loaded);

            SelectedPoint.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
            SelectedPoint.SetYMapping(var => var.Value);

            ObsGraph.MouseLeftButtonDown += new MouseButtonEventHandler(g_MouseLeftButtonDown);

            ObsGraph.AddLineGraph(SelectedPoint, null, new CircleElementPointMarker {
                Size  = 10,
                Brush = Brushes.Red,
                Fill  = Brushes.Orange
            }
                                  , null);

            pens = new Pen[6];

            pens[0] = new Pen(Brushes.Black, 3);
            pens[1] = new Pen(Brushes.Red, 3);
            pens[2] = new Pen(Brushes.Blue, 3);
            pens[3] = new Pen(Brushes.Green, 3);
            pens[4] = new Pen(Brushes.Yellow, 3);
            pens[5] = new Pen(Brushes.Brown, 3);
        }
        private ObservableDataSource <TimeParam> InitSource()
        {
            var source = new ObservableDataSource <TimeParam>();

            source.SetXMapping(x => timeSpanAxis.ConvertToDouble(x.Time));
            source.SetYMapping(y => y.y);
            return(source);
        }
Пример #5
0
        void EditPlotter()
        {
            _source = new ObservableDataSource <Trade>();
            _source.SetXMapping(x => x.Counter);
            _source.SetYMapping(y => y.Price);

            var line = plotter.AddLineGraph(_source,
                                            new Pen(Brushes.Gold, 3),
                                            new PenDescription("Sin(x + phase)"));
        }
Пример #6
0
		void EditPlotter()
		{
			_source = new ObservableDataSource<Trade>();
			_source.SetXMapping(x => x.Counter);
			_source.SetYMapping(y => y.Price);

			var line = plotter.AddLineGraph(_source,
					new Pen(Brushes.Gold, 3),
					new PenDescription("Sin(x + phase)"));
		}
        public void Register(HotItem item, ObservableDataSource <ItemProxy> items)
        {
            items.SetYMapping(y => y.SellPrice);
            items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime));

            ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S");

            chartItems.Add(item.DataId, items);
            item.PropertyChanged += item_PropertyChanged;
        }
        public MainWindow()
        {
            InitializeComponent();
            FillTestData();

            y_valuesDataSource = new ObservableDataSource<int>(y_values);
            y_valuesDataSource.SetYMapping(y => y);

            x_valuesDataSource = new ObservableDataSource<int>(x_values);
            x_valuesDataSource.SetXMapping(x => x);

            var compositeDataSource = new CompositeDataSource(x_valuesDataSource, y_valuesDataSource);

            //chartPlotter.AddLineGraph(compositeDataSource);

            //chartPlotter.Viewport.FlowDirection = FlowDirection.RightToLeft;
            //chartPlotter.Viewport.FitToView();
        }
Пример #9
0
        public DataHandler(Multimeter refer)
        {
            s            = new Stopwatch();
            g            = new Stopwatch();
            multimeter   = refer;
            currentMeter = "DMM " + (multimeter.Index + 1).ToString();

            totalStopWatch = new Stopwatch();
            totalLogTimer  = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                multimeter.overview.ElapsedTimeDisplay.Text = String.Format("{0:hh\\:mm\\:ss}", totalStopWatch.Elapsed);
            }, Application.Current.Dispatcher);

            HorizontalDateTimeAxis axis = multimeter.dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;

            loggedValues = new ObservableDataSource <DatePoint>();
            loggedValues.SetXMapping(p => axis.ConvertToDouble(p.X));
            loggedValues.SetYMapping(p => p.Y);
            graph = multimeter.dynamicChart.AddLineGraph(loggedValues, Colors.Blue, 2, currentMeter);
        }
Пример #10
0
        private void ChkItemRecord_OnChecked(object sender, RoutedEventArgs e)
        {
            ToggleButton chkSelecttedItem = (ToggleButton)sender;

            if (chkSelecttedItem.Content != null)
            {
                string nameLine = chkSelecttedItem.Tag.ToString();
                var    source   = new ObservableDataSource <PointsGraph>();
                source.SetXMapping(x => SpanAxis.ConvertToDouble(x.TimeG));
                source.SetYMapping(y => y.PointG);
                var uid = ((string)chkSelecttedItem.Uid).Split('.').Last();
                _lstGraph.Add(new GraphInfo
                {
                    LineGraph = Plotter.AddLineGraph(source, 2, nameLine),
                    Source    = source,
                    Uid       = uid
                });
                AddToLog("Отображен график: " + nameLine);
            }
        }
Пример #11
0
        private void AddNewTab(int index = 1)
        {
            TabItem t = new TabItem();

            MultimeterTabs.Items.Insert(index, t);
            Multimeter multimeter = new Multimeter(this, t, MultimeterTabs, multimeters.Count);

            multimeters.Add(multimeter);
            t.Content = multimeter;
            MultimeterTabs.SelectedIndex = index;

            HorizontalDateTimeAxis           axis   = dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;
            ObservableDataSource <DatePoint> values = new ObservableDataSource <DatePoint>();

            values.SetYMapping(p => p.Y);
            values.SetXMapping(p => axis.ConvertToDouble(p.X));
            points.Add(values);
            graphs.Add(dynamicChart.AddLineGraph(values, 2, multimeter.handler.currentMeter));
            multimeter.graph = graphs.Last <LineGraph>();
        }
Пример #12
0
		public void EditGraph()
		{
			ObservableDataSource<Trade> source = new ObservableDataSource<Trade>(_listOfTrade);
			source.SetXMapping(c => c.Counter);
			source.SetYMapping(d => d.Price);

			ObservableDataSource<Trade> sourceMarker = new ObservableDataSource<Trade>(_listMarker);
			sourceMarker.SetXMapping(c => c.Counter);
			sourceMarker.SetYMapping(d => d.Price);

			plotter.AddLineGraph(source, new Pen(Brushes.Gold, 3), new PenDescription("chart"));

			LineAndMarker<MarkerPointsGraph> chartMarkerBuy = plotter.AddLineGraph(
				sourceMarker,
				new Pen(Brushes.Red, 3),
				new TrianglePointMarker { Size = 5, Fill = Brushes.Blue },
				new PenDescription("marker"));
			//chartMarkerBuy.LineGraph.DataSource = null;

			plotter.Viewport.FitToView();
		}
Пример #13
0
        public EssaiChrono(InputOutput io)
        {
            InitializeComponent();
            p.Children.Remove(p.MouseNavigation);
            p.Children.Remove(p.HorizontalAxisNavigation);
            p.Children.Remove(p.VerticalAxisNavigation);
            p.Children.Remove(p.KeyboardNavigation);

            xMin      = d.ConvertToDouble(new TimeSpan(0));
            startXMax = d.ConvertToDouble(new TimeSpan(0, 0, a));
            p.Visible = new Rect {
                X = xMin, Width = startXMax - xMin, Y = startYMin, Height = startYMax - startYMin
            };
            p.AxisGrid.Visibility           = Visibility.Hidden;
            p.MainHorizontalAxis.Visibility = Visibility.Hidden;
            p.MainVerticalAxis.Visibility   = Visibility.Hidden;
            dataSource.SetXMapping(model => d.ConvertToDouble(model.interval));
            dataSource.SetYMapping((model) => { if (model.Value == true)
                                                {
                                                    return(1);
                                                }
                                                else
                                                {
                                                    return(0);
                                                } });

            //Bind the data with the graph
            chrono.DataSource = dataSource;

            //Labels
            if (io.Parent != null)
            {
                Legend.SetDescription(chrono, io.getEtiquette() + "_" + (((io.Parent as Grid).Parent as Canvas).Parent as Gate).outil.getLabel());
            }

            this.io     = io;
            Stop        = true;
            DataContext = this;
        }
Пример #14
0
        public void UpdateUi()
        {
            var bar = Context.TargetElement;

            for (var i = plotter.Children.Count - 1; i >= 0; i--)
            {
                if (plotter.Children[i] is LineGraph)
                {
                    plotter.Children.RemoveAt(i);
                }
            }

            if (bar == null)
            {
                return;
            }

            var elementDiscPonits = Context.TargetElement.GetInternalForceDiscretationPoints(Context.SelectedLoadCase).Select(i => i.Xi).ToArray();

            var samples = 100;

            var lst = new List <double>(elementDiscPonits);

            //remove discrete points and add a little before and after

            var eps = 1e-10;

            foreach (var discPonit in elementDiscPonits)
            {
                lst.Add(discPonit - eps);
                lst.Add(discPonit + eps);
            }

            for (int i = 0; i <= samples; i++)
            {
                var c = i * 1.0 / samples;

                var xi = c * 2 - 1;

                lst.Add(xi);
            }

            var l2 = lst.Where(i => i >= -1 && i <= 1).Where(i => !elementDiscPonits.Contains(i)).Distinct().ToArray();

            Array.Sort(l2);

            var pts = new List <Point>();

            var lc = Context.SelectedLoadCase;

            for (var i = 0; i < l2.Length; i++)
            {
                var xi = l2[i];
                var x  = Context.TargetElement.IsoCoordsToLocalCoords(xi)[0];

                Force frc;

                if (Context.Type == BarInternalForceContext.ForceType.Approximate)
                {
                    frc = bar.GetInternalForceAt(xi, lc);
                }
                else
                {
                    frc = bar.GetExactInternalForceAt(xi, lc);
                }

                var y = 0.0;

                switch (Context.Component)
                {
                case BarInternalForceContext.ForceComponent.Fx:
                    y = frc.Fx;
                    break;

                case BarInternalForceContext.ForceComponent.Fy:
                    y = frc.Fy;
                    break;

                case BarInternalForceContext.ForceComponent.Fz:
                    y = frc.Fz;
                    break;

                case BarInternalForceContext.ForceComponent.Mx:
                    y = frc.Mx;
                    break;

                case BarInternalForceContext.ForceComponent.My:
                    y = frc.My;
                    break;

                case BarInternalForceContext.ForceComponent.Mz:
                    y = frc.Mz;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                pts.Add(new Point(x, y, 0));
            }

            var src = new ObservableDataSource <Point>(pts);

            src.SetXMapping(i => i.X);
            src.SetYMapping(i => i.Y);


            var gr = new LineGraph(src);

            gr.Stroke          = Brushes.Black;
            gr.StrokeThickness = 2;
            gr.Name            = Context.Component.ToString();

            plotter.Children.Add(gr);
            //plotter.AddLineGraph(src, Colors.Black, 2, Context.Component.ToString());
            Microsoft.Research.DynamicDataDisplay.Charts.Legend.SetDescription(gr, Context.Component.ToString());
        }
        public void Register(HotItem item, ObservableDataSource<ItemProxy> items)
        {
            items.SetYMapping(y => y.SellPrice);
            items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime));

            ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S");

            chartItems.Add(item.DataId, items);
            item.PropertyChanged += item_PropertyChanged;
        }
        public void UpdateUi()
        {
            //plotter.Children.Clear();


            for (var i = plotter.Children.Count - 1; i >= 0; i--)
            {
                if (plotter.Children[i] is LineGraph)
                {
                    plotter.Children.RemoveAt(i);
                }
            }

            if (Min >= Max)
            {
                return;
            }

            if (SamplingCount < 2)
            {
                return;
            }

            if (TargetFunction == null)
            {
                return;
            }

            var vals = new List <double>();

            var delta = (Max - Min) / (SamplingCount - 1);

            for (var i = 0; i < SamplingCount; i++)
            {
                vals.Add(Min + i * delta);
            }

            var pts = new List <Tuple <double, double> >();
            var fnc = TargetFunction;

            foreach (var val in vals)
            {
                pts.Add(Tuple.Create(val, fnc(val)));
            }

            var src = new ObservableDataSource <Tuple <double, double> >(pts);

            src.SetXMapping(i => i.Item1);
            src.SetYMapping(i => i.Item2);

            var thickNess = 2.0;
            var pen       = new Pen(new SolidColorBrush(GraphColor), thickNess);

            if (string.IsNullOrEmpty(VerticalAxisLabel))
            {
                plotter.AddLineGraph(src, GraphColor, thickNess);
            }
            else
            {
                plotter.AddLineGraph(src, pen, new StandardDescription(VerticalAxisLabel == null ? "" : VerticalAxisLabel));
            }


            var src2 = new ObservableDataSource <Tuple <double, double> >(pts);

            src2.SetXMapping(i => i.Item1);
            src2.SetYMapping(i => 0);

            plotter.AddLineGraph(src2);
        }
Пример #17
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (_ping == null)
            {
                Debug.Assert(_plotterChildren == null);
                Debug.Assert(_ds == null);
                try
                {
                    var host = (tbHost.Text ?? string.Empty).Trim();
                    if (string.IsNullOrWhiteSpace(host))
                    {
                        throw new ArgumentException("Host can not be empty.");
                    }
                    var interval = TimeSpan.Parse((tbInterval.Text ?? string.Empty));
                    if (interval <= TimeSpan.Zero)
                    {
                        throw new ArgumentException("Interval must be greater than zero.");
                    }
                    var timeout = TimeSpan.Parse((tbTimeout.Text ?? string.Empty));
                    if (timeout <= TimeSpan.Zero)
                    {
                        throw new ArgumentException("Timeout must be greater than zero.");
                    }
                    _ping = new PingClient(host, interval, timeout);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                _ds = new ObservableDataSource<PingResult>();
                _ping.PingTick += PingOnPingTick;
                //_ping.PingException += PingOnPingException;
                _ds.SetXMapping(item => dateAxis.ConvertToDouble(item.DateTime));
                _ds.SetYMapping(item => item.TimeCost.TotalMilliseconds);
                _plotterChildren = new IPlotterElement[]
                {
                    new LineGraph(_ds)
                    {
                        LinePen = new Pen(new SolidColorBrush(Colors.Green), 2),
                        Description = new PenDescription(_ping.Host)
                    },
                    new MarkerPointsGraph(_ds) {Marker = new CirclePointMarker {Size = 5}}
                };
                foreach (var child in _plotterChildren)
                {
                    plotter.AddChild(child);
                }

                Header.Content = string.Format("Ping {0}", _ping.Host);
            }
            _ping.Start();

            btnStart.IsEnabled = false;
            btnPause.IsEnabled = true;
            pnSettings.IsEnabled = false;
        }