private void SetGraph(long[] sensorValue) { // InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.sensorChart.InvokeRequired) { SetGraphCallback d = new SetGraphCallback(SetGraph); this.Invoke(d, sensorValue); } else { // A cast is needed to convert the stored elapsed time from a long to a double type double timeInSeconds = ((double)sensorValue[0]) / 1000; // Add the new datapoints to the charts this.sensorChart.Series["X-Axis"].Points.AddXY(timeInSeconds, sensorValue[1]); this.sensorChart.Series["Y-Axis"].Points.AddXY(timeInSeconds, sensorValue[2]); this.sensorChart.Series["Z-Axis"].Points.AddXY(timeInSeconds, sensorValue[3]); if (this.sensorChart.ChartAreas[0].AxisX.ScrollBar.IsVisible) { this.sensorChart.ChartAreas[0].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[0].AxisX.Maximum - (0.9 * axisView); this.sensorChart.ChartAreas[1].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[1].AxisX.Maximum - (0.9 * axisView); this.sensorChart.ChartAreas[2].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[2].AxisX.Maximum - (0.9 * axisView); } } }//end method SetGraph
private void SetGraph() { if (this.zedGraphControl1.InvokeRequired) { var d = new SetGraphCallback(SetGraph); this.Invoke(d); } else { DrawGraphOfRealData(); } }
}//end method SetText private void SetGraph(short[] sensorValue) { // InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.sensorChart.InvokeRequired) { SetGraphCallback d = new SetGraphCallback(SetGraph); this.Invoke(d, new object[] { sensorValue }); } else { this.sensorChart.Series["X-Axis"].Points.AddY(sensorValue[0]); this.sensorChart.Series["Y-Axis"].Points.AddY(sensorValue[1]); this.sensorChart.Series["Z-Axis"].Points.AddY(sensorValue[2]); } } //end method SetGraph
private void SetGraph(long[] sensorValue) { // InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.sensorChart.InvokeRequired) { SetGraphCallback d = new SetGraphCallback(SetGraph); this.Invoke(d, sensorValue); } else { // A cast is needed to convert the stored elapsed time from a long to a double type double timeInSeconds = ((double)sensorValue[0]) / 1000; // Add the new datapoints to the charts this.sensorChart.Series["X-Axis"].Points.AddXY(timeInSeconds, sensorValue[1]); this.sensorChart.Series["Y-Axis"].Points.AddXY(timeInSeconds, sensorValue[2]); this.sensorChart.Series["Z-Axis"].Points.AddXY(timeInSeconds, sensorValue[3]); // Keep only a minute-worth of data history (based on 10 Hz) foreach (var series in this.sensorChart.Series) { if (series.Points.Count > 600) { series.Points.RemoveAt(0); } }//end foreach // Generate an auto-scrolling for all charts if (this.sensorChart.ChartAreas[0].AxisX.ScrollBar.IsVisible) { this.sensorChart.ChartAreas[0].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[0].AxisX.Maximum - (0.9 * axisView); this.sensorChart.ChartAreas[1].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[1].AxisX.Maximum - (0.9 * axisView); this.sensorChart.ChartAreas[2].AxisX.ScaleView.Position = this.sensorChart.ChartAreas[2].AxisX.Maximum - (0.9 * axisView); } //end if } //end else } //end method SetGraph
/// <summary> /// rysowanie grafu w formsie /// </summary> private void fillGraph() { IVertexAndEdgeListGraph<string, Edge<string>> g = networkGraph; var populator = GleeGraphExtensions.CreateGleePopulator<String, Edge<String>>(g); populator.Compute(); Microsoft.Glee.Drawing.Graph graph = populator.GleeGraph; if (this.gViewer.InvokeRequired) { SetGraphCallback d = new SetGraphCallback(SetGraph); this.Invoke(d, new object[] { graph }); } else { try { gViewer.Graph = graph; } catch { } } }
private void updatePlot() { if (this.chart1.InvokeRequired) { SetGraphCallback d = new SetGraphCallback(updatePlot); this.Invoke(d, new object[] { }); } else { if (engUnits != null) { int newPointsNumber = NumPoints / numOfPointsPerGraphPoint; counterMeas = counterMeas + newPointsNumber; //myBoard.AIn(0, MccDaq.Range.Bip10Volts,out dataValue); //myBoard.ToEngUnits(MccDaq.Range.Bip10Volts, dataValue, out engUnits); //label1.Text = engUnits.ToString(); if (counterMeas > pointsNumOnGraph) { for (int i = 0; i < newPointsNumber; i++) chart1.Series[0].Points.RemoveAt(0);// (counterMeas, (double)engUnits); } for (int i = 0; i < newPointsNumber; i++) chart1.Series[0].Points.AddY(engUnits[i]); // label1.Text = (sw.ElapsedMilliseconds).ToString(); chart1.Update(); chartPulseTimerCounter++; } if (chartPulseTimerCounter == 5) { double max1 = chart1.Series[0].Points.FindMaxByValue().YValues[0]; double min1 = chart1.Series[0].Points.FindMinByValue().YValues[0]; double delta = Math.Abs(max1 * 0.001); chart1.ChartAreas[0].AxisY.Maximum = max1 + delta; chart1.ChartAreas[0].AxisY.Minimum = min1 - delta; chartPulseTimerCounter = 0; } } }