Esempio n. 1
0
        protected override bool InitMonitor()
        {
            IVisionMonitorConfig vmConfig = VisionMonitorConfig;

            if (vmConfig != null)
            {
                string       vsName = vmConfig.Watcher.ActiveVSName;
                IVideoSource vs     = SystemContext.VideoSourceManager.GetVideoSource(vsName);
                if (vs == null)
                {
                    vs = SystemContext.VideoSourceManager.Open(vsName, IntPtr.Zero);
                }

                if (vs != null)
                {
                    IKernelVideoSource kvs = vs as IKernelVideoSource;
                    kvs.KernelInit();

                    vs.Play();

                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
 public void PlayVideo(IVisionMonitorConfig config)
 {
     if (config != null)
     {
         PlayVideo(config.Watcher.ActiveVisionParamConfig.VSName);
     }
 }
Esempio n. 3
0
        public override string ToXml()
        {
            StringBuilder sb = new StringBuilder("<AlarmInfo>");

            try
            {
                sb.Append("<SystemContext>" + SystemContext.MonitorSystem.Name + "</SystemContext>");
                sb.Append("<ID>" + ID + "</ID>");
                sb.Append("<Sender>" + Sender + "</Sender>");

                IVisionMonitorConfig config = this.Monitor.Config as IVisionMonitorConfig;
                if (config != null)
                {
                    sb.Append("<VideoSource>" + config.VisionParamConfig.VSName + "</VideoSource>");
                }
                sb.Append("<AlarmType>" + (int)EventType + "</AlarmType>");
                sb.Append("<GuardLevel>" + (int)GuardLevel + "</GuardLevel>");
                sb.Append("<AreaIndex>" + AreaIndex + "</AreaIndex>");
                sb.Append("<AreaType>" + (int)AreaType + "</AreaType>");
                sb.Append("<AlertOpt>" + (int)AlertOpt + "</AlertOpt>");
                sb.Append("<AlarmTime>" + AlarmTime.ToString("yyyy-MM-dd HH:mm:ss") + "</AlarmTime>");
                sb.Append("<TransactTime>" + TransactTime.ToString("yyyy-MM-dd HH:mm:ss") + "</TransactTime>");
                sb.Append("<Transactor>" + Transactor + "</Transactor>");
            }
            finally
            {
                sb.Append("</AlarmInfo>");
            }
            return(sb.ToString());
        }
Esempio n. 4
0
        protected bool InitDialog()
        {
            comboBox_vs.SelectedItem = null;

            if (mConfig != null)
            {
                textBox_desc.Text          = mConfig.Desc;
                comboBox_type.SelectedItem = mConfig.SystemContext.MonitorTypeManager.GetConfig(mConfig.Type);
                textBox_ip.Text            = mConfig.Host;
                numericUpDown_port.Value   = mConfig.Port;
                checkBox_enabled.Checked   = mConfig.Enabled;

                mVisionConfig = mConfig as IVisionMonitorConfig;
                if (mVisionConfig != null)
                {
                    comboBox_vs.SelectedItem = mConfig.SystemContext.VideoSourceConfigManager.GetConfig(mVisionConfig.VisionParamConfig.VSName);
                }

                mVisionUserConfig = mConfig as IVisionUserConfig;
                if (mVisionUserConfig != null)
                {
                    checkBox_processMode.Checked = mVisionUserConfig.VisionUserParamConfig.ProcessMode == 0;
                }

                mBlobTrackerConfig = mConfig as IBlobTrackerConfig;
                if (mBlobTrackerConfig != null)
                {
                }
                comboBox_type.Enabled = false;
            }
            else
            {
                textBox_desc.Text          = mType != null ? "新" + mType.Desc : "监控应用";
                comboBox_type.SelectedItem = mType != null?mType.SystemContext.MonitorTypeManager.GetConfig(mType.Name) : null;

                textBox_ip.Text          = "";
                numericUpDown_port.Value = 3800;
                checkBox_enabled.Checked = true;

                comboBox_type.Enabled = mType == null;
            }

            alertAreaConfigCtrl_alertArea.VSConfig = comboBox_vs.SelectedItem as IVideoSourceConfig;

            IBlobTrackerConfig btConfig = mConfig as IBlobTrackerConfig;

            if (btConfig != null)
            {
                alertAreaConfigCtrl_alertArea.BlobTrackParamConfig = btConfig.BlobTrackParamConfig;
            }

            monitorActionConfigCtrl_action.ActionParamConfig = mConfig.ActionParamConfig;

            runPlanConfigCtrl_runPlan.RunParamConfig = mConfig.RunParamConfig;

            comboBox_runMode.SelectedIndex = (int)mConfig.RunParamConfig.RunMode;

            return(true);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public IVideoSource GetVideoSource()
        {
            IVisionMonitorConfig config = VisionMonitorConfig;

            if (config != null)
            {
                IVideoSourceConfig vsConfig = SystemContext.GetVideoSourceConfig(config.VisionParamConfig.VSName);
                if (vsConfig != null)
                {
                    return(SystemContext.VideoSourceManager.GetVideoSource(vsConfig.Name));
                }
            }
            return(null);
        }
Esempio n. 7
0
        protected bool SetConfig()
        {
            DoBeforeChanged();

            if (mConfig != null)
            {
                mConfig.Desc = textBox_desc.Text;
                mConfig.Type = CtrlUtil.GetComboBoxText(comboBox_type);

                mConfig.Host = textBox_ip.Text;
                mConfig.Port = (short)numericUpDown_port.Value;
                //mConfig.AutoRun = checkBox_autorun.Checked;
                mConfig.Enabled            = checkBox_enabled.Checked;
                mConfig.AutoSaveAlarmInfo  = true;
                mConfig.AutoSaveAlarmImage = true;

                mVisionConfig = mConfig as IVisionMonitorConfig;
                if (mVisionConfig != null)
                {
                    mVisionConfig.VisionParamConfig.VSName = CtrlUtil.GetComboBoxText(comboBox_vs);
                }

                mVisionUserConfig = mConfig as IVisionUserConfig;
                if (mVisionUserConfig != null)
                {
                    mVisionUserConfig.VisionUserParamConfig.ProcessMode = checkBox_processMode.Checked ? 0 : 1;
                }

                mBlobTrackerConfig = mConfig as IBlobTrackerConfig;
                if (mBlobTrackerConfig != null)
                {
                    mBlobTrackerConfig.BlobTrackParamConfig.ProcessorParams = "0,0,0,1,0,0:100";// textBox_processorParams.Text;
                    alertAreaConfigCtrl_alertArea.ApplyConfig();
                }

                runPlanConfigCtrl_runPlan.ApplyConfig();
                monitorActionConfigCtrl_action.ApplyConfig();

                mConfig.OnChanged(); //yhx 2013-9-30 add;

                if (SetVSConfig())
                {
                    DoAfterChanged();
                    return(true);
                }
            }
            DoAfterChanged();
            return(false);
        }
Esempio n. 8
0
 private void toolStripButton_preview_Click(object sender, EventArgs e)
 {
     if (ActiveBox != null)
     {
         CFuncNode node = ActiveBox.LinkObj as CFuncNode;
         if (node != null)
         {
             IVisionMonitorConfig config = node.ExtConfigObj as IVisionMonitorConfig;
             if (config != null)
             {
                 ActiveBox.Preview();
             }
         }
     }
 }
Esempio n. 9
0
 public override bool PostAlarmEvent(IMonitorAlarm alarm)
 {
     if (alarm != null && base.PostAlarmEvent(alarm))
     {
         IVisionMonitorConfig config = Config as IVisionMonitorConfig;
         if (config != null)
         {
             if (config.VisionParamConfig.AutoSaveAlarmRecord)
             {
                 (alarm as IVisionMonitorAlarm).StartAlarmRecord();
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
 private bool IsVisionMonitor(IMonitorType type)
 {
     if (mSystemContext != null)
     {
         bool value = type.ACEnabled;
         try
         {
             type.ACEnabled = false;
             IMonitorConfig       config       = mSystemContext.MonitorConfigManager.CreateConfigInstance(type);
             IVisionMonitorConfig visionConfig = config as IVisionMonitorConfig;
             return(visionConfig != null);
         }
         finally
         {
             type.ACEnabled = value;
         }
     }
     return(false);
 }
Esempio n. 11
0
        public bool Preview()
        {
            if (mRealPlayVS != null && mRealPlayVS.IsOpen)
            {
                mRealPlayVS.SystemContext.VideoSourceManager.Close(mRealPlayVS.Name);
            }
            else
            {
                CFuncNode node = mLinkObj as CFuncNode;
                if (node != null)
                {
                    IVisionMonitorConfig config = node.ExtConfigObj as IVisionMonitorConfig;
                    if (config != null)
                    {
                        IVideoSourceConfig vsConfig = config.SystemContext.VideoSourceConfigManager.GetConfig(config.VisionParamConfig.VSName);

                        CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig;
                        if (newVSConfig != null)
                        {
                            newVSConfig.Name    = vsConfig.Name + "_RealPlay_" + newVSConfig.Handle;
                            newVSConfig.Enabled = true;

                            if (mRealPlayVS != null)
                            {
                                mRealPlayVS.SystemContext.VideoSourceManager.Close(mRealPlayVS.Name);
                                mRealPlayVS = null;
                            }

                            mRealPlayVS = config.SystemContext.VideoSourceManager.Open(newVSConfig, HWnd);
                            if (mRealPlayVS != null)
                            {
                                mRealPlayVS.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged);
                                return(mRealPlayVS.Play());
                            }
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 12
0
        public bool CleanupVideoSource(IMonitorConfig config)
        {
            IVisionMonitorConfig vmConfig = config as IVisionMonitorConfig;

            if (vmConfig != null)
            {
                StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                sb.Append(vmConfig.VisionParamConfig.VSName + "<VideoSource>");
                sb.Append("Cleanup<Command>");

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
                else
                {
                    return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                }
            }
            return(false);
        }
Esempio n. 13
0
        public bool Init()
        {
            string monitorName = MonitorName;

            if (monitorName != null && !monitorName.Equals(""))
            {
                IMonitorSystemContext context = SystemContext;
                IVisionMonitorConfig  mc      = context.GetMonitorConfig(monitorName) as IVisionMonitorConfig;
                if (mc != null)
                {
                    bool isStopVideo = !(mVS != null && mVS.Name.StartsWith(mc.Watcher.ActiveVisionParamConfig.VSName + "_"));

                    if (Cleanup(isStopVideo))
                    {
                        PlayVideo(mc.Watcher.ActiveVisionParamConfig.VSName);
                        mMonitor = context.MonitorManager.CreateMonitor(mc);
                        if (mMonitor != null)
                        {
                            mMonitor.OnMonitorStateChanged -= new MonitorStateChanged(DoMonitorStateChanged);
                            mMonitor.OnMonitorStateChanged += new MonitorStateChanged(DoMonitorStateChanged);

                            mMonitor.OnMonitorAlarm -= new MonitorAlarmEvent(DoMonitorAlarm);
                            mMonitor.OnMonitorAlarm += new MonitorAlarmEvent(DoMonitorAlarm);

                            mMonitor.OnTransactAlarm -= new TransactAlarm(DoTransactAlarm);
                            mMonitor.OnTransactAlarm += new TransactAlarm(DoTransactAlarm);


                            mMonitor.Config.SetValue("BoxIndex", this.TabIndex);

                            mMonitor.RefreshState();
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 14
0
        protected bool SetConfig()
        {
            if (mConfig != null)
            {
                (mConfig as CConfig).Name = textBox_name.Text;
                mConfig.SetValue("Name", textBox_name.Text);

                mConfig.Desc = textBox_desc.Text;
                mConfig.Type = CtrlUtil.GetComboBoxText(comboBox_type);

                mConfig.Host = textBox_ip.Text;
                mConfig.Port = (short)numericUpDown_port.Value;

                mConfig.Enabled            = checkBox_enabled.Checked;
                mConfig.AutoSaveAlarmInfo  = checkBox_autoSaveAlarmInfo.Checked;
                mConfig.AutoSaveAlarmImage = checkBox_autoSaveAlarmImage.Checked;

                mVisionConfig = mConfig as IVisionMonitorConfig;
                if (mVisionConfig != null)
                {
                    visionParamConfigCtrl_visionParams.ApplyConfig();
                }

                mBlobTrackerConfig = mConfig as IBlobTrackerConfig;
                if (mBlobTrackerConfig != null)
                {
                    alertAreaConfigCtrl_alertArea.ApplyConfig();
                }

                monitorActionConfigCtrl_action.ApplyConfig();
                runPlanConfigCtrl_runPlan.ApplyConfig();

                return(true);
            }
            return(false);
        }
Esempio n. 15
0
        protected bool InitDialog()
        {
            tabControl_monitor.SelectedIndex = 0;

            if (mConfig != null)
            {
                textBox_name.Text                   = mConfig.Name;
                textBox_desc.Text                   = mConfig.Desc;
                comboBox_type.SelectedItem          = mConfig.SystemContext.MonitorTypeManager.GetConfig(mConfig.Type);
                textBox_ip.Text                     = mConfig.Host;
                numericUpDown_port.Value            = mConfig.Port;
                checkBox_enabled.Checked            = mConfig.Enabled;
                checkBox_autoSaveAlarmInfo.Checked  = mConfig.AutoSaveAlarmInfo;
                checkBox_autoSaveAlarmImage.Checked = mConfig.AutoSaveAlarmImage;

                comboBox_type.Enabled = false;

                textBox_name.Enabled = false;
            }
            else
            {
                textBox_name.Text          = mType != null ? mType.Name + "_" : "Monitor_";
                textBox_desc.Text          = mType != null ? "新" + mType.Desc : "监控应用";
                comboBox_type.SelectedItem = mType != null?mType.SystemContext.MonitorTypeManager.GetConfig(mType.Name) : null;

                textBox_ip.Text                     = "";
                numericUpDown_port.Value            = 3800;
                checkBox_enabled.Checked            = true;
                checkBox_autoSaveAlarmInfo.Checked  = false;
                checkBox_autoSaveAlarmImage.Checked = false;

                comboBox_type.Enabled = mType == null;

                if (mManager != null && mType != null)
                {
                    mConfig = mManager.CreateConfigInstance(mType);
                }

                textBox_name.Enabled = true;
            }

            if (mConfig != null)
            {
                IVisionMonitorConfig visionMonitorConfig = mConfig as IVisionMonitorConfig;
                if (visionMonitorConfig != null)
                {
                    visionParamConfigCtrl_visionParams.VisionParamConfig = visionMonitorConfig.VisionParamConfig;
                }

                IBlobTrackerConfig blobTrackerConfig = mConfig as IBlobTrackerConfig;
                if (blobTrackerConfig != null)
                {
                    alertAreaConfigCtrl_alertArea.VSConfig             = visionParamConfigCtrl_visionParams.VSConfig;
                    alertAreaConfigCtrl_alertArea.BlobTrackParamConfig = blobTrackerConfig.BlobTrackParamConfig;
                }

                monitorActionConfigCtrl_action.ActionParamConfig = mConfig.ActionParamConfig;

                runPlanConfigCtrl_runPlan.RunParamConfig = mConfig.RunParamConfig;

                comboBox_runMode.SelectedIndex = (int)mConfig.RunParamConfig.RunMode;

                return(true);
            }
            return(false);
        }
Esempio n. 16
0
        public bool InitMonitor(IMonitorConfig config)
        {
            IVisionMonitorConfig vmConfig = config as IVisionMonitorConfig;

            if (vmConfig != null)
            {
                IVideoSourceConfig vsConfig = config.SystemContext.GetVideoSourceConfig(vmConfig.Watcher.ActiveVisionParamConfig.VSName);
                if (vsConfig != null)
                {
                    IVideoSourceType vsType = config.SystemContext.GetVideoSourceType(vsConfig.Type);

                    StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                    sb.Append(vsConfig.Name + "<VideoSource>");
                    sb.Append("Open;Play;InitKernel<Command>");
                    sb.Append(vsType.ToXml() + "<Type>");
                    sb.Append(vsConfig.ToXml() + "<Config><CommandSegment>");

                    IActionConfig  ac;
                    IActionParam[] apList;
                    if (!config.Watcher.ActiveActionParamConfig.LocalAlarmAction)
                    {
                        apList = config.Watcher.ActiveActionParamConfig.GetAlarmActionList();
                        if (apList != null)
                        {
                            foreach (IActionParam pc in apList)
                            {
                                ac = config.SystemContext.ActionConfigManager.GetConfig(pc.Name);
                                if (ac != null)
                                {
                                    IActionType at = config.SystemContext.ActionTypeManager.GetConfig(ac.Type);

                                    if (at != null)
                                    {
                                        sb.Append(ac.Name + "<Action>");
                                        sb.Append("Init;Start<Command>");
                                        sb.Append(at.ToXml() + "<Type>");
                                        sb.Append(ac.ToXml() + "<Config><CommandSegment>");
                                    }
                                }
                            }
                        }
                    }
                    if (!config.Watcher.ActiveActionParamConfig.LocalTransactAction)
                    {
                        apList = config.Watcher.ActiveActionParamConfig.GetTransactActionList();
                        if (apList != null)
                        {
                            foreach (IActionParam pc in apList)
                            {
                                ac = config.SystemContext.ActionConfigManager.GetConfig(pc.Name);
                                if (ac != null)
                                {
                                    IActionType at = config.SystemContext.ActionTypeManager.GetConfig(ac.Type);

                                    if (at != null)
                                    {
                                        sb.Append(ac.Name + "<Action>");
                                        sb.Append("Init;Start<Command>");
                                        sb.Append(at.ToXml() + "<Type>");
                                        sb.Append(ac.ToXml() + "<Config><CommandSegment>");
                                    }
                                }
                            }
                        }
                    }

                    IMonitorType vuType = config.SystemContext.GetMonitorType(config.Type);

                    sb.Append(config.Name + "<Monitor>");
                    sb.Append("Init<Command>");
                    sb.Append(vuType.ToXml() + "<Type>");
                    sb.Append(config.ToXml() + "<Config>");

                    IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                    else
                    {
                        return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                    }
                }
            }
            else
            {
                IMonitorType vuType = config.SystemContext.GetMonitorType(config.Type);

                StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                sb.Append(config.Name + "<Monitor>");
                sb.Append("Init<Command>");
                sb.Append(vuType.ToXml() + "<Type>");
                sb.Append(config.ToXml() + "<Config>");

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
                else
                {
                    return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                }
            }
            return(false);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        public bool Playback()
        {
            if (mBackPlayVS != null && mBackPlayVS.IsOpen)
            {
                mBackPlayVS.SystemContext.VideoSourceManager.Close(mBackPlayVS.Name);
            }
            else if (mCurIndex >= 0 && mCurIndex < Count)
            {
                IVisionMonitorAlarm visionAlarm = Goto(mCurIndex) as IVisionMonitorAlarm;
                if (visionAlarm != null)
                {
                    IVisionMonitor monitor = visionAlarm.Monitor as IVisionMonitor;
                    if (monitor != null)
                    {
                        IVisionMonitorConfig config = monitor.Config as IVisionMonitorConfig;
                        if (config != null)
                        {
                            IVideoSourceConfig vsConfig = monitor.SystemContext.VideoSourceConfigManager.GetConfig(config.VisionParamConfig.VSName);
                            if (vsConfig != null)
                            {
                                if (!vsConfig.IsRecord)
                                {
                                    IVideoSourceType vsType = vsConfig.SystemContext.VideoSourceTypeManager.GetConfig(vsConfig.Type);
                                    if (vsType != null)
                                    {
                                        string backPlayType = vsType.BackPlayType;

                                        if (backPlayType.Equals(""))
                                        {
                                            backPlayType = vsConfig.Type;
                                        }

                                        if (!backPlayType.Equals(""))
                                        {
                                            CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig;
                                            if (newVSConfig != null)
                                            {
                                                newVSConfig.Name      = vsConfig.Name + "_BackPlay_" + newVSConfig.Handle;
                                                newVSConfig.Type      = backPlayType;
                                                newVSConfig.StartTime = visionAlarm.AlarmTime.AddSeconds(-10);
                                                newVSConfig.StopTime  = visionAlarm.AlarmTime;

                                                if (!backPlayType.Equals("FileVideoSource"))
                                                {
                                                    newVSConfig.FileName = "";
                                                }

                                                newVSConfig.IsRecord = false;
                                                newVSConfig.IsCycle  = false;
                                                newVSConfig.Enabled  = true;

                                                if (mBackPlayVS != null)
                                                {
                                                    mBackPlayVS.SystemContext.VideoSourceManager.Close(mBackPlayVS.Name);
                                                    mBackPlayVS = null;
                                                }

                                                mBackPlayVS = vsType.SystemContext.VideoSourceManager.Open(newVSConfig, HWnd);
                                                if (mBackPlayVS != null)
                                                {
                                                    mBackPlayVS.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged);
                                                    if (!mBackPlayVS.Play())
                                                    {
                                                        MessageBox.Show("回放失败,可能是回放录像还未生成,请稍后再试!", "回放错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                                    }
                                                }
                                                else
                                                {
                                                    MessageBox.Show("打开录像失败,可能是回放录像还未生成,请稍后再试!", "回放错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                                }
                                            }
                                        }
                                    }
                                    return(true);
                                }
                            }
                        }
                    }

                    if (!visionAlarm.IsRecord && !visionAlarm.IsPlay)
                    {
                        return(visionAlarm.PlayAlarmRecord(HWnd));
                    }
                }
            }
            return(false);
        }
Esempio n. 19
0
        protected override bool ExecuteAction(object source, IActionParam param)
        {
            try
            {
                CMonitorAlarm alarm = source as CMonitorAlarm;
                if (alarm != null)
                {
                    //CLocalSystem.WriteDebugLog(string.Format("{0} CHKAlarmOutAction({1}).ExecuteAction: Sender={2}, AlarmID={3}, ActionParam={4}", Config.Desc, Name, alarm.Sender, alarm.ID, param.Name));

                    AlarmClient alarmClient = GetAlarmClient();
                    if (alarmClient == null)
                    {
                        IVisionMonitorConfig vmc = alarm.Monitor.Config as IVisionMonitorConfig;
                        if (vmc != null)
                        {
                            IVideoSourceConfig vsConfig = vmc.SystemContext.VideoSourceConfigManager.GetConfig(vmc.VisionParamConfig.VSName);
                            alarmClient = GetAlarmClient(vsConfig);
                        }
                    }

                    if (alarmClient != null)
                    {
                        int outputPort = -1;
                        if (param.IsExist("OutputPort"))
                        {
                            outputPort = param.IntValue("OutputPort");
                        }
                        else
                        {
                            outputPort = AlarmOutConfig.OutputPort;
                        }

                        string key = CAlarmOut.GetKey(alarmClient, outputPort);

                        CAlarmOut alarmOut = mAlarmOutTable[key] as CAlarmOut;
                        if (alarmOut == null)
                        {
                            lock (mAlarmOutTable.SyncRoot)
                            {
                                alarmOut = mAlarmOutTable[key] as CAlarmOut;
                                if (alarmOut == null)
                                {
                                    alarmOut = new CAlarmOut(alarmClient, outputPort);
                                    mAlarmOutTable.Add(alarmOut.Key, alarmOut);
                                }
                            }
                        }

                        alarm.Property.SetValue("_AlarmOutObj", alarmOut);
                        alarm.OnTransactAlarm += new TransactAlarm(DoTransactAlarm);

                        alarmOut.StartAlarmOut();
                    }
                    else
                    {
                        CLocalSystem.WriteErrorLog(string.Format("CHKAlarmOutAction({0}).ExecuteAction: Sender={1} 无法获取报警输出对象!", Name, alarm.Sender));
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CHKAlarmOutAction({0}).ExecuteAction Excepton: {1}", Name, e));
            }
            return(false);
        }