Beispiel #1
0
        private void m_wndClearTimer_Tick(object sender, EventArgs e)
        {
            // 查找需要清除的目标
            DateTime   now        = DateTime.Now;
            TimeSpan   tenMinutes = new TimeSpan(0, 20, 0);
            List <int> removeKeys = new List <int>();

            foreach (AISTarget target in m_AISCollection.Values)
            {
                if ((now - target.UpdateTime) >= tenMinutes)
                {
                    removeKeys.Add(target.MMSI);
                }
            }

            // 开展清除工作
            foreach (int mmsi in removeKeys)
            {
                AISTarget target = null;
                if (m_AISCollection.TryGetValue(mmsi, out target) && (target != null))
                {
                    m_AISCollection.Remove(mmsi);
                    m_wndAISList.Items.Remove(target.ListItem);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新位置
        /// </summary>
        private void UpdatePosition(int mmsi, double latitude, double longitude, double speed, double course, double heading)
        {
            if (this.InvokeRequired)
            {
                Delegate method = new UpdatePositionHandler(UpdatePosition);
                this.Invoke(method, new object[] { mmsi, latitude, longitude, speed, course, heading });
                return;
            }

            AISTarget target = null;

            if (m_AISCollection.TryGetValue(mmsi, out target))
            {
                // 更新现有数据项
                target.Latitude  = latitude;
                target.Longitude = longitude;
                target.Speed     = speed;
                target.Course    = course;
                target.Heading   = heading;
            }
            else
            {
                // 新增新数据项
                target           = new AISTarget();
                target.MMSI      = mmsi;
                target.Latitude  = latitude;
                target.Longitude = longitude;
                target.Speed     = speed;
                target.Course    = course;
                target.Heading   = heading;

                // 添加到集合中
                m_AISCollection.Add(mmsi, target);
                target.ListItem = new System.Windows.Forms.ListViewItem(mmsi.ToString());
                target.ListItem.SubItems.AddRange(new string[] { "***", "***", "***", "***", "***", "***", "***", "***" });
                m_wndAISList.Items.Add(target.ListItem);
            }

            if (target != null)
            {
                target.UpdateTime = DateTime.Now;
                // 更新显示
                target.UpdateContent();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新静态信息
        /// </summary>
        private void UpdateData(int mmsi, string name, string callSign, string destination)
        {
            if (this.InvokeRequired)
            {
                Delegate method = new UpdateDataHandler(UpdateData);
                this.Invoke(method, new object[] { mmsi, name, callSign, destination });
                return;
            }

            AISTarget target = null;

            if (m_AISCollection.TryGetValue(mmsi, out target))
            {
                // 更新现有数据项
                target.Name        = name;
                target.CallSign    = callSign;
                target.Destination = destination;
            }
            else
            {
                // 新增新数据项
                target             = new AISTarget();
                target.MMSI        = mmsi;
                target.Name        = name;
                target.CallSign    = callSign;
                target.Destination = destination;

                // 添加到集合中
                m_AISCollection.Add(mmsi, target);
                target.ListItem = new System.Windows.Forms.ListViewItem(mmsi.ToString());
                target.ListItem.SubItems.AddRange(new string[] { "***", "***", "***", "***", "***", "***", "***", "***" });
                m_wndAISList.Items.Add(target.ListItem);
            }

            if (target != null)
            {
                target.UpdateTime = DateTime.Now;
                // 更新显示
                target.UpdateContent();
            }
        }