Beispiel #1
0
        void localizer_OnLocationUpdated(object sender, LocationUpdatedEventArgs e)
        {
            try
            {
                App.Current.Dispatcher.Invoke((Action)delegate
                {

                    if (localizer != null)
                    {
                        if (localizer.lastData != null)
                        {
                            List<string> legend = new List<string>();
                            for (int i = 0; i < localizer.lastData.ColumnCount; i++)
                            {
                                legend.Add(String.Format("Channel {0}", i + 1));
                            }
                            if (pw != null)
                            {
                                if (pw.IsLoaded)
                                    pw.Update("Data", localizer.lastData, legend, ASIO.T, localizer.lastMaxes);
                            }
                            else
                            {
                                pw = new PlotWindow("Data", localizer.lastData, legend, ASIO.T, localizer.lastMaxes);
                                pw.Show();
                            }

                        }
                    }
                    //Debug.WriteLine(e.Position);
                    Position3D pos = new Position3D() { X = (lpos.X * 2 + e.Position.X) / 3, Y = (lpos.Y * 2 + e.Position.Y) / 3, Z = 0 };
                    posistionLog.AppendText(pos.ToString() + "\n");
                    lpos = e.Position;
                    posistionLog.ScrollToEnd();
                });
            }
            catch
            {
                //nothing
            }
        }
Beispiel #2
0
        void localizer_OnLocationUpdated(object sender, LocationUpdatedEventArgs e)
        {
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                lock (_localizerLock)
                {
                    if (localizer != null)
                    {
                        if (localizer.lastData != null)
                        {
                            List<string> legend = new List<string>();
                            for (int i = 0; i < localizer.lastData.ColumnCount; i++)
                            {
                                legend.Add(String.Format("Channel {0}", i + 1));
                            }
                            if (pw != null)
                            {
                                if (pw.IsLoaded)
                                    pw.Update("Data", localizer.lastData, legend, ASIO.T, localizer.lastMaxes);
                            }
                            else
                            {
                                pw = new PlotWindow("Data", localizer.lastData, legend, ASIO.T, localizer.lastMaxes);
                                pw.Show();
                            }

                        }
                    }
                }
            }
            else
            {
                Debug.WriteLine("Could not display PlotWindow due to ThreadApartment");
            }
            //Debug.WriteLine(e.Position);
            //Position3D pos = new Position3D() { X = (lpos.X * 2 + e.Position.X) / 3, Y = (lpos.Y * 2 + e.Position.Y) / 3, Z = 0 };
            //posistionLog.AppendText(pos.ToString() + "\n");
            Vector<double> lastPosition = Position;
            Position = (Position * Data.cfg.SmoothFactor + DenseVector.OfArray(new double[] { e.Position.X, e.Position.Y })) / (1 + Data.cfg.SmoothFactor);
            Vector<double> difference = Position - lastPosition;
            if (difference.Magnitude() > 0.01)
            {
                bearing = difference.Angle();
            }

            //posistionLog.ScrollToEnd();
            UpdateField();
        }