Ejemplo n.º 1
0
        /// <summary>
        /// 设置监控通道视频源
        /// </summary>
        /// <param name="channelLabel">通道label</param>
        /// <param name="cameraNo">摄像头NO</param>
        /// <returns></returns>
        public SmcErr SwitchChannelVideoSource(string channelLabel, string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            if (serviceControl.MonitorServiceRun())
            {
                if (!string.IsNullOrEmpty(channelLabel))
                {
                    //切换通道关联
                    err = manageChannel.SwitchChannelRelation(channelLabel, cameraNo);
                }
                else
                {
                    //监控通道号不能为空
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELNO_NULL);
                }
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }

            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("SwitchChannelVideoSource Successful");
            }
            else
            {
                logEx.Error("SwitchChannelVideoSource failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.RefreshMonitorCamera.");
            SmcErr err = new SmcErr();

            //copy 一份,防止长时间占用锁
            Dictionary <string, IVideoMonitor> monitorsDictionaryTemp = null;

            if (this.monitorsOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    monitorsDictionaryTemp = new Dictionary <string, IVideoMonitor>(monitorsDictionary);
                }
                catch (Exception e)
                {
                    logEx.Error("RefreshMonitorCamera failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("RefreshMonitorCamera from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.ERR_REFRESH_MONITOR_CAMERA_FAIL);
                return(err);
            }

            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回
            foreach (KeyValuePair <string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                IVideoMonitor videoMonitor = monitor.Value;
                err = videoMonitor.RefreshMonitorCamera();

                if (err.IsSuccess())
                {
                    logEx.Info("RefreshMonitorCamera success.");
                }
                else
                {
                    logEx.Error("RefreshMonitorCamera failed.");
                    err.SetErrorNo(CgwError.ERR_REFRESH_MONITOR_CAMERA_FAIL);
                    break;
                }
            }
            return(err);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取监控设备列表,返回摄像头基本信息,组基本信息,所属分组关系信息
        /// </summary>
        public SmcErr QueryMonitorCamera(Cgw.Common.PlatformType platformType, Cgw.Common.PageParam pageParam, out List <Common.Camera> CameraInfoList, out List <Common.CameraGroup> CameraGroupList, out List <Common.NodeRelation> nodeRelationList, out Cgw.Common.PagesInfo pagesInfo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            CameraInfoList   = null;
            CameraGroupList  = null;
            nodeRelationList = null;
            pagesInfo        = null;
            if (serviceControl.MonitorServiceRun())
            {
                try
                {
                    err = CgwMonitorManageAdapter.Instance().GetAllCameras(platformType, pageParam, out CameraInfoList, out CameraGroupList, out nodeRelationList, out pagesInfo, licenseInfo);
                }
                catch (Exception ex)
                {
                    logEx.Trace("QueryMonitorCamera.Exception = {0}", ex.ToString());
                }
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("QueryMonitorCamera Successful");
            }
            else
            {
                logEx.Error("QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 分配监控通道
        /// </summary>
        /// <param name="ChannelInfoList"></param>
        /// <returns></returns>
        public SmcErr AssignMonitorChannel(List <Common.ChannelInfo> ChannelInfoList)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            if (serviceControl.MonitorServiceRun())
            {
                err = manageChannel.AssignChannel(ChannelInfoList);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }

            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("AssignMonitorChannel Successful");
            }
            else
            {
                logEx.Error("AssignMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 加载监控平台,加载通道管理模块,加载license管理模块
        /// </summary>
        /// <returns></returns>
        public SmcErr Load()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            //开启连接监控平台线程
            this.connectMonitorManageServiceThread = new Thread(new ThreadStart(ConnectMonitorManageServiceTimer));
            this.connectMonitorManageServiceThread.Start();
            logEx.Info("ConnectMonitorManageServiceTimer Run");
            //初始话定时器
            this.monitorManageServiceKeepLiveTimer.AutoReset = true;
            this.monitorManageServiceKeepLiveTimer.Elapsed  += new ElapsedEventHandler(MonitorManageServiceKeepLiveTimer_Elapsed);
            //保活时间间隔,5秒
            this.monitorManageServiceKeepLiveTimer.Interval = CgwConst.MONITOR_MANAGE_KEEPLIVE_WAIT_TIME;
            this.monitorManageServiceKeepLiveTimer.Start();

            manageChannel = new MonitorChannelRelationManager();
            try
            {
                IPAddressEx ip = new IPAddressEx(ConfigSettings.CgwServiceIp);
            }
            catch (System.Exception ex)
            {
                logEx.Error("CgwService configuration files is error ,The IP address  format  is error,Please Check this configuration files! " + ex.ToString());
                err.SetErrorNo(CgwError.ERR_CGW_CONFIGURE_FORMAT);
            }
            if (err.IsSuccess())
            {
                InitSotParam param = new InitSotParam();
                param.cgwIp           = ConfigSettings.CgwServiceIp;
                param.audioType       = ConfigSettings.CgwAudioProtocol;
                param.channelCallPort = ConfigSettings.CgwChanelCallPort;
                param.rtpStartPort    = ConfigSettings.CgwChannelRTPStartPort;
                param.rtpPortCount    = ConfigSettings.CgwChannelRTPPortCount;
                err = manageChannel.Init(param);
            }

            if (err.IsSuccess())
            {
                logEx.Info("CgwServiceLoad Successful !");
            }
            else
            {
                logEx.Error("CgwServiceLoad failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 保活监控平台服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MonitorManageServiceKeepLiveTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            try
            {
                if (isNeedKeepAliver)
                {
                    //Connect Monitor
                    if (!serviceControl.MonitorServiceRun())
                    {
                        isNeedConnect = true;

                        //2015/2/13 Monitor服务不在线,将KeepAliver置为false,避免线程不断保活,待测试
                        isNeedKeepAliver = false;
                        err.SetErrorNo(CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                    }
                    else
                    {
                        err = CgwMonitorManageAdapter.Instance().KeepAliver();
                    }
                    if (err.IsSuccess())
                    {
                        logEx.Trace("MonitorManageServiceKeepLive Successful !");
                    }
                    else
                    {
                        isNeedConnect    = true;
                        isNeedKeepAliver = false;
                        logEx.Warn("MonitorManageServiceKeepLive Failed !");
                    }
                }
            }
            catch (System.Exception ex)
            {
                isNeedConnect    = true;
                isNeedKeepAliver = false;
                logEx.Error("MonitorManageServiceKeepLive.Exception is {0}", ex.ToString());
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.GetRefreshStatus.");

            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            SmcErr err = new SmcErr();

            //copy 一份,防止长时间占用锁
            Dictionary <string, IVideoMonitor> monitorsDictionaryTemp = null;

            if (this.monitorsOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    monitorsDictionaryTemp = new Dictionary <string, IVideoMonitor>(monitorsDictionary);
                }
                catch (Exception e)
                {
                    logEx.Error("GetRefreshStatus failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("GetRefreshStatus from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED);
                return(err);
            }
            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回

            SmcErr tempMonitor = new SmcErr();

            tempMonitor.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            SmcErr tempLTE = new SmcErr();

            tempLTE.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            foreach (KeyValuePair <string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                IVideoMonitor videoMonitor = monitor.Value;

                if (monitor.Key != "eLTE")
                {
                    if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
                    {
                        err = videoMonitor.GetRefreshStatus(out tempMonitor);
                    }
                }
                else
                {
                    err = videoMonitor.GetRefreshStatus(out tempLTE);
                }

                if (!err.IsSuccess())
                {
                    logEx.Error("GetRefreshStatus failed.");
                    err.SetErrorNo(CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED);
                    refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
                    return(err);
                }
            }

            //监控和elte都刷新完毕
            if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            }
            //监控和elte都刷新执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
            }
            //监控和elte都刷新失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
            }
            //监控成功、elte失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_SUCCESS_ELTE_FAIL;
            }
            //监控成功、elte执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_SUCCESS_ELTE_EXECUTING;
            }
            //监控执行中、elte成功
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_EXECUTING_ELTE_SUCCESS;
            }
            //监控执行中、elte失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_EXECUTING_ELTE_FAIL;
            }
            //监控失败、elte成功
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_FAIL_ELTE_SUCCESS;
            }
            //监控失败、elte执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_FAIL_ELTE_EXECUTING;
            }
            return(err);
        }