예제 #1
0
        static async Task add_data(Client.ReceiveEventArgs data)
        {
            int pt = BitConverter.ToInt32(data.data, 8);

            if (pt == 0)
            {
                list_lock.WaitOne();
                if (point_time_list.Count != 0)
                {
                    await r.get_results(point_time_list, point_list);
                }
                point_time_list.Clear();
                point_list.Clear();
                list_lock.ReleaseMutex();
                return;
            }
            float x = (float)(BitConverter.ToInt32(data.data, 0));
            float y = (float)(BitConverter.ToInt32(data.data, 4));
            long  t = (long)Math.Round((data.time - base_time).TotalMilliseconds);

            list_lock.WaitOne();
            if (point_time_list.Count >= MAX_NODE)
            {
                point_time_list.RemoveFirst();
                point_list.RemoveFirst();
            }
            point_time_list.AddLast(t);
            point_list.AddLast(new PointF(x, y));
            list_lock.ReleaseMutex();
        }
예제 #2
0
        static void add_data_sync(Client.ReceiveEventArgs data)
        {
            int pt = BitConverter.ToInt32(data.data, 8);

            if (pt == 0)
            {
                if (point_time_list.Count != 0)
                {
                    var wait = r.get_results(point_time_list, point_list);
                    while (!wait.IsCompleted)
                    {
                        ;
                    }
                }
                point_time_list.Clear();
                point_list.Clear();
                return;
            }
            float x = (float)(BitConverter.ToInt32(data.data, 0));
            float y = (float)(BitConverter.ToInt32(data.data, 4));
            long  t = (long)Math.Round((data.time - base_time).TotalMilliseconds);

            if (point_time_list.Count >= MAX_NODE)
            {
                point_time_list.RemoveFirst();
                point_list.RemoveFirst();
            }
            point_time_list.AddLast(t);
            point_list.AddLast(new PointF(x, y));
        }