コード例 #1
0
        private void DoTransactAlarm(IMonitorAlarm alarm, bool isExist)
        {
            CLocalSystem.WriteDebugLog(string.Format("CMonitor({0}).DoTransactAlarm AlarmID={1}", Name, alarm.ID));

            if (OnTransactAlarm != null)
            {
                OnTransactAlarm(alarm, isExist);
            }
        }
コード例 #2
0
ファイル: MonitorAction.cs プロジェクト: ewin66/Monitor
        public bool Execute(IMonitorAlarm alarm, IActionParam param)
        {
            if (alarm != null && IsActive && param != null && param.Enabled)
            {
                CLocalSystem.WriteDebugLog(string.Format("{0} CMonitorAction({1}).Execute: Sender={2}, AlarmID={3}, ActionParam={4}", Config.Desc, Name, alarm.Sender, alarm.ID, param.Name));

                return(Execute((object)alarm, param));
            }
            return(false);
        }
コード例 #3
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);
        }
コード例 #4
0
        public bool StartAlarmOut()
        {
            lock (this)
            {
                mRefCount++;

                if (mRefCount <= 1)
                {
                    mAlarmClient.SetAlarmOut(mOutputPort, 1);
                }

                CLocalSystem.WriteDebugLog(string.Format("CAlarmOut({0}).StartAlarmOut RefCount={1}", Key, mRefCount));
            }
            return(true);
        }
コード例 #5
0
        private void DoTransactAlarm(IMonitorAlarm alarm, bool isExist)
        {
            if (alarm != null)
            {
                //System.Console.Out.WriteLine("CMonitorAlarmManager.DoTransactAlarm " + alarm.Monitor.Name);
                CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarmManager.DoTransactAlarm MonitorName={0}, AlarmID={1}", alarm.Monitor.Name, alarm.ID));

                RemoveAlarm(alarm);

                if (OnTransactAlarm != null)
                {
                    OnTransactAlarm(alarm, isExist);
                }
            }
        }
コード例 #6
0
ファイル: HKPTZAction.cs プロジェクト: ewin66/Monitor
        private bool StartPTZ(IVideoSourceConfig vsConfig, int index)
        {
            CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ Begin...", Name));

            IPTZCtrl ptz = GetPTZCtrl(vsConfig);

            if (ptz != null)
            {
                if (System.Threading.Monitor.TryEnter(ptz))
                {
                    try
                    {
                        if (ptz.GotoPreset(index))
                        {
                            CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ OK: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));

                            int interval = PTZConfig.Interval;
                            if (interval > 0)
                            {
                                System.Threading.Thread.Sleep(interval);
                            }
                            return(true);
                        }
                        else
                        {
                            CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GOTO_PRESET Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
                        }
                    }
                    catch (Exception e)
                    {
                        CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ(PTZVSName={1}, Channel={2}, PresetIndex={3}) Exception: {4}", Name, vsConfig.Name, vsConfig.Channel, index, e));
                    }
                    finally
                    {
                        System.Threading.Monitor.Exit(ptz);
                    }
                }
                else
                {
                    CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ TryEnter Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
                }
            }
            else
            {
                CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GetHKPTZCtrl Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
            }
            return(false);
        }
コード例 #7
0
ファイル: VideoSource.cs プロジェクト: ewin66/Monitor
        public Bitmap GetFrame()
        {
            if (IsOpen)
            {
                try
                {
                    //DateTime begin = DateTime.Now;
                    Bitmap bmp = GetCurFrame();
                    //System.Console.Out.WriteLine(string.Format("抓帧耗时:{0}", DateTime.Now.Millisecond - begin.Millisecond));

                    if (mConfig.IsRecord && bmp != null)
                    {
                        if (mRecorder == null)
                        {
                            initImageRecorder();
                        }

                        if (mRecorder != null)
                        {
                            mRecorder.Append(new Bitmap(bmp), false);
                        }
                    }
                    return(bmp);
                }
                catch (Exception e)
                {
                    CLocalSystem.WriteErrorLog(string.Format("{0} GetFrame Exception: {1}", Name, e));

                    Process curproc = Process.GetCurrentProcess();

                    StringBuilder sb = new StringBuilder(curproc.ProcessName + "进程信息:\n");
                    sb.Append("进程分配的物理内存量=" + curproc.WorkingSet64 + "字节\n");
                    sb.Append("进程分配的虚拟内存量=" + curproc.VirtualMemorySize64 + "字节\n");
                    sb.Append("进程分配的专用内存量=" + curproc.PrivateMemorySize64 + "字节\n");
                    sb.Append("进程分配的分页内存量=" + curproc.PagedMemorySize64 + "字节\n");
                    sb.Append("进程分配的可分页系统内存量=" + curproc.PagedSystemMemorySize64 + "字节\n");
                    sb.Append("进程使用的虚拟内存分页文件中的最大内存量=" + curproc.PeakPagedMemorySize64 + "字节\n");
                    sb.Append("进程使用的最大虚拟内存量=" + curproc.PeakVirtualMemorySize64 + "字节\n");
                    sb.Append("进程打开的句柄数=" + curproc.HandleCount + "个\n");

                    CLocalSystem.WriteDebugLog(string.Format("{0} GetFrame Exception: 内存信息={1}", Name, sb.ToString()));
                }
            }
            return(null);
        }
コード例 #8
0
        public void StopAlarmOut(bool forceStop)
        {
            lock (this)
            {
                if (mRefCount > 0)
                {
                    mRefCount--;
                }

                if (forceStop || mRefCount <= 0)
                {
                    mAlarmClient.SetAlarmOut(mOutputPort, 0);
                    mRefCount = 0;
                }

                CLocalSystem.WriteDebugLog(string.Format("CAlarmOut({0}).StopAlarmOut RefCount={1}", Key, mRefCount));
            }
        }
コード例 #9
0
ファイル: Action.cs プロジェクト: ewin66/Monitor
        private void DoReceiveData(IMonitorSystemContext context, IProcessor processor, string data)
        {
            if (CheckOrigin(context, processor))
            {
                string kk = string.Format("{0}<Action>", Name);
                if (data.StartsWith(kk))
                {
                    CLocalSystem.WriteDebugLog(string.Format("CAction({0}).DoReceiveData 接收到 {1} 发送数据: {2}", Name, processor.Name, data));

                    data = data.Remove(0, kk.Length);
                    if (data.StartsWith("<State>"))
                    {
                        int n = data.IndexOf("</State>");
                        if (n > 0)
                        {
                            string state = data.Substring(7, n - 7);
                            if (state.Equals("Init"))
                            {
                                this.State = ActionState.Init;
                            }
                            else if (state.Equals("Start"))
                            {
                                this.State = ActionState.Run;
                            }
                            else if (state.Equals("Stop"))
                            {
                                this.State = ActionState.Stop;
                            }
                            else if (state.Equals("Cleanup"))
                            {
                                this.State = ActionState.None;
                            }
                            else if (state.Equals("Error"))
                            {
                                this.State = ActionState.Problem;
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
        private bool StartPTZ(IVideoSourceConfig vsConfig, int index)
        {
            CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).StartPTZ Begin...", Name));

            IPTZCtrl ptz = GetPTZCtrl(vsConfig.Channel);

            if (ptz != null)
            {
                if (ptz.GotoPreset(index))
                {
                    CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).StartPTZ OK: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));

                    int interval = PTZConfig.Interval;
                    if (interval > 0)
                    {
                        System.Threading.Thread.Sleep(interval);
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #11
0
ファイル: HKPTZAction.cs プロジェクト: ewin66/Monitor
        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);
        }
コード例 #12
0
ファイル: VideoSource.cs プロジェクト: ewin66/Monitor
        private void DoVideoSourceKernelStateChanged(string name, VideoSourceKernelState state)
        {
            CLocalSystem.WriteDebugLog(string.Format("{0} CVideoSource({1}).DoKernelStateChanged KernelState={2}", Config.Desc, name, state));

            if (OnKernelStatus != null)
            {
                if (CLocalSystem.MainForm != null)
                {
                    MethodInvoker form_invoker = delegate
                    {
                        OnKernelStatus(SystemContext, name, state);
                    };
                    CLocalSystem.MainForm.Invoke(form_invoker);
                }
                else
                {
                    OnKernelStatus(SystemContext, name, state);
                }
            }

            if (state < 0)
            {
                if (VideoSourceStatus != VideoSourceState.NoLink)
                {
                    VideoSourceStatus = VideoSourceState.KernelError;
                }

                switch (state)
                {
                case VideoSourceKernelState.VSState_FrameFailed:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源帧内容失效!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源帧内容失效!", name));
                    break;

                case VideoSourceKernelState.VSState_FrameNull:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源抓帧连续为空!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源抓帧连续为空!", name));
                    break;

                case VideoSourceKernelState.VSState_LockLost:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源抓帧死锁!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源抓帧死锁!", name));
                    break;

                case VideoSourceKernelState.VSState_TimerFailed:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源抓帧失效!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源抓帧失效!", name));
                    break;

                case VideoSourceKernelState.VSState_OtherProblem:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源出现其它问题!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源出现其它问题!", name));
                    break;

                default:
                    //System.Windows.Forms.MessageBox.Show(name + " 视频源出现未知错误!", "视频源内核状态提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CLocalSystem.WriteErrorLog(string.Format("\"{0}\"视频源出现未知错误!", name));
                    //KernelReset();
                    break;
                }
            }
        }
コード例 #13
0
 protected override bool InitAction()
 {
     CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).InitAction: IP={1}, Port={2}, UserName={3}, Password={4}", Name, PTZConfig.IP, PTZConfig.Port, PTZConfig.UserName, PTZConfig.Password));
     mDVRDevice = CHKDVRDevice.GetHKDevice(PTZConfig.IP, (short)PTZConfig.Port, PTZConfig.UserName, PTZConfig.Password);
     return(mDVRDevice != null);
 }
コード例 #14
0
        private void DoTransactAlarm()
        {
            try
            {
                TransactTime = DateTime.Now;
                IsTransact   = true;

                if (Transactor.Equals("") && SystemContext.MonitorSystem.LoginUser != null)
                {
                    Transactor = SystemContext.MonitorSystem.LoginUser.Name;
                }

                if (TransactText.Equals(""))
                {
                    TransactText = "×Ô¶¯´¦Àí";
                }

                if (mMonitor.Config.AutoSaveAlarmInfo)
                {
                    SaveAlarmInfo();
                }

                mMonitor.AlarmManager.RemoveAlarm(this);

                bool isExist = mMonitor.AlarmManager.Count > 0;

                CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarm.DoTransactAlarm MonitorName={0} AlarmCount={1}", mMonitor.Name, mMonitor.AlarmManager.Count));

                if (CLocalSystem.MainForm != null)
                {
                    MethodInvoker form_invoker = delegate
                    {
                        if (OnTransactAlarm != null)
                        {
                            OnTransactAlarm(this, isExist);
                        }

                        if (IsTransact)
                        {
                            StartTransactAction();
                        }
                    };
                    CLocalSystem.MainForm.Invoke(form_invoker);
                }
                else
                {
                    if (OnTransactAlarm != null)
                    {
                        OnTransactAlarm(this, isExist);
                    }

                    if (IsTransact)
                    {
                        StartTransactAction();
                    }
                }
                //OnRecordStateChanged -= new RecordStateChanged(DoRecordStateChanged);
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarm.DoTransactAlarm Exception: {0}", e));
            }
        }
コード例 #15
0
ファイル: MonitorWatcher.cs プロジェクト: ewin66/Monitor
        private void CheckRun()
        {
            try
            {
                TimeSpan ts;

                IRunConfig[] runConfigs = mMonitorConfig.RunParamConfig.GetRunConfigs();
                IRunConfig   runConfig;

                DateTime curTime   = DateTime.Now;
                string   extParams = ExtParams;
                int      count     = runConfigs.Length;

                bool checkPlanMode = CheckPlanMode(ref curTime, ref extParams);

                if (count > 0 && checkPlanMode)
                {
                    int index = ActiveIndex;

                    DateTime beginTime, endTime;

                    for (int i = index; i < count; i++)
                    {
                        runConfig = runConfigs[i];

                        if (runConfig.Enabled)
                        {
                            beginTime = new DateTime(curTime.Year, curTime.Month, curTime.Day, runConfig.BeginTime.Hour, runConfig.BeginTime.Minute, runConfig.BeginTime.Second);
                            endTime   = new DateTime(curTime.Year, curTime.Month, curTime.Day, runConfig.EndTime.Hour, runConfig.EndTime.Minute, runConfig.EndTime.Second);

                            if (curTime.CompareTo(beginTime) < 0)
                            {
                                ActiveRunConfig = null;

                                if (CheckSeconds <= 0)
                                {
                                    CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher{0}.CheckRun 未到运行时间,开始时间: {1}", Name, beginTime.ToString("yyyy-MM-dd HH:mm:ss")));
                                }

                                StopMonitor();

                                ts = new TimeSpan(beginTime.Ticks - curTime.Ticks);
                                if (CheckSeconds > 0 && ts.TotalSeconds > CheckSeconds)
                                {
                                    ts = new TimeSpan(0, 0, CheckSeconds);
                                }

                                mTimer.Change(ts, mInfinite);

                                return;
                            }
                            else if (curTime.CompareTo(endTime) < 0)
                            {
                                ActiveRunConfig = runConfig;

                                if (CheckSeconds <= 0)
                                {
                                    CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher{0}.CheckRun 已到运行时间,停止时间: {1}", Name, endTime.ToString("yyyy-MM-dd HH:mm:ss")));
                                }

                                StartMonitor();

                                ts = new TimeSpan(endTime.Ticks - curTime.Ticks);
                                if (CheckSeconds > 0 && ts.TotalSeconds > CheckSeconds)
                                {
                                    ts = new TimeSpan(0, 0, CheckSeconds);
                                }

                                mTimer.Change(ts, mInfinite);

                                return;
                            }
                        }
                    }
                }

                ActiveRunConfig = null;

                if (checkPlanMode && count == 0)
                {
                    if (CheckSeconds <= 0)
                    {
                        CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher({0}).CheckRun 符合计划模式,但未设置计划, 立即运行.", Name));
                    }

                    StartMonitor();
                }
                else
                {
                    if (CheckSeconds <= 0)
                    {
                        CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher({0}).CheckRun 不符合计划模式,停止运行.", Name));
                    }

                    StopMonitor();
                }

                runConfig = GetRunConfig(0, count);

                DateTime nextTime = GetNextPeriodsBeginTime(ref curTime, runConfig != null ? runConfig.BeginTime : new DateTime(curTime.Year, curTime.Month, curTime.Day), ref extParams);

                if (CheckSeconds <= 0)
                {
                    CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher({0}).CheckRun 已过本次运行时间,下一运行时间: {1}", Name, nextTime.ToString("yyyy-MM-dd HH:mm:ss")));
                }

                ts = new TimeSpan(nextTime.Ticks - curTime.Ticks);
                if (CheckSeconds > 0 && ts.TotalSeconds > CheckSeconds)
                {
                    ts = new TimeSpan(0, 0, CheckSeconds);
                }

                mTimer.Change(ts, mInfinite);
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorWatcher({0}).CheckRun Exception: {1}", Name, e));
            }
        }
コード例 #16
0
        private void ProcessData(IMonitorSystemContext context, IProcessor processor, string data)
        {
            //System.Console.Out.WriteLine(client.Name + " 接收到数据 " + data.Substring(0, data.Length > 100 ? 100 : data.Length));

            if (CheckOrigin(context, processor))
            {
                string kk = string.Format("{0}<Monitor>", Name);
                if (data.StartsWith(kk))
                {
                    CLocalSystem.WriteDebugLog(string.Format("CMonitor({0}).DoReceiveData({1}): {2}", Name, processor.Name, data));

                    data = data.Remove(0, kk.Length);
                    if (data.StartsWith("<State>"))
                    {
                        int n = data.IndexOf("</State>");
                        if (n > 0)
                        {
                            string state = data.Substring(7, n - 7);
                            if (state.Equals("Init"))
                            {
                                this.State = MonitorState.Init;
                            }
                            else if (state.Equals("Start"))
                            {
                                this.State = MonitorState.Run;
                            }
                            else if (state.Equals("Stop"))
                            {
                                this.State = MonitorState.Stop;
                            }
                            else if (state.Equals("Cleanup"))
                            {
                                this.State = MonitorState.None;
                            }
                            else if (state.Equals("Error"))
                            {
                                this.State = MonitorState.Problem;
                            }
                        }
                    }
                    else if (data.StartsWith("<MonitorAlarmImage>"))
                    {
                        int n = data.IndexOf("<AlarmImage>");
                        int m = data.IndexOf("<ID>");

                        string id = data.Substring(n + 12, m - n - 12);

                        MemoryStream ms = new MemoryStream(Convert.FromBase64String(data.Substring(18, n - 18)));

                        Image image = Bitmap.FromStream(ms);
                        if (image != null)
                        {
                            try
                            {
                                if (mHWndPreviewAlarmImage != IntPtr.Zero)
                                {
                                    Utils.CommonUtil.PreviewImage(image, mHWndPreviewAlarmImage);
                                    mHWndPreviewAlarmImage = IntPtr.Zero;
                                }

                                string file = string.Format("{0}\\{1}\\{2}.jpg", mImageRootPath, Name, id);
                                if (!System.IO.File.Exists(file))
                                {
                                    SaveAlarmImage(id, image);
                                }
                            }
                            finally
                            {
                                image.Dispose();
                                ms.Close();
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            ProcessReceiveData(context, processor, data);
                        }
                        catch (Exception e)
                        {
                            CLocalSystem.WriteErrorLog(string.Format("CMonitor({0}).ProcessReceiveData Exception: {1}", Name, e));
                        }
                    }
                }
            }
        }