/// <summary> /// /// </summary> /// <param name="manualControl">动作触发</param> public void Next(bool manualControl = false) { ////section that is going to stop //if (m_RoundSectionIndex >= 0) // m_LastRoundSection = m_videoRoundScene.VideoRoundSections.ElementAt(m_RoundSectionIndex); if (manualControl && m_videoRoundScene.VideoRoundSections.Count > 1) { m_WaitTokenSource.Cancel(); //中断,进入下一片段 return; } //section that is going to run m_RoundSectionIndex++; if (m_RoundSectionIndex == m_videoRoundScene.VideoRoundSections.Count()) { m_RoundSectionIndex = 0; } m_CurrentRoundSection = m_videoRoundScene.VideoRoundSections.ElementAt(m_RoundSectionIndex); Console.WriteLine("{0:HH:mm:ss}--do next,Current section index:{1}", DateTime.Now, m_RoundSectionIndex); if (ExecuteRoundAction != null) { ExecuteRoundAction(m_CurrentRoundSection); } }
/// <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); } }
/// <summary> /// 轮巡动作执行 /// </summary> /// <param name="section"></param> private void ExecuteRoundActionInvoke(VideoRoundSectionView section) { int cameraIndex = 0; _logger.LogInformation("执行视频上墙轮巡动作"); foreach (var camera in section.PlayInfoList) { TVCameraView tvPlayParam = new TVCameraView() { CameraView = camera.CameraView, MonitorView = section.Monitors[cameraIndex] }; cameraIndex++; try { m_TvActionApi.StartTvVideo(tvPlayParam); } catch (Exception ex) { _logger.LogError("执行上墙预案异常:{0}", ex.InnerException); } } }
/// <summary> /// 是否人工触发 /// </summary> /// <param name="manualControl"></param> public void Previous(bool manualControl = false) { //if (m_RoundSectionIndex >= 0) // m_LastRoundSection = m_videoRoundScene.VideoRoundSections.ElementAt(m_RoundSectionIndex); if (manualControl && m_videoRoundScene.VideoRoundSections.Count > 1) { GoToNext = false; m_WaitTokenSource.Cancel(); return; } m_RoundSectionIndex--; if (m_RoundSectionIndex < 0) { m_RoundSectionIndex = m_videoRoundScene.VideoRoundSections.Count() - 1; } Console.WriteLine("{0:HH:mm:ss}--do previous, Current section index:{1}", DateTime.Now, m_RoundSectionIndex); m_CurrentRoundSection = m_videoRoundScene.VideoRoundSections.ElementAt(m_RoundSectionIndex); if (ExecuteRoundAction != null) { ExecuteRoundAction(m_CurrentRoundSection); } }