예제 #1
0
        private void PopulateData()
        {
            // Prepare data base connection and query strings
            System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm) this.ParentForm;
            string fileNameString = mainForm.applicationPath + "\\";

            fileNameString += "data\\chartdata.mdb";
            string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString;
            string mySelectQuery      = "SELECT * FROM STOCKDATA WHERE SymbolName = '" + comboBoxStockSymbol.Text + "' ORDER BY Date";

            // Open data base connection
            OleDbConnection myConnection = new OleDbConnection(myConnectionString);
            OleDbCommand    myCommand    = new OleDbCommand(mySelectQuery, myConnection);

            myCommand.Connection.Open();

            // Create a database reader
            OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            // Data bind to the reader
            chart1.Series["StockPrice"].Points.Clear();
            chart1.Series["StockPrice"].Points.DataBindXY(myReader, "Date", myReader, "High,Low,Open,Close");

            // Group series data points by interval. Different formulas are used for each Y value:
            //   Y1 (High) - maximum of all Y1 points values in the group
            //   Y2 (Low) - minimum of all Y2 points values in the group
            //   Y3 (Open) - Y3 value of the first point in the group
            //   Y4 (Close) - Y4 value of the last point in the group
            chart1.Series["GroupedStockPrice"].Points.Clear();
            if (comboBoxGroupingInterval.Text == "Week")
            {
                chart1.DataManipulator.Group("Y1:MAX,Y2:MIN,Y3:FIRST,Y4:LAST", 1, IntervalType.Weeks, "StockPrice", "GroupedStockPrice");
            }
            else if (comboBoxGroupingInterval.Text == "Month")
            {
                chart1.DataManipulator.Group("Y1:MAX,Y2:MIN,Y3:FIRST,Y4:LAST", 1, IntervalType.Months, "StockPrice", "GroupedStockPrice");
            }
            else if (comboBoxGroupingInterval.Text == "Quarter")
            {
                chart1.DataManipulator.Group("Y1:MAX,Y2:MIN,Y3:FIRST,Y4:LAST", 3, IntervalType.Months, "StockPrice", "GroupedStockPrice");
            }

            // close the reader and the connection
            myReader.Close();
            myConnection.Close();

            chart1.ResetAutoValues();
            chart1.Invalidate();
        }
예제 #2
0
        private void checkBoxGrouped_CheckedChanged(object sender, System.EventArgs e)
        {
            if (checkBoxGrouped.Checked)
            {
                chart1.Series["Series1"]["StackedGroupName"] = "Group1";
                chart1.Series["Series2"]["StackedGroupName"] = "Group1";
                chart1.Series["Series3"]["StackedGroupName"] = "Group2";
                chart1.Series["Series4"]["StackedGroupName"] = "Group2";

                chart1.ResetAutoValues();
                chart1.Invalidate();
            }

            else
            {
                foreach (Series series in chart1.Series)
                {
                    series["StackedGroupName"] = "";
                }

                chart1.ResetAutoValues();
                chart1.Invalidate();
            }
        }
예제 #3
0
        private void UpdateChartSettings()
        {
            // Show data points using point's index
            if (comboBoxShowAsIndexed.Text == "True")
            {
                chart1.Series["Series Output"].IsXValueIndexed = true;
                chart1.DataManipulator.FilterSetEmptyPoints    = false;
                chart1.ResetAutoValues();
            }
            else
            {
                chart1.Series["Series Output"].IsXValueIndexed = false;
                chart1.DataManipulator.FilterSetEmptyPoints    = true;
                chart1.ResetAutoValues();
                chart1.ChartAreas["FilteredData"].AxisY.Minimum = 0;
                chart1.ChartAreas["FilteredData"].AxisY.Maximum = 1000;
            }

            // Filter series data
            if (comboBoxPointsFilter.Text == "Weekends")
            {
                chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "0,6", "Series Input", "Series Output");
            }
            else if (comboBoxPointsFilter.Text == "Weekdays")
            {
                chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "1-5", "Series Input", "Series Output");
            }
            else if (comboBoxPointsFilter.Text == "Except 15")
            {
                chart1.DataManipulator.Filter(DateRangeType.DayOfMonth, "1-14,16-31", "Series Input", "Series Output");
            }
            else if (comboBoxPointsFilter.Text == "Except 1-15")
            {
                chart1.DataManipulator.Filter(DateRangeType.DayOfMonth, "16-31", "Series Input", "Series Output");
            }
        }
예제 #4
0
        private void timerRealTimeData_Tick(object sender, System.EventArgs e)
        {
            // Define some variables
            int numberOfPointsInChart      = int.Parse(comboBoxVisiblePoints.Text);
            int numberOfPointsAfterRemoval = numberOfPointsInChart - int.Parse(comboBoxPointsRemoved.Text);

            // Simulate adding new data points
            int numberOfPointsAddedMin = 5;
            int numberOfPointsAddedMax = 10;

            for (int pointNumber = 0; pointNumber <
                 random.Next(numberOfPointsAddedMin, numberOfPointsAddedMax); pointNumber++)
            {
                chart1.Series[0].Points.AddXY(pointIndex + 1, random.Next(1000, 5000));
                ++pointIndex;
            }

            // Adjust Y & X axis scale
            chart1.ResetAutoValues();
            if (chart1.ChartAreas["Default"].AxisX.Maximum < pointIndex)
            {
                chart1.ChartAreas["Default"].AxisX.Maximum = pointIndex;
            }

            // Keep a constant number of points by removing them from the left
            while (chart1.Series[0].Points.Count > numberOfPointsInChart)
            {
                // Remove data points on the left side
                while (chart1.Series[0].Points.Count > numberOfPointsAfterRemoval)
                {
                    chart1.Series[0].Points.RemoveAt(0);
                }

                // Adjust X axis scale
                chart1.ChartAreas["Default"].AxisX.Minimum = pointIndex - numberOfPointsAfterRemoval;
                chart1.ChartAreas["Default"].AxisX.Maximum = chart1.ChartAreas["Default"].AxisX.Minimum + numberOfPointsInChart;
            }

            // Redraw chart
            chart1.Invalidate();
        }
        public void SetEigenVecToChart(Chart chart1)
        {
            // 波数
            double k0 = 2.0 * Constants.pi / WaveLength;
            // 角周波数
            double omega = k0 * Constants.c0;

            int[] portModeCntAry = getPortModeCntFromBetaData();

            // チャート初期化
            setupChartColor(chart1);
            chart1.Titles[0].Text = "固有モードEz実部、虚部の分布 (2W/λ = " + (isInputDataReady()? string.Format("{0:F2}", GetNormalizedFrequency()) : "---") + ")";
            chart1.ChartAreas[0].Axes[0].Title = "x / W";
            chart1.ChartAreas[0].Axes[1].Title = "Ez";
            chart1.ChartAreas[0].Axes[0].Minimum = 0.0;
            chart1.ChartAreas[0].Axes[0].Maximum = 1.0;
            chart1.ChartAreas[0].Axes[0].Interval = 0.2;
            chart1.ChartAreas[0].Axes[1].Minimum = -1.0;
            chart1.ChartAreas[0].Axes[1].Maximum = 1.0;
            chart1.ChartAreas[0].Axes[1].Interval = 0.2;
            chart1.Series.Clear();
            if (!isInputDataReady())
            {
                //MessageBox.Show("入力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            for (int portIndex = 0; portIndex < Ports.Count; portIndex++)
            {
                for (int iMode = 0; iMode < portModeCntAry[portIndex]; iMode++)
                {
                    string modeDescr = "---モード";
                    if (isOutputDataReady())
                    {
                        Complex beta = 0.0;
                        if (iMode < EigenValuesList[portIndex].Length)
                        {
                            beta = EigenValuesList[portIndex][iMode];
                        }
                        if (Math.Abs(beta.Imaginary / k0) >= Constants.PrecisionLowerLimit)
                        {
                            modeDescr = "減衰モード";
                        }
                        else if (Math.Abs(beta.Real / k0) >= Constants.PrecisionLowerLimit)
                        {
                            modeDescr = "伝搬モード";
                        }
                    }

                    Series series;
                    series = new Series();
                    series.Name = string.Format(((WaveModeDv == FemSolver.WaveModeDV.TM) ? "TM({0}) 実部 at {1}" : "TE({0}) 実部 at {1}")
                        + Environment.NewLine + modeDescr, iMode + 1, portIndex + 1);
                    series.ChartType = SeriesChartType.Line;
                    //series.MarkerStyle = MarkerStyle.Square;
                    series.BorderDashStyle = ChartDashStyle.Solid;
                    chart1.Series.Add(series);
                    series = new Series();
                    series.Name = string.Format(((WaveModeDv == FemSolver.WaveModeDV.TM) ? "TM({0}) 虚部 at {1}" : "TE({0}) 虚部 at {1}")
                        + Environment.NewLine + modeDescr, iMode + 1, portIndex + 1);
                    series.ChartType = SeriesChartType.Line;
                    //series.MarkerStyle = MarkerStyle.Cross;
                    series.BorderDashStyle = ChartDashStyle.Dash;
                    chart1.Series.Add(series);
                }
            }
            // 計算されたグラフのプロパティ値をAutoに設定
            chart1.ResetAutoValues();

            if (!isInputDataReady())
            {
                //MessageBox.Show("入力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!isOutputDataReady())
            {
                //MessageBox.Show("出力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int dataIndex = 0;
            for (int portIndex = 0; portIndex < Ports.Count; portIndex++)
            {
                IList<int> portNodes = Ports[portIndex];
                Complex[,] eigenVecs = EigenVecsList[portIndex];
                int nodeCnt = eigenVecs.GetLength(1);
                for (int iMode = 0; iMode < portModeCntAry[portIndex]; iMode++)
                {
                    Complex beta = 0.0;
                    if (iMode < EigenValuesList[portIndex].Length)
                    {
                        beta = EigenValuesList[portIndex][iMode];
                    }
                    /*
                    if (Math.Abs(beta.Imaginary/k0) >= Constants.PrecisionLowerLimit)
                    {
                        // 減衰モードは除外
                        continue;
                    }
                    */

                    double maxValue = 0.0;
                    for (int ino = 0; ino < nodeCnt; ino++)
                    {
                        Complex cval = 0.0;
                        if (iMode < eigenVecs.GetLength(0))
                        {
                            cval = eigenVecs[iMode, ino];
                        }
                        double abs = cval.Magnitude;
                        if (abs > maxValue)
                        {
                            maxValue = abs;
                        }
                    }
                    Series seriesReal = chart1.Series[dataIndex];
                    Series seriesImag = chart1.Series[dataIndex + 1];
                    {
                        int ino = 0;  // 強制境界を除いた節点のインデックス
                        for (int inoB = 0; inoB < portNodes.Count; inoB++)
                        {
                            int nodeNumber = portNodes[inoB];
                            // 正確には座標を取ってくる必要があるが等間隔が保障されていれば、下記で規格化された位置は求まる
                            double x0;
                            x0 = inoB / (double)(portNodes.Count - 1);
                            if (ForceNodes.Contains(nodeNumber))
                            {
                                seriesReal.Points.AddXY(x0, 0.0); // 実数部
                                seriesImag.Points.AddXY(x0, 0.0); // 虚数部
                            }
                            else if (Math.Abs(maxValue) < Constants.PrecisionLowerLimit)
                            {
                                seriesReal.Points.AddXY(x0, 0.0); // 実数部
                                seriesImag.Points.AddXY(x0, 0.0); // 虚数部
                                ino++;
                            }
                            else
                            {
                                Complex cval = eigenVecs[iMode, ino];
                                double real = cval.Real / maxValue;
                                double imag = cval.Imaginary / maxValue;
                                seriesReal.Points.AddXY(x0, real); // 実数部
                                seriesImag.Points.AddXY(x0, imag); // 虚数部
                                ino++;
                            }
                        }
                    }
                    // 実数部と虚数部の2データ分進める
                    dataIndex += 2;
                }
            }
        }
        /// <summary>
        /// 反射、透過係数周波数特性グラフの初期化
        /// </summary>
        /// <param name="chart1"></param>
        public void ResetSMatChart(Chart chart1, bool dataClearFlg = true)
        {
            double normalizedFreq1 = FemSolver.GetNormalizedFreq(FirstWaveLength, WaveguideWidth);
            normalizedFreq1 = Math.Round(normalizedFreq1, 2);
            double normalizedFreq2 = FemSolver.GetNormalizedFreq(LastWaveLength, WaveguideWidth);
            normalizedFreq2 = Math.Round(normalizedFreq2, 2);

            // チャート初期化
            setupChartColor(chart1);
            chart1.Titles[0].Text = "散乱係数周波数特性";
            chart1.ChartAreas[0].Axes[0].Title = "2W/λ";
            chart1.ChartAreas[0].Axes[1].Title = string.Format("|Si{0}|", IncidentPortNo);
            SetChartFreqRange(chart1, normalizedFreq1, normalizedFreq2);
            //chart1.ChartAreas[0].Axes[1].Minimum = 0.0;
            //chart1.ChartAreas[0].Axes[1].Maximum = 1.0;
            //chart1.ChartAreas[0].Axes[1].Interval = 0.2;
            chart1.Series.Clear();
            if (dataClearFlg)
            {
                SMatChartXValueList.Clear();
                SMatChartYValuesList.Clear();
            }
            if (!isInputDataReady())
            {
                //MessageBox.Show("入力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 表示するモード数をデータから判定する
            int portCnt = Ports.Count;
            int[] portModeCntAry = getPortModeCntFromSMatData();

            for (int portIndex = 0; portIndex < portCnt; portIndex++)
            {
                int portModeCnt = portModeCntAry[portIndex];
                if (portModeCnt <= 1)
                {
                    Series series = new Series();
                    series.Name = string.Format("|S{0}{1}|", portIndex + 1, IncidentPortNo);
                    series.ChartType = SeriesChartType.Line;
                    series.BorderDashStyle = ChartDashStyle.Solid;
                    chart1.Series.Add(series);
                }
                else
                {
                    for (int iMode = 0; iMode < portModeCnt; iMode++)
                    {
                        Series series = new Series();
                        series.Name = string.Format("|S{0}({1}){2}|", portIndex + 1, (iMode + 1), IncidentPortNo);
                        series.ChartType = SeriesChartType.Line;
                        series.BorderDashStyle = ChartDashStyle.Solid;
                        chart1.Series.Add(series);
                    }
                }
            }
            // 基本モード以外への電力損失のルート値
            {
                Series series = new Series();
                series.Name = "√|loss|";
                series.ChartType = SeriesChartType.Line;
                series.BorderDashStyle = ChartDashStyle.Dash;
                series.Color = chart1.ChartAreas[0].AxisX.LineColor;//chart1.Parent.ForeColor;
                chart1.Series.Add(series);
            }
            // 計算されたグラフのプロパティ値をAutoに設定
            chart1.ResetAutoValues();
        }
        /// <summary>
        /// 伝搬定数分散特性(グラフの初期化
        /// </summary>
        /// <param name="chart1"></param>
        public void ResetEigenValueChart(Chart chart1, bool isDataClear = true)
        {
            double normalizedFreq1 = FemSolver.GetNormalizedFreq(FirstWaveLength, WaveguideWidth);
            normalizedFreq1 = Math.Round(normalizedFreq1, 2);
            double normalizedFreq2 = FemSolver.GetNormalizedFreq(LastWaveLength, WaveguideWidth);
            normalizedFreq2 = Math.Round(normalizedFreq2, 2);

            if (isDataClear)
            {
                BetaChartXValueList.Clear();
                BetaChartYValuesList.Clear();
            }

            // 表示モード数
            int[] portModeCntAry = getPortModeCntFromBetaData();

            // チャート初期化
            setupChartColor(chart1);
            chart1.Titles[0].Text = "規格化伝搬定数周波数特性";
            chart1.ChartAreas[0].Axes[0].Title = "2W/λ";
            chart1.ChartAreas[0].Axes[1].Title = "β/ k0";
            SetChartFreqRange(chart1, normalizedFreq1, normalizedFreq2);
            chart1.ChartAreas[0].Axes[1].Minimum = 0.0;
            //chart1.ChartAreas[0].Axes[1].Maximum = 1.0; // 誘電体比誘電率の最大となるので可変
            //chart1.ChartAreas[0].Axes[1].Interval = 0.2;
            chart1.Series.Clear();
            if (!isInputDataReady())
            {
                //MessageBox.Show("入力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            for (int portIndex = 0; portIndex < Ports.Count; portIndex++)
            {
                for (int modeIndex = 0; modeIndex < portModeCntAry[portIndex]; modeIndex++)
                {
                    Series series = new Series();
                    series.Name = string.Format(((WaveModeDv == FemSolver.WaveModeDV.TM) ? "TM({0}) at {1}" : "TE({0}) at {1}"), modeIndex + 1, portIndex + 1);
                    series.ChartType = SeriesChartType.Line;
                    chart1.Series.Add(series);
                }
            }
            // 計算されたグラフのプロパティ値をAutoに設定
            chart1.ResetAutoValues();
        }
예제 #8
0
        public static void ParseStreamIntoChart( NetworkStream NetworkStream, Chart NetworkChart, string ActorFilter, string PropertyFilter, string RPCFilter )
        {
            var StartTime = DateTime.UtcNow;

            NetworkChart.BeginInit();

            // Reset existing data.
            foreach( var Series in NetworkChart.Series )
            {
                Series.Points.Clear();
            }
            NetworkChart.ResetAutoValues();
            NetworkChart.Invalidate();

            int FrameCounter = 0;
            foreach( PartialNetworkStream RawFrame in NetworkStream.Frames )
            {
                PartialNetworkStream Frame = RawFrame.Filter(ActorFilter,PropertyFilter,RPCFilter);

                if( Frame.EndTime == Frame.StartTime )
                {
                    throw new InvalidOperationException();
                }
                float OneOverDeltaTime = 1 / (Frame.EndTime - Frame.StartTime);

                NetworkChart.Series["ActorCount"].Points.AddXY( FrameCounter, Frame.ActorCount );
                NetworkChart.Series["ActorCountSec"].Points.AddXY(FrameCounter, Frame.ActorCount * OneOverDeltaTime);
                NetworkChart.Series["PropertyCount"].Points.AddXY( FrameCounter, Frame.PropertyCount );
                NetworkChart.Series["PropertyCountSec"].Points.AddXY( FrameCounter, Frame.PropertyCount * OneOverDeltaTime );
                NetworkChart.Series["PropertySize"].Points.AddXY( FrameCounter, Frame.ReplicatedSizeBits / 8 );
                NetworkChart.Series["PropertySizeSec"].Points.AddXY( FrameCounter, Frame.ReplicatedSizeBits / 8 * OneOverDeltaTime );
                NetworkChart.Series["RPCCount"].Points.AddXY( FrameCounter, Frame.RPCCount );
                NetworkChart.Series["RPCCountSec"].Points.AddXY( FrameCounter, Frame.RPCCount * OneOverDeltaTime );
                NetworkChart.Series["RPCSize"].Points.AddXY( FrameCounter, Frame.RPCSizeBits / 8 );
                NetworkChart.Series["RPCSizeSec"].Points.AddXY( FrameCounter, Frame.RPCSizeBits / 8 * OneOverDeltaTime );
                NetworkChart.Series["SendBunchCount"].Points.AddXY( FrameCounter, Frame.SendBunchCount );
                NetworkChart.Series["SendBunchCountSec"].Points.AddXY( FrameCounter, Frame.SendBunchCount * OneOverDeltaTime );
                NetworkChart.Series["SendBunchSize"].Points.AddXY( FrameCounter, Frame.SendBunchSizeBits / 8 );
                NetworkChart.Series["SendBunchSizeSec"].Points.AddXY( FrameCounter, Frame.SendBunchSizeBits / 8 * OneOverDeltaTime );
                NetworkChart.Series["GameSocketSendSize"].Points.AddXY( FrameCounter, Frame.UnrealSocketSize );
                NetworkChart.Series["GameSocketSendSizeSec"].Points.AddXY( FrameCounter, Frame.UnrealSocketSize * OneOverDeltaTime );
                NetworkChart.Series["GameSocketSendCount"].Points.AddXY( FrameCounter, Frame.UnrealSocketCount );
                NetworkChart.Series["GameSocketSendCountSec"].Points.AddXY( FrameCounter, Frame.UnrealSocketCount * OneOverDeltaTime );
                NetworkChart.Series["MiscSocketSendSize"].Points.AddXY( FrameCounter, Frame.OtherSocketSize );
                NetworkChart.Series["MiscSocketSendSizeSec"].Points.AddXY( FrameCounter, Frame.OtherSocketSize * OneOverDeltaTime );
                NetworkChart.Series["MiscSocketSendCount"].Points.AddXY( FrameCounter, Frame.OtherSocketCount );
                NetworkChart.Series["MiscSocketSendCountSec"].Points.AddXY( FrameCounter, Frame.OtherSocketCount * OneOverDeltaTime );
                int OutgoingBandwidth = Frame.UnrealSocketSize + Frame.OtherSocketSize + NetworkStream.PacketOverhead * (Frame.UnrealSocketCount + Frame.OtherSocketCount);
                NetworkChart.Series["OutgoingBandwidthSize"].Points.AddXY( FrameCounter, OutgoingBandwidth );
                NetworkChart.Series["OutgoingBandwidthSizeSec"].Points.AddXY( FrameCounter, OutgoingBandwidth * OneOverDeltaTime );
                NetworkChart.Series["ActorReplicateTimeInMS"].Points.AddXY(FrameCounter, Frame.ActorReplicateTimeInMS);

                if( Frame.NumEvents > 0 )
                {
                    NetworkChart.Series["Events"].Points.AddXY( FrameCounter, 0 );
                }

                FrameCounter++;
            }

            NetworkChart.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage,"30","GameSocketSendSizeSec","GameSocketSendSizeAvgSec");
            NetworkChart.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage,"30","OutgoingBandwidthSizeSec","OutgoingBandwidthSizeAvgSec");

            NetworkChart.ChartAreas["DefaultChartArea"].RecalculateAxesScale();

            NetworkChart.EndInit();

            Console.WriteLine("Adding data to chart took {0} seconds", (DateTime.UtcNow - StartTime).TotalSeconds);
        }
예제 #9
0
        /// <summary>
        /// Add graphics point overload method - Series Name instead of Series Num
        /// </summary>
        /// <param name="CurChart"></param>
        /// <param name="serName">Series name</param>
        /// <param name="XVal"></param>
        /// <param name="YVal"></param>
        private void addGraphicsPoint(Chart CurChart, string serName, DateTime XVal, double YVal)
        {
            //curX=DateTime.Now;
            CurChart.Series[serName].Points.AddXY(XVal, YVal);

            // Keep a constant number of points by removing them from the left
            if (CurChart.Series[serName].Points.Count > maxNumberOfPointsInChart)
            {
                // Remove data points on the left side
                while (CurChart.Series[serName].Points.Count > maxNumberOfPointsInChart)
                {
                    CurChart.Series[serName].Points.RemoveAt(0);
                }

                // Adjust X axis scale
                //CurChart.ChartAreas[0].AxisX.Minimum = curX - maxNumberOfPointsInChart;
                //CurChart.ChartAreas[0].AxisX.Maximum = CurChart.ChartAreas[0].AxisX.Minimum + maxNumberOfPointsInChart;
            }

            // Adjust Y & X axis scale
            CurChart.ResetAutoValues();

            // Invalidate chart
            CurChart.Invalidate();
        }
예제 #10
0
        private void DisplayChartFOnIteration(Chart chart, List<double> fList)
        {
            Series fOnIter = new Series
            {
                ChartType = SeriesChartType.Line
            };
            for (int i = 0; i < fList.Count; i++)
            {
                fOnIter.Points.AddXY(i, fList[i]);
            }

            chart.Series.Clear();
            chart.Series.Add(fOnIter);
            chart.ResetAutoValues();
        }
예제 #11
0
		public static void ParseStreamIntoChart( MainWindow InMainWindow, NetworkStream NetworkStream, Chart NetworkChart, FilterValues InFilterValues )
		{
			var StartTime = DateTime.UtcNow;

			InMainWindow.ShowProgress( true );

			// Save old scroll position
			double OldPosition = NetworkChart.ChartAreas["DefaultChartArea"].AxisX.ScaleView.Position;

			NetworkChart.BeginInit();

			// Reset existing data.
			for ( int i = 0; i < NetworkChart.Series.Count; i++ )
			{
				float Percent = ( float )i / ( float )NetworkChart.Series.Count;
				InMainWindow.UpdateProgress( ( int )( Percent * 100 ) );

				NetworkChart.Series[i].Points.Clear();
			}

			InMainWindow.ShowProgress( true );

			NetworkChart.ResetAutoValues();
			NetworkChart.Invalidate();

			NetworkChart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;
			NetworkChart.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
			NetworkChart.ChartAreas[0].AxisX.ScrollBar.Size = 15;
			NetworkChart.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.LightGray;

			NetworkChart.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = false;
			NetworkChart.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
			NetworkChart.ChartAreas[0].AxisY.ScrollBar.Size = 15;
			NetworkChart.ChartAreas[0].AxisY.ScrollBar.ButtonColor = Color.LightGray;

			int FrameCounter = 0;

			foreach( PartialNetworkStream RawFrame in NetworkStream.Frames )
			{
				if ( FrameCounter % 1000 == 0 )
				{
					float Percent = ( float )FrameCounter / ( float )NetworkStream.Frames.Count;
					InMainWindow.UpdateProgress( ( int )( Percent * 100 ) );
				}

				PartialNetworkStream Frame = RawFrame.Filter( InFilterValues );

				if( Frame.EndTime == Frame.StartTime )
				{
					throw new InvalidOperationException();
				}

				float OneOverDeltaTime = 1 / (Frame.EndTime - Frame.StartTime);

				int OutgoingBandwidth = Frame.UnrealSocketSize + Frame.OtherSocketSize + NetworkStream.PacketOverhead * ( Frame.UnrealSocketCount + Frame.OtherSocketCount );

				InMainWindow.AddChartPoint( SeriesType.OutgoingBandwidthSize,		FrameCounter, OutgoingBandwidth );
				InMainWindow.AddChartPoint( SeriesType.OutgoingBandwidthSizeSec,	FrameCounter, OutgoingBandwidth * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.ActorCount,					FrameCounter, Frame.ActorCount );
				InMainWindow.AddChartPoint( SeriesType.PropertySize,				FrameCounter, Frame.ReplicatedSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.PropertySizeSec,				FrameCounter, Frame.ReplicatedSizeBits / 8 * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.RPCSize,						FrameCounter, Frame.RPCSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.RPCSizeSec,					FrameCounter, Frame.RPCSizeBits / 8 * OneOverDeltaTime );

#if true
				InMainWindow.AddChartPoint( SeriesType.ActorCountSec,				FrameCounter, Frame.ActorCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.PropertyCount,				FrameCounter, Frame.PropertyCount );
				InMainWindow.AddChartPoint( SeriesType.PropertyCountSec,			FrameCounter, Frame.PropertyCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.RPCCount,					FrameCounter, Frame.RPCCount );
				InMainWindow.AddChartPoint( SeriesType.RPCCountSec,					FrameCounter, Frame.RPCCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.ExportBunchCount,			FrameCounter, Frame.ExportBunchCount );
				InMainWindow.AddChartPoint( SeriesType.ExportBunchSize,				FrameCounter, Frame.ExportBunchSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.MustBeMappedGuidsCount,		FrameCounter, Frame.MustBeMappedGuidCount / 8 );
				InMainWindow.AddChartPoint( SeriesType.MustBeMappedGuidsSize,		FrameCounter, Frame.MustBeMappedGuidSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.SendAckCount,				FrameCounter, Frame.SendAckCount );
				InMainWindow.AddChartPoint( SeriesType.SendAckCountSec,				FrameCounter, Frame.SendAckCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.SendAckSize,					FrameCounter, Frame.SendAckSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.SendAckSizeSec,				FrameCounter, Frame.SendAckSizeBits / 8 * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.ContentBlockHeaderSize,		FrameCounter, Frame.ContentBlockHeaderSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.ContentBlockFooterSize,		FrameCounter, Frame.ContentBlockFooterSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.PropertyHandleSize,			FrameCounter, Frame.PropertyHandleSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.SendBunchCount,				FrameCounter, Frame.SendBunchCount );
				InMainWindow.AddChartPoint( SeriesType.SendBunchCountSec,			FrameCounter, Frame.SendBunchCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.SendBunchSize,				FrameCounter, Frame.SendBunchSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.SendBunchSizeSec,			FrameCounter, Frame.SendBunchSizeBits / 8 * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.SendBunchHeaderSize,			FrameCounter, Frame.SendBunchHeaderSizeBits / 8 );
				InMainWindow.AddChartPoint( SeriesType.GameSocketSendSize,			FrameCounter, Frame.UnrealSocketSize );
				InMainWindow.AddChartPoint( SeriesType.GameSocketSendSizeSec,		FrameCounter, Frame.UnrealSocketSize * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.GameSocketSendCount,			FrameCounter, Frame.UnrealSocketCount );
				InMainWindow.AddChartPoint( SeriesType.GameSocketSendCountSec,		FrameCounter, Frame.UnrealSocketCount * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.ActorReplicateTimeInMS,		FrameCounter, Frame.ActorReplicateTimeInMS);
#endif

#if false
				InMainWindow.AddChartPoint( SeriesType.MiscSocketSendSize,			FrameCounter, Frame.OtherSocketSize );
				InMainWindow.AddChartPoint( SeriesType.MiscSocketSendSizeSec,		FrameCounter, Frame.OtherSocketSize * OneOverDeltaTime );
				InMainWindow.AddChartPoint( SeriesType.MiscSocketSendCount,			FrameCounter, Frame.OtherSocketCount );
				InMainWindow.AddChartPoint( SeriesType.MiscSocketSendCountSec,		FrameCounter, Frame.OtherSocketCount * OneOverDeltaTime );								
#endif

				if ( Frame.NumEvents > 0 )
				{
					InMainWindow.AddChartPoint( SeriesType.Events, FrameCounter, 0 );
				}

				FrameCounter++;
			}

			//NetworkChart.DataManipulator.FinancialFormula( FinancialFormula.MovingAverage, "30", SeriesType.GameSocketSendSizeSec, SeriesType.GameSocketSendSizeAvgSec );
			NetworkChart.DataManipulator.FinancialFormula( FinancialFormula.MovingAverage, "30", SeriesType.OutgoingBandwidthSizeSec.ToString(), SeriesType.OutgoingBandwidthSizeAvgSec.ToString() );

			NetworkChart.ChartAreas["DefaultChartArea"].RecalculateAxesScale();

			NetworkChart.ChartAreas["DefaultChartArea"].AxisX.ScaleView.Position = OldPosition;

			NetworkChart.EndInit();

			InMainWindow.ShowProgress( false );

            Console.WriteLine("Adding data to chart took {0} seconds", (DateTime.UtcNow - StartTime).TotalSeconds);
		}
        /// <summary>
        /// 伝搬定数分散特性(グラフの初期化
        /// </summary>
        /// <param name="chart1"></param>
        public void ResetEigenValueChart(Chart chart1)
        {
            double normalizedFreq1 = FemSolver.GetNormalizedFreq(FirstWaveLength, WaveguideWidth);
            normalizedFreq1 = Math.Round(normalizedFreq1, 2);
            double normalizedFreq2 = FemSolver.GetNormalizedFreq(LastWaveLength, WaveguideWidth);
            normalizedFreq2 = Math.Round(normalizedFreq2, 2);

            // 表示モード数
            int showMaxMode = ShowMaxMode;
            /*
            if (MaxMode > 0)
            {
                showMaxMode = MaxMode;
            }
             */
            // チャート初期化
            setupChartColor(chart1);
            chart1.Titles[0].Text = "規格化伝搬定数周波数特性";
            chart1.ChartAreas[0].Axes[0].Title = "2W/λ";
            chart1.ChartAreas[0].Axes[1].Title = "β/ k0";
            SetChartFreqRange(chart1, normalizedFreq1, normalizedFreq2);
            chart1.ChartAreas[0].Axes[1].Minimum = 0.0;
            //chart1.ChartAreas[0].Axes[1].Maximum = 1.0; // 誘電体比誘電率の最大となるので可変
            chart1.ChartAreas[0].Axes[1].Interval = 0.2;
            chart1.Series.Clear();
            if (!isInputDataReady())
            {
                //MessageBox.Show("入力データがセットされていません", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            for (int portIndex = 0; portIndex < Ports.Count; portIndex++)
            {
                for (int modeIndex = 0; modeIndex < showMaxMode; modeIndex++)
                {
                    Series series = new Series();
                    series.Name = string.Format("TE{0}0 at {1}", modeIndex + 1, portIndex + 1);
                    series.ChartType = SeriesChartType.Line;
                    chart1.Series.Add(series);
                }
            }
            // 計算されたグラフのプロパティ値をAutoに設定
            chart1.ResetAutoValues();
        }
예제 #13
0
        /// <summary>
        /// チャート更新
        /// </summary>
        /// <param name="targetChart"></param>
        /// <param name="targetColPos"></param>
        private void drawChart(Chart targetChart, int targetColPos)
        {
            targetChart.Series.Clear();

            if (targetColPos < 0)
            {
                return;
            }

            Series series = new Series();
            series.ChartType = SeriesChartType.FastPoint;
            series.MarkerSize = 2;
            series.MarkerStyle = MarkerStyle.Circle;
            series.ToolTip = "#VALX{D}, #VAL{D}";

            for (int ii = 0; ii < dataGridView.Rows.Count; ii++)
            {
                if (dataGridView.Rows[ii].Cells[targetColPos].Value == null
                    || "".Equals(dataGridView.Rows[ii].Cells[targetColPos].Value.ToString()))
                {
                    break;
                }

                DataPoint point = series.Points.Add(Convert.ToDouble(dataGridView.Rows[ii].Cells[targetColPos].Value));
                point.XValue = Convert.ToDouble(dataGridView.Rows[ii].Cells[0].Value.ToString());
                point.AxisLabel = dataGridView.Rows[ii].Cells[0].Value.ToString();
            }
            targetChart.Series.Add(series);
            targetChart.ResetAutoValues();
        }