private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // 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
            plotter.AddLineGraph(source1, 2, "Data row 1");
            plotter.AddLineGraph(source2, 2, "Data row 2");
            plotter.AddLineGraph(source3, 2, "Data row 3");

            // Start computation process in second thread
            Thread simThread = new Thread(new ThreadStart(Simulation));
            simThread.IsBackground = true;
            simThread.Start();
        }
        public MainWindow()
        {
            InitializeComponent();

            // Create first source
            source1 = new ObservableDataSource<Point>();
            // Set identity mapping of point in collection to point on plot
            source1.SetXYMapping(p => p);

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

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

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

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

            // Add all three graphs. Colors are not specified and chosen random
            graphT = plotterT.AddLineGraph(source1, Colors.Red, 2, "TEMP");
            graphH = plotterH.AddLineGraph(source2, Colors.Green, 2, "HUM");
            graphD = plotterD.AddLineGraph(source3, Colors.Blue, 2, "DUST");
            graphP = plotterP.AddLineGraph(source4, Colors.DarkSeaGreen, 2, "PRESS");
            graphACC = plotterACC.AddLineGraph(source5, Colors.CadetBlue, 2, "ACC");

            //timer.Tick += new EventHandler(timer_Tick);//Alarm Signal lamp flicker
            //timer.Interval = new TimeSpan(1000);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            planeLocations = new ObservableDataSource <Point>();
            // Set identity mapping of point in collection to point on plot
            planeLocations.SetXYMapping(p => p);

            plotter.AddLineGraph(planeLocations, 2, "Route");
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Glass.ExtendGlassFrame(this);
     ValidationPlot.SetXYMapping(p => p);
     TrainingPlot.SetXYMapping(p => p);
     plotter.AddLineGraph(ValidationPlot, new Pen(Brushes.DarkBlue, 2.0), new PenDescription("Validation Error"));
     plotter.AddLineGraph(TrainingPlot, new Pen(Brushes.DarkGreen, 2.0), new PenDescription("Training Error"));
     New();
 }
Exemple #5
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            planeLocations = new ObservableDataSource <Point>();
            // Set identity mapping of point in collection to point on plot
            planeLocations.SetXYMapping(p => p);

            plotter.AddLineGraph(planeLocations, 2, "Route");
            //Subscribe to event changes for points.
            vm.PropertyChanged += Vm_PropertyChanged;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            irrResults = new ObservableDataSource<Point>();
            irrResults.SetXYMapping(p => p);

            plotter.AddLineGraph(irrResults, 1, "IRR");

            Thread simThread = new Thread(new ThreadStart(Plot));
            simThread.IsBackground = true;
            simThread.Start();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            irrResults = new ObservableDataSource <Point>();
            irrResults.SetXYMapping(p => p);

            plotter.AddLineGraph(irrResults, 1, "IRR");

            Thread simThread = new Thread(new ThreadStart(Plot));

            simThread.IsBackground = true;
            simThread.Start();
        }
Exemple #8
0
        public Series(ChartPlotter plotter, string descr, double thick, Color color)
        {
            DataSource = new ObservableDataSource<Point>();
              DataSource.SetXYMapping(pt => pt);

              plotter.Dispatcher.Invoke((Action)
            delegate()
            {
              Graph = plotter.AddLineGraph(DataSource, color, thick, descr);
            }
              );
        }
Exemple #9
0
 private void Push()
 {
     plotter.Children.Remove(pushCurGraph);
     plotter.Children.Remove(pushPoleGraph);
     pushCurDS     = new ObservableDataSource <Point>(pushCurArr);
     pushPoleDS    = new ObservableDataSource <Point>(pushPoleArr);
     pushPoleGraph = plotter.AddLineGraph(pushPoleDS, Colors.Green, 2, "推焦杆长");
     pushCurGraph  = plotter.AddLineGraph(pushCurDS, Colors.Red, 2, "推焦电流");
     plotter.Viewport.FitToView();
     pushPoleDS.SetXYMapping(p => new Point(p.X / 5, p.Y));//数字5的意义:1000ms,记录电流的timer的Interval为200ms,即5次计数为1s,X轴的单位为秒
     pushCurDS.SetXYMapping(p => new Point(p.X / 5, p.Y));
     pushCurGraph.Cursor = Cursors.Hand;
 }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            planeLocations = new ObservableDataSource <Point>();
            // Set identity mapping of point in collection to point on plot
            planeLocations.SetXYMapping(p => p);

            vm.PropertyChanged += Vm_PropertyChanged;

            plotter.AddLineGraph(planeLocations, 2, "Route");

            // dissconnecting the client and the server while closing the GUI.
            this.Dispatcher.ShutdownStarted += vm.Dissconnect;
        }
Exemple #11
0
        private void Ping()
        {
            plotter.Children.Remove(pingPoleGraph);
            plotter.Children.Remove(pingCurGraph);
            pingPoleDS    = new ObservableDataSource <Point>(pingPoleArr);
            pingCurDS     = new ObservableDataSource <Point>(pingCurArr);
            pingPoleGraph = plotter.AddLineGraph(pingPoleDS, Colors.Yellow, 2, "平煤杆长");
            pingCurGraph  = plotter.AddLineGraph(pingCurDS, Colors.Black, 2, "平煤电流");
            plotter.Viewport.FitToView();

            pingPoleDS.SetXYMapping(p => new Point(p.X / 5, p.Y));//数字5的意义:1000ms,记录电流的timer的Interval为200ms,即5次计数为1s,X轴的单位为秒
            pingCurDS.SetXYMapping(p => new Point(p.X / 5, p.Y));
            pingCurGraph.Cursor = Cursors.Hand;
        }
        /// <summary>
        /// Display data for both Processor graph and Queue graph
        /// </summary>
        /// <param name="procStats">Processor usage statistics</param>
        /// <param name="queueStats">Queue usage statistics per processor</param>
        public void DisplayGraphs(IEnumerable<Point> procStats, IEnumerable<IEnumerable<Point>> queueStats)
        {
            var colors = new[]
            {
              "#FFBF00",
              "#E32636",
              "#0000FF",
              "#008000",
              "#00FFFF",
              "#5D8AA8",
              "#4B5320",
              "#B8860B",
              "#6D351A",
              "#BDB76B",
              "#66FF00",
              "#CC5500",
              "#85BB65",
              "#DFFF00",
              "#8B008B"
            };

              // initialize processor usage graph
              var procSource = new ObservableDataSource<Point>();
              procSource.SetXYMapping(pt => pt);
              ProcessorUsageChart.AddLineGraph(procSource, Colors.Blue, 1, "Processor usage");
              procSource.AppendMany(procStats);

              var pidx = 1;
              foreach(var curr in queueStats)
              {
            var queueSource = new ObservableDataSource<Point>();
            procSource.SetXYMapping(pt => pt);
            QueueLengthChart.AddLineGraph(queueSource, (Color)ColorConverter.ConvertFromString(colors[(pidx-1) % colors.Length]), 2, "Processor #" + pidx.ToString() + " queue");
            queueSource.AppendMany(curr);
            pidx++;
              }
        }
Exemple #13
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            planeLocations = new ObservableDataSource <Point>();
            // Set identity mapping of point in collection to point on plot
            planeLocations.SetXYMapping(p => p);

            plotter.AddLineGraph(planeLocations, 2, "Route");

            INotifyPropertyChanged vm = DataContext as INotifyPropertyChanged;

            if (vm != null)
            {
                vm.PropertyChanged += Vm_PropertyChanged;
            }
        }
 /// <summary>
 /// 加热曲线开始采集
 /// </summary>
 private void HeatCurveStart()
 {
     if (timeSecondHeat == 0)
     {
         dataSource1 = new ObservableDataSource <Point>();
         dataSource1.SetXYMapping(p => p);
         dataSource2 = new ObservableDataSource <Point>();
         dataSource2.SetXYMapping(p => p);
         dataSource3 = new ObservableDataSource <Point>();
         dataSource3.SetXYMapping(p => p);
         graph1 = plotter1.AddLineGraph(dataSource1, Colors.Red, 2, "轨顶温度");
         graph2 = plotter1.AddLineGraph(dataSource2, Colors.Green, 2, "轨脚边温度");
         graph3 = plotter1.AddLineGraph(dataSource3, Colors.Blue, 2, "内轨脚温度");
     }
 }
Exemple #15
0
        /// <summary>
        /// sourceNum为线条数量
        /// lineColors为线条颜色,数组长度与sourceNum保持一致
        /// lineNames为线条名称,数组长度与sourceNum保持一致
        /// </summary>
        public void Initial(int sourceNum, Color[] lineColors, string[] lineNames, int legendFontSize = 9)
        {
            plotter1.Legend.LegendLeft = 5;
            plotter1.Legend.FontSize   = legendFontSize;

            for (int i = 0; i < sourceNum; i++)
            {
                List <Point> addPoint = new List <Point>();
                m_AddPoints.Add(addPoint);

                ObservableDataSource <Point> lineGraphSource = new ObservableDataSource <Point>();
                lineGraphSource.SetXYMapping(p => p);
                plotter1.AddLineGraph(lineGraphSource, lineColors[i], 1, lineNames[i]);
                m_LineGraphSources.Add(lineGraphSource);
            }
        }
Exemple #16
0
        private void addVector(int index)
        {
            ObservableDataSource <Point> plist = new ObservableDataSource <Point>();

            plist.Collection.Add(new Point(0, 0));
            plist.Collection.Add(new Point(0, 0));
            plist.SetXYMapping(p => p);

            source1[index].Add(plist);

            int vectNum = source1[index].Count - 1;

            int thickness = (vectNum == 0) ? 4 : 3;

            vectGraph[index].Add(vectPlotter.AddLineGraph(source1[index][vectNum], col[index], thickness, names[index]));
        }
    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        // Create source
        source1 = new ObservableDataSource <Point>();
        // Set identity mapping of point in collection to point on plot
        source1.SetXYMapping(p => p);

        // Add the graph. Colors are not specified and chosen random
        plotter.AddLineGraph(source1, 2, "Data row");
        // Force everyting to fit in view
        plotter.Viewport.FitToView();
        // Start computation process in second thread
        Thread simThread = new Thread(new ThreadStart(Simulation));

        simThread.IsBackground = true;
        simThread.Start();
    }
Exemple #18
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeComboBox();

            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 0);
            dispatcherTimer.Tick    += dispatcherTimer_Tick;
            dispatcherTimer.Start();

            sourceYaw.SetXYMapping(p => p);
            sourcePitch.SetXYMapping(p => p);
            sourceRoll.SetXYMapping(p => p);
            sourceElevasi.SetXYMapping(p => p);
            sourceTinggi.SetXYMapping(p => p);

            dataYaw.SetXYMapping(p => p);
            dataPitch.SetXYMapping(p => p);
            dataRoll.SetXYMapping(p => p);
            dataElevasi.SetXYMapping(p => p);
            dataTinggi.SetXYMapping(p => p);

            AccPlot.AddLineGraph(sourceYaw, new Pen(Brushes.Red, 2), new PenDescription("Yaw (deg/s)"));
            AccPlot.AddLineGraph(sourcePitch, new Pen(Brushes.Yellow, 2), new PenDescription("Pitch (deg/s)"));
            AccPlot.AddLineGraph(sourceRoll, new Pen(Brushes.Green, 2), new PenDescription("Roll (deg/s)"));

            GyroPlot.AddLineGraph(sourceElevasi, new Pen(Brushes.Blue, 2), new PenDescription("Elevasi sudut (deg)"));

            TinggiPlot.AddLineGraph(sourceTinggi, new Pen(Brushes.Purple, 2), new PenDescription("Ketinggian (m)"));


            AccPlot.Viewport.FitToView();
            GyroPlot.Viewport.FitToView();
            TinggiPlot.Viewport.FitToView();

            ObjectForScriptingHelper helper = new ObjectForScriptingHelper(this);

            mySensorLog.No = 0;

            InitializeDataTable();

            //var matrix = model.Transform.Value;
            //matrix.Rotate(new Quaternion(new Vector3D(0, 0, 1), -90));
            //model.Transform = new MatrixTransform3D(matrix);
            //Viewport3D.Camera.LookAt(new Point3D(150, 175, 190), new Vector3D(-1, -1, -1), 0);
        }
Exemple #19
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
                    );
            }
        }
Exemple #20
0
        private void Wykres_Loaded(object sender, RoutedEventArgs e)
        {
            source1 = new ObservableDataSource <Point>();
            source1.SetXYMapping(p => p);
            Chart.AddLineGraph(source1, 1, "Speed");;

            source2 = new ObservableDataSource <Point>();
            source2.SetXYMapping(p => p);
            Chart.AddLineGraph(source2, 1, "Fuel");;

            source3 = new ObservableDataSource <Point>();
            source3.SetXYMapping(p => p);
            Chart.AddLineGraph(source3, 1, "Temp.");;

            Thread simThread = new Thread(new ThreadStart(Simulation));

            simThread.IsBackground = true;
            simThread.Start();
        }
Exemple #21
0
 private void StartPing()
 {
     if (NextPing)
     {
         NextPing = false;
         plotter.Children.Remove(pingPoleGraph);
         plotter.Children.Remove(pingCurGraph);
         pingPoleDS    = new ObservableDataSource <Point>();
         pingCurDS     = new ObservableDataSource <Point>();
         pingPoleGraph = plotter.AddLineGraph(pingPoleDS, Colors.Yellow, 2, "平煤杆长");
         pingCurGraph  = plotter.AddLineGraph(pingCurDS, Colors.Black, 2, "平煤电流");
         plotter.Viewport.FitToView();
     }
     pingPoleDS.AppendAsync(Dispatcher, T.PingLenPoint);
     pingPoleDS.SetXYMapping(p => new Point(p.X / 5, p.Y));//数字5的意义:1000ms,记录电流的timer的Interval为200ms,即5次计数为1s,X轴的单位为秒
     pingCurDS.AppendAsync(Dispatcher, T.PingCurPoint);
     pingCurDS.SetXYMapping(p => new Point(p.X / 5, p.Y));
     ToolTipService.SetToolTip(pingCurGraph, "最大平煤电流:" + T.PingCurMax + ",平均平煤电流:" + T.PingCurAvg);
     pingCurGraph.Cursor = Cursors.Hand;
 }
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var newViewModel = e.NewValue as FFTProcessorViewModel;
            var oldViewModel = e.OldValue as FFTProcessorViewModel;

            if (oldViewModel != null)
            {
                oldViewModel.PropertyChanged -= OnViewModelPropertyChanged;
                source = null;
            }

            if (newViewModel != null)
            {
                newViewModel.PropertyChanged += OnViewModelPropertyChanged;
                source = new ObservableDataSource <Point>();
                source.SetXYMapping(x => x);

                var lineGraph = fftChart.AddLineGraph(source, Color.FromRgb(0, 128, 255), 1, "Widmo");
            }
        }
Exemple #23
0
 private void StartPush()
 {
     if (NextPush)
     {
         NextPush = false;
         plotter.Children.Remove(pushPoleGraph);
         plotter.Children.Remove(pushCurGraph);
         pushCurDS     = new ObservableDataSource <Point>();
         pushPoleDS    = new ObservableDataSource <Point>();
         pushPoleGraph = plotter.AddLineGraph(pushPoleDS, Colors.Green, 2, "推焦杆长");
         pushCurGraph  = plotter.AddLineGraph(pushCurDS, Colors.Red, 2, "推焦电流");
         plotter.Viewport.FitToView();
     }
     pushPoleDS.AppendAsync(Dispatcher, T.PushLenPoint);
     pushPoleDS.SetXYMapping(p => new Point(p.X / 5, p.Y));//数字5的意义:1000ms,记录电流的timer的Interval为200ms,即5次计数为1s,X轴的单位为秒
     pushCurDS.AppendAsync(Dispatcher, T.PushCurPoint);
     pushCurDS.SetXYMapping(p => new Point(p.X / 5, p.Y));
     ToolTipService.SetToolTip(pushCurGraph, "最大推焦电流:" + T.PushCurMax + ",平均推焦电流:" + T.PushCurAvg);
     pushCurGraph.Cursor = Cursors.Hand;
 }
Exemple #24
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
                );
            }
        }
        public UIWindow(SimulationCore displayModule)
        {
            ElementHost.EnableModelessKeyboardInterop(this);

            InitializeComponent();

            mutationButtonMapping = new Dictionary<Button, List<Mutation>>();

            startConfigChoices = new Dictionary<ComboBoxItem, Type>();
            IEnumerable<String> paramFileNames = Directory.EnumerateFiles("Content");

            foreach (String f in paramFileNames)
            {
                if(System.IO.Path.GetExtension(f) == ".json"){
                    ComboBoxItem newItem = new ComboBoxItem();
                    newItem.Content = System.IO.Path.GetFileName(f);
                    startConfigurationComboBox.Items.Add(newItem);
                }
            }

            finalCellNumberDataSource = new ObservableDataSource<Point>();
            finalCellNumberDataSource.SetXYMapping(p => p);
            blastCellNumberDataSource = new ObservableDataSource<Point>();
            blastCellNumberDataSource.SetXYMapping(p => p);
            cellCount.AddLineGraph(finalCellNumberDataSource, Colors.Green, 2, "final cells");
            cellCount.AddLineGraph(blastCellNumberDataSource, Colors.Red, 2, "blast cells");
            cellCount.LegendVisible = false;

            mutationCountDataSource = new ObservableDataSource<Point>();
            mutationCountDataSource.SetXYMapping(p => p);
            mutationCount.AddLineGraph(mutationCountDataSource, Colors.Black, 2, "mutations");
            mutationCount.LegendVisible = false;

            bloodVesselCountCountDataSource = new ObservableDataSource<Point>();
            bloodVesselCountCountDataSource.SetXYMapping(p => p);
            bloodVesselCount.AddLineGraph(bloodVesselCountCountDataSource, Colors.Purple, 2, "blood vessels");
            bloodVesselCount.LegendVisible = false;

            stopSimulationButton.IsEnabled = false;
            mutationCreationButton.IsEnabled = false;
        }
 /// <summary>
 /// 冷却曲线开始采集
 /// </summary>
 private void CoolingCurveStart()
 {
     if (timeSecondCooling == 0)
     {
         dataSource4 = new ObservableDataSource <Point>();
         dataSource4.SetXYMapping(p => p);
         dataSource5 = new ObservableDataSource <Point>();
         dataSource5.SetXYMapping(p => p);
         dataSource6 = new ObservableDataSource <Point>();
         dataSource6.SetXYMapping(p => p);
         dataSource7 = new ObservableDataSource <Point>();
         dataSource7.SetXYMapping(p => p);
         dataSource8 = new ObservableDataSource <Point>();
         dataSource8.SetXYMapping(p => p);
         graph4 = plotter2.AddLineGraph(dataSource4, Colors.Red, 2, "压力");
         graph5 = plotter3.AddLineGraph(dataSource5, Colors.Red, 2, "冷却温度");
         graph6 = plotter4.AddLineGraph(dataSource6, Colors.Green, 2, "轨顶流量");
         graph7 = plotter4.AddLineGraph(dataSource7, Colors.Blue, 2, "轨腰流量");
         graph8 = plotter4.AddLineGraph(dataSource8, Colors.Yellow, 2, "轨底流量");
     }
 }
Exemple #27
0
        public GraphViewModel()
        {
            SourceL = new ObservableDataSource <Point>();
            SourceL.SetXYMapping(p => p);

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

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

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

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

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

            PreviewDropCommand = new RelayCommand(param => this.HandlePreviewDrop(param));
        }
        /// <summary>
        /// Constructeur
        /// </summary>
        public HomeViewModel()
        {
            // Set-up commands
            DisconnectCommand = new RelayCommand(param => Disconnect(), param => true);
            UserProfileCommand = new RelayCommand(param => UserProfile(), param => true);
            AllPatientCommand = new RelayCommand(param => AllPatient(), param => true);
            AllUserCommand = new RelayCommand(param => AllUser(), param => true);

            // Loading default viewmodel
            CurrentViewModel = new PatientManagementViewModel();

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

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

            /*
            ServiceLive.ServiceLiveClient serviceClient = new ServiceLive.ServiceLiveClient();
            serviceClient.Subscribe();
             */
        }
        // Mainwindow
        public MainWindow()
        {
            hubConnection.StateChanged += new Action <StateChange>(hubConnectionStateChangedEvent);

            // Initialise GUI
            InitializeComponent();

            // Update GUI
            update_variable_listBox();

            // D3 DEMO
            source1 = new ObservableDataSource <Point>();
            source1.SetXYMapping(p => p);
            plotter.AddLineGraph(source1);

            try
            {
                hubConnection.Start();
            }
            catch (Exception ex)
            {
                status_message_text.Text = ex.Message;
            }
        }
Exemple #30
0
        public MainWindow()
        {
            InitializeComponent();

            this.MouseLeftButtonDown += (sender, e) => this.DragMove();

            ConnectPort = new SerialPort();

            int[] Default = { 11, 4, 10, 6, 5, 4};
            Box_AngleKp.Text = Default[0].ToString();
            Box_AngleKd.Text = Default[1].ToString();
            Box_GyroKp.Text = Default[2].ToString();
            Box_GyroKd.Text = Default[3].ToString();
            Box_AngleGain.Text = Default[4].ToString();
            Box_GyroGain.Text = Default[5].ToString();
            Label_AngleKp.Text = Box_AngleKp.Text;
            Label_AngleKd.Text = Box_AngleKd.Text;
            Label_GyroKp.Text = Box_GyroKp.Text;
            Label_GyroKd.Text = Box_GyroKd.Text;
            Label_AngleGain.Text = Box_AngleGain.Text;
            Label_GyroGain.Text = Box_GyroGain.Text;

            int[] MotorDefault = { 93, 87, 100, 90};
            Box_Motor_L.Text = MotorDefault[0].ToString();
            Box_Motor_R.Text = MotorDefault[1].ToString();
            Box_Motor_F.Text = MotorDefault[2].ToString();
            Box_Motor_B.Text = MotorDefault[3].ToString();
            Label_MotorIn_L.Text = Box_Motor_L.Text;
            Label_MotorIn_R.Text = Box_Motor_R.Text;
            Label_MotorIn_F.Text = Box_Motor_F.Text;
            Label_MotorIn_B.Text = Box_Motor_B.Text;

            Moyashi = new string[12];

            Point_Accel_X = new ObservableDataSource<System.Windows.Point>();
            Point_Accel_X.SetXYMapping(point => point);
            Plotter_Accel.AddLineGraph(Point_Accel_X, Colors.DarkTurquoise, 1.0);
            Point_Accel_Y = new ObservableDataSource<System.Windows.Point>();
            Point_Accel_Y.SetXYMapping(point => point);
            Plotter_Accel.AddLineGraph(Point_Accel_Y, Colors.GreenYellow, 1.0);
            Point_Accel_Z = new ObservableDataSource<System.Windows.Point>();
            Point_Accel_Z.SetXYMapping(point => point);
            Plotter_Accel.AddLineGraph(Point_Accel_Z, Colors.Red, 1.0);
            Plotter_Accel.Legend.Remove();

            Point_Gyro_X = new ObservableDataSource<System.Windows.Point>();
            Point_Gyro_X.SetXYMapping(point => point);
            Plotter_Gyro.AddLineGraph(Point_Gyro_X, Colors.DarkTurquoise, 1.0);
            Point_Gyro_Y = new ObservableDataSource<System.Windows.Point>();
            Point_Gyro_Y.SetXYMapping(point => point);
            Plotter_Gyro.AddLineGraph(Point_Gyro_Y, Colors.GreenYellow, 1.0);
            Point_Gyro_Z = new ObservableDataSource<System.Windows.Point>();
            Point_Gyro_Z.SetXYMapping(point => point);
            Plotter_Gyro.AddLineGraph(Point_Gyro_Z, Colors.Red, 1.0);
            Plotter_Gyro.Legend.Remove();

            Point_Angle_X = new ObservableDataSource<System.Windows.Point>();
            Point_Angle_X.SetXYMapping(point => point);
            Plotter_Angle.AddLineGraph(Point_Angle_X, Colors.DarkTurquoise, 1.0);
            Point_Angle_Y = new ObservableDataSource<System.Windows.Point>();
            Point_Angle_Y.SetXYMapping(point => point);
            Plotter_Angle.AddLineGraph(Point_Angle_Y, Colors.GreenYellow, 1.0);
            Plotter_Angle.Legend.Remove();

            Point_AnglePD_X = new ObservableDataSource<System.Windows.Point>();
            Point_AnglePD_X.SetXYMapping(point => point);
            Plotter_AnglePD.AddLineGraph(Point_AnglePD_X, Colors.DarkTurquoise, 1.0);
            Point_AnglePD_Y = new ObservableDataSource<System.Windows.Point>();
            Point_AnglePD_Y.SetXYMapping(point => point);
            Plotter_AnglePD.AddLineGraph(Point_AnglePD_Y, Colors.Red, 1.0);
            Plotter_AnglePD.Legend.Remove();

            Point_GyroPD_X = new ObservableDataSource<System.Windows.Point>();
            Point_GyroPD_X.SetXYMapping(point => point);
            Plotter_GyroPD.AddLineGraph(Point_GyroPD_X, Colors.DarkTurquoise, 1.0);
            Point_GyroPD_Y = new ObservableDataSource<System.Windows.Point>();
            Point_GyroPD_Y.SetXYMapping(point => point);
            Plotter_GyroPD.AddLineGraph(Point_GyroPD_Y, Colors.GreenYellow, 1.0);
            Point_GyroPD_Z = new ObservableDataSource<System.Windows.Point>();
            Point_GyroPD_Z.SetXYMapping(point => point);
            Plotter_GyroPD.AddLineGraph(Point_GyroPD_Z, Colors.Red, 1.0);
            Plotter_GyroPD.Legend.Remove();

            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 30;
            timer.Enabled = true;
            timer.Tick += new EventHandler(Control);

            System.Windows.Forms.Timer Write = new System.Windows.Forms.Timer();
            Write.Interval = 100;
            Write.Enabled = true;
            Write.Tick += new EventHandler(AsyncWrite);

            PortList = SerialPort.GetPortNames();

            ChangeUnder(2,"Component Initialized");
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create first source
            plotter.DataTransform = new Log10Transform();

            double[] xArray = new double[] { 15, 14, 16, 48, 50, 51 };
            double[] yArray = new double[] { 60, 63, 64, 124, 131, 144 };

            var xds = xArray.AsXDataSource();
            var yds = yArray.AsYDataSource();

            //var ds = new CompositeDataSource(xds, yds);

            //LineGraph hola = new LineGraph(ds);
            //plotter.Children.Add(hola);
            source1 = new ObservableDataSource <Tuple <double, double> >();
            source2 = new ObservableDataSource <Tuple <double, double> >();
            source1.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return(p);
            });

            source2.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return(p);
            });

            for (int i = 0; i < xArray.Length; i++)
            {
                source1.Collection.Add(new Tuple <double, double>(xArray[i], yArray[i]));
                source2.Collection.Add(new Tuple <double, double>(xArray[i], yArray[i]));
            }

            plotter.MainHorizontalAxis = new HorizontalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
                {
                    CustomFormatter = info => StringUtils.CodeString(info.Tick)
                }
            };

            plotter.MainVerticalAxis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
                {
                    CustomFormatter = info => StringUtils.CodeString(info.Tick)
                }
            };
            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            //axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            //VerticalAxis axis2 = (VerticalAxis)plotter.MainVerticalAxis;
            ////axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            //axis2.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            //HorizontalAxis xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider() { CustomFormatter = info => StringUtils.CodeString(info.Tick) }
            //};
            //plotter.MainHorizontalAxis = xAxis;

            //VerticalAxis yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //plotter.MainVerticalAxis = yAxis;



            otherPlotter.DataTransform      = new Log10XTransform();
            otherPlotter.MainHorizontalAxis = new HorizontalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
                {
                    CustomFormatter = info => StringUtils.CodeString(info.Tick)
                }
            };
            //otherPlotter.MainHorizontalAxis = xAxis2;
            //otherPlotter.MainVerticalAxis = xAxis;

            //yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            // otherPlotter.MainVerticalAxis = yAxis;



            linegraph.DataSource  = source1;
            phasegraph.DataSource = source2;
        }
Exemple #32
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);
                }
        }
Exemple #33
0
 private void UpdatePlotter_training(bool flag)
 {
     if (plotter.Dispatcher.CheckAccess() == false)
     {
         updatePlotterCallback_training uCallBack = new updatePlotterCallback_training(UpdatePlotter_training);
         dp_test.Invoke(uCallBack, flag);
     }
     else
     {
         try
         {
             chart_line_source_1.DataSource = null;
             // chart_line_source_2.DataSource = null;
             count_channel_1 = 1;
             count_channel_2 = 1;
             // Create first source
             source1 = new ObservableDataSource<Point>();
             // Set identity mapping of point in collection to point on plot
             source1.SetXYMapping(p => p);
             chart_line_source_1 = plotter.AddLineGraph(source1, Color.FromRgb(12, 0, 4), 2, "Измерения");
         }
         catch (Exception fail)
         {
             String error = "The following error has occurred:\n\n";
             error += fail.Message.ToString() + "\n\n";
             MessageBox.Show(error);
         }
     }
 }
 private static ObservableDataSource<Point> CreateObservableDataSourceWithIdentiyMapping()
 {
     var result = new ObservableDataSource<Point>();
     result.SetXYMapping(p => p);
     return result;
 }
Exemple #35
0
        void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            RunWorkerInitMasterEmulator();
            lbDeviceDiscovery.ItemsSource = discoveredDevices;
            SetColorOfRect(false);
            UpdateButtons();

            //for (int i = 0; i < animatedX.Length; i++)
            //{
            //    animatedX[i] = 2 * Math.PI * i / animatedX.Length;
            //    animatedY[i] = Math.Sin(animatedX[i]);
            //}
            //EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(animatedX);
            //xSrc.SetXMapping(x => x);
            //animatedDataSource = new EnumerableDataSource<double>(animatedY);
            //animatedDataSource.SetYMapping(y => y);

            //// Adding graph to plotter
            //plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
            //    new Pen(Brushes.Magenta, 3),
            //    new PenDescription("Sin(x + phase)"));

            //timer.Interval = TimeSpan.FromMilliseconds(10);
            //timer.Tick += AnimatedPlot_Timer;
            //timer.IsEnabled = true;

            // Force evertyhing plotted to be visible
            //plotter.FitToView();

            // 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
            plotter.AddLineGraph(source1, Colors.Red, 2, "Data 1");
            plotter.AddLineGraph(source2, Colors.Green, 2, "Data 2");
            plotter.AddLineGraph(source3, Colors.Blue, 2, "Data 3");
        }
Exemple #36
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;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //plotter.DataTransform = new Log10Transform();

            // Create first source
            sourcecurrent = new ObservableDataSource <Tuple <double, double> >();
            sourcecurrent.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return(p);
            });

            //plotter.DataTransform = new Log10Transform();
            //HorizontalAxis xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new NumericTicksProvider(),
            //    LabelProvider = new ExponentialLabelProvider()
            //};
            //plotter.MainHorizontalAxis = xAxis;
            //VerticalAxis yAxis = new VerticalAxis
            //{
            //    //TicksProvider = new LogarithmNumericTicksProvider(10),
            //    TicksProvider = new NumericTicksProvider(),
            //    LabelProvider = new ExponentialLabelProvider()
            //};
            //plotter.MainVerticalAxis = yAxis;

            HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis;

            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            VerticalAxis axisv = (VerticalAxis)plotter.MainVerticalAxis;

            //String.Format(new TelephoneFormatter(), "{0}", 0)
            axisv.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));

            sourcevoltage = new ObservableDataSource <Tuple <double, double> >();
            sourcevoltage.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return(p);
            });

            //otherPlotter.DataTransform = new Log10Transform();
            //xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //otherPlotter.MainHorizontalAxis = xAxis;
            //yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //otherPlotter.MainVerticalAxis = yAxis;



            //List<Point> list = new List<Point>();

            Random rnd = new Random();

            for (int i = 10; i < 300; i++)
            {
                sourcecurrent.Collection.Add(new Tuple <double, double>(i, 20000 + rnd.Next(10000)));
                sourcevoltage.Collection.Add(new Tuple <double, double>(i, 30 + rnd.Next(20)));
                //list.Add(new Point(i, rnd.Next(50)));
            }
            //plotter1.VerticalAxis.LabelProvider = new ExponentialLabelProvider();
            //LineGraph line = new LineGraph(source1);
            //line.AddToPlotter(plotter);
            // plotter.Children.Add(line);

            //otherPlotter.MainVerticalAxis.

            linegraph.DataSource = sourcevoltage;
            linephase.DataSource = sourcecurrent;
            //axis = new VerticalAxisTitle();
            //linegraph = new Microsoft.Research.DynamicDataDisplay.LineGraph(
            // Creating the new DraggablePoint
            if (false)
            {
                int   x1 = 10, y1 = 10;
                Point q           = new Point(x1, y1);
                var   globalPoint = new DraggablePoint(q);

                globalPoint.PositionChanged += (s, r) =>
                {
                    globalPoint.Position = q;
                };
                plotter.Children.Add(globalPoint);
            }

            // Set the point on the map
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //plotter.DataTransform = new Log10Transform();
            
            // Create first source
            sourcecurrent = new ObservableDataSource<Tuple<double, double>>();
            sourcecurrent.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return p;
            });

            //plotter.DataTransform = new Log10Transform();
            //HorizontalAxis xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new NumericTicksProvider(),
            //    LabelProvider = new ExponentialLabelProvider()
            //};
            //plotter.MainHorizontalAxis = xAxis;
            //VerticalAxis yAxis = new VerticalAxis
            //{
            //    //TicksProvider = new LogarithmNumericTicksProvider(10),
            //    TicksProvider = new NumericTicksProvider(),
            //    LabelProvider = new ExponentialLabelProvider()
            //};
            //plotter.MainVerticalAxis = yAxis;

            HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis;
            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            VerticalAxis axisv = (VerticalAxis)plotter.MainVerticalAxis;
            //String.Format(new TelephoneFormatter(), "{0}", 0)
            axisv.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));

            sourcevoltage = new ObservableDataSource<Tuple<double, double>>();
            sourcevoltage.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return p;
            });

            //otherPlotter.DataTransform = new Log10Transform();
            //xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //otherPlotter.MainHorizontalAxis = xAxis;
            //yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //otherPlotter.MainVerticalAxis = yAxis;



            //List<Point> list = new List<Point>();

            Random rnd = new Random();
            for (int i = 10; i < 300; i++)
            {
                sourcecurrent.Collection.Add(new Tuple<double, double>(i, 20000 + rnd.Next(10000)));
                sourcevoltage.Collection.Add(new Tuple<double, double>(i, 30 + rnd.Next(20)));
                //list.Add(new Point(i, rnd.Next(50)));
            }
            //plotter1.VerticalAxis.LabelProvider = new ExponentialLabelProvider();
            //LineGraph line = new LineGraph(source1);
            //line.AddToPlotter(plotter);
            // plotter.Children.Add(line);

            //otherPlotter.MainVerticalAxis.

            linegraph.DataSource = sourcevoltage ;
            linephase.DataSource = sourcecurrent;
            //axis = new VerticalAxisTitle();
            //linegraph = new Microsoft.Research.DynamicDataDisplay.LineGraph(
            // Creating the new DraggablePoint
            if (false)
            {
                int x1 = 10, y1 = 10;
                Point q = new Point(x1, y1);
                var globalPoint = new DraggablePoint(q);

                globalPoint.PositionChanged += (s, r) =>
                {
                    globalPoint.Position = q;
                };
                plotter.Children.Add(globalPoint);

            }
            
            // Set the point on the map

           
        }
        //private void click_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        //{
        //    showDetailsUG.Children.Clear();
        //    for (int i = 1; i <= 30; i++)
        //        showDetailsUG.Children.Add(new ShowDetails(i));
        //}
        private void plotDetails_Click(object sender, RoutedEventArgs e)
        {
            ObservableDataSource<Point> source1 = null;

            // Create first source
            source1 = new ObservableDataSource<Point>();

            List<Point> list1 = new List<Point>();

            for (int i = 0; i < 30; i++)
            {
                Point p1 = new Point(i, 2 * i);
                list1.Add(p1);
            }
            source1.AppendMany(list1);
            // Set identity mapping of point in collection to point on plot
            source1.SetXYMapping(p => p);

            // Add all three graphs. Colors are not specified and chosen random
            plotter.AddLineGraph(source1, Color.FromRgb(0, 255, 0), 2, "Data row 1");

            // Create second source
            ObservableDataSource<Point> source2 = null;
            source2 = new ObservableDataSource<Point>();
            List<Point> list2 = new List<Point>();
            for (int j = 0; j < 30; j++)
            {
                Point p1 = new Point(j, 3 * j);
                list2.Add(p1);
            }
            source2.AppendMany(list2);

            // Set identity mapping of point in collection to point on plot
            source2.SetXYMapping(p => p);

            plotter.AddLineGraph(source2, Color.FromRgb(0, 0, 255), 2, "Data row 2");

            getDatewiseReport();
        }
        private void connect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                plotterT.Children.Remove(graphT);
                plotterH.Children.Remove(graphH);
                plotterD.Children.Remove(graphD);
                plotterP.Children.Remove(graphP);
                plotterACC.Children.Remove(graphACC);

                // Create first source
                source1 = new ObservableDataSource<Point>();
                // Set identity mapping of point in collection to point on plot
                source1.SetXYMapping(p => p);

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

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

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

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

                // Add all three graphs. Colors are not specified and chosen random
                graphT = plotterT.AddLineGraph(source1, Colors.Red, 2, "TEMP");
                graphH = plotterH.AddLineGraph(source2, Colors.Green, 2, "HUM");
                graphD = plotterD.AddLineGraph(source3, Colors.Blue, 2, "DUST");
                graphP = plotterP.AddLineGraph(source4, Colors.DarkSeaGreen, 2, "PRESS");
                graphACC = plotterACC.AddLineGraph(source5, Colors.CadetBlue, 2, "ACC");

                InitClient();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create first source
            plotter.DataTransform = new Log10Transform();

            double[] xArray = new double[] { 15, 14, 16, 48, 50, 51 };
            double[] yArray = new double[] { 60, 63, 64, 124, 131, 144 };

            var xds = xArray.AsXDataSource();
            var yds = yArray.AsYDataSource();
            //var ds = new CompositeDataSource(xds, yds);
            
            //LineGraph hola = new LineGraph(ds);
            //plotter.Children.Add(hola);
            source1 = new ObservableDataSource<Tuple<double, double>>();
            source2 = new ObservableDataSource<Tuple<double, double>>();
            source1.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return p;
            });

            source2.SetXYMapping(z =>
            {
                Point p = new Point(z.Item1, z.Item2);
                return p;
            });

            for (int i=0; i<xArray.Length; i++ )
            {
                source1.Collection.Add(new Tuple<double, double>(xArray[i], yArray[i]));
                source2.Collection.Add(new Tuple<double, double>(xArray[i], yArray[i]));
            }

            plotter.MainHorizontalAxis = new HorizontalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider() { CustomFormatter = info => StringUtils.CodeString(info.Tick) }
            };

            plotter.MainVerticalAxis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider() { CustomFormatter = info => StringUtils.CodeString(info.Tick) }
            };
            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            //axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            //VerticalAxis axis2 = (VerticalAxis)plotter.MainVerticalAxis;
            ////axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            //axis2.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            //HorizontalAxis xAxis = new HorizontalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider() { CustomFormatter = info => StringUtils.CodeString(info.Tick) }
            //};
            //plotter.MainHorizontalAxis = xAxis;

            //VerticalAxis yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //plotter.MainVerticalAxis = yAxis;



            otherPlotter.DataTransform = new Log10XTransform();
            otherPlotter.MainHorizontalAxis = new HorizontalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider() { CustomFormatter = info => StringUtils.CodeString(info.Tick) }
            };
            //otherPlotter.MainHorizontalAxis = xAxis2;
            //otherPlotter.MainVerticalAxis = xAxis;

            //yAxis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            // otherPlotter.MainVerticalAxis = yAxis;



            linegraph.DataSource = source1;
            phasegraph.DataSource = source2;

        }
 // Connect between a point of the graph to a point in the point collection.
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     coordinates = new ObservableDataSource <Point>();
     coordinates.SetXYMapping(p => p);
     plotter.AddLineGraph(coordinates, Colors.DeepSkyBlue, 2, "Route");
 }
Exemple #43
0
 public GraphingData()
 {
     Channel_AllData = new ObservableDataSource<Point>();
     Channel_GraphData = new ObservableDataSource<Point>();
     Channel_GraphData.SetXYMapping(p => p);
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create first source
            source1 = new ObservableDataSource<Tuple<double, double>>();
            source1.SetXYMapping(z =>   {
                                            Point p = new Point(z.Item1, z.Item2);
                                            return p;
                                        });
            HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis;
            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            VerticalAxis axis2 = (VerticalAxis)plotter.MainVerticalAxis;
            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis2.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            Random rnd = new Random();
            for (int i = 0; i < 50; i++)
            {
                source1.Collection.Add(new Tuple<double, double>(i, rnd.Next(100)));
                //sourcevoltage.Collection.Add(new Tuple<double, double>(i, 10 + rnd.Next(20)));
            }

            linegraph.DataSource = source1;
        }