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); }