Ejemplo n.º 1
0
        /// <summary>
        /// 过滤设备列表,获取摄像机和目录列表
        /// </summary>
        /// <param name="deviceList">输入设备列表</param>
        /// <param name="cameraListTemp">返回摄像机列表</param>
        /// <param name="groupListTemp">返回组列表</param>
        private void FilterDeviceList(List<DeviceItem> deviceList, ref List<Camera> cameraListTemp, ref List<CameraGroup> groupListTemp)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: T28181VideoMonitor.FilterDeviceList().");

            try
            {

                foreach (DeviceItem item in deviceList)
                {
                    //根据设备ID获取设备类型
                    string devType = GetResourceType(item.DeviceID);
                    //共享摄像机类型、共享主设备类型,需要通过主设备来查找设备的父节点
                    if (devType == "01" || devType == "00")
                    {
                        Camera camera = new Camera(item.DeviceID, item.Name);
                        camera.Status = item.Status == "ON" ? CameraStatus.Online : CameraStatus.Offline;
                        camera.ParentID = item.ParentID;
                        camera.DeviceType = devType;
                        cameraListTemp.Add(camera);
                    }
                    //共享目录类型
                    else if (devType == "99")
                    {
                        CameraGroup group = new CameraGroup(item.DeviceID, item.Name);
                        group.ParentID = item.ParentID;
                        groupListTemp.Add(group);
                    }
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("FilterDeviceList failed. {0} ", ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="isRealTime">是否实时获取,融合网关有个缓存,间隔一段时间获取,默认是从融合网关获取列表,如果该值为true,则实时获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(bool fromMonitorSys, out List<Camera> cameraList, out List<CameraGroup> groupList, out List<NodeRelation> nodeRelationList)
        {
            cameraList = new List<Camera>();
            groupList = new List<CameraGroup>();
            nodeRelationList = new List<NodeRelation>();

            for (int i = 1; i < 10000; i++)
            {
                Camera cs = new Camera("41552873131314642203" + i.ToString(), i.ToString());
                cs.DeviceType = "01";
                cs.Status = CameraStatus.Online;
                //cs.ParentID = "41552873135005642565";
                cameraList.Add(cs);
            }

            //CameraGroup group = new CameraGroup("41552873135005642565","group");
            //groupList.Add(group);

            //NodeRelation rea = new NodeRelation("41552873135005642565", new List<string>(), NodeType.GROUP);
            //nodeRelationList.Add(rea);

            for (int i = 1; i < 10000; i++)
            {
                NodeRelation rea1 = new NodeRelation("41552873131314642203" + i.ToString(), new List<string>(), NodeType.CAMERA);
                nodeRelationList.Add(rea1);
            }

            return new CgwError();

            //NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            //logEx.Trace("Enter: T28181VideoMonitor.GetAllCameras().");

            //SmcErr err = new CgwError();
            //cameraList = new List<Camera>();
            //groupList = new List<CameraGroup>();
            //nodeRelationList = new List<NodeRelation>();

            //if (fromMonitorSys)
            //{
            //    //开始查询设备列表
            //    Thread th = new Thread(new ThreadStart(()
            //        =>
            //    {
            //        GetAllCamerasTimer(null, null);
            //    }));
            //    th.Priority = ThreadPriority.Highest;
            //    th.Start();
            //    //等待结束查询
            //    th.Join();
            //}

            //if (this.cameraOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            //{
            //    try
            //    {
            //        #region 深度克隆数据
            //        foreach (Camera ivsCamera in this.cameraList)
            //        {
            //            //从缓存获取
            //            Camera camera = new Camera(ivsCamera.No, ivsCamera.Name);
            //            camera.Status = ivsCamera.Status;
            //            cameraList.Add(camera);
            //        }
            //        foreach (CameraGroup cameraGroup in this.groupList)
            //        {
            //            CameraGroup cameraGroupTemp = new CameraGroup(cameraGroup.No, cameraGroup.Name);
            //            groupList.Add(cameraGroupTemp);
            //        }
            //        foreach (NodeRelation nodeRelation in this.nodeRelationList)
            //        {
            //            NodeRelation nodeRelationTemp = new NodeRelation(nodeRelation.No, nodeRelation.Path, nodeRelation.Type);
            //            nodeRelationList.Add(nodeRelationTemp);
            //        }
            //        #endregion
            //    }
            //    catch (Exception e)
            //    {
            //        err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
            //        logEx.Error("Get all cameras failed.Execption message:{0}", e.Message);
            //        return err;
            //    }
            //    finally
            //    {
            //        this.cameraOperateLock.ExitReadLock();
            //    }
            //}
            //logEx.Info("cameraList.{0}", cameraList.Count);
            //logEx.Info("groupList.{0}", groupList.Count);
            //logEx.Info("nodeRelationList.{0}", nodeRelationList.Count);
            //logEx.Info("Get all cameras success.");
            //return err;
        }