Ejemplo n.º 1
0
        private void Simulation()
        {
            CultureInfo culture           = CultureInfo.InvariantCulture;
            Assembly    executingAssembly = Assembly.GetExecutingAssembly();
            // load spim-generated data from embedded resource file
            const string spimDataName = "Microsoft.Research.DynamicDataDisplay.Samples.Demos.v03.Repressilator.txt";

            using (Stream spimStream = executingAssembly.GetManifestResourceStream(spimDataName))
            {
                using (StreamReader r = new StreamReader(spimStream))
                {
                    string line = r.ReadLine();
                    while (!r.EndOfStream)
                    {
                        line = r.ReadLine();
                        string[] values = line.Split(',');

                        double x  = Double.Parse(values[0], culture);
                        double y1 = Double.Parse(values[1], culture);
                        double y2 = Double.Parse(values[2], culture);
                        double y3 = Double.Parse(values[3], culture);

                        Point p1 = new Point(x, y1);
                        Point p2 = new Point(x, y2);
                        Point p3 = new Point(x, y3);

                        source1.AppendAsync(Dispatcher, p1);
                        source2.AppendAsync(Dispatcher, p2);
                        source3.AppendAsync(Dispatcher, p3);

                        Thread.Sleep(10);                         // Long-long time for computations...
                    }
                }
            }
        }
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         planeLocations.AppendAsync(Dispatcher, new Point(flightboardVM.Lat, flightboardVM.Lon));
     }
 }
 // If the changed property is lon or lat add the new point after travel to the collection.
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lon") || e.PropertyName.Equals("Lat"))
     {
         coordinates.AppendAsync(Dispatcher, new Point(viewModel.Lat, viewModel.Lon));
     }
 }
Ejemplo n.º 4
0
 public void AddMessage(Message m, Color c)//显示曲线
 {
     if (c == Colors.Green)
     {
         Message message = SimulateCalculate.EveryHourCalculate(m);
         dataSource1.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Temp));
         dataSource2.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Wind));
         dataSource3.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Visible));
         dataSource4.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Press));
         dataSource5.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Humi));
         dataSource6.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Apptemp));
         dataSource13.AppendAsync(base.Dispatcher, new Point(message.Hour, message.Windbear));
         TimeSpan span    = new TimeSpan(message.Hour / 24, message.Hour % 24, 0, 0);
         DateTime newDate = datetime + span;
         beyond.Text = newDate.ToString("yyyy-MM-dd HH:mm:ss");
         //加入数据库并显示历史记录
         Dao.InsertQuestionData(message);
         messageData.Add(message);
         messageData          = new ObservableCollection <Message>(messageData.OrderBy(item => item.Hour));
         dataGrid.DataContext = messageData;
     }
     else
     {
         dataSource7.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Temp));
         dataSource8.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Wind));
         dataSource9.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Visible));
         dataSource10.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Press));
         dataSource11.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Humi));
         dataSource12.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Apptemp));
         dataSource14.AppendAsync(base.Dispatcher, new Point(m.Hour, m.Windbear));
         TimeSpan span    = new TimeSpan(m.Hour / 24, m.Hour % 24, 0, 0);
         DateTime newdate = datetime + span;
         now.Text = newdate.ToString("yyyy-MM-dd HH:mm:ss");
     }
 }
Ejemplo n.º 5
0
        private void AreaDetection()
        {
            double shortSum = 0, longSum = 0, shortAve, longAve;

            for (int j = i; j > (i - shortNum + 1); j--)
            {
                double slope     = (data[j, 1] - data[j - 1, 1]) / (data[j, 0] - data[j - 1, 0]);
                double intercept = data[j, 1] - slope * data[j, 0];
                var    result1   = Integrate.OnClosedInterval(x => slope * x + intercept, data[j - 1, 0], (data[j, 0]));

                shortSum += Math.Abs(result1);
            }
            for (int j = i; j > (i - longNum + 1); j--)
            {
                double slope     = (data[j, 1] - data[j - 1, 1]) / (data[j, 0] - data[j - 1, 0]);
                double intercept = data[j, 1] - slope * data[j, 0];
                var    result2   = Integrate.OnClosedInterval(x => slope * x + intercept, data[j - 1, 0], (data[j, 0]));

                longSum += Math.Abs(result2);
            }
            shortAve = shortSum / shortNum;
            longAve  = longSum / longNum;

            if (Math.Abs((shortAve - longAve) / longAve) > ArgDetect)
            {
                Point point = new Point();
                point = new Point(data[i, 0], data[i, 1]);
                dataSource2.AppendAsync(base.Dispatcher, point);
                flag = 2;
            }
        }
Ejemplo n.º 6
0
        private void AnimatedLine(object sender, EventArgs e)
        {
            var      model = dataModel;
            DateTime dt    = DateTime.Now;

            if (!string.IsNullOrEmpty(model.ThisWeekSubResult))
            {
                double y = Math.Round(double.Parse(model.ThisWeekSubResult.Split(' ')[0]));
                dataSourceThisWeek.AppendAsync(this.Dispatcher, new KeyValuePair <DateTime, double>(dt, y));
            }

            if (!string.IsNullOrEmpty(model.NextWeekSubResult))
            {
                double y = Math.Round(double.Parse(model.NextWeekSubResult.Split(' ')[0]));
                dataSourceNextWeek.AppendAsync(this.Dispatcher, new KeyValuePair <DateTime, double>(dt, y));
            }

            if (!string.IsNullOrEmpty(model.QuarterSubResult))
            {
                double y = Math.Round(double.Parse(model.QuarterSubResult.Split(' ')[0]));
                dataSourceQuarter.AppendAsync(this.Dispatcher, new KeyValuePair <DateTime, double>(dt, y));
            }

            if (model.LatestIndex != null)
            {
                double y = Math.Round(double.Parse(model.LatestIndex.futureIndex));
                dataSourceIndex.AppendAsync(this.Dispatcher, new KeyValuePair <DateTime, double>(dt, y));
            }
        }
Ejemplo n.º 7
0
        //接收实时采样数据
        private void MyPort_sampleDataReceived(object sender, EventArgs e)
        {
            if (!myPort.IsOpen)
            {
                return;
            }

            try
            {
                //读取44个字节
                byte[] Redata = new byte[44];
                myPort.Read(Redata, 0, 44);

                //提取数据,并赋给数据源
                Point point  = new Point();
                Point point1 = new Point();
                for (i = 3; i < 22; i += 2)       //第3位到42位为采样数据,每次递增2
                {
                    data1 = (Redata[i] << 8) + Redata[i + 1];
                    data2 = (Redata[i + 20] << 8) + Redata[i + 21];

                    point  = new Point(k, data1);
                    point1 = new Point(k, data2);
                    dataSource.AppendAsync(base.Dispatcher, point);
                    dataSource1.AppendAsync(base.Dispatcher, point1);
                    k++;
                }


                if (k - group > 0)     //x轴移动
                {
                    xaxis = k - group;
                }
                else
                {
                    xaxis = 0;
                }

                //X轴动态显示,Y轴范围在全局变量定义中设置
                plotter.Viewport.Visible  = new System.Windows.Rect(xaxis, ymin - 0.2 * Math.Abs(ymax - ymin), group, 1.4 * (ymax - ymin));
                plotter1.Viewport.Visible = new System.Windows.Rect(xaxis, ymin1 - 0.2 * Math.Abs(ymax1 - ymin1), group, 1.4 * (ymax1 - ymin1));

                //删除数据源中1000个以前的历史数据
                int m = dataSource.Collection.Count;

                if (m / 1000 > 0)
                {
                    for (int ii = (m - 1000); ii >= 0; ii--)
                    {
                        dataSource.Collection.RemoveAt(ii);
                        dataSource1.Collection.RemoveAt(ii);
                    }
                }
            }
            catch (Exception err1)
            {
                MessageBox.Show(err1.Message);
            }
        }
Ejemplo n.º 8
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lon") || e.PropertyName.Equals("Lat"))
     {
         Point p1 = new Point(this.flightBoardVM.Lon, this.flightBoardVM.Lat);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 9
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("/position/latitude-deg") || e.PropertyName.Equals("/position/longitude-deg"))
     {
         Point p1 = new Point(vm.Lat, vm.Lon);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 10
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point p1 = new Point((double)this.flightViewModel.Lat, (double)this.flightViewModel.Lon);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 11
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point p1 = new Point(((FlightBoardViewModel)sender).Lat, ((FlightBoardViewModel)sender).Lon);          // Fill here!
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 12
0
 /*
  * If a property with one of the names specified changes-
  * write the new point on the FlightBoard.
  * */
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if ((e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon")) && (viewModel.Lat != 0 && viewModel.Lon != 0))
     {
         Point p1 = new Point(viewModel.Lat, viewModel.Lon);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 13
0
 public void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point p1 = new Point(FlightBoardViewModel.Instance.Lat, FlightBoardViewModel.Instance.Lon);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 14
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point p1 = new Point(0, 0);            // Fill here!
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 15
0
 private void InitDataSource()
 {
     dataSource = new ObservableDataSource <Point>();
     for (int _ = 0; _ < TIMESPAN; ++_)
     {
         dataSource.AppendAsync(base.Dispatcher, new Point(0, 0));
     }
 }
Ejemplo n.º 16
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point point = new Point(this.viewModel.Lat, this.viewModel.Lon);
         planeLocations.AppendAsync(Dispatcher, point);
     }
 }
Ejemplo n.º 17
0
        public void UpdateData(UInt64 time, EngineNS.Profiler.PerfViewer.PfValue_PerfCounter value)
        {
            if (value == null)
            {
                return;
            }
            //var view = CCore.Game.PerformanceViewManager.Instance.GetPerformanceView(ItemName, InheritName);
            //if (view == null)
            //    return;

            //var datas = view.GetData();
            //double value = 0;
            //foreach(var data in datas)
            //{
            //    var dataType = data.GetType();
            //    if(dataType == typeof(sbyte) ||
            //       dataType == typeof(Int16) ||
            //       dataType == typeof(Int32) ||
            //       dataType == typeof(Int64) ||
            //        dataType == typeof(byte) ||
            //        dataType == typeof(UInt16) ||
            //        dataType == typeof(UInt32) ||
            //        dataType == typeof(UInt64) ||
            //        dataType == typeof(Single) ||
            //        dataType == typeof(Double))
            //    {
            //        value = System.Convert.ToDouble(data);
            //        break;
            //    }
            //}

            AvgTime = value.AvgTime;
            AvgHit  = value.AvgHit;

            EngineNS.CEngine.Instance.EventPoster.RunOn(() =>
            {
                mAvgTimeDataSource.AppendAsync(Application.Current.MainWindow.Dispatcher, new Point(time, value.AvgTime));
                mAvgCounterDataSource.AppendAsync(Application.Current.MainWindow.Dispatcher, new Point(time, value.AvgHit));
                return(true);
            }, EngineNS.Thread.Async.EAsyncTarget.Editor);
            //Application.Current.MainWindow.Dispatcher.BeginInvoke(new Action(() =>
            //{
            //    mAvgTimeDataSource.AppendAsync(Application.Current.MainWindow.Dispatcher, new Point(time, value.AvgTime));
            //    mAvgCounterDataSource.AppendAsync(Application.Current.MainWindow.Dispatcher, new Point(time, value.AvgHit));
            //}));
        }
Ejemplo n.º 18
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("VM_Lat") || e.PropertyName.Equals("VM_Lon"))
     {
         Point p1 = new Point(vm.VM_Lat, vm.VM_Lon);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Property changed event.
 /// </summary>
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         //Create new points and plot it asynchronously.
         Point p1 = new Point(vm.Lon, vm.Lat);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         Point p = new Point(vm.Lat, vm.Lon);
         //Debug.WriteLine(p.ToString());
         planeLocations.AppendAsync(Dispatcher, p);
     }
 }
Ejemplo n.º 21
0
        void UpdateChart()
        {
            RecCount.Text = (Rec_count).ToString();
            double x     = Rec_count;
            double y     = Rec_Data;
            Point  point = new Point(x, y);

            dataSource.AppendAsync(base.Dispatcher, point);
        }
Ejemplo n.º 22
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     // In event check if property changes fit, is so add plane location.
     if (e.PropertyName.Equals("VM_Lat") || e.PropertyName.Equals("VM_Lon"))
     {
         // Add point to collection.
         planeLocations.AppendAsync(Dispatcher, new Point(vm.Lat, vm.Lon));
     }
 }
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("VM_Lat") || e.PropertyName.Equals("VM_Lon"))
     {
         // Create a point based on the values received from the simulator and draw it on the path board
         Point p = new Point(vm.VM_Lat, vm.VM_Lon);
         planeLocations.AppendAsync(Dispatcher, p);
     }
 }
Ejemplo n.º 24
0
        public void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var Sender = sender as FlightBoardViewModel;

            if (Sender != null)
            {
                planeLocations.AppendAsync(Dispatcher, Sender.LonAndLat);
            }
        }
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
     {
         var   vm = sender as FlightBoardViewModel;
         Point p1 = new Point(vm.Lon, vm.Lat);
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
        private void Timer_Tick_CPU(object sender, EventArgs e)
        {
            performanceCounter.CategoryName = "Processor";
            performanceCounter.CounterName  = "% Processor Time";
            performanceCounter.InstanceName = "_Total";

            double x = currentSecond;
            double y = performanceCounter.NextValue();

            Point point = new Point(x, y);

            dataSource.AppendAsync(base.Dispatcher, point);

            if (rock)
            {
                if (q.Count < group)
                {
                    q.Enqueue((int)y);//入队
                    yaxis = 0;
                    foreach (int c in q)
                    {
                        if (c > yaxis)
                        {
                            yaxis = c;
                        }
                    }
                }
                else
                {
                    q.Dequeue();       //出队
                    q.Enqueue((int)y); //入队
                    yaxis = 0;
                    foreach (int c in q)
                    {
                        if (c > yaxis)
                        {
                            yaxis = c;
                        }
                    }
                }

                if (currentSecond - group > 0)
                {
                    xaxis = currentSecond - group;
                }
                else
                {
                    xaxis = 0;
                }

                Debug.Write("yaxis = " + yaxis.ToString());
                plotter.Viewport.Visible = new System.Windows.Rect(xaxis, 0, group, 108);//主要注意这里一行
            }

            currentSecond++;
        }
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon") && (vm.Lat != 0 && vm.Lon != 0))
     {
         //create point form the lat and the lon that get from the flight gear
         Point p1 = new Point(vm.Lat, vm.Lon);
         //draw the road for the new position
         planeLocations.AppendAsync(Dispatcher, p1);
     }
 }
Ejemplo n.º 28
0
        //非白色,最大曲线
        public void DrawNotWhiteLightMaximum()
        {
            graphNotWhiteLightMaximum = DimmingCurveChart.AddLineGraph(DataSourceNotWhiteLightMaximum, Colors.Red, 2, "最大值");

            for (int i = 0; i < 41; i++)
            {
                Point point = new Point(CurrentArray[i], PercentageNotWhiteLightMaximumArray[i]);
                DataSourceNotWhiteLightMaximum.AppendAsync(base.Dispatcher, point);
            }
        }
Ejemplo n.º 29
0
 private void AppendSpeedSource(MainDevDataContains container_1, SliverDataContainer container_2, SliverDataContainer container_3, SliverDataContainer container_4, SliverDataContainer container_5, MainDevDataContains container_6)
 {
     speed1.AppendAsync(base.Dispatcher, new Point(x, (container_1.SpeedA1Shaft1 + container_1.SpeedA1Shaft2) / 2));
     speed2.AppendAsync(base.Dispatcher, new Point(x, (container_2.SpeedShaft1 + container_2.SpeedShaft2) / 2));
     speed3.AppendAsync(base.Dispatcher, new Point(x, (container_3.SpeedShaft1 + container_3.SpeedShaft2) / 2));
     speed4.AppendAsync(base.Dispatcher, new Point(x, (container_4.SpeedShaft1 + container_4.SpeedShaft2) / 2));
     speed5.AppendAsync(base.Dispatcher, new Point(x, (container_5.SpeedShaft1 + container_5.SpeedShaft2) / 2));
     speed6.AppendAsync(base.Dispatcher, new Point(x, (container_6.SpeedA1Shaft1 + container_6.SpeedA1Shaft2) / 2));
     refSpeed.AppendAsync(base.Dispatcher, new Point(x, container_1.RefSpeed));
 }
Ejemplo n.º 30
0
 private void AnimatedLine(object sender, EventArgs e)
 {
     //定时更新数据
     if (viewModel.PriceTradeQuarter != 0 && viewModel.PriceBitMexTrade != 0)
     {
         double subResult = viewModel.PriceTradeQuarter - viewModel.PriceBitMexTrade;
         dataSourceSubMix.AppendAsync(this.Dispatcher, new KeyValuePair <DateTime, double>(DateTime.Now, subResult));
         App.Log.LogInfo("季度升贴水:" + subResult);
     }
 }
Ejemplo n.º 31
0
        private void run()
        {
            var lens = new LensCompiler();

            var currX = getDouble(StartPos, -10);
            var endX = getDouble(EndPos, 10);
            var currY = 0.0;
            var step = getDouble(Step, 0.1);

            var obs = new ObservableDataSource<Point>();
            obs.SetXYMapping(p => p);

            if (m_PreviousGraph != null)
                m_PreviousGraph.Remove();

            m_PreviousGraph = Chart.AddLineGraph(obs, Colors.Green, 2, "Graph");

            lens.RegisterProperty("x", () => currX);
            lens.RegisterProperty("y", () => currY, y => currY = y);

            try
            {
                var fx = lens.Compile(Func.Text);

                while (currX < endX)
                {
                    fx();
                    obs.AppendAsync(Chart.Dispatcher, new Point(currX, currY));
                    currX += step;
                }
            }
            catch (LensCompilerException ex)
            {
                MessageBox.Show(
                    ex.FullMessage,
                    "Compilation Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                );
            }
        }
Ejemplo n.º 32
0
        public void lineDisplay(int node)
        {
            nowTextBlock.Text = DateTime.Now.ToShortDateString();

            DataTable dataTable = new DataTable();
            dbTool.getNodeTeperature(DateTime.Now.ToShortDateString(), node, out dataTable);

            // 将dataTable中的temperature加入到datasource
            plotter.Children.Remove(graphTemperature);
            dataSource = new ObservableDataSource<Point>();
            graphTemperature = plotter.AddLineGraph(dataSource, Colors.Green, 2, "结点"+node.ToString());
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                float temperature = float.Parse(dataTable.Rows[i].ItemArray[1].ToString());
                //Console.WriteLine("{0}", temperature);
                dataSource.AppendAsync(base.Dispatcher, new Point(i, temperature));
            }
        }
Ejemplo n.º 33
0
 public void set_scale()
 {
     if (point_treshold != null)
     {
         if (point_treshold.DataSource != null)
             point_treshold.DataSource = null;
     }
     source_temp_1 = new ObservableDataSource<Point>();
     Point p_temp = new Point(t_treshold, F_treshold);
     source_temp_1.AppendAsync(dp_test, p_temp);
     point_treshold = plotter.AddLineGraph(source_temp_1, 0);
 }
Ejemplo n.º 34
0
        public void plot_measured_data()
        {
            int buffer_length = count_channel_2;
            count_channel_1 = 0;
            count_channel_2 = 0;

            // Create first source
            source1 = new ObservableDataSource<Point>();
            // Set identity mapping of point in collection to point on plot
            source1.SetXYMapping(p => p);
            // Create second source
            source2 = new ObservableDataSource<Point>();
            // Set identity mapping of point in collection to point on plot
            source2.SetXYMapping(p => p);
            // Create third source
            source3 = new ObservableDataSource<Point>();
            // Set identity mapping of point in collection to point on plot
            source3.SetXYMapping(p => p);
            // Add all three graphs. Colors are not specified and chosen random
            chart_line_source_1 = plotter.AddLineGraph(source1, Color.FromRgb(12, 0, 4), 2, "Измерения");
            //plotter.AddLineGraph(source2, 2, "Шаблон");
            ObservableDataSource<Point> source_temp = new ObservableDataSource<Point>();
            Point p_temp = new Point(30, 210);
            source_temp.AppendAsync(dp_test, p_temp);
            plotter.AddLineGraph(source_temp, 0);

            double x_1 = 0;
            double y_1 = 0;
            double x_2 = 0;
            double y_2 = 0;
            for (int i = 1; i < buffer_length; i++)
            {
                x_1 = (float)timeCoordinate[i - 1];
                y_1 = (float)channel_1[i - 1];
                x_2 = (float)timeCoordinate[i - 1];
                y_2 = (float)channel_2[i - 1];

                Point p1 = new Point(x_2, y_2);
                Point p2 = new Point(x_1, y_1);

                source1.AppendAsync(dp_test, p1);
                source2.AppendAsync(dp_test, p2);
            }
            count_channel_1 = buffer_length;
            count_channel_2 = buffer_length;
        }
Ejemplo n.º 35
0
        // 查询
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string strDate = date.Text.ToString();
            nowTextBlock.Text = strDate;
            nowText = strDate;

            DataTable dataTable = new DataTable();
            dbTool.getNodeTeperature(strDate, this.node, out dataTable);

            // 将dataTable中的temperature加入到datasource
            plotter.Children.Remove(graphTemperature);
            dataSource = new ObservableDataSource<Point>();
            graphTemperature = plotter.AddLineGraph(dataSource, Colors.Green, 2, "结点"+this.node.ToString());
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                float temperature = float.Parse(dataTable.Rows[i].ItemArray[1].ToString());
                //Console.WriteLine("{0}", temperature);
                dataSource.AppendAsync(base.Dispatcher, new Point(i, temperature));
            }
        }
Ejemplo n.º 36
0
        public void StartPlotter()
        {
            try
                {
                    // Create first source
                    source1 = new ObservableDataSource<Point>();
                    // Set identity mapping of point in collection to point on plot
                    source1.SetXYMapping(p => p);
                    // Create second source
                    source2 = new ObservableDataSource<Point>();
                    // Set identity mapping of point in collection to point on plot
                    source2.SetXYMapping(p => p);
                    // Create third source
                    source3 = new ObservableDataSource<Point>();
                    // Set identity mapping of point in collection to point on plot
                    source3.SetXYMapping(p => p);
                    // Create third source
                    source4 = new ObservableDataSource<Point>();
                    // Set identity mapping of point in collection to point on plot
                    source4.SetXYMapping(p => p);
                    // Add all three graphs. Colors are not specified and chosen random
                    chart_line_source_1 = plotter.AddLineGraph(source1, Color.FromRgb(12, 0, 4), 2, "Измерения");
                    chart_line_source_2 = plotter.AddLineGraph(source2, 2, "Шаблон");
                    if (TRAIN_FLAG)
                    {
                        plot_template();
                    }
                    {
                        temp_x[0] = 0;
                        temp_y[0] = 0;
                    }
                    if (TRAIN_FLAG || PRECALIBRATE_FLAG)
                    {
                        EnumerableDataSource<float> xSrc = new EnumerableDataSource<float>(temp_x);
                        xSrc.SetXMapping(x => x);
                        animatedDataSource = new EnumerableDataSource<float>(temp_y);
                        animatedDataSource.SetYMapping(y => y);
                        // Adding graph to plotter
                        plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
                              new Pen(Brushes.Magenta, 3),
                              new Microsoft.Research.DynamicDataDisplay.PointMarkers.CirclePointMarker
                              {
                                  Size = 10,
                                  Fill = Brushes.Orange
                              },
                              new PenDescription("Sin(x + phase)"));
                        ObservableDataSource<Point> source_temp_1 = new ObservableDataSource<Point>();
                        Point p_temp_1 = new Point(0, 0);
                        source_temp_1.AppendAsync(dp_test, p_temp_1);
                        plotter.AddLineGraph(source_temp_1, 0);
                    }
                    ObservableDataSource<Point> source_temp = new ObservableDataSource<Point>();
                    Point p_temp = new Point(pattern.time_axis, program_settings.f_max * 1.25);
                    source_temp.AppendAsync(dp_test, p_temp);
                    plotter.AddLineGraph(source_temp, 0);

                    simThread = new Thread(new ThreadStart(Simulation));
                    simThread.IsBackground = true;
                    simThread.Start();
                }
               catch (Exception ex)
                {
                    string messageBoxText = ex.ToString();
                    string caption = "Error";
                    MessageBoxButton button = MessageBoxButton.YesNoCancel;
                    MessageBoxImage icon = MessageBoxImage.Warning;
                    MessageBox.Show(messageBoxText, caption, button, icon);
                }
        }