SetErrorNo() public method

设置错误码
public SetErrorNo ( uint err ) : void
err uint 状态
return void
Exemplo n.º 1
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.RefreshMonitorCamera");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.RefreshMonitorCamera();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.RefreshMonitorCamera failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.RefreshMonitorCamera failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 连接监控平台管理服务
        /// </summary>
        /// <param name="monitorPwd">加密后的密码字符串</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Connect(string monitorPwd)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: CgwMonitorManageAdapter.Connect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                if (serviceControl.MonitorServiceRun())
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect Opened");
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Connect(out monitorPwd);

                    sessionID = monitorPwd;
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Connect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect MonitorServiceStart");
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                    serviceControl.MonitorServiceStart();//自动重连监控服务
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Connect failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 断开监控平台管理服务
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Disconnect()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.Disconnect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //判断Monitor服务是否在线,在线调用DisConnect方法
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Disconnect();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Disconnect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else //不在线,无需调用DisConnect方法
                {
                    logEx.Info("CgwMonitorManageAdapter.Disconnect,MonitorManage Stopped");
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Disconnect failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 停止预览摄像头视频,并清理命名管道
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StopReceiveVideoByPipe(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StopReceiveVideoByPipe");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StopReceiveVideoByPipe(cameraNo);
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.StopReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        VideoPipe videoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                        if (videoPipe != null)
                        {
                            videoPipe.Stop();
                            logEx.Info("CgwMonitorManageAdapter.StopReceiveVideoByPipe Success. cameraNo = {0} ", cameraNo);
                        }
                        else
                        {
                            logEx.Error("CgwMonitorManageAdapter.StopReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        }
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StopReceiveVideoByPipe failed. Exception is {0} ", ex.ToString());
                logEx.Error("CameraNo:" + cameraNo);
            }
            return(err);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus">返回值,刷新状态</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetRefreshStatus(out SmcError.SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetRefreshStatus");

            refreshStatus       = new Cgw.SmcError.SmcErr();
            refreshStatus.ErrNo = Cgw.SmcError.CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.SmcErr i_refreshStatus = new CgwMonitorManageServiceReference.SmcErr();

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetRefreshStatus(out i_refreshStatus);
                    client.Close();

                    refreshStatus.ErrNo = i_refreshStatus.ErrNo;
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetRefreshStatus failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        logEx.Info("CgwMonitorManageAdapter.GetRefreshStatus Success. ");
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetRefreshStatus failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 关闭PTZ操作
        /// </summary>
        /// <param name="Camerano">摄像头</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StopControlPtz(string cameraNo, Common.PtzCommandType ptzCommandType)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StopControlPtz");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.PtzCommandType ptzCommand = (CgwMonitorManageServiceReference.PtzCommandType)ptzCommandType;  //将平台的枚举转换成服务中的枚举

                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StopControlPtz(cameraNo, ptzCommand);
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("Stop control ptz failed.Camera no:{0},ptzCommandType:{1},Error Code:{2} ", cameraNo, ptzCommand, err.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        logEx.Info("Stop control ptz success.Camera no:{0},ptzCommandType:{1}.", cameraNo, ptzCommand);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StopControlPtz failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 设置扬声器
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="isOn"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr SetSpeaker(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.SetSpeaker");

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.SetSpeaker(cameraNo, isOn);
                    client.Close();
                    if (serviceErr.ErrNo == Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Info("Cgw SetSpeaker  Successful,Current Cgw IP is : {0}", CgwConst.CGWSERVICE_IP_TAG);
                    }
                    else
                    {
                        logEx.Error("Cgw SetSpeaker failed,ErrNo :{0}", err.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.SetSpeaker failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 保持连接
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr KeepAliver()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.KeepAliver");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                client = new MonitorManageServiceClient();
                CgwMonitorManageServiceReference.SmcErr serviceErr = client.KeepAliver(sessionID);
                client.Close();
                if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                {
                    logEx.Error("CgwMonitorManageAdapter.KeepAliver failed. ErrNo = {0} ", serviceErr.ErrNo);
                    err = SetCgwErrNo(serviceErr);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.KeepAliver failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
        /// <summary>
        /// 同步通道会议信息
        /// </summary>
        /// <param name="channelNo">通道号码</param>
        /// <param name="confNo">会议号</param>
        private SmcErr SyncChannelConfAccessCode(string channelLabel, string confAccessCode, ChannelControlType controlType)
        {
            SmcErr err = new SmcErr();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            string oldConfAccessCode = string.Empty;
            logEx.Trace("SyncChannelConfAccessCode Start. input channelLabel:{0}, ConfAccessCode:{1}, ControlType:{2}.", channelLabel, confAccessCode, controlType);

            if ((this.monitorChannelRelationDic.ContainsKey(channelLabel) && controlType == ChannelControlType.Add)
                || (!this.monitorChannelRelationDic.ContainsKey(channelLabel) && controlType != ChannelControlType.Add))
            {
                err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_INPUT_ERROR);
                logEx.Trace("SyncChannelConfAccessCode input error channelLabel:{0}, ConfAccessCode:{1}, ControlType:{2}.", channelLabel, confAccessCode, controlType);
                return err;
            }

            // 判断是否需要添加通道
            if (ChannelControlType.Add == controlType)
            {
                // 通道关系字典添加一个通道
                this.monitorChannelRelationDic.Add(channelLabel, new MonitorChannelRelation(channelLabel));

                // 通道字典添加一个新通道
                this.monitorChannelManager.AddChannel(channelLabel);

                // 判断需要切换的会议号是否为空
                if (!string.IsNullOrEmpty(confAccessCode))
                {
                    // 添加通道到软终端
                    this.monitorChannelManager.AddSotChannel(channelLabel, confAccessCode);
                    this.monitorChannelRelationDic[channelLabel].ConfAccessCode = confAccessCode;
                }

                logEx.Trace("SyncChannelConfAccessCode add channel:{0} successfully.", channelLabel);
            }
            else if (ChannelControlType.None == controlType)
            {
                oldConfAccessCode = this.monitorChannelRelationDic[channelLabel].ConfAccessCode;
                if (string.IsNullOrEmpty(oldConfAccessCode))    // 判断本地通道号码是否入会
                {
                    // 判断需要切换的会议号是否为空
                    if (!string.IsNullOrEmpty(confAccessCode))
                    {
                        // 添加通道到软终端
                        this.monitorChannelManager.AddSotChannel(channelLabel, confAccessCode);
                        this.monitorChannelRelationDic[channelLabel].ConfAccessCode = confAccessCode;
                    }
                }
                else
                {
                    // 判断需要切换的会议号是否为空
                    if (!string.IsNullOrEmpty(confAccessCode))
                    {
                        if (confAccessCode == oldConfAccessCode)
                        {
                            logEx.Trace("SyncChannelConfAccessCode [oldConfAccessCode:{0},ConfAccessNo:{1}] is same.", oldConfAccessCode, confAccessCode);
                            return err;
                        }

                        // 关闭视频码流
                        //err = this.SwitchChannelVideo(channelLabel, string.Empty);
                        err = this.StopCameraRtpAudio(channelLabel);
                        if (!err.IsSuccess())
                        {
                            logEx.Trace("SyncChannelConfAccessCode [oldConfAccessCode:{0},ConfAccessNo:{1}] stoprtp failed.", oldConfAccessCode, confAccessCode);
                            return err;
                        }

                        // 软终端删除该通道
                        this.monitorChannelManager.RemoveSotChannel(channelLabel);

                        // 软终端重新添加该通道
                        this.monitorChannelManager.AddSotChannel(channelLabel, confAccessCode);
                    }
                    else
                    {
                        // 关闭视频码流
                        //err = this.SwitchChannelVideo(channelLabel, string.Empty);
                        err = this.StopCameraRtpAudio(channelLabel);
                        if (!err.IsSuccess())
                        {
                            logEx.Trace("SyncChannelConfAccessCode [oldConfAccessCode:{0},ConfAccessNo:{1}] stoprtp failed.", oldConfAccessCode, confAccessCode);
                            return err;
                        }

                        // 软终端删除该通道
                        this.monitorChannelManager.RemoveSotChannel(channelLabel);
                    }

                    this.monitorChannelRelationDic[channelLabel].ConfAccessCode = confAccessCode;
                }
            }
            else
            {
                oldConfAccessCode = this.monitorChannelRelationDic[channelLabel].ConfAccessCode;
                if (!string.IsNullOrEmpty(oldConfAccessCode))
                {
                    // 关闭视频码流
                    //err = this.SwitchChannelVideo(channelLabel, string.Empty);
                    err = this.StopCameraRtpAudio(channelLabel);
                    if (!err.IsSuccess())
                    {
                        logEx.Trace("SyncChannelConfAccessCode [oldConfAccessCode:{0},ConfAccessNo:{1}] stoprtp failed.", oldConfAccessCode, confAccessCode);
                        return err;
                    }

                    // 软终端删除该通道
                    this.monitorChannelManager.RemoveSotChannel(channelLabel);
                    this.monitorChannelRelationDic[channelLabel].ConfAccessCode = string.Empty;
                }

                // 通道关系字典删除该通道
                if (this.monitorChannelRelationDic.ContainsKey(channelLabel))
                {
                    this.monitorChannelRelationDic.Remove(channelLabel);
                }

                // 通道字典删除该通道
                this.monitorChannelManager.RemoveChannel(channelLabel);
                logEx.Trace("SyncChannelConfAccessCode remove channel:{0} successfully.", channelLabel);
            }

            logEx.Trace("SyncChannelConfAccessCode [oldConfAccessCode:{0},ConfAccessNo:{1}] successfully.", oldConfAccessCode, confAccessCode);
            return err;
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetAllCameras(Cgw.Common.PlatformType platformType, Common.PageParam pageParam, out List<Cgw.Common.Camera> cameraList, out List<Cgw.Common.CameraGroup> groupList, out List<Cgw.Common.NodeRelation> nodeRelationList, out PagesInfo pageInfo, Cgw.Common.PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetAllCameras");

            cameraList = new List<Cgw.Common.Camera>();
            groupList = new List<Common.CameraGroup>();
            nodeRelationList = new List<Common.NodeRelation>();
            pageInfo = new PagesInfo();

            CgwMonitorManageServiceReference.Camera[] cameraListTemp = null;
            CgwMonitorManageServiceReference.CameraGroup[] groupListTemp = null;
            CgwMonitorManageServiceReference.NodeRelation[] nodeRelationListTemp = null;
            CgwMonitorManageServiceReference.PageInfo pagesInfoTemp = null;

            CgwMonitorManageServiceReference.PlatformLicenseInfo info = new CgwMonitorManageServiceReference.PlatformLicenseInfo();
            if (licenseInfo != null)
            {
                info.IsEltePlatform = licenseInfo.IsEltePlatform;
                info.IsMonitorPlatform = licenseInfo.IsMonitorPlatform;
            }

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.PlatformType platformTypeTemp = (CgwMonitorManageServiceReference.PlatformType)platformType;
                    CgwMonitorManageServiceReference.PagesParam pageParamTemp = new CgwMonitorManageServiceReference.PagesParam();
                    pageParamTemp.CurrentPage = pageParam.CurrentPage;
                    pageParamTemp.NumberPerPage = pageParam.NumberPerPage;

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp, out pagesInfoTemp, platformTypeTemp, pageParamTemp, info);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetAllCameras failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        if (pagesInfoTemp != null)
                        {
                            pageInfo.CurrentPage = pagesInfoTemp.CurrentPage;
                            pageInfo.TotalPages = pagesInfoTemp.TotalPages;
                            pageInfo.TotalRecords = pagesInfoTemp.TotalRecords;
                        }

                        if (cameraListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.Camera ca in cameraListTemp)
                            {
                                Common.Camera temp = new Common.Camera(ca.No, ca.Name, (Common.CameraStatus)ca.Status);
                                cameraList.Add(temp);
                            }
                        }

                        if (groupListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.CameraGroup cg in groupListTemp)
                            {
                                Common.CameraGroup temp = new Common.CameraGroup(cg.No, cg.Name);
                                groupList.Add(temp);
                            }
                        }

                        if (nodeRelationList != null && nodeRelationListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.NodeRelation no in nodeRelationListTemp)
                            {
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, new List<String>(no.Path), (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        //增加顶层分组
                        if (string.IsNullOrEmpty(monitorPlatformCameraGroupName))
                        {
                            monitorPlatformCameraGroupName = "MonitorPlatform";
                        }
                        if (string.IsNullOrEmpty(eLTEPlatformCameraGroupName))
                        {
                            eLTEPlatformCameraGroupName = "eLTEPlatform";
                        }

                        //查询第一页数据时增加顶层分组信息
                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if(licenseInfo!=null)
                            {
                                groupList.Add(new Common.CameraGroup(eLTEPlatformCameraGroupName, eLTEPlatformCameraGroupName));
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if(licenseInfo!=null)
                            {
                                groupList.Add(new Common.CameraGroup(monitorPlatformCameraGroupName, monitorPlatformCameraGroupName));
                            }
                        }

                        if (nodeRelationList.Count > 0)
                        {
                            List<Common.NodeRelation> nodeRelationTemp = new List<Common.NodeRelation>(nodeRelationList);
                            nodeRelationList.Clear();

                            foreach (Common.NodeRelation no in nodeRelationTemp)
                            {
                                List<String> path = new List<String>(no.Path);
                                if (path.Count > 1)
                                {
                                    //按照从底到顶排序
                                    path.Reverse();
                                }
                                if (no.No.IndexOf("eLTE") > -1)
                                {
                                    path.Add(eLTEPlatformCameraGroupName);
                                }
                                else
                                {
                                    path.Add(monitorPlatformCameraGroupName);
                                }

                                if (path.Count > 1)
                                {
                                    //按照从顶到底排序
                                    path.Reverse();
                                }
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, path, (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }

                        }

                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if(licenseInfo!=null)
                            {
                                Common.NodeRelation tempELTE = new Common.NodeRelation(eLTEPlatformCameraGroupName, new List<String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempELTE);
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if(licenseInfo !=null)
                            {
                                Common.NodeRelation tempMonitor = new Common.NodeRelation(monitorPlatformCameraGroupName, new List<String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempMonitor);
                            }
                        }
                    }
                }
                else
                {
                    err.ErrNo = Cgw.SmcError.CgwError.GET_ALL_CAMERAS_FAILED;
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetAllCameras failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus">返回值,刷新状态</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetRefreshStatus(out SmcError.SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetRefreshStatus");

            refreshStatus = new Cgw.SmcError.SmcErr();
            refreshStatus.ErrNo = Cgw.SmcError.CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.SmcErr i_refreshStatus = new CgwMonitorManageServiceReference.SmcErr();

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetRefreshStatus(out i_refreshStatus);
                    client.Close();

                    refreshStatus.ErrNo = i_refreshStatus.ErrNo;
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetRefreshStatus failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        logEx.Info("CgwMonitorManageAdapter.GetRefreshStatus Success. ");
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetRefreshStatus failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 12
0
        /// <summary>
        /// 预览摄像头视频,使用命名管道方式接收数据
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="pipeName"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StartReceiveVideoByPipe(string cameraNo, out string pipeName)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StartReceiveVideoByPipe");
            pipeName = "";
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StartReceiveVideoByPipe(out pipeName, cameraNo);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        //将摄像头通道删除。避免重启服务后,VideoPipe未清除,导致调用停止播放。by zWX231378 2015/7/16
                        VideoPipe delVideoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                        if (delVideoPipe != null)
                        {
                            logEx.Info("CgwMonitorManageAdapter.StartReceiveVideoByPipe delete VideoPipe. cameraNo = {0}", cameraNo);
                            delVideoPipe.Stop();
                        }

                        VideoPipe videoPipe = VideoPipeManage.Instance().AddVideoPipe(cameraNo, pipeName);
                        if (videoPipe != null)
                        {
                            try
                            {
                                videoPipe.Run();
                                if (videoPipe.HaveConnect)
                                {
                                    videoPipe.ReadData(this.dataCallBack);

                                    logEx.Info("CgwMonitorManageAdapter.StartReceiveVideoByPipe Success. pipeName = {0} ", pipeName);
                                }
                                else
                                {
                                    logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. cameraNo = {0} ", cameraNo);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe Exception= {0} ", ex.ToString());
                            }
                        }
                        else
                        {
                            logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. cameraNo = {0} ", cameraNo);
                        }
                    }
                }
                else
                {
                    //当监控服务未启动,则关闭管道。
                    //StopReceiveVideoByPipe(cameraNo);
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StartReceiveVideoByPipe failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 保持连接
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr KeepAliver()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.KeepAliver");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                client = new MonitorManageServiceClient();
                CgwMonitorManageServiceReference.SmcErr serviceErr = client.KeepAliver(sessionID);
                client.Close();
                if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                {
                    logEx.Error("CgwMonitorManageAdapter.KeepAliver failed. ErrNo = {0} ", serviceErr.ErrNo);
                    err = SetCgwErrNo(serviceErr);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.KeepAliver failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 14
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.RefreshMonitorCamera");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.RefreshMonitorCamera();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.RefreshMonitorCamera failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.RefreshMonitorCamera failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetAllCameras(Cgw.Common.PlatformType platformType, Common.PageParam pageParam, out List <Cgw.Common.Camera> cameraList, out List <Cgw.Common.CameraGroup> groupList, out List <Cgw.Common.NodeRelation> nodeRelationList, out PagesInfo pageInfo, Cgw.Common.PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetAllCameras");

            cameraList       = new List <Cgw.Common.Camera>();
            groupList        = new List <Common.CameraGroup>();
            nodeRelationList = new List <Common.NodeRelation>();
            pageInfo         = new PagesInfo();

            CgwMonitorManageServiceReference.Camera[]       cameraListTemp       = null;
            CgwMonitorManageServiceReference.CameraGroup[]  groupListTemp        = null;
            CgwMonitorManageServiceReference.NodeRelation[] nodeRelationListTemp = null;
            CgwMonitorManageServiceReference.PageInfo       pagesInfoTemp        = null;

            CgwMonitorManageServiceReference.PlatformLicenseInfo info = new CgwMonitorManageServiceReference.PlatformLicenseInfo();
            if (licenseInfo != null)
            {
                info.IsEltePlatform    = licenseInfo.IsEltePlatform;
                info.IsMonitorPlatform = licenseInfo.IsMonitorPlatform;
            }

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.PlatformType platformTypeTemp = (CgwMonitorManageServiceReference.PlatformType)platformType;
                    CgwMonitorManageServiceReference.PagesParam   pageParamTemp    = new CgwMonitorManageServiceReference.PagesParam();
                    pageParamTemp.CurrentPage   = pageParam.CurrentPage;
                    pageParamTemp.NumberPerPage = pageParam.NumberPerPage;

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp, out pagesInfoTemp, platformTypeTemp, pageParamTemp, info);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetAllCameras failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        if (pagesInfoTemp != null)
                        {
                            pageInfo.CurrentPage  = pagesInfoTemp.CurrentPage;
                            pageInfo.TotalPages   = pagesInfoTemp.TotalPages;
                            pageInfo.TotalRecords = pagesInfoTemp.TotalRecords;
                        }

                        if (cameraListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.Camera ca in cameraListTemp)
                            {
                                Common.Camera temp = new Common.Camera(ca.No, ca.Name, (Common.CameraStatus)ca.Status);
                                cameraList.Add(temp);
                            }
                        }

                        if (groupListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.CameraGroup cg in groupListTemp)
                            {
                                Common.CameraGroup temp = new Common.CameraGroup(cg.No, cg.Name);
                                groupList.Add(temp);
                            }
                        }

                        if (nodeRelationList != null && nodeRelationListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.NodeRelation no in nodeRelationListTemp)
                            {
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, new List <String>(no.Path), (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        //增加顶层分组
                        if (string.IsNullOrEmpty(monitorPlatformCameraGroupName))
                        {
                            monitorPlatformCameraGroupName = "MonitorPlatform";
                        }
                        if (string.IsNullOrEmpty(eLTEPlatformCameraGroupName))
                        {
                            eLTEPlatformCameraGroupName = "eLTEPlatform";
                        }

                        //查询第一页数据时增加顶层分组信息
                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(eLTEPlatformCameraGroupName, eLTEPlatformCameraGroupName));
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(monitorPlatformCameraGroupName, monitorPlatformCameraGroupName));
                            }
                        }

                        if (nodeRelationList.Count > 0)
                        {
                            List <Common.NodeRelation> nodeRelationTemp = new List <Common.NodeRelation>(nodeRelationList);
                            nodeRelationList.Clear();

                            foreach (Common.NodeRelation no in nodeRelationTemp)
                            {
                                List <String> path = new List <String>(no.Path);
                                if (path.Count > 1)
                                {
                                    //按照从底到顶排序
                                    path.Reverse();
                                }
                                if (no.No.IndexOf("eLTE") > -1)
                                {
                                    path.Add(eLTEPlatformCameraGroupName);
                                }
                                else
                                {
                                    path.Add(monitorPlatformCameraGroupName);
                                }

                                if (path.Count > 1)
                                {
                                    //按照从顶到底排序
                                    path.Reverse();
                                }
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, path, (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempELTE = new Common.NodeRelation(eLTEPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempELTE);
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempMonitor = new Common.NodeRelation(monitorPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempMonitor);
                            }
                        }
                    }
                }
                else
                {
                    err.ErrNo = Cgw.SmcError.CgwError.GET_ALL_CAMERAS_FAILED;
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetAllCameras failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 设置扬声器
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="isOn"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr SetSpeaker(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.SetSpeaker");

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.SetSpeaker(cameraNo, isOn);
                    client.Close();
                    if (serviceErr.ErrNo == Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Info("Cgw SetSpeaker  Successful,Current Cgw IP is : {0}", CgwConst.CGWSERVICE_IP_TAG);
                    }
                    else
                    {
                        logEx.Error("Cgw SetSpeaker failed,ErrNo :{0}", err.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.SetSpeaker failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 17
0
        /// <summary>
        /// 断开监控平台管理服务
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Disconnect()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.Disconnect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //判断Monitor服务是否在线,在线调用DisConnect方法
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Disconnect();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Disconnect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else //不在线,无需调用DisConnect方法
                {
                    logEx.Info("CgwMonitorManageAdapter.Disconnect,MonitorManage Stopped");
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Disconnect failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 18
0
        /// <summary>
        /// 停止预览摄像头视频,并清理命名管道
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StopReceiveVideoByPipe(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StopReceiveVideoByPipe");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StopReceiveVideoByPipe(cameraNo);
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.StopReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        VideoPipe videoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                        if (videoPipe != null)
                        {
                            videoPipe.Stop();
                            logEx.Info("CgwMonitorManageAdapter.StopReceiveVideoByPipe Success. cameraNo = {0} ", cameraNo);
                        }
                        else
                        {
                            logEx.Error("CgwMonitorManageAdapter.StopReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        }
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StopReceiveVideoByPipe failed. Exception is {0} ", ex.ToString());
                logEx.Error("CameraNo:" + cameraNo);
            }
            return err;
        }
Exemplo n.º 19
0
        /// <summary>
        /// 关闭PTZ操作
        /// </summary>
        /// <param name="Camerano">摄像头</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StopControlPtz(string cameraNo, Common.PtzCommandType ptzCommandType)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StopControlPtz");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.PtzCommandType ptzCommand = (CgwMonitorManageServiceReference.PtzCommandType)ptzCommandType;  //将平台的枚举转换成服务中的枚举

                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StopControlPtz(cameraNo, ptzCommand);
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("Stop control ptz failed.Camera no:{0},ptzCommandType:{1},Error Code:{2} ", cameraNo, ptzCommand, err.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        logEx.Info("Stop control ptz success.Camera no:{0},ptzCommandType:{1}.", cameraNo, ptzCommand);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StopControlPtz failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 20
0
        /// <summary>
        /// 预览摄像头视频,使用命名管道方式接收数据
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="pipeName"></param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr StartReceiveVideoByPipe(string cameraNo, out string pipeName)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.StartReceiveVideoByPipe");
            pipeName = "";
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.StartReceiveVideoByPipe(out pipeName, cameraNo);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        //将摄像头通道删除。避免重启服务后,VideoPipe未清除,导致调用停止播放。by zWX231378 2015/7/16
                        VideoPipe delVideoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                        if (delVideoPipe != null)
                        {
                            logEx.Info("CgwMonitorManageAdapter.StartReceiveVideoByPipe delete VideoPipe. cameraNo = {0}", cameraNo);
                            delVideoPipe.Stop();
                        }

                        VideoPipe videoPipe = VideoPipeManage.Instance().AddVideoPipe(cameraNo, pipeName);
                        if (videoPipe != null)
                        {
                            try
                            {
                                videoPipe.Run();
                                if (videoPipe.HaveConnect)
                                {
                                    videoPipe.ReadData(this.dataCallBack);

                                    logEx.Info("CgwMonitorManageAdapter.StartReceiveVideoByPipe Success. pipeName = {0} ", pipeName);
                                }
                                else
                                {
                                    logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. cameraNo = {0} ", cameraNo);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe Exception= {0} ", ex.ToString());
                            }
                        }
                        else
                        {
                            logEx.Error("CgwMonitorManageAdapter.StartReceiveVideoByPipe failed. cameraNo = {0} ", cameraNo);
                        }
                    }
                }
                else
                {
                    //当监控服务未启动,则关闭管道。
                    //StopReceiveVideoByPipe(cameraNo);
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.StartReceiveVideoByPipe failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }
Exemplo n.º 21
0
        /// <summary>
        /// 设置摄像头音频状态
        /// </summary>
        /// <param name="channelLabel"></param>
        /// <param name="cameraNo"></param>
        /// <param name="isOn"></param>
        /// <returns></returns>
        public SmcErr SetMic(string channelLabel, string cameraNo, bool isOn)
        {
            SmcErr err = new SmcErr();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("SetMic start.");

            try
            {
                bool successed = this.monitorChannelRelationDicLocker.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME);
                // 申请互斥
                if (successed)
                {
                    try
                    {
                        err = this.SetCameraAudio(channelLabel, cameraNo, isOn);
                        if (!err.IsSuccess())
                        {
                            logEx.Error("SetMic channelLabel={0}, cameraNo={1},isOn={2} failed.", channelLabel, cameraNo, isOn);
                            return err;
                        }
                    }
                    finally
                    {
                        // 释放互斥量
                        this.monitorChannelRelationDicLocker.ExitWriteLock();
                    }
                }
                else
                {
                    // 日志
                    logEx.Error("SetMic: Enert Write Lock Failed.WaitingReadCount:{0};WaitingWriteCount:{1}.", this.monitorChannelRelationDicLocker.WaitingReadCount, this.monitorChannelRelationDicLocker.WaitingWriteCount);
                    err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_GET_LOCK_FAIL);
                }
            }
            catch (Exception ex)
            {
                // 日志
                logEx.Error(ex, "SetMic: Enert Write Lock Exception.");
                err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_SERVICE_ADNORMAL);
            }

            logEx.Info("SetMic SetMic={0}, cameraNo={1},isOn={2} successfully.", channelLabel, cameraNo, isOn);
            return err;
        }
Exemplo n.º 22
0
        /// <summary>
        /// 连接监控平台管理服务
        /// </summary>
        /// <param name="monitorPwd">加密后的密码字符串</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Connect(string monitorPwd)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: CgwMonitorManageAdapter.Connect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                if (serviceControl.MonitorServiceRun())
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect Opened");
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Connect(out monitorPwd);

                    sessionID = monitorPwd;
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Connect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect MonitorServiceStart");
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                    serviceControl.MonitorServiceStart();//自动重连监控服务

                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Connect failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }