Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Relative position cannot contain NaN values

Hi there.  I am getting an error when updating my WPF graph "Relative position cannot contain NaN values".  The graph data is simply bound to an ObservableCollection<Point[]> so I'm not sure how this error makes sense in that context.  The relevant part of the stack trace is as follows.  Any help would be appreciated.  My customer is running MeasurementStudio 12, not the latest 13.  Thanks!

 

System.ArgumentException: Relative position cannot contain NaN values.
Parameter name: relativePosition
   at NationalInstruments.Restricted.Guard`1.Satisfies(Boolean condition, Func`4 exceptionCreator, String format, Object[] args)
   at NationalInstruments.Controls.Primitives.LayeredGraph.c(Point A_0)
   at NationalInstruments.Controls.Primitives.LayeredGraph.FindNearestValue(IPlot startingPlot, Point relativePosition, GraphQueryArgs args)
   at NationalInstruments.Controls.Cursor.b(IList A_0)
   at NationalInstruments.Controls.Cursor.d()
   at NationalInstruments.Controls.Cursor.a(Object A_0, DataProcessedEventArgs A_1)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at NationalInstruments.Controls.Primitives.GraphBase.OnDataProcessed(DataProcessedEventArgs e)
   at NationalInstruments.Controls.Graph.NationalInstruments.Controls.Internal.IDefaultDataProcessorTarget.ReceiveData(IDictionary`2 data)
   at NationalInstruments.Controls.Internal.DefaultPipelineDataProcessor.a(ICollection`1 A_0)
   at NationalInstruments.Controls.Internal.DefaultPipelineDataProcessor.ProcessDataCore(IDictionary`2 changedData)
   at NationalInstruments.Controls.Primitives.DataProcessorBase.ProcessData(IDictionary`2 changedData)
   at NationalInstruments.Controls.Primitives.GraphBase.a(IDictionary`2 A_0)
   at NationalInstruments.Controls.Primitives.GraphBase.<>c__DisplayClassa.<OnDataCollectionChanging>b__8()
   at System.Action.Invoke()
   at NationalInstruments.Controls.Primitives.NotifyingCollection`1.ChangeItemsCore(Int32 index, Int32 removeCount, T[] newItems)
   at NationalInstruments.Controls.Primitives.DataCollection.ChangeItemsCore(Int32 index, Int32 removeCount, Object[] newItems)
   at NationalInstruments.Controls.Primitives.NotifyingCollection`1.ChangeItems(Int32 index, Int32 removeCount, T[] newItems)
   at NationalInstruments.Controls.Primitives.NotifyingCollection`1.ReplaceAll(IEnumerable`1 newItems, Boolean notifyOnUnchanged)
   at NationalInstruments.Controls.Primitives.DataCollection.a(IEnumerable`1 A_0)
   at NationalInstruments.Controls.Primitives.DataCollection.SetDataSource(Object newDataSource, DataProcessorBase dataProcessor)
   at NationalInstruments.Controls.Primitives.GraphBase.OnDataSourceChanged()
   at NationalInstruments.Controls.Primitives.GraphBase.a(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
0 Kudos
Message 1 of 7
(6,193 Views)

Hey danxia,

 

How are you generating your relative position?  Could you attach some code that reproduces this so I can take a look at this?  I can try to pinpoint where relativePosition = NaN.

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(6,180 Views)

Unfortunately, I do not have access to Measurement Studio 2012 to test, and I cannot get the issue to reproduce in Measurement Studio 2013 for Point data containing special double values. Could you provide an example of the data causing the issue?


If you have access to the source, you could derive from the graph type you are using and override the DataToRelativeCore(IPlot,IList) method that the Cursor is calling, breaking when one of the Point values is double.NaN.

~ Paul H
0 Kudos
Message 3 of 7
(6,178 Views)

Thanks guys.

 

Unfortunately I'm kind of shooting in the dark with this one.  I can't reproduce the error either but a client of mine is getting this error.

 

Where does relative position come into play during a data source update for the graph?  Maybe if you can briefly explain the logic behind that it will hit me that I'm doing something that could lead to a potential error like this.  Grasping for straws here! 🙂

 

In the meantime I'll get my client up on our latest build which includes measurement studio 2013.

 

Thanks,
Dan

0 Kudos
Message 4 of 7
(6,160 Views)

Hi danxia,

 

So this looks to be coming from the LayerGraph class which gives a basis for a two dimentional graph and then the "relativePosition" parameter is being called in the FindNearestValue Method which locates the nearest value on the graph with respect to this "relativePosition".  The relativePosition is a Point, which has both X and Y numerics included in the object, and this error is occuring because instead of something like relativePoint= "x,y" we have relativePoint= NaN.

 

I have been trying to reproduce this on my side and haven't been able to.  This function is most likely being called behind the scenes though and the problem probably origninates when either setting up the graph or the process of re-calling and updating the graph since the LayeredGraph Class is the base class for 2-D graphs.  A few things your client can try are resetting up the graph space again in the .XAML file, deleting and re-adding the NationalInstruments.Controls.Primitives reference in the Solution Explorer and also take a closer look at the parameters of how they are setting up the graph and then how they are pushing data to the graph, whether there is parameter that is not initialized for some reason.

 

Is this error a runtime error or is it a build error?

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(6,149 Views)
I am traveling this week, but from what I remember and reviewing the call stack, the issue looked like a runtime error when the cursor updates in response to new data in the graph. The cursor is using its current relative position in the plot area to find the closest value in the new data set.

So it seems the cursor received an invalid value, maybe from NaN data in the graph. Updating to 2013 may resolve the issue. With access to the source, you could also derive from the graph and override DataToRelativeCore to return a safe default if the result contains a NaN X or Y value.
~ Paul H
0 Kudos
Message 6 of 7
(6,139 Views)

Thanks for the explanation, guys.  Yes, it is a runtime error and Paul, you are right on with your description.  If the upgrade to 2013 doesn't work I'll derive from the graph and override the DataToRelativeCore method.

 

Thank you!

Dan

0 Kudos
Message 7 of 7
(6,131 Views)