/// <summary> /// 轮询摄像头 /// </summary> private void QueryCamera() { while (true) { Thread.Sleep(10000); //线程挂起10s //更新一遍摄像头状态 SkyinforHikvision skyinforhk = new SkyinforHikvision(); skyinforhk.QueryCameras(); } }
/// <summary> /// 轮询摄像头 /// </summary> private void InitCamera(ref SkyinforHikvision skyinforhk) { skyinforhk.InitNVR(); skyinforhk.InitHKCamera(); //初始化报警回调函数。zzt 这里有问题,可能有多个NVR,这里要对所有的NVR跟所有的通道整体注册 Hikvision hikAlarmCallBack = new HikvisionAlarmCallBackFun(); //对所有NVR进行注册报警 //根据NVR里面的通道,获取到了所有通道在线信息,然后根据nvr id 跟nvr datatable进行关联,将nvr id 与 nvr ip 地址与 nvr通道号一起跟摄像头关联 for (int i = 0; i < StaticData.g_dtNVR.Rows.Count; i++) { hikAlarmCallBack.AlarmCallBackFun(Convert.ToInt32(StaticData.g_dtNVR.Rows[i]["userid"]), 0); } //更新下列表界面 CameraListUpdate listUpdate = new CameraListUpdate(StaticData.g_dtCamera); }
/// <summary> /// 用于设置websocket端口同时开启所有功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_StartWebSocket_Click(object sender, EventArgs e) { /// ///初始化界面相关数据 /// InitUI(); /// ///初始化第三方设备 /// //注册设备线程 InitDevices(); /// ///开启websocket线程 /// Thread thrWebSocket = new Thread(new ThreadStart(WebSocketInit)); thrWebSocket.IsBackground = true; thrWebSocket.Start(); /// ///开启摄像头初始化线程 ////* 摄像头数量较多,初始化过程牵扯到多步操作(eg:数据库摄像头相关状态更新)。因此开启子线程执行耗时操作,避免主线程卡死 */ /// SkyinforHikvision skyinforhk = new SkyinforHikvision(); InitCamera(ref skyinforhk); Thread thrCamerainit = new Thread(new ThreadStart(skyinforhk.UpdateDB)); thrCamerainit.IsBackground = true; thrCamerainit.Start(); //轮询完所有摄像头,开启摄像头转码线程, //读取dt表中flag字段跟rtsp留,然后开线程转码 //SkyinforVideoTransform videoTransform = SkyinforVideoTransform.getInstance(); //Thread thrCamerainit = new Thread(new ThreadStart(videoTransform.SkyinforVideoServer)); //thrCamerainit.IsBackground = true; //thrCamerainit.Start(); /// ///轮询第三方设备 /// //轮询机房环控 SkyinforMachineRoom environment = new SkyinforMachineRoom(); Thread thrEnvironment = new Thread(new ThreadStart(environment.MachineRoom_Get)); thrEnvironment.IsBackground = true; thrEnvironment.Start(); //轮询广播 : 一直监听broadcast硬件的广播,没隔30秒左右会返回一遍状态 BroadcastUDP serverReceive = new BroadcastUDP(); Thread thrUDP = new Thread(new ThreadStart(serverReceive.BroadServerReceive)); thrUDP.IsBackground = true; thrUDP.Start(); //轮询停车场 SkyinforParking skinforParing = new SkyinforParking(); Thread Parking = new Thread(new ThreadStart(skinforParing.ParkingWebRequest_Get)); Parking.IsBackground = true; Parking.Start(); //轮询闸机 SkyinforGate skyinforGate = new SkyinforGate(); Thread Gate = new Thread(new ThreadStart(skyinforGate.Gate_Get)); Gate.IsBackground = true; Gate.Start(); //轮询Wifi列表 SkyinforWifi skyinforWifi = new SkyinforWifi(); Thread Wifi = new Thread(new ThreadStart(skyinforWifi.WifiList_Get)); // 获取所有AP的基本信息的列表 Wifi.IsBackground = true; Wifi.Start(); //App上报故障事件监听线程 Thread AppEventListener = new Thread(new ThreadStart(PollForAppEvent)); AppEventListener.IsBackground = true; AppEventListener.Start(); /// ///界面刷新及状态监控 /// //软件占用资源信息线程 Thread ProgramInfo = new Thread(new ThreadStart(GetProgramInfo)); ProgramInfo.IsBackground = true; ProgramInfo.Start(); //设备状态统计信息线程 Thread DeviceInfo = new Thread(new ThreadStart(UpdateForm)); DeviceInfo.IsBackground = true; DeviceInfo.Start(); kBut_StartService.Text = "服务运行中..."; kBut_StartService.BackColor = ColorTranslator.FromHtml("#4679FF"); kBut_StartService.FlatAppearance.BorderSize = 0; kBut_StartService.Enabled = false; }