public void vUpdateMeasures(List <UInt32> lstData, int iActiveMeasureIndex) { Single sUnscaledData; Single sScaledData; UInt32 u32MeasureData; int iTimeStampIDXOffset = false == mboPCTimeStamps ? 1 : 0; Single fMeasureTimeStamp = 0; if (miFormIDX != iActiveMeasureIndex) { return; } if (true == mboSuspendUpdates) { return; } else if ((false == mboSuspendUpdates) && (true == mboOldSuspendUpdates)) { Array.Clear(maau32LogData, 0, maau32LogData.Length); mboOldSuspendUpdates = false; mboSuspendUpdates = false; mu32GlobalLogPCMsStart = 0; miLoggingIDX = 1; mu32GlobalLogMeasureMsStart = 0xffffffff; miTimeStampIDX = -1; } if (0 == mu32GlobalLogPCMsStart) { mu32GlobalLogPCMsStart = (UInt32)(DateTime.Now.Ticks / 10000); } mu32GlobalLogPCMs = (UInt32)(DateTime.Now.Ticks / 10000) - mu32GlobalLogPCMsStart; if ((miFormIDX == iActiveMeasureIndex) && (true == mboLogging) && ((maau32LogData.Length / mastActiveMeasureIndices.Length) > miLoggingIDX)) { if (lstData.Count == mastActiveMeasureIndices.Length) { UInt32[] au32Data = lstData.ToArray(); Buffer.BlockCopy(au32Data, 0, maau32LogData, 4 * mastActiveMeasureIndices.Length * miLoggingIDX, 4 * mastActiveMeasureIndices.Length); } /* If using PC timestamps */ if (-1 == miTimeStampIDX) { fMeasureTimeStamp = (Single)mu32GlobalLogPCMs; } for (int iLogElementIDX = 0; iLogElementIDX < mastActiveMeasureIndices.Length; iLogElementIDX++) { if (miTimeStampIDX == iLogElementIDX) { iTimeStampIDXOffset = 1; if (0xffffffff == mu32GlobalLogMeasureMsStart) { mu32GlobalLogMeasureMsStart = maau32LogData[miLoggingIDX, iLogElementIDX]; } mu32GlobalLogMeasureMs = maau32LogData[miLoggingIDX, iLogElementIDX] - mu32GlobalLogMeasureMsStart; fMeasureTimeStamp = (Single)mu32GlobalLogMeasureMs; } else { u32MeasureData = maau32LogData[miLoggingIDX, iLogElementIDX]; switch (tclsASAM.mailstActiveMeasLists[miFormIDX][mastActiveMeasureIndices[iLogElementIDX].iMeasureQueueIDX].enRecLayout) { case tenRecLayout.enRL_VALU8: { sUnscaledData = (Single)(char)u32MeasureData; break; } case tenRecLayout.enRL_VALU16: { sUnscaledData = (Single)(0xffff & u32MeasureData); break; } case tenRecLayout.enRL_VALU32: { sUnscaledData = (Single)u32MeasureData; break; } case tenRecLayout.enRL_VALS8: { sUnscaledData = (Single)(char)u32MeasureData; break; } case tenRecLayout.enRL_VALS16: { sUnscaledData = (Single)(Int16)u32MeasureData; break; } case tenRecLayout.enRL_VALS32: { sUnscaledData = (Single)(Int32)u32MeasureData; break; } default: { sUnscaledData = u32MeasureData; break; } } sScaledData = fGetScaledData(maiMeasCompuMethodIndices[iLogElementIDX], iLogElementIDX, sUnscaledData); seriesdata[iLogElementIDX].Points.Add(new DataPoint(fMeasureTimeStamp, sScaledData)); if (mu32TableRefreshCount != mu32TableRefreshCountOld) { vShowGridData(iLogElementIDX, sScaledData); } } } if (0 < (fMeasureTimeStamp - (Single)miZoomBack / 1000f)) { mstXAxis.Zoom(fMeasureTimeStamp - (Double)(miZoomBack), (Double)fMeasureTimeStamp + (Double)(miZoomForward)); mstXAxis.IsZoomEnabled = true; } else { mstXAxis.Zoom(0f, fMeasureTimeStamp + (Single)miZoomForward / 1000f); } mclsPlotLogging.InvalidatePlot(true); miLoggingIDX++; progressBarLogBuffer.Value = 1 + miLoggingIDX / 660; mu32TableRefreshCountOld = mu32TableRefreshCount; } }
public void Axis_DesiredSize() { var xaxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" }; var yaxis = new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" }; var plot = new PlotModel { Title = "Simple plot" }; plot.Axes.Add(xaxis); plot.Axes.Add(yaxis); var ls = new LineSeries(); ls.Points.Add(new DataPoint(3, 13)); ls.Points.Add(new DataPoint(10, 47)); ls.Points.Add(new DataPoint(30, 23)); ls.Points.Add(new DataPoint(40, 65)); ls.Points.Add(new DataPoint(80, 10)); plot.Series.Add(ls); // initial setting plot.UpdateAndRenderToNull(800, 600); Assert.That(yaxis.DesiredSize.Width, Is.EqualTo(35.0).Within(0.5), "y-axis width"); Assert.That(yaxis.DesiredSize.Height, Is.EqualTo(0.0).Within(1e-6), "y-axis height"); Assert.That(xaxis.DesiredSize.Width, Is.EqualTo(0.0).Within(1e-6), "x-axis width"); Assert.That(xaxis.DesiredSize.Height, Is.EqualTo(35.0).Within(0.5), "x-axis height"); // larger numbers on axis -> larger desired size yaxis.Zoom(10000, 11000); plot.UpdateAndRenderToNull(800, 600); Assert.That(yaxis.DesiredSize.Width, Is.EqualTo(50.0).Within(0.5), "y-axis width"); Assert.That(yaxis.DesiredSize.Height, Is.EqualTo(0.0).Within(1e-6), "y-axis height"); }
private void vLoadPlotView() { tableLayoutPanelLogging.Controls.Remove(mclsPlotLogging); if (maau32LogData.GetLength(1) != mastActiveMeasureIndices.Length) { ResizeArray(ref maau32LogData, 65536, mastActiveMeasureIndices.Length); } if (maafMinMaxLogData.GetLength(0) != mastActiveMeasureIndices.Length) { ResizeArray(ref maafMinMaxLogData, mastActiveMeasureIndices.Length, 2); } seriesdata = new LineSeries[mastActiveMeasureIndices.Length]; mastYAxes = new LinearAxis[mastActiveMeasureIndices.Length]; mclsPlotLogging = new OxyPlot.WindowsForms.PlotView(); mclsPlotLogging.Dock = System.Windows.Forms.DockStyle.Fill; mclsPlotLogging.Location = new System.Drawing.Point(0, 0); mclsPlotLogging.Margin = new System.Windows.Forms.Padding(0); mclsPlotLogging.Name = "plot1"; mclsPlotLogging.PanCursor = System.Windows.Forms.Cursors.Hand; mclsPlotLogging.Size = new System.Drawing.Size(632, 446); mclsPlotLogging.TabIndex = 0; mclsPlotLogging.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE; mclsPlotLogging.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE; mclsPlotLogging.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS; miZoomForwardIDX = 6; miZoomBackIDX = 6; miZoomForward = maiZoom[miZoomForwardIDX]; miZoomBack = maiZoom[miZoomBackIDX]; for (int iSeriesIDX = 0; iSeriesIDX < mastActiveMeasureIndices.Length; iSeriesIDX++) { seriesdata[iSeriesIDX] = new LineSeries(); seriesdata[iSeriesIDX].Points.Add(new DataPoint(0, 0)); seriesdata[iSeriesIDX].Color = maenLogColours[iSeriesIDX]; Single fMax; Single fMin; string szVarName; string szUnits; fMax = tclsASAM.mailstActiveMeasLists[miFormIDX][mastActiveMeasureIndices[iSeriesIDX].iMeasureQueueIDX].sUpperLim; fMin = tclsASAM.mailstActiveMeasLists[miFormIDX][mastActiveMeasureIndices[iSeriesIDX].iMeasureQueueIDX].sLowerLim; szVarName = tclsASAM.mailstActiveMeasLists[miFormIDX][mastActiveMeasureIndices[iSeriesIDX].iMeasureQueueIDX].szMeasurementName; szUnits = tclsASAM.milstCompuMethodList[maiMeasCompuMethodIndices[iSeriesIDX]].szUnitsString; mastYAxes[iSeriesIDX] = pstCreateNewYAxis(iSeriesIDX, fMax, 0, szVarName, szUnits, maenLogColours[iSeriesIDX]); seriesdata[iSeriesIDX].YAxisKey = "YAxis" + iSeriesIDX.ToString(); maafMinMaxLogData[iSeriesIDX, 0] = tclsASAM.mailstActiveMeasLists[miFormIDX][mastActiveMeasureIndices[iSeriesIDX].iMeasureQueueIDX].sUpperLim; } mclsPlotModel = new PlotModel { PlotType = PlotType.Cartesian, Background = OxyColors.Black, TextColor = OxyColors.Aqua }; mstXAxis = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, AbsoluteMaximum = 3600000, AbsoluteMinimum = 0, MinorStep = 5, Unit = "s", TicklineColor = OxyColors.Aqua, TitleColor = OxyColors.Aqua, AxislineColor = OxyColors.Aqua, ExtraGridlineColor = OxyColors.Aqua, MajorGridlineColor = OxyColors.Aqua, TitleFontWeight = FontWeights.Bold }; mstXAxis.Zoom(0f, 30f); mclsPlotModel.Axes.Add(mstXAxis); for (int iSeriesIDX = 0; iSeriesIDX < mastActiveMeasureIndices.Length; iSeriesIDX++) { if (iSeriesIDX != miTimeStampIDX) { mclsPlotModel.Series.Add(seriesdata[iSeriesIDX]); mclsPlotModel.Axes.Add(mastYAxes[iSeriesIDX]); } } mclsPlotLogging.Model = mclsPlotModel; miLoggingIDX = 1; tableLayoutPanelLogging.Controls.Add(mclsPlotLogging, 0, 1); tableLayoutPanelLogging.SetColumnSpan(mclsPlotLogging, 9); tableLayoutPanelLogging.SetRowSpan(mclsPlotLogging, 1); LoadComboBoxLoggingVars(); }