protected override bool ExecuteAction(object source, IActionParam param) { //System.Console.Out.WriteLine("CPTZAction.ExecuteAction: Action=" + Config.Desc); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}[{1}]).ExecuteAction", Config.Desc, Name)); IVisionAlarm alarm = source as IVisionAlarm; if (alarm != null) { //System.Console.Out.WriteLine("CPTZAction.ExecuteAction: Sender=" + alarm.Sender + ", AlarmID=" + alarm.ID); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).ExecuteAction: Sender={1}, AlarmID={2}, ActionParam={3}", Name, alarm.Sender, alarm.ID, param.Name)); //alarm.OnTransactAlarm += new TransactAlarm(DoTransactAlarm); if (System.Threading.Monitor.TryEnter(mPTZLockObj)) { try { IVisionMonitorConfig vmc = alarm.Monitor.Config as IVisionMonitorConfig; if (vmc != null) { IConfigManager <IVideoSourceConfig> vsConfigManager = vmc.SystemContext.VideoSourceConfigManager; if (vsConfigManager != null) { CVideoSourceConfig vcConfig = vsConfigManager.GetConfig(vmc.VisionParamConfig.VSName) as CVideoSourceConfig; if (vcConfig != null) { string vsName = vcConfig.StrValue("PTZVSName"); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).ExecuteAction: PTZVSName={1}", Config.Desc, vsName)); if (!vsName.Equals("")) { IVideoSourceConfig ptzvsConfig = vsConfigManager.GetConfig(vsName); if (ptzvsConfig != null) { return(StartPTZ(ptzvsConfig, alarm.AreaIndex)); } } } } } } finally { System.Threading.Monitor.Exit(mPTZLockObj); } } } return(false); }
private bool StartPlay(IVisionAlarm alarm) { if (alarm == null) { return(false); } lock (mCountObj) { mPlayRefCount++; if (mPlayRefCount <= 1) { return(SoundPlay(alarm)); } } return(true); }
private bool SoundPlay(IVisionAlarm alarm) { if (!IsActive) { return(false); } lock (mSoundObj) { ISoundActionConfig config = Config as ISoundActionConfig; if (alarm == null || config == null || config.IsMute) { return(false); //静音 } if (alarm.EventType == TVisionEventType.Perimeter) { if (alarm.GuardLevel == TGuardLevel.Red) { if (PlayState != SoundPlayState.ALARMPLAYING)//当前未发报警音 { if (PlayState != SoundPlayState.NOSOUND) { mSoundPlayer.Stop(); } try { mSoundPlayer.SoundLocation = config.AlarmSoundFile; mSoundPlayer.LoadAsync(); if (!IsMute) { mSoundPlayer.PlayLooping(); } PlayState = SoundPlayState.ALARMPLAYING; return(true); } catch { System.Console.Out.Write("找不到报警声音文件"); } } else { return(true); } } else if (alarm.GuardLevel == TGuardLevel.Prompt) { if (PlayState != SoundPlayState.PORMATPLAYING)//当前未发提示音 { if (PlayState != SoundPlayState.NOSOUND) { mSoundPlayer.Stop(); } try { mSoundPlayer.SoundLocation = config.PormatSoundFile; mSoundPlayer.LoadAsync(); if (!IsMute) { mSoundPlayer.Play();//仅一次 } //mSoundPlayer.PlayLooping(); PlayState = SoundPlayState.NOSOUND; return(true); } catch { System.Console.Out.Write("找不到提示声音文件"); } } else { return(true); } } } else if (alarm.EventType == TVisionEventType.Leave || alarm.EventType == TVisionEventType.Remove) { if (PlayState != SoundPlayState.ALARMPLAYING)//当前未发报警音 { if (PlayState != SoundPlayState.NOSOUND) { mSoundPlayer.Stop(); } try { mSoundPlayer.SoundLocation = config.AlarmSoundFile; mSoundPlayer.LoadAsync(); if (!IsMute) { mSoundPlayer.PlayLooping(); } PlayState = SoundPlayState.ALARMPLAYING; return(true); } catch { System.Console.Out.Write("找不到报警声音文件"); } } else { return(true); } } else if (alarm.EventType == TVisionEventType.CameraUnusual) { if (PlayState != SoundPlayState.CAMABOUT)//当前未发报警音 { if (PlayState != SoundPlayState.NOSOUND) { mSoundPlayer.Stop(); } try { mSoundPlayer.SoundLocation = config.CamaboutSoundFile; mSoundPlayer.LoadAsync(); if (!IsMute) { mSoundPlayer.PlayLooping(); } PlayState = SoundPlayState.CAMABOUT; return(true); } catch { System.Console.Out.Write("找不到镜头异常声音文件"); } } else { return(true); } } PlayState = SoundPlayState.NOSOUND; return(false); } }
protected override bool ExecuteAction(object source, IActionParam param) { IVisionAlarm alarm = source as IVisionAlarm; if (alarm != null) { //CLocalSystem.WriteDebugLog(string.Format("{0} CHKPTZAction({1}).ExecuteAction: Sender={2}, AlarmID={3}, ActionParam={4}", Config.Desc, Name, alarm.Sender, alarm.ID, param.Name)); try { IConfigManager <IVideoSourceConfig> vsConfigManager = null; string vsName = param.StrValue("VSName"); if (vsName.Equals("")) { vsName = PTZConfig.VSName; if (vsName.Equals("")) { IVisionMonitorConfig vmc = alarm.Monitor.Config as IVisionMonitorConfig; if (vmc != null) { vsConfigManager = vmc.SystemContext.VideoSourceConfigManager; if (vsConfigManager != null) { CVideoSourceConfig vcConfig = vsConfigManager.GetConfig(vmc.VisionParamConfig.VSName) as CVideoSourceConfig; if (vcConfig != null) { vsName = vcConfig.StrValue("PTZVSName"); } if (vsName.Equals("")) { CLocalSystem.WriteWarnLog(string.Format("{0} CHKPTZAction({1}).ExecuteAction Failed: {2}({3})未设置属性\"PTZVSName\"", Config.Desc, Name, vcConfig.Desc, vcConfig.Name)); return(false); } } } } } if (!vsName.Equals("")) { if (vsConfigManager == null) { vsConfigManager = Config.SystemContext.VideoSourceConfigManager; } IVideoSourceConfig ptzvsConfig = vsConfigManager.GetConfig(vsName); if (ptzvsConfig != null) { CLocalSystem.WriteDebugLog(string.Format("{0} CHKPTZAction({1}).ExecuteAction: PTZVSName={2}", Config.Desc, Name, vsName)); return(StartPTZ(ptzvsConfig, alarm.AreaIndex)); } else { CLocalSystem.WriteWarnLog(string.Format("{0} CHKPTZAction({1}).ExecuteAction Failed: PTZVSName({2})所指向的视频源不存在!", Config.Desc, Name, vsName)); } } else { CLocalSystem.WriteWarnLog(string.Format("{0} CHKPTZAction({1}).ExecuteAction Failed: 未设置PTZ视频源!", Config.Desc, Name)); } } catch (Exception e) { CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).ExecuteAction Exception: {1}", Config.Desc, e)); } } return(false); }