示例#1
0
        void StartTracking()
        {
            Task.Run(() =>
            {
                try
                {
                    while (true)
                    {
                        CalculationsManager.Point position = new CalculationsManager.Point();
                        if (timeRanges.Count > 0)
                        {
                            double[] points = timeRanges.Dequeue();

                            /*for (int i = 0; i < 3; i++)
                             * {
                             *  text += points[i] + ";   " + '\r' + '\n';
                             * }*/
                            position = CalculationsManager.FindTarget(points, locators);
                            position.Write(this);
                            trajectory.Add(position);
                            lastPoint = position;
                        }
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            });
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CalculationsManager.Point point = new CalculationsManager.Point();
            double temp = locators[0].point.x;

            if (!Double.TryParse(textBox2.Text, out locators[0].point.x))
            {
                locators[0].point.x = temp;
            }
            temp = locators[0].point.y;
            if (!Double.TryParse(textBox3.Text, out locators[0].point.y))
            {
                locators[0].point.y = temp;
            }
            temp = locators[1].point.x;
            if (!Double.TryParse(textBox4.Text, out locators[1].point.x))
            {
                locators[1].point.x = temp;
            }
            temp = locators[1].point.y;
            if (!Double.TryParse(textBox5.Text, out locators[1].point.y))
            {
                locators[1].point.y = temp;
            }
            temp = locators[2].point.x;
            if (!Double.TryParse(textBox6.Text, out locators[2].point.x))
            {
                locators[2].point.x = temp;
            }
            temp = locators[2].point.y;
            if (!Double.TryParse(textBox7.Text, out locators[2].point.y))
            {
                locators[2].point.y = temp;
            }
            temp = lastPoint.x;
            if (!Double.TryParse(textBox8.Text, out point.x))
            {
                point.x = temp;
            }
            temp = lastPoint.y;
            if (!Double.TryParse(textBox9.Text, out point.y))
            {
                point.y = temp;
            }

            lock (timeRanges) {
                timeRanges.Clear();
                double[] newTimeRanges = new double[3];
                for (int i = 0; i < newTimeRanges.Length; i++)
                {
                    newTimeRanges[i] = CalculationsManager.GetDistanceBetweenPoints(locators[i].point, point);
                }
                timeRanges.Enqueue(newTimeRanges);
            }
        }