Beispiel #1
0
        /// <summary>
        /// 接收到GPS信号事件
        /// </summary>
        /// <param name="gpsInfo">GPS信息</param>
        private void PGPSUDPListener_OnReceiveGPSInfo(GPSInfo gpsInfo)
        {
            MeshAllInfo mesh = mMeshAllInfo.Find(m => m.PlanInfo.Model265ID == gpsInfo.ID);

            //如果ID不存在,则退出
            if (mesh == null)
            {
                return;
            }

            if (mesh.PlanInfo != null)
            {
                GPSInfo gi = mesh.MeshGPSInfo;
                gi.Time          = gpsInfo.Time;
                gi.Lat           = gpsInfo.Lat;
                gi.Lon           = gpsInfo.Lon;
                mesh.MeshGPSInfo = gi;

                BMeshPoint bmp = mesh.BuddyBMeshPoint;
                bmp.IsOnline         = true;
                bmp.ReceiveGPSDT     = DateTime.Now;
                bmp.Location         = new LatLngPoint(gpsInfo.Lon, gpsInfo.Lat);
                mesh.BuddyBMeshPoint = bmp;
            }

            if (mesh.BuddyNode != null)
            {
                doUpdateAdvTreeMeshList(mesh.DeviceInfo.IPV4, "在线", "GPS在线");
            }

            //如果之前没有在地图上显示该设备则添加显示
            BMeshPoint p = mBMeshPoints.Find(b => b.IPV4 == mesh.PlanInfo.MeshIP);

            if (p != null)
            {
                p.Location = new LatLngPoint(gpsInfo.Lon, gpsInfo.Lat);
                if (BuddyBMapControl != null)
                {
                    BuddyBMapControl.AddMeshDevicePlaces(mBMeshPoints);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// GIS地图上点击打开视频事件
        /// </summary>
        /// <param name="p"></param>
        private void BuddyBMapControl_OnOpenVideo(BMeshPoint p)
        {
            VideoInject inject = new VideoInject(mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerIPV4],
                                                 mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerUserName],
                                                 mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerPassword]);
            Process process = mFormMain.VideoWindowProcesses.Find(ps => ps.StartInfo.Arguments.Contains(p.Model265ID));

            if (BuddyBMapControl != null)
            {
                //查找曾经试图关闭视频进程的进程是否已经完全结束,如果没有结束再自动Kill一次
                foreach (string pidf in Directory.GetFiles(FileUtils.VIDEO_PROCESS_ID_DIRECTORY))
                {
                    string  pid   = Path.GetFileNameWithoutExtension(pidf);
                    Process tempP = mFormMain.VideoWindowProcesses.Find(ps => ps.Id.ToString() == pid);
                    if (tempP != null && !tempP.HasExited)
                    {//说明进程曾经试图关闭自己,但是没有关闭掉
                        tempP.Kill();
                        mFormMain.VideoProcesses.Remove(tempP);
                    }
                    if (File.Exists(pidf))
                    {
                        File.Delete(pidf);
                    }
                }

                if (process == null)
                {
                    mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                }
                else
                {
                    if (process.HasExited)
                    {
                        mFormMain.VideoWindowProcesses.Remove(process);
                        mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                    }
                    else
                    {
                        //进程ID文件
                        string idFile = Path.Combine(FileUtils.VIDEO_PROCESS_ID_DIRECTORY, process.Id + ".txt");
                        if (File.Exists(idFile))
                        {
                            if (File.Exists(idFile))
                            {
                                File.Delete(idFile);
                            }
                            if (!process.HasExited)
                            {
                                process.Kill();
                            }
                            mFormMain.VideoWindowProcesses.Remove(process);
                            mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                        }
                        else
                        {
                            //如果已经打开过该视频,则直接将视频窗口置顶
                            VideoInject.SetForegroundWindow(process.MainWindowHandle);
                        }
                    }
                }
            }
        }