Example 119: Scientific Graph showing real-time 5

PesgoScientific Graph Objectadvanced

Real-time 5

Preview

ProEssentials Pesgo Scientific Graph Object - Scientific Graph showing real-time 5
Click to enlarge

Source Code

Form3.cs
1//! Chart holds 2000 points. Data is fed into
2//! data arrays at current data index. Once 2000
3//! points have been passed, 250 are truncated as
4//! data is shifted to make room for 250 more data
5//! points.
6
7// Depending upon ZoomMode property, this example with
8// either show most current 3 minutes or all data in
9// object.
10
11Pesgo1.PeData.Subsets = 1;
12Pesgo1.PeData.Points = 2000;
13
14Pesgo1.PeData.DateTimeMode = true; // Date/Time Mode
15Pesgo1.PeData.UsingXDataii = true; // Using Double Precision XDataII
16
17//Some functional attributes// // 1440 is minutes in a day
18MainWindow.ZoomInterval = (3.0 / 1440.0); // 3 minute scale zoom interval
19MainWindow.ZoomSmallInterval = (0.5 / 1440.0); // 30 second scale adjustment
20
21// Extents to show all data points //
22MainWindow.StartTime = DateTime.Now.ToOADate();
23Pesgo1.PeGrid.Configure.ManualScaleControlX = ManualScaleControl.MinMax;
24Pesgo1.PeGrid.Configure.ManualMinX = MainWindow.StartTime;
25Pesgo1.PeGrid.Configure.ManualMaxX = Pesgo1.PeGrid.Configure.ManualMinX + MainWindow.ZoomInterval;
26
27Pesgo1.PeGrid.Configure.ManualScaleControlY = ManualScaleControl.MinMax;
28Pesgo1.PeGrid.Configure.ManualMinY = 1;
29Pesgo1.PeGrid.Configure.ManualMaxY = 100;
30
31//Set Zoomed partial Range of X Scale//
32MainWindow.ZoomStart = MainWindow.StartTime;
33MainWindow.ZoomEnd = MainWindow.ZoomStart + MainWindow.ZoomInterval;
34Pesgo1.PeGrid.Zoom.MinX = MainWindow.ZoomStart;
35Pesgo1.PeGrid.Zoom.MaxX = MainWindow.ZoomEnd;
36Pesgo1.PeGrid.Zoom.MinY = 1;
37Pesgo1.PeGrid.Zoom.MaxY = 100;
38Pesgo1.PeGrid.Zoom.Mode = true;
39//If ZoomMode is true, you will see 3 minutes of data//
40//If ZoomMode is false, you will see all data in object//
41
42// Clear out default data//
43// No need to clear out XData since using XDataII//
44Pesgo1.PeData.Y[0, 0] = 0;
45Pesgo1.PeData.Y[0, 1] = 0;
46Pesgo1.PeData.Y[0, 2] = 0;
47Pesgo1.PeData.Y[0, 3] = 0;
48
49// Set Various Other Properties ///
50Pesgo1.PeColor.BitmapGradientMode = true;
51Pesgo1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;
52
53//Set various properties//
54Pesgo1.PeString.MainTitle = "Scientific Real-Time Example";
55Pesgo1.PeString.SubTitle = "";
56Pesgo1.PeUserInterface.Dialog.RandomPointsToExport = true;
57Pesgo1.PeUserInterface.Allow.FocalRect = false;
58Pesgo1.PePlot.Allow.Bar = false;
59Pesgo1.PeUserInterface.Allow.Popup = false;
60Pesgo1.PeConfigure.PrepareImages = true;
61Pesgo1.PeConfigure.CacheBmp = true;
62Pesgo1.PeFont.Fixed = true;
63Pesgo1.PeColor.SubsetColors[0] = Color.FromArgb(255, 200, 200, 20);
64
65Pesgo1.PeConfigure.TextShadows = TextShadows.BoldText;
66Pesgo1.PeFont.MainTitle.Bold = true;
67Pesgo1.PeFont.SubTitle.Bold = true;
68Pesgo1.PeFont.Label.Bold = true;
69Pesgo1.PePlot.Option.LineShadows = true;
70Pesgo1.PeFont.FontSize = FontSize.Large;
71Pesgo1.PeFont.SizeGlobalCntl = 1.4F;
72
73Pesgo1.PePlot.SubsetLineTypes[0] = LineType.MediumThickSolid;
74Pesgo1.PePlot.Method = SGraphPlottingMethod.Line;
75Pesgo1.PePlot.DataShadows = DataShadows.Shadows;
76Pesgo1.PeGrid.Configure.AutoMinMaxPaddingX = 0;
77// Not ideal for real-time, but nice for presentation/demonstration
78Pesgo1.PePlot.Option.PointGradientStyle = PlotGradientStyle.VerticalAscentInverse;
79Pesgo1.PeColor.PointBorderColor = Color.FromArgb(100, 0, 0, 0);
80Pesgo1.PeGrid.Style = GridStyle.Dash;
81
82// Set various export defaults //
83Pesgo1.PeSpecial.DpiX = 600;
84Pesgo1.PeSpecial.DpiY = 600;
85
86Pesgo1.PeConfigure.RenderEngine = RenderEngine.Direct2D;
87Pesgo1.PeConfigure.AntiAliasText = true;
88Pesgo1.PeConfigure.AntiAliasGraphics = true;
89
90Pesgo1.PeFunction.ReinitializeResetImage();
91
92// Initialize Counters and Timer //
93MainWindow.m_nRealTimeCounter = 1;
94MainWindow.m_nSinCounter = 1;
95
96MainWindow.Timer1.Interval = 500;
97MainWindow.Timer1.Start();
98
99/*
100/////////////////////////
101// Example Timer Event //
102/////////////////////////
103private void Timer1_Tick(object sender, System.EventArgs e)
104{
105 double newx2;
106 float newy;
107
108 // New y value and x value //
109 newy = (float)(50 + (Math.Sin(m_nSinCounter * 0.075) * 30) + (Rand_Num.NextDouble() * 15));
110 newx2 = DateTime.Now.ToOADate();
111
112 // Shift data when counter reaches end of data. //
113 if (m_nRealTimeCounter >= 1999)
114 {
115 // Shift Data by 250 data points, oldest 250 will be lost.
116 m_nRealTimeCounter = m_nRealTimeCounter - 250;
117 float[] NewYData = new float[250];
118 double[] NewXData = new double[250];
119 Pesgo1.PeData.Y.AppendData(NewYData, 250);
120 Pesgo1.PeData.Xii.AppendData(NewXData, 250);
121 }
122
123 // Store new values at current index //
124 Pesgo1.PeData.Xii[0, m_nRealTimeCounter] = newx2;
125 Pesgo1.PeData.Y[0, m_nRealTimeCounter] = newy;
126
127 // Increment index counter //
128 m_nRealTimeCounter = m_nRealTimeCounter + 1;
129
130 // SinCounter is only to produce sin wave data //
131 m_nSinCounter = m_nSinCounter + 1;
132 if (m_nSinCounter > 30000)
133 m_nSinCounter = 1;
134
135 // If current time is beyond zoom max, the re-adjust zoom max //
136 if (newx2 > ZoomEnd)
137 {
138 ZoomEnd = ZoomEnd + ZoomSmallInterval;
139 ZoomStart = ZoomEnd - ZoomInterval;
140 Pesgo1.PeGrid.Zoom.MinX = ZoomStart;
141 Pesgo1.PeGrid.Zoom.MaxX = ZoomEnd;
142 Pesgo1.PeGrid.Configure.ManualMinX = Pesgo1.PeData.Xii[0, 1];
143 Pesgo1.PeGrid.Configure.ManualMaxX = ZoomEnd;
144 }
145
146 // Update image and force paint //
147 Pesgo1.PeFunction.ReinitializeResetImage();
148 Pesgo1.Refresh();
149}
150*/
Tip: Uses property syntax like Pego1.PeData.Y[s, p]Click underlined properties to view documentation