04-29-2009 11:07 AM
I am seeing what appears to be some rounding issues with the Xaxis on a Waveformgraph.
I have attached a sample. The sample interval has been specified as 2 ms. After app loads, hit the right arrow key to move the cursor to the next sample to see the problem. I would expect it to report a time of 04-29-09 14:28:31.0020 and it reports the milliseconds as 0019
I say the problem appears to be rounding because the discrepency between the time I expect to see and the time reported by the cursor label widens as one moves further into the dataset. Note how the cursor does not line up on the second line that has been drawn using the DataConverter.
I have looked for properties name that might suggest a way to control precision and have had no joy.
Perhaps I need to load the data differently......? I have looked around for that too...... again.... no joy.
Please help and thanks in advance.
Joe
Solved! Go to Solution.
05-01-2009 01:09 PM
By the way I am referencing the following versions
<Reference Include="NationalInstruments.Common, Version=8.6.35.131, Culture=neutral, PublicKeyToken=18cbae0f9955702a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="NationalInstruments.UI, Version=8.6.35.189, Culture=neutral, PublicKeyToken=18cbae0f9955702a, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="NationalInstruments.UI.WindowsForms, Version=8.6.35.189, Culture=neutral, PublicKeyToken=18cbae0f9955702a, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
05-01-2009 04:28 PM
I believe I have a workaround. Unfortunately, it involves using a ScatterGraph instead of a WaveformGraph. It also required building a custom FormatString.
The sample I am now posting definitely shows an issue with the way the plot is drawn on the WaveformGraph. This is not surprising because it appears that the x values are not being generated properly. I am guaranteeing the x values are being generated properly with the data provided to the ScatterPlot.
The CustomFormatString was still necessary even after creating the x data properly. Without the CustomFormatString the exact same incorrect values were displayed as on the WaveformGraph.
The sample has the WaveformGraph on top and the ScatterGraph on the bottom.
While I am glad to have been able to create a workaround for this problem, I am building an application that uses the WaveformGraph as an integral component. The idea of switching over to the ScatterGraph at this stage of our development cycle is not appealing. The issues I am seeing in the WaveformGraph really do look like bugs to me and I am hoping they can be resolved soon.
Thanks.
Joe
05-04-2009 11:25 AM
Joe,
Thank you for the detailed research you put in regarding this issue. Looking at your code, if you apply the custom format string to the WaveformGraph cursor as well, you see the same as you see in the ScatterGraph, which should work for you.
This does look like a bug though, so we will be filing a bug report and will post back once the report has been filed with the bug ID. We give you the bug ID so you can ask about the status if you call in. You can also check the release notes whenever a new version of Measurement Studio is released. All of the bugs that have been fixed have their bug ID listed in the readme of every new version of our software (you can see the readme for Measurement Studio 8.6 for Visual Studio 2008 here as an example)
05-04-2009 02:11 PM - edited 05-04-2009 02:12 PM
Eric -
While using the custom format string may *seem* to provide what I need for formatting the dates, it does not. It is not simply a formatting problem – in the case of the WaveformGraph control the waveform itself appears to be generated improperly. I used the ScatterGraph to show the difference because the ScatterGraph provided me with a way to ensure that the x data values were generated properly.
There are really at least two problems here. One problem is the formatting and I my workaround for that is fine... for now. The more serious issue appears to be the way the x data values are generated in the WaveformGraph. If these values are not generated correctly, a custom formatter is not going to help. To me, this appears to be caused by some form of rounding and/or floating point issue. It does appear to be linear in nature as the discrepancy between the two graphs increases as more data points are introduced (see below).
The best way to see each problem on a single screen is to drag the cursor on both graphs to the end of the plot (900000 samples with 2 ms interval = 30 minutes of data), then zoom to a very small portion of the end of the plot, then use the right arrow key until both cursors are at the last data point on each plot (if one reaches the end before the other keep using the right arrow until the other reaches the end). As you can see by comparing the values provided by the two cursors, the x values are almost a whole second off.
I will be interested in knowing that I have properly characterized the problem(s) I am seeing properly. So please respond with your understanding so we can make sure we get the bug report submitted accurately. Please understand that I am not at all concerned with your ability to grasp the problem. Quite the contrary in fact. I am more concerned that I may not have explained the problem adequately.
One thing to note is that the behavior only manifests itself when the accuracy required for x values is to the millisecond. One need only inspect the way I am generating the x values for the ScatterGraph to see why.
Even though the problem occurs only when x value granularity is to the millisecond, I would think the accuracy of the waveform would have to be considered a fundamental characteristic of the WaveformGraph control. Accordingly, my hope is that this bug fix will get a high priority.
I am glad that you will post the bug ID to this thread. As my application does have a requirement to draw lines on the graph at times that must coincide with the graph, I will be out of luck with the WaveformGraph until this waveform issue is addressed. I expect to release my application in 60-90 days. Consequently, I hope I will have some visibility into the priority given to fixing this issue. I realize that I will need to track this outside of this forum.
Thanks again.
Joe
05-04-2009 04:01 PM
Eric -
Good news.... I found another workaround that definitely reduces the *my* urgency for getting the plot fix. With my two workarounds, all of my reported issues with the WaveformGraph object are addressed.
I now believe it is more accurate to state that the waveform problem may really be solely with the WaveformPlot.PlotY method. I replaced the PlotY method of generating the wave form with the following code and I get the required results with respect to the waveform. It is still necessary for me to use the custom format string.
//plot.PlotY(ydata, startDate, TimeSpan.FromMilliseconds(2D));
WaveformTiming timing = WaveformTiming.CreateWithRegularInterval(TimeSpan.FromMilliseconds(2D), startDate);AnalogWaveformPlotOptions options = new AnalogWaveformPlotOptions(AnalogWaveformPlotDisplayMode.Time, AnalogWaveformPlotScaleMode.Raw);
AnalogWaveform wave = AnalogWaveform.FromArray1D(ydata);wave.Timing = timing;
plot.PlotWaveform(wave, options);
I would expect the WaveformPlot.PlotY method to produce the same waveform/timing combination as the code above. Consequently, I do think a bug needs to be submitted.
I am also curious if the PlotY method is supposed to provide better performance. If so, I would definitely prefer to use a new and improved (and correct) version of the method.
Thanks again for your time.
Joe
05-05-2009 05:23 PM
Joe,
Thanks for posting that workaround. I applied that to the sample you posted and saw that it did improve the accuracy of the x-values generated. You asked me to explain in your previous post what the problem is, and here is what I understand: When you use the PlotY function on your WaveformPlot and you set a TimeSpan manually, the numbers aren't generated accurately (.001996 when it should be .002, etc). However you are saying your method you use to generate the X data for the ScatterGraph generates the X values correctly, but I do not see that in the example you posted. When I remove the custom formatting on the cursor, it still shows the incorrect data (.001996 instead of .002). In any case, implementing the workaround you noted (building and plotting a waveform) does seem to work for me.
Again, thanks for the additional information. This will be helpful for our developers.
The bug report was filed and the ID is 164969.
05-06-2009 09:55 AM
Eric -
You just about have it. There are at least two problems as I see it.
The problems seem to apply only to WaveformPlots with data intervals to the millisecond. The PlotY generation of the X data values is a problem. Another problem is the default display behavior of FormatString.FormatDouble. I cannot speculate how many underlying problems are involved between the problems I can see on the surface. I suspect that logic that is used by the DataConverter.Convert function is involved but I can only speculate.
WaveformPlot.PlotY - my assertion that PlotY is generating the X values improperly is a guess. I did verify by placing a breakpoint in the code after executing WaveformPlot.PlotY that the values returned by the WaveformPlot.GetXData() were not correct. This could simply mean there is an issue with GetXData but I did see consistency so I ruled that out. Similarly, after generating the ScatterPlot, I used a breakpoint to verify the values I provided to the ScatterPlot constructor were correct. Thing was, even with correct values. I needed a custom FormatString to display the values of the ScatterPlot properly. Also, after seeing that the ScatterPlot rendered differently and appear to line up with the Xaxis differently, I had an idea I was on to something.
FormatString.FormatDouble - After working through the PlotY/ScatterPlot stuff above, I still needed to correct the display values with the CustomFormatString. I suspect that the logic used by the DataConverter.Convert function may also be involved within the default behavior of FormatString.FormatDouble. I applied the same principles used to generate the x data for the ScatterPlot to the CustomFormatString.FormatDouble and I had a workaround.
Further, I tried the WaveFormPlot.PlotWaveForm and discovered the discrepancy within WaveformPlot between plot correlation with Xaxis and/or rendering between plots created by PlotY and PlotWaveform. To my glee, PlotWaveform provided the results I require.
Hope that helps.
Thanks for your help.
Joe
05-07-2009 10:23 AM
Joe,
That makes sense to me. Thank you for the detailed notes...they will be a good resource for the developers when they are trying to pin down the root cause of this problem.
06-10-2009 07:27 PM
Eric -
Found a similar and possibly related problem... The symptoms here may refute my suspicions of the logic within your DataConverter.Convert .
I do some custom drawing on my plots to change the line color at certain areas of the plot. I use the OnBeforeDraw event of the WaveFormPlot class. If I am not mistaken I clipped the code to do the mulitcolor line thing from this forum (been a while).
In the code below... You'll see that I have commented the use of the data generated by InverseMapDataPoints and have replaced the values used to create my Pen instance with the values generated by a linq query that creates a DateTime array (dates) by way of DataConverter.Convert and the plot.GetXData values. The routine not shown here (SegmentRangeExists) simply checks if the plot has had a range defined where alt color is needed. The values returned from InverseMapDataPoints definitely displayed the same symptoms with regard to X value accuracy. My alternative method is as right as rain. My use of DataConverter along with GetXData would seem to indicate that DataConverter is performing fine (in this case anyway).
Cheers... and GO WINGS!!
Joe
using (Pen secondPen = new Pen(SecondColor)) using (Pen normalPen = new Pen(this.LineColor)) { // Iterate through the points and draw the lines one at a time with // the appropriate color depending on if it's increasing or decreasing. DateTime[] dates = (from dbl in this.GetXData() select (DateTime)DataConverter.Convert(dbl, typeof(DateTime))).ToArray(); for (int i = 1; i < points.Length; i++) { PointF point1 = points[i - 1]; PointF point2 = points[i]; if (System.Double.IsNaN(point1.Y) == false && System.Double.IsNaN(point2.Y) == false) { double[] xdata = new double[2], ydata = new double[2]; //this.InverseMapDataPoints(e.Bounds, new PointF[] { point1, point2 }, out xdata, out ydata); Pen pen = SegmentRangeExists( true, dates[i - 1], dates[i] //true, (DateTime)DataConverter.Convert(xdata[0], typeof(DateTime)), // (DateTime)DataConverter.Convert(xdata[1], typeof(DateTime)) ) ? secondPen : normalPen; g.DrawLine(pen, point1, point2); } } } // Cancel the event since we handled all drawing here. e.Cancel = true; }