コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: mgcarmueja/MPTCE
        public MainWindow()
        {
            InitializeComponent();

            _bufferLength = _maxSamples;

            _nChannels = 8;
            _graphModels = new GraphModel[_nChannels];
            _graphs = new Graph[_nChannels];

            for (int i = 0; i < _nChannels; i++)
            {
                _graphs[i] = new Graph();
                _graphModels[i] = new GraphModel(_graphs[i]);

                _graphs[i].xMin = 0;
                _graphs[i].xMax = _maxSamples-1;
                _graphs[i].yMin = -1500;
                _graphs[i].yMax = 1500;

                _graphs[i].topEdge = 5;
                _graphs[i].bottomEdge = 5;
                _graphs[i].rightEdge = 5;
                _graphs[i].leftEdge = 5;

                _graphs[i].plotColor = Color.FromArgb(200,0,0,255); //Because writable bitmaps use premultiplied alpha!

                graphsGrid.Children.Add(_graphs[i]);
            }

            //Initialising plot data
            PrepareData();

            //Setting and starting timer;
            _timer = new FastTimer(3, 100, InsertPoints);
            _timer.Start();
        }
コード例 #2
0
        public DataGraphs(string fileName)
        {
            string filePath = Utils.GetFullFilePath(fileName);

            try
            {
                using (StreamReader reader = new StreamReader(filePath))
                {
                    string line;
                    int iLine = 0;
                    int iGraph = -1;
                    int iEdge = 0;
                    bool curLineIsGraphArgs = false;

                    while ((line = reader.ReadLine()) != null)
                    {
                        switch (iLine)
                        {
                            case 0:
                                _count = int.Parse(line);
                                _graphs = new Graph[_count];
                                break;
                            default:
                                if (line == "")
                                {
                                    iGraph++; 
                                    curLineIsGraphArgs = true;
                                    break;
                                }

                                if (curLineIsGraphArgs)
                                {
                                    curLineIsGraphArgs = false;
                                    string[] args = line.Split(' ');
                                    int countVerticles = int.Parse(args[0]);
                                    int countEdges = int.Parse(args[1]);

                                    _graphs[iGraph] = new Graph();
                                    _graphs[iGraph].CountVerticles = countVerticles;
                                    _graphs[iGraph].CountEdges = countEdges;
                                    _graphs[iGraph].edges = new Edge[countEdges];

                                    iEdge = 0;
                                }
                                else
                                {
                                    string[] edge = line.Split(' ');
                                    _graphs[iGraph].edges[iEdge] = new Edge();
                                    _graphs[iGraph].edges[iEdge].v0 = int.Parse(edge[0]);
                                    _graphs[iGraph].edges[iEdge].v1 = int.Parse(edge[1]);
                                    iEdge++;
                                }

                                break;
                        }
                        iLine++;
                    }
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: mgcarmueja/MPTCE
        /// <summary>
        /// Initialization of the view components for all graphs in the program
        /// </summary>
        private void PrepareGraphs()
        {
            //Acquisition
            _acqGraphs = new Graph[acqViewModel.plotModels.Length];
            _acqIntervals = new IntervalMarker[acqViewModel.plotModels.Length];

            for (int i = 0; i < acqViewModel.plotModels.Length; i++)
            {
                _acqGraphs[i] = new Graph();
                _acqGraphs[i].leftTitle = (i+1).ToString();
                _acqGraphs[i].isToggleable = true;

                _acqIntervals[i] = new IntervalMarker();
                _acqIntervals[i].visualIndex = -1;
                _acqIntervals[i].color = Color.FromArgb(64, 0, 255, 0);
                _acqIntervals[i].visible = false;
                _acqGraphs[i].graphMarkers.Add(_acqIntervals[i]);

                acqViewModel.plotModels[i].graph = _acqGraphs[i];
                _acqGraphs[i].Margin = new Thickness(2);
                _acqGraphs[i].bottomEdge = 1;
                _acqGraphs[i].topEdge = 1;

                acqGraphsGrid.Children.Add(_acqGraphs[i]);

                _acqGraphs[i].toggle = true;
            }

            //Realtime -> Should be something similar
            _reaGraphs = new Graph[reaViewModel.plotModels.Length];
            _reaIntervals = new IntervalMarker[reaViewModel.plotModels.Length];
            _reaThresholds = new ThresholdMarker[reaViewModel.plotModels.Length];

            for (int i = 0; i < reaViewModel.plotModels.Length; i++)
            {
                _reaGraphs[i] = new Graph();
                _reaGraphs[i].leftTitle = (i+1).ToString();
                _reaGraphs[i].isToggleable = false;

                _reaIntervals[i] = new IntervalMarker();
                _reaIntervals[i].visualIndex = -1;
                _reaIntervals[i].color = Color.FromArgb(64, 0, 255, 0);
                _reaIntervals[i].visible = false;
                _reaGraphs[i].graphMarkers.Add(_reaIntervals[i]);

                _reaThresholds[i] = new ThresholdMarker();
                _reaThresholds[i].visualIndex = 1;
                _reaThresholds[i].color = Color.FromArgb(255, 255, 0, 255);
                _reaThresholds[i].visible = false;
                _reaGraphs[i].graphMarkers.Add(_reaThresholds[i]);

                reaViewModel.plotModels[i].graph = _reaGraphs[i];
                _reaGraphs[i].Margin = new Thickness(2);
                reaGraphsGrid.Children.Add(_reaGraphs[i]);
            }
        }
コード例 #4
0
		/// <summary>
		/// Draw the statistics
		/// </summary>
		/// <param name="state"></param>
		public void Draw(DrawState state)
		{
#if DEBUG


			float fade = 8 - state.TotalTimeSeconds * 0.5f;
			if (fade > 1)
				fade = 1;
			if (fade < 0)
				fade = 0;


			if (!enabled)
			{
				if (toggleTextDisplay != null && fade > 0)
				{
					this.toggleTextDisplay.ColourFloat = new Vector4(1, 1, 1, fade);
					toggleTextDisplay.Draw(state);

					AlignElements(state);
				}
				return;
			}


			if (state.Application.IsHiDefDevice)
			{
				if (fillRateQuery == null)
				{
					GraphicsDevice device = (GraphicsDevice)state;
					fillRateQuery = new OcclusionQuery(device);

					fillRateQuery.Begin();
					fillRateQueryActive = true;
				}

				if (fillRateQueryActive)
				{
					fillRateQuery.End();
					fillRateQueryActive = false;
				}
			}

			DrawStatistics stats;
			state.GetPreviousFrameStatistics(out stats);

			stats -= previousFrameOverhead;

			if (graphs == null)
			{
				const int width = 210;
				const int height = 128;
				const int fontPix = 20;
				List<Call> calls = new List<Call>();

				Func<string, Call, float, Graph> add = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width, height, width - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalf = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalfMin1 = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 1, font, -good); };

				graphs = new Graph[]
				{
					add("Frame Rate (Approx)",delegate(ref DrawStatistics s, DrawState dstate)
						{return (float)dstate.ApproximateFrameRate;}, -20),
					
#if XBOX360
					addHalf("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn\n(Approx)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled - (float)s.XboxPixelFillBias);}, 20000000), // not accurate
#else
			
					add("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled);}, 18000000),
#endif
					
					addHalf("Draw Calls",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.DrawIndexedPrimitiveCallCount + s.DrawPrimitivesCallCount);}, 300),
					
					addHalf("Garbage Collected",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							if (garbageTracker.Target == null) { garbageTracker.Target = new object(); return 1; }
							return 0;
						},0),
						
					addHalf("Allocated Bytes (Managed)",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							return (int)GC.GetTotalMemory(false);
						},0),
					
#if XBOX360
					
					addHalfMin1("CPU Usage\n(Primary)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return threads[0].Usage;},-0.5f),
					addHalfMin1("CPU Usage\n(Task Threads)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (threads[1].Usage+threads[2].Usage+threads[3].Usage) / 3.0f;},-0.25f),
#endif
						
				};

				this.setGraphCalls = calls.ToArray();
			}

			for (int i = 0; i < graphs.Length; i++)
			{
				graphs[i].SetGraphValue(setGraphCalls[i](ref stats, state));
				graphs[i].Visible = true;
			}

			AlignElements(state);


			DrawStatistics currentPreDraw;
			state.GetCurrentFrameStatistics(out currentPreDraw);


			for (int i = 0; i < graphs.Length; i++)
			{
				if (graphs[i].Visible)
					graphs[i].Draw(state);
			}


			DrawStatistics currentPostDraw;
			state.GetCurrentFrameStatistics(out currentPostDraw);

			previousFrameOverhead = currentPostDraw - currentPreDraw;


			if (state.Application.IsHiDefDevice)
			{
				if (fillRateQuery.IsComplete)
				{
					pixelsFillled = (float)fillRateQuery.PixelCount;

					fillRateQuery.Begin();
					fillRateQueryActive = true;
				}
			}
			else
				pixelsFillled = -1;
#endif
		}