コード例 #1
0
        // function handles the event when user clicks
        // on item in the list
        public void FeatureSelected(int selectedIndex)
        {
            M_Points.Clear();
            M_CorrelatedPoints.Clear();
            regPoints.Clear();
            regPoints30.Clear();
            indexOfFeature = selectedIndex;
            string feature     = listOfFeaturesNames[selectedIndex];
            int    index       = 0;
            string correlatedF = getCorreltadFeature(feature);

            // find the index of the feature
            for (int i = 0; i < listOfFeaturesNames.Count; i++)
            {
                if (correlatedF == listOfFeaturesNames[i])
                {
                    index = i;
                }
            }
            indexOfCorrelatedFeature = index;
        }
コード例 #2
0
        // this function updates the lists of points
        // using thread
        public void updateFeaturesList()
        {
            bool isConnected = true;
            long currentLine = 0;
            Line reg_line    = new Line();

            new Thread(delegate()
            {
                while (isConnected)
                {
                    Thread.Sleep(100);
                    if (Client.client_instance.currentFlightState() == null)
                    {
                        continue;
                    }
                    string[] flightsInsturment;
                    flightsInsturment = Client.client_instance.currentFlightState().Split(',');



                    if (Client.client_instance.getCurrentLine() != -99)
                    {
                        // get current line number
                        currentLine = Client.client_instance.getCurrentLine();
                    }
                    // if user takes the control bar reverse
                    if (M_Points.Count != 0 && M_Points.Last().X > currentLine)
                    {
                        // clear the lists
                        M_Points.Clear();
                        M_CorrelatedPoints.Clear();
                        M_LineReg.Clear();
                    }
                    DataPoint feature    = new DataPoint(currentLine, Convert.ToDouble(flightsInsturment[indexOfFeature]));
                    DataPoint correlated = new DataPoint(currentLine, Convert.ToDouble(flightsInsturment[indexOfCorrelatedFeature]));

                    M_Points.Add(feature);
                    M_CorrelatedPoints.Add(correlated);

                    regPoints30.Add(new DataPoint(feature.Y, correlated.Y));
                    if (regPoints30.Count() > 50)
                    {
                        regPoints.Add(regPoints30[0]);
                        regPoints30.RemoveAt(0);
                    }


                    if (M_Points.Count > 2)
                    {
                        M_LineReg.Clear();
                        reg_line.linear_regg(M_Points, M_CorrelatedPoints, M_Points.Count());

                        //Console.WriteLine(M_Points[0].X + " , " + reg_line.f(M_Points[0].Y));
                        M_LineReg.Add(new DataPoint(M_Points[0].X, reg_line.f(M_Points[0].Y)));
                        //Console.WriteLine(currentLine + " , " + reg_line.f(M_CorrelatedPoints[M_CorrelatedPoints.Count - 1].Y));
                        M_LineReg.Add(new DataPoint(currentLine, reg_line.f(M_CorrelatedPoints[M_CorrelatedPoints.Count - 1].Y)));
                    }


                    // M_LineReg.Add(feature);
                }
            }).Start();
        }