Diagnostics - code fix: update info in satellites tab

Mar 17, 2010 at 4:06 PM

I found a small bug in Diagnostic application (3.5 desktop, windows form). File is Mainform.cs.

This issue causes the listView with satellites info not to update correctly (actually only first row in list is updated).

changes are in red:

 

 

        private void nmeaInterpreter_SatellitesChanged(object sender, SatelliteListEventArgs e)
        {
            BeginInvoke(new MethodInvoker(delegate()
            {
                foreach (Satellite satellite in e.Satellites)
                {

                    bool isSatelliteNew = true;
                    // Look for an existing satellite
                    foreach (ListViewItem viewItem in satellitesListView.Items)
                    {
                        Satellite existing = (Satellite)viewItem.Tag;
                        if (existing.PseudorandomNumber.Equals(satellite.PseudorandomNumber))
                        {
                            // Update shiz
                            viewItem.SubItems[2].Text = satellite.Azimuth.ToString();
                            viewItem.SubItems[3].Text = satellite.Elevation.ToString();
                            viewItem.SubItems[4].Text = satellite.SignalToNoiseRatio.ToString();
                            isSatelliteNew = false; // in old code here was a return;
                        }
                    }

                    if (isSatelliteNew)
                    {
                        ListViewItem newItem = new ListViewItem(satellite.PseudorandomNumber.ToString());
                        newItem.SubItems.Add(satellite.Name);
                        newItem.SubItems.Add(satellite.Azimuth.ToString());
                        newItem.SubItems.Add(satellite.Elevation.ToString());
                        newItem.SubItems.Add(satellite.SignalToNoiseRatio.ToString());
                        newItem.Tag = satellite;
                        satellitesListView.Items.Add(newItem);
                    }
                }
            }));
        }

 

 

 

 

Developer
Mar 17, 2010 at 8:50 PM

Thanks for catching that and for taking the time to fix it.  I've applied your code changes to both the C# and VB.Net versions of the Diagnostics utility

Mar 22, 2010 at 3:58 PM

Thanks for submitting updates.

Presentation code in Diagnostic is now correct, but there is still an imprecision with satellites updates.

I thinks this problem also causes issue 9879 (SatelliteViewer Control Not Working).

The first time we start nmeaInterpreter the list of Satellites catched is correctly filled.

The interpreter periodically fires the SatellitesChanged event: this event has a SatelliteList argument. But satellite list passed as argument is not updated! it always show the same satellites whe had when the interpreter was started. (in fact we can get an updated satellites list only stopping and restarting the interpreter).

Hope this hint may help someone getting deeper on the issue, on the meantime i'm also working on this...