/// <summary> /// 适用于场景轮巡 /// </summary> /// <param name="roundScene">null 引发ArgumentNullException异常</param> public VideoRoundTask(VideoRoundSceneView roundScene) { if (roundScene == null) { throw new ArgumentNullException("参数roundScene未设置为对象引用实例"); } this.m_videoRoundScene = roundScene; }
public VideoRoundSceneView GetVideoRoundSceneViewById(Guid videoRoundSceneId) { using (var db = new AllInOneContext.AllInOneContext()) { VideoRoundSceneView sceneView = null; //先获取轮巡场景 var scene = db.VideoRoundScene.Include(t => t.VideoRoundSections).ThenInclude(t => t.TemplateLayout).ThenInclude(t => t.Cells). Include(t => t.VideoRoundSections).ThenInclude(t => t.RoundMonitorySiteSettings).ThenInclude(t => t.MonitorySite).ThenInclude(t => t.Camera). FirstOrDefault(t => t.VideoRoundSceneId.Equals(videoRoundSceneId)); //获取摄像机信息 var cameras = GetAllCameraView(db); //按照场景视图定义封装数据 List <VideoRoundSectionView> sectionViews = new List <VideoRoundSectionView>(); scene.VideoRoundSections.ForEach(f => { //场景片段的摄像机 var sectionCams = (from ms in (f.RoundMonitorySiteSettings ?? new List <VideoRoundMonitorySiteSetting>()) join cam in cameras on ms.MonitorySite.CameraId equals cam.CameraId select new { PlayInfo = new RealPlayParam() { CameraView = cam, StreamType = (VideoStream)ms.VideoStream, }, MonitorView = new MonitorView() { Monitor = ms.Monitor, SubView = ms.SubView } }).ToList(); //select cam).ToList(); sectionViews.Add(new VideoRoundSectionView() { PlayInfoList = sectionCams.Select(a => a.PlayInfo).ToList(), Monitors = sectionCams.Select(a => a.MonitorView).ToList(), RoundInterval = f.RoundInterval, TemplateLayout = f.TemplateLayout }); }); sceneView = new VideoRoundSceneView() { VideoRoundSceneName = scene.VideoRoundSceneName, VideoRoundSections = sectionViews }; return(sceneView); } }
/// <summary> /// 适用于普通视频轮巡 /// </summary> /// <param name="cameras">轮巡监控点</param> /// <param name="template">视频模板</param> /// <param name="roundInterval">轮巡间隔</param> public VideoRoundTask(IEnumerable <CameraView> cameras, TemplateLayout template, int roundInterval) { if (cameras == null) { throw new ArgumentNullException("参数monitorysites未设置为对象引用实例"); } if (cameras.Count() == 0) { throw new Exception("参数monitorysitesl元素数量不能少于0"); } if (template == null) { throw new ArgumentNullException("参数template未设置为对象引用实例"); } if (roundInterval < 0) { throw new Exception("参数roundInterval不能少于0"); } int stepLength = template.Cells.Count(); int monitorysiteCount = cameras.Count(); int sectionCount = monitorysiteCount % stepLength == 0 ? monitorysiteCount / stepLength : monitorysiteCount / stepLength + 1; m_videoRoundScene = new VideoRoundSceneView(); m_videoRoundScene.VideoRoundSections = new List <VideoRoundSectionView>(); for (int i = 0; i < sectionCount; ++i) { VideoRoundSectionView section = new VideoRoundSectionView(); section.RoundInterval = roundInterval; section.TemplateLayout = template; List <RealPlayParam> playInfoList = new List <RealPlayParam>(); cameras.Skip(i * stepLength).Take(stepLength).ToList().ForEach(t => { playInfoList.Add(new RealPlayParam() { CameraView = t }); }); section.PlayInfoList = playInfoList; m_videoRoundScene.VideoRoundSections.Add(section); } }
public override void Execute() { try { //视频上墙参数整理 _logger.LogInformation("执行视频上墙动作 Begin...."); if (m_actionArgumentList != null && m_actionArgumentList.Count > 0) { //获取上墙场景数据 var videoRoundSceneId = m_actionArgumentList.FirstOrDefault().VideoRoundSceneId; string url = string.Format("{0}/Resources/VideoRoundScene/View/videoRoundSceneId={1}", GlobalSetting.AppServerBaseUrl, videoRoundSceneId); VideoRoundSceneView sceneView = HttpClientHelper.GetOne <VideoRoundSceneView>(url); if (sceneView != null) { Resources.Model.ServiceInfo dvm = TaskUtility.GetDefaultDMCService(); if (dvm != null) { m_TvActionApi = new TvActionApi(dvm); VideoRoundTask = new VideoRoundTask(sceneView); VideoRoundTask.ExecuteRoundAction += ExecuteRoundActionInvoke; //判断是否为报警预案 bool executed = false; if (PlanTrigger != null) { RemoveBeforePlanAction(); _logger.LogInformation("报警联动预案,优先响应!"); executed = true; } else //普通预案启动 { //判断是否有报警预案启动,有则不启动 var alarmTvAction = s_cacheTvAction.FirstOrDefault(t => t.PlanTrigger != null && t.VideoRoundTask != null && t.VideoRoundTask.RoundStatus == RoundStatus.Running); if (alarmTvAction != null) { _logger.LogInformation("当前有报警预案正在联动执行,将上墙动作执行缓存到列表"); } else { executed = true; } } //暂停所有其他视频上墙 if (executed) { s_cacheTvAction.ForEach(t => { if (t.VideoRoundTask != null && t.VideoRoundTask.RoundStatus == RoundStatus.Running) { t.VideoRoundTask.Pause(); } }); _logger.LogInformation("满足条件,执行视频上墙动作"); VideoRoundTask.Start(); } s_cacheTvAction.Add(this); } else { _logger.LogInformation("没有配置矩阵服务器,取消视频上墙动作"); } } else { _logger.LogInformation("没有找到预案场景!!!"); } } _logger.LogInformation("执行视频上墙动作 End...."); } catch (Exception ex) { _logger.LogError("执行实时视频预览异常:Message:{0}\r\nStackTrace:{1}", ex.Message, ex.StackTrace); } }