private void InitializeController() { MultiController = new WpfGraphController <DoubleDataPoint, DoubleDataPoint>(); MultiController.Renderer = new ScrollingLineRenderer <WpfGraphDataSeries>(); MultiController.Surface = new WpfGraphSurface(); MultiController.Range.MinimumY = SettingsModel.YMax; MultiController.Range.MaximumY = SettingsModel.YMax; MultiController.Range.MaximumX = SettingsModel.Duration; MultiController.Range.AutoY = true; }
public ViewModel() { Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); Controller.Renderer = new ScrollingLineRenderer <WpfGraphDataSeries>(); Controller.Range.AutoY = true; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series Name", Stroke = Colors.Red, IsVisible = true, }); MultiController = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); MultiController.Range.MinimumY = 0; MultiController.Range.MaximumY = 1080; MultiController.Range.MaximumX = TimeSpan.FromSeconds(10); MultiController.Range.AutoY = true; MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 1", Stroke = Colors.Red, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 2", Stroke = Colors.Green, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 3", Stroke = Colors.Blue, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 4", Stroke = Colors.Yellow, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 5", Stroke = Colors.Gray, }); //We will attach the surface using WPF binding... //Controller.Surface = null; }
public GraphController(int waitTimeMS) { Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); Controller.Range.MinimumY = 0; Controller.Range.MaximumY = 1; Controller.Range.MaximumX = TimeSpan.FromSeconds(waitTimeMS); Controller.Range.AutoY = true; Controller.Range.AutoYFallbackMode = GraphRangeAutoYFallBackMode.MinMax; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Y", Stroke = Colors.Red, StrokeThickness = 5 }); Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "X", Stroke = Colors.Red, StrokeThickness = 5 }); }
public GraphViewModel() { Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); Controller.Range.MinimumY = 0; Controller.Range.MaximumY = 1024; Controller.Range.MaximumX = TimeSpan.FromSeconds(15); Controller.Range.AutoY = false; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Serial Values", Stroke = Color.FromRgb(11, 99, 205) }); GraphTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(GlobalSettings.DEFAULT_GRAPH_SPEED_MS) }; GraphTimer.Tick += GraphTimer_Tick; }
/// <summary> /// MainWindow /// </summary> public MainWindow() { InitializeComponent(); ViewModel = new MainViewModel(); ViewModel.DataReady += ViewModel_DataReady; ViewModel.History.CollectionChanged += History_CollectionChanged; DataContext = this; ThrottleController = new WpfGraphController <Int32DataPoint, Int32DataPoint>(); ThrottleController.Range.MinimumY = 0; ThrottleController.Range.MaximumY = 100; ThrottleController.Range.MaximumX = 100; ThrottleController.Range.AutoY = true; ThrottleController.Range.AutoYFallbackMode = GraphRangeAutoYFallBackMode.MinMax; ThrottleController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series", Stroke = Colors.DodgerBlue, }); ThrottleController.PushData(new Int32DataPoint(0), new Int32DataPoint(0)); }
public MainWindowVM() { Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); Controller.Range.MinimumY = 0; Controller.Range.MaximumY = 1080; Controller.Range.MaximumX = TimeSpan.FromSeconds(10); Controller.Range.AutoY = true; Controller.Range.AutoYFallbackMode = GraphRangeAutoYFallBackMode.MinMax; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series", Stroke = Colors.DodgerBlue, }); MultiController = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); MultiController.Range.MinimumY = 0; MultiController.Range.MaximumY = 1080; MultiController.Range.MaximumX = TimeSpan.FromSeconds(10); MultiController.Range.AutoY = true; MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 1", Stroke = Colors.Red, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 2", Stroke = Colors.Green, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 3", Stroke = Colors.Blue, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 4", Stroke = Colors.Yellow, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Series 5", Stroke = Colors.Gray, }); Stopwatch watch = new Stopwatch(); watch.Start(); Task.Factory.StartNew(() => { while (true) { var y = System.Windows.Forms.Cursor.Position.Y; List <DoubleDataPoint> yy = new List <DoubleDataPoint>() { y, y + 20, y + 40, y + 60, y + 80, }; var x = watch.Elapsed; List <TimeSpanDataPoint> xx = new List <TimeSpanDataPoint>() { x, x, x, x, x }; Controller.PushData(x, y); MultiController.PushData(xx, yy); Thread.Sleep(30); } }); }
//public WpfGraphController<DateTimeDataPoint, DoubleDataPoint> Controller { get; set; } public MainWindowVM() { Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); //Controller = new WpfGraphController<DateTimeDataPoint, DoubleDataPoint>(); Controller.Range.MinimumY = 0; Controller.Range.MaximumY = 33000; Controller.Range.MaximumX = TimeSpan.FromSeconds(30); //Controller.Range.MaximumX =DateTime.Now; Controller.Range.AutoY = true; Controller.Range.AutoYFallbackMode = GraphRangeAutoYFallBackMode.MinMax; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Coonnect MB Device", Stroke = Colors.DarkGreen, }); ModbusClient modbusClient; //modbusClient = new ModbusClient("192.168.79.56", 502); modbusClient = new ModbusClient("127.0.0.1", 502); modbusClient.Connect(); Stopwatch watch = new Stopwatch(); TimeSpan myData = DateTime.Now.TimeOfDay; watch.Start(); string ConnectionString = @"Data Source=.\SQLEXPRESS; Initial Catalog = test_DB; integrated Security=True; Connect Timeout = 30"; SqlConnection connection = new SqlConnection(ConnectionString); Task.Factory.StartNew(() => { while (true) { int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(1, 1); int y = readHoldingRegisters[0]; double res; res = 0.01869 * y + 700; int value = Convert.ToInt32(res); var x = (watch.Elapsed); TimeSpan newtime = myData + x; Controller.PushData(newtime, res); DateTime date_ = DateTime.Now;; //string ConnectionString = @"Data Source=.\SQLEXPRESS; Initial Catalog = test_DB; integrated Security=True; Connect Timeout = 30"; string sqlExpression = "INSERT INTO Table_Teast2 (value, Time) VALUES (@value, @date_)"; //SqlConnection connection = new SqlConnection(ConnectionString); try { connection.Open(); SqlCommand command = new SqlCommand(sqlExpression, connection); SqlParameter dateParam = new SqlParameter("@date_", date_); command.Parameters.Add(dateParam); SqlParameter valueParam = new SqlParameter("@value", value); command.Parameters.Add(valueParam); command.ExecuteNonQuery(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { // закрываем подключение connection.Close(); } Thread.Sleep(150); } }); }
public MainWindowVM(MainWindow mainWindow) { this.mainWindow = mainWindow; MultiController = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); MultiController.Range.MinimumY = 0; MultiController.Range.MaximumY = 1080; MultiController.Range.MaximumX = TimeSpan.FromSeconds(30); MultiController.Range.AutoY = true; MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Ventilöffnung Y", Stroke = Colors.Red, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Erregerstrom IE", Stroke = Colors.Green, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Drehzahl n", Stroke = Colors.Blue, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Frequenz f", Stroke = Colors.Yellow, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Generatorspannung UG", Stroke = Colors.Gray, }); MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = "Phasenlage", Stroke = Colors.Crimson }); Stopwatch watch = new Stopwatch(); watch.Start(); Task.Factory.StartNew(() => { while (true) { List <DoubleDataPoint> yy = new List <DoubleDataPoint>() { mainWindow.Y, mainWindow.Ie, mainWindow.Y, // mainWindow.n, mainWindow.Y, // mainWindow.fGenerator, mainWindow.Y, // mainWindow.UGenerator, mainWindow.Y, // mainWindow.Phasenlage, }; var x = watch.Elapsed; List <TimeSpanDataPoint> xx = new List <TimeSpanDataPoint>() { x, x, x, x, x, x }; MultiController.PushData(xx, yy); Thread.Sleep(50); } }); }
public MainWindowVM(string _name, DataObject[] _Objects) { Objects = _Objects; Controller = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); Controller.Range.MinimumY = 0; Controller.Range.MaximumY = 1080; Controller.Range.MaximumX = TimeSpan.FromSeconds(10); Controller.Range.AutoY = true; Controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = _name, Stroke = Colors.DodgerBlue, }); MultiController = new WpfGraphController <TimeSpanDataPoint, DoubleDataPoint>(); MultiController.Range.MinimumY = 0; MultiController.Range.MaximumY = 1080; MultiController.Range.MaximumX = TimeSpan.FromSeconds(10); MultiController.Range.AutoY = true; Color[] color_list = { Colors.Red, Colors.Green, Colors.Blue, Colors.Yellow, Colors.Gray, Colors.Purple, Colors.White, Colors.Silver, Colors.Orange, Colors.GreenYellow }; y = new DoubleDataPoint[Objects.Length]; for (int i = 0; i < Objects.Length; i++) { MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() { Name = _name + " " + (i + 1).ToString(), Stroke = color_list[i], }); y[i] = 0; } /* * MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() * { * Name = _name + " 1", * Stroke = Colors.Red, * }); * * MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() * { * Name = _name + " 2", * Stroke = Colors.Green, * }); * * MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() * { * Name = _name + " 3", * Stroke = Colors.Blue, * }); * * MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() * { * Name = _name + " 4", * Stroke = Colors.Yellow, * }); * * MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries() * { * Name = _name + " 5", * Stroke = Colors.Gray, * }); */ Stopwatch watch = new Stopwatch(); watch.Start(); Task.Factory.StartNew(() => { while (true) { List <DoubleDataPoint> yy = new List <DoubleDataPoint>(); for (int i = 0; i < Objects.Length; i++) { yy.Add(y[i]); } var x = watch.Elapsed; List <TimeSpanDataPoint> xx = new List <TimeSpanDataPoint>(); for (int i = 0; i < Objects.Length; i++) { xx.Add(x); } Controller.PushData(x, y[0]); MultiController.PushData(xx, yy); Thread.Sleep(30); } }); }