コード例 #1
0
        private void ProcessMonitorAction(IMonitorSystemContext context, IActionParam[] actionList)
        {
            if (actionList != null && actionList.Length > 0)
            {
                foreach (IActionParam config in actionList)
                {
                    if (config != null && config.Enabled)
                    {
                        IMonitorAction action = context.ActionManager.GetAction(config.Name) as IMonitorAction;

                        if (action != null && action.IsActive)
                        {
                            try
                            {
                                //CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarm.ProcessMonitorAction: ExecuteActionName={0}", action.Name));

                                action.Execute(this, config);
                            }
                            catch (Exception e)
                            {
                                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarm.ProcessMonitorAction Exception: {0}", e));
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: VideoSource.cs プロジェクト: ewin66/Monitor
        protected void DoPlayStatusChange(string vsName, VideoSourceState vsStatus, PlayState playStatus)
        {
            try
            {
                if (IsPlay && vsStatus > VideoSourceState.Norme)
                {
                    this.Reset();
                }

                if (OnPlayStatusChanged != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnPlayStatusChanged(SystemContext, vsName, vsStatus, playStatus);
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnPlayStatusChanged(SystemContext, vsName, vsStatus, playStatus);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CVideoSource.DoPlayStatusChange Exception:{0}", e));
            }
        }
コード例 #3
0
ファイル: Action.cs プロジェクト: ewin66/Monitor
        protected void DoActionStateChanged(ActionState state)
        {
            try
            {
                if (SystemContext.RemoteManageServer != null)
                {
                    SystemContext.RemoteManageServer.SyncActionState(this, null);
                }

                if (OnActionStateChanged != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnActionStateChanged(SystemContext, Name, state);
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnActionStateChanged(SystemContext, Name, state);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CAction({0}).DoActionStateChanged Exception: {1}", Name, e));
            }
        }
コード例 #4
0
ファイル: VideoSource.cs プロジェクト: ewin66/Monitor
 protected void DoRecordProgress(int hRecord, int progress)
 {
     try
     {
         if (OnRecordProgress != null)
         {
             if (CLocalSystem.MainForm != null)
             {
                 MethodInvoker form_invoker = delegate
                 {
                     OnRecordProgress(hRecord, progress);
                 };
                 CLocalSystem.MainForm.Invoke(form_invoker);
             }
             else
             {
                 OnRecordProgress(hRecord, progress);
             }
         }
     }
     catch (Exception e)
     {
         CLocalSystem.WriteErrorLog(string.Format("CVideoSource.OnRecordProgress Exception:{0}", e));
     }
 }
コード例 #5
0
ファイル: ShapeDrawCtrl.cs プロジェクト: ewin66/Monitor
        private void pictureBox_shape_Paint(object sender, PaintEventArgs e)
        {
            if (mShapeManager != null)
            {
                mShapeManager.DrawShapes(e.Graphics);

                if (mMouseX >= 0 && mMouseY >= 0)
                {
                    Point point = new Point(mMouseX, mMouseY);

                    IShape shape = mShapeManager.ActiveShape;
                    if (shape != null && shape.State == ShapeState.Draw)
                    {
                        Point[] points = shape.GetPoints();
                        if (points != null && points.Length > 0)
                        {
                            try
                            {
                                e.Graphics.DrawLine(shape.DrawLinePen, points[points.Length - 1], point);
                            }
                            catch (Exception ex)
                            {
                                CLocalSystem.WriteErrorLog(string.Format("ShapeDrawCtrl.OnPaint DrawException: {0}", ex));
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        private void AsyncDoReceiveData(IProcessor processor, string data)
        {
            //CLocalSystem.WriteDebugLog(string.Format("CRemoteManagerClient.AsyncDoReceiveData: 接收到 {0} 发送数据: {1}", processor.Name, data));

            try
            {
                int index = data.IndexOf("<RemoteSystem>");
                if (index >= 0 && CLocalSystem.RemoteManageServer != null)
                {
                    CLocalSystem.RemoteManageServer.Send(data);
                }

                IMonitorSystemContext context = null;
                string contextname            = "";

                index = data.IndexOf("<SystemContext>");
                if (index > 0)
                {
                    contextname = data.Substring(0, index);
                    context     = CLocalSystem.GetSystemContext(contextname);
                    data        = data.Remove(0, index + 15);
                }

                if (context == null)
                {
                    context = mSystemContext;
                }

                if (data.IndexOf("<RemoteConfig>") > 0)
                {
                    if (!contextname.Equals(""))
                    {
                        ReceiveRemoteConfigData(contextname, processor, data);
                    }
                    return;
                }
                else if (!ReceiveRemoteData(contextname, processor, data))
                {
                    if (OnReceiveData != null)
                    {
                        if (CLocalSystem.MainForm != null)
                        {
                            MethodInvoker form_invoker = delegate
                            {
                                OnReceiveData(context, processor, data);
                            };
                            CLocalSystem.MainForm.Invoke(form_invoker);
                        }
                        else
                        {
                            OnReceiveData(context, processor, data);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CRemoteManageClient.AsyncDoReceiveData Exception: {0}", e));
            }
        }
コード例 #7
0
ファイル: VideoSource.cs プロジェクト: ewin66/Monitor
 public void KernelReset()
 {
     if (IsKernelInit)
     {
         if (CLocalSystem.MainForm != null)
         {
             MethodInvoker form_invoker = delegate
             {
                 try
                 {
                     KernelCleanup();
                     KernelInit();
                 }
                 catch (Exception e)
                 {
                     CLocalSystem.WriteErrorLog(string.Format("CVideoSource.KernelReset Exception:{0}", e));
                 }
             };
             CLocalSystem.MainForm.Invoke(form_invoker);
         }
         else
         {
             try
             {
                 KernelCleanup();
                 KernelInit();
             }
             catch (Exception e)
             {
                 CLocalSystem.WriteErrorLog(string.Format("CVideoSource.KernelReset Exception:{0}", e));
             }
         }
     }
 }
コード例 #8
0
        private void DoMonitorAlarmLocated(IMonitorAlarm alarm, int index)
        {
            try
            {
                if (alarm != null)
                {
                    //CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarmManager.DoMonitorAlarmLocated AlarmID={0}, Index={1}", alarm.ID, index));
                }

                if (OnMonitorAlarmLocated != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnMonitorAlarmLocated(alarm, index);
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnMonitorAlarmLocated(alarm, index);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarmManager.DoMonitorAlarmLocated Exception:{0}", e));
            }
        }
コード例 #9
0
ファイル: Action.cs プロジェクト: ewin66/Monitor
        protected void DoAfterAction(object source, IActionParam param)
        {
            try
            {
                //CLocalSystem.WriteDebugLog(string.Format("CAction({0}).DoAfterAction({1})", Name, param.Name));

                if (OnAfterAction != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnAfterAction(SystemContext, Name, source, param);
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnAfterAction(SystemContext, Name, source, param);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CAction({0}).DoAfterAction Exception: {1}", Name, e));
            }
        }
コード例 #10
0
        protected override bool PrepPlay()
        {
            if (PlayHandle < 0)
            {
                PlayHandle = HCNetSDKWrap.NET_DVR_RealPlay(DVRDevice.UserID, ref mClientInfo);
                if (PlayHandle > -1)
                {
                    HCNetSDKWrap.NET_DVR_SetPlayerBufNumber(PlayHandle, 10);

                    HCNetSDKWrap.NET_DVR_SetRealDataCallBack(PlayHandle, mPlayDataCallback, 0);

                    if (ImageDrawer.DrawFun != null)
                    {
                        HCNetSDKWrap.NET_DVR_RigisterDrawFun(PlayHandle, ImageDrawer.DrawFun, DVRDevice.UserID);
                    }

                    Thread.Sleep(1000);
                    PlayPort = HCNetSDKWrap.NET_DVR_GetRealPlayerIndex(PlayHandle);
                    int n = 0;
                    while (PlayPort < 0)
                    {
                        Thread.Sleep(100);
                        PlayPort = HCNetSDKWrap.NET_DVR_GetRealPlayerIndex(PlayHandle);
                        if (++n > 5)
                        {
                            break;
                        }
                    }

                    if (PlayPort > -1)
                    {
                        return(true);
                    }
                    else
                    {
                        HKDVRException hke = new HKDVRException("获取播放器端口失败");
                        CLocalSystem.WriteErrorLog(string.Format("HKDVRRealPlayer({0}) 播放时获取播放器端口({1})失败:{2}", this.Name, PlayPort, hke.Message));

                        if (HCNetSDKWrap.NET_DVR_StopRealPlay(PlayHandle))
                        {
                            PlayHandle = -1;
                        }
                    }
                }
                else
                {
                    HKDVRException hke = new HKDVRException("播放失败");
                    CLocalSystem.WriteErrorLog(string.Format("HKDVRRealPlayer({0}) {1}", this.Name, hke.Message));
                }
            }
            return(false);
        }
コード例 #11
0
 private void DoReceiveData(IMonitorSystemContext context, IProcessor processor, string data)
 {
     lock (mProcessLock)
     {
         try
         {
             ProcessData(context, processor, data);
         }
         catch (Exception e)
         {
             CLocalSystem.WriteErrorLog(string.Format("CMonitor({0}).DoReceiveData Exception: {1}", Name, e));
         }
     }
 }
コード例 #12
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);
        }
コード例 #13
0
ファイル: MonitorWatcher.cs プロジェクト: ewin66/Monitor
        public IRunConfig CheckActiveRunConfig()
        {
            try
            {
                ActiveRunConfig = null;

                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;

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

                        if (runConfig.Enabled)
                        {
                            if (curTime.CompareTo(runConfig.BeginTime) < 0)
                            {
                                ActiveRunConfig = null;

                                break;
                            }
                            else if (curTime.CompareTo(runConfig.EndTime) < 0)
                            {
                                ActiveRunConfig = runConfig;

                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorWatcher({0}).CheckActiveRunConfig Exception: {1}", Name, e));
            }

            return(ActiveRunConfig);
        }
コード例 #14
0
        protected override bool PrepOpen(object target)
        {
            if (PlayHandle < 0)
            {
                if (mType == 1)
                {
                    PlayHandle = HCNetSDKWrap.NET_DVR_PlayBackByName(DVRDevice.UserID, target.ToString(), HWnd);
                }
                else if (mType == 2)
                {
                    PlayHandle = HCNetSDKWrap.NET_DVR_PlayBackByTime(DVRDevice.UserID, (Int32)target, ref mStartTime, ref mStopTime, HWnd);
                }
                else
                {
                    throw new Exception("回放类型不支持!");
                }

                if (PlayHandle > -1)
                {
                    PlayPort = HCNetSDKWrap.NET_DVR_GetPlayBackPlayerIndex(PlayHandle);
                    if (PlayPort > -1)
                    {
                        mTryCount = 0;

                        if (ImageDrawer.DrawFun != null)
                        {
                            HCNetSDKWrap.PlayM4_RigisterDrawFun(PlayPort, ImageDrawer.DrawFun, DVRDevice.UserID);
                        }

                        return(true);
                    }
                    else if (HCNetSDKWrap.NET_DVR_StopPlayBack(PlayHandle))
                    {
                        PlayHandle = -1;
                        CLocalSystem.WriteErrorLog(string.Format("HKDVRBackPlayer({0}) 播放时获取播放器句柄失败:{1}", this.Name, PlayPort));
                    }
                }
                else
                {
                    int nErr = HCNetSDKWrap.NET_DVR_GetLastError();
                    CLocalSystem.WriteErrorLog(string.Format("HKDVRBackPlayer({0}) 播放失败:{1}", this.Name, nErr));

                    PlayStatus = PlayState.Error;
                }
            }
            return(false);
        }
コード例 #15
0
        protected override Bitmap GetCurFrame()
        {
            if (IsPlay)
            {
                lock (mLockFrameObj)
                {
                    int size = 0;
                    try
                    {
                        if (PlayM4SDKWrap.PlayM4_GetBMP(mPort, mBuffer, mBuffer.Length, ref size))
                        {
                            if (size > 0)
                            {
                                MemoryStream ms = new MemoryStream(mBuffer, 0, size);
                                try
                                {
                                    return(new Bitmap(ms));
                                }
                                finally
                                {
                                    ms.Close();
                                    ms.Dispose();
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        CLocalSystem.WriteErrorLog(string.Format("FilePlayer.GetCurFrame Exception: {0}", e));
                    }
                }
            }
            else if (IsOpen && Config.IsCycle)
            {
                lock (mLockFrameObj)
                {
                    PrepClose();

                    if (PrepOpen(Target))
                    {
                        PrepPlay();
                    }
                }
            }
            return(null);
        }
コード例 #16
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);
        }
コード例 #17
0
        private void DoDisconnected(IMonitorSystemContext context, IProcessor processor)
        {
            CLocalSystem.WriteInfoLog(string.Format("CMonitor({0}).DoDisconnected: 已经与服务器({1})断开.", Name, processor.Name));

            if (CheckOrigin(context, processor))
            {
                this.State = MonitorState.Problem;

                try
                {
                    ProcessDisconnected(context, processor);
                }
                catch (Exception e)
                {
                    CLocalSystem.WriteErrorLog(string.Format("CMonitor({0}).ProcessDisconnected Exception: {1}", Name, e));
                }
            }
        }
コード例 #18
0
        private void DoConnected(IMonitorSystemContext context, IProcessor processor)
        {
            CLocalSystem.WriteInfoLog(string.Format("CMonitor({0}).DoConnected: 已经连接服务器({1}).", Name, processor.Name));

            if (CheckOrigin(context, processor))
            {
                processor.Send(string.Format("{0}{1}<Monitor>QueryState<Command>", context.RequestHeadInfo, Name));

                try
                {
                    ProcessConnected(context, processor);
                }
                catch (Exception e)
                {
                    CLocalSystem.WriteErrorLog(string.Format("CMonitor({0}).ProcessConnected Exception: {1}", e));
                }
            }
        }
コード例 #19
0
        protected override bool LoadFromXmlNode(XmlNode node)
        {
            try
            {
                if (node != null && node.Name.Equals(TypeName))
                {
                    lock (mConfigs.SyncRoot)
                    {
                        Clear(0);

                        IConfig config;

                        foreach (XmlNode xSubNode in node.ChildNodes)
                        {
                            if (!xSubNode.Name.Equals("#comment"))
                            {
                                try
                                {
                                    config = CreateConfigInstance(xSubNode);

                                    if (config != null)
                                    {
                                        config.LoadFromXml(xSubNode);
                                        config.OnConfigChanged += new ConfigEventHandler(DoConfigChanged);
                                        mConfigs.Add(config.Name, config);
                                    }
                                }
                                catch (Exception e)
                                {
                                    CLocalSystem.WriteErrorLog(string.Format("CConfigManager.LoadFromXmlNode: ¼ÓÔØ{0}ÅäÖÃÊý¾Ýʧ°Ü: {1}", xSubNode.Name, e));
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CConfigManager.LoadFromXmlNode: ¼ÓÔØÅäÖÃÊý¾Ýʧ°Ü: {0}", e));
            }
            return(false);
        }
コード例 #20
0
ファイル: Action.cs プロジェクト: ewin66/Monitor
        private void DoActionEvent(IMonitorSystemContext context, string name, object source, IActionParam param)
        {
            try
            {
                if (IsActive && param != null && param.Enabled)
                {
                    DoBeforeAction(source, param);

                    if (ExecuteAction(source, param))
                    {
                        DoAfterAction(source, param);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CAction({0}).DoActionEvent Exception: {1}", Name, e));
            }
        }
コード例 #21
0
        protected override void OnMessageCallback(string id, string sender, IntPtr message)
        {
            DateTime CurAlarmTime = DateTime.Now;

            if (message != IntPtr.Zero)
            {
                try
                {
                    if (this.CheckAlarmInterval(CurAlarmTime))
                    {
                        CVisionEvent msg = (CVisionEvent)Marshal.PtrToStructure(message, typeof(CVisionEvent));

                        //if (msg.eventType == 0)
                        //{
                        //    System.Console.Out.WriteLine("EventType=" + msg.eventType + ", AlertOpt=" + msg.alertOpt);
                        //    return;
                        //}

                        CVisionAlarm alarm = new CVisionAlarm(this);

                        alarm.ID         = id;
                        alarm.Sender     = sender;
                        alarm.Desc       = Config.Desc;
                        alarm.EventType  = (TVisionEventType)msg.eventType;
                        alarm.GuardLevel = (TGuardLevel)msg.guardLevel;
                        alarm.AreaIndex  = msg.areaIndex;
                        alarm.AreaType   = (TAreaType)msg.areaType;
                        alarm.AlertOpt   = (TAlertOpt)msg.alertOpt;
                        alarm.AlarmTime  = CurAlarmTime;
                        alarm.AlarmImage = ImageUtil.IplImageToBitmap(msg.image);

                        CLocalSystem.WriteInfoLog(string.Format("CBlobTracker.OnMessageCallback AlertOpt:{0}", (TAlertOpt)msg.alertOpt));

                        this.PostAlarmEvent(alarm);
                    }
                }
                catch (Exception e)
                {
                    CLocalSystem.WriteErrorLog(string.Format("CBlobTracker.OnMessageCallback Exception:{0}", e));
                }
            }
        }
コード例 #22
0
        private void OnTimerTick(Object sender, EventArgs e)
        {
            //mTimer.Enabled = false;
            if (System.Threading.Monitor.TryEnter(mPlayLockObj))
            {
                try
                {
                    if (mGraophics != null && mBmp != null)
                    {
                        Bitmap curBmp = null;

                        lock (mLockFrameObj)
                        {
                            curBmp = new Bitmap(mBmp);
                        }

                        if (curBmp != null)
                        {
                            try
                            {
                                mGraophics.DrawImage(curBmp, 0, 0, mRect.right, mRect.bottom);
                            }
                            finally
                            {
                                curBmp.Dispose();
                                curBmp = null;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CLocalSystem.WriteErrorLog(string.Format("ImageVideoSource.OnTimerTick Excpetion: {0}", ex));
                }
                finally
                {
                    System.Threading.Monitor.Exit(mPlayLockObj);
                }
            }
            mTimer.Enabled = IsPlay;
        }
コード例 #23
0
 public void SyncMonitorState()
 {
     IMonitor[] monitors = mSystemContext.MonitorManager.GetMonitors();
     if (monitors != null)
     {
         foreach (IMonitor monitor in monitors)
         {
             try
             {
                 if (monitor != null)
                 {
                     SyncMonitorState(monitor.Config);
                 }
             }
             catch (Exception e)
             {
                 CLocalSystem.WriteErrorLog(string.Format("SyncMonitorState Exception: {0}", e));
             }
         }
     }
 }
コード例 #24
0
        public IConfig BuildConfigFromXml(string xml)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(xml.StartsWith("<?xml ") ? xml : string.Format("<?xml version=\"1.0\" encoding=\"GBK\" ?>{0}", xml));
                IConfig config = CreateConfigInstance(doc.DocumentElement);
                if (config != null)
                {
                    config.BuildConfig(xml);

                    return(config);
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CConfigManager.CreateConfigFromXml Exception: {0}", e));
            }
            return(null);
        }
コード例 #25
0
        private void DoMonitorAlarm(IMonitorAlarm alarm)
        {
            try
            {
                if (alarm != null)
                {
                    if (SystemContext.RemoteManageServer != null)
                    {
                        SystemContext.RemoteManageServer.Send((alarm as CMonitorAlarm).GetAlarmInfo());
                    }

                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            alarm.StartAlarmAction();

                            if (OnMonitorAlarm != null)
                            {
                                OnMonitorAlarm(alarm);
                            }
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        alarm.StartAlarmAction();

                        if (OnMonitorAlarm != null)
                        {
                            OnMonitorAlarm(alarm);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitor({0}).DoMonitorAlarm Exception: {1}", Name, e));
            }
        }
コード例 #26
0
        private void DoAlarmListChanged(ChangeType type)
        {
            try
            {
                //CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarmManager.DoAlarmListChanged ChangeType={0}, Count={1}", type, Count));

                if (mCurIndex >= 0 && mCurIndex < Count)
                {
                    if (type == ChangeType.Remove || type == ChangeType.Both)
                    {
                        Locate(mCurIndex);
                    }
                }
                else
                {
                    First();
                }

                if (OnAlarmListChanged != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnAlarmListChanged(type);
                        };
                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnAlarmListChanged(type);
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarmManager.DoAlarmListChanged Exception:{0}", e));
            }
        }
コード例 #27
0
        protected void DoPlayDataCallback(int lRealHandle, int dwDataType, IntPtr pBuffer, int dwBufSize, int dwUser)
        {
            switch (dwDataType)
            {
            case HCNetSDKWrap.NET_DVR_SYSHEAD:
                //System.Console.Out.WriteLine(Name + " DataType=" + dwDataType + ", Size=" + dwBufSize);
                if (this.VideoSourceStatus != VideoSourceState.Norme)
                {
                    //CLocalSystem.WriteLog("Debug", string.Format("{0} DataType={1}, Size={2}", Name, dwDataType, dwBufSize));
                    HCNetSDKWrap.PlayM4_ResetSourceBuffer(mPlayPort);
                    HCNetSDKWrap.PlayM4_ResetBuffer(mPlayPort, HCNetSDKWrap.BUF_VIDEO_SRC);
                    HCNetSDKWrap.PlayM4_ResetBuffer(mPlayPort, HCNetSDKWrap.BUF_VIDEO_RENDER);
                    MakeKeyFrame();
                    mCancelCount = 0;
                    //this.VideoSourceStatus = VideoSourceState.Norme;
                }
                break;

            case HCNetSDKWrap.NET_DVR_STREAMDATA:
                if (this.VideoSourceStatus != VideoSourceState.Norme)
                {
                    mCancelCount++;
                    if (mCancelCount > (Config.FPS * 10))
                    {
                        this.VideoSourceStatus = VideoSourceState.Norme;
                        mCancelCount           = 0;
                    }
                }
                //System.Console.Out.WriteLine(Name + " DataType=" + dwDataType + ", Size=" + dwBufSize);
                break;

            default:
                CLocalSystem.WriteErrorLog(string.Format("HKDVRPlayer({0}) DataType={1}, Size={2}", Name, dwDataType, dwBufSize));
                this.VideoSourceStatus = VideoSourceState.NoLink;

                break;
            }
        }
コード例 #28
0
        public bool SaveAlarmInfo()
        {
            string path = string.Format("{0}\\{1}\\{2}\\{3}", mAlarmInfoRootPath, SystemContext.MonitorSystem.Name, Sender, AlarmTime.ToString("yyyy-MM-dd"));

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(ToFullXml());
                doc.Save(string.Format("{0}\\{1}.xml", path, ID));
                return(true);
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarm.SaveAlarmInfo Exception: {0}", e));
                return(false);
            }
        }
コード例 #29
0
        private void ThreadProc()
        {
            CClientReceiveContext ctx;

            while (!mIsExit)
            {
                if (mProcessList.Count > 0)
                {
                    ctx = null;
                    lock (mProcessList.SyncRoot)
                    {
                        if (mProcessList.Count > 0)
                        {
                            ctx = (CClientReceiveContext)mProcessList[0];
                            mProcessList.RemoveAt(0);
                        }
                    }

                    if (ctx != null)
                    {
                        try
                        {
                            DoProcessData(ctx.Processor, ctx.Data);
                        }
                        catch (Exception e)
                        {
                            CLocalSystem.WriteErrorLog(string.Format("CClientReceiveContext.ProcessPipe Exception: {0}", e));
                        }
                    }
                }
                else
                {
                    Thread.Sleep(10);
                }
            }
            mIsExit = false;
        }
コード例 #30
0
        private void ThreadProc()
        {
            CSendContext ctx;
            SendState    state = SendState.Error;

            //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            while (!mIsExit)
            {
                if (mList.Count > 0)
                {
                    ctx = (CSendContext)mList[0];
                    if (ctx != null && !ctx.IsFinish)
                    {
                        try
                        {
                            ctx.Count++;

                            //sw.Reset();
                            //sw.Start();
                            DoSendOperate(ctx.IP, ctx.Port, ctx.Data, ref state);
                            //sw.Stop();
                            //System.Console.Out.WriteLine("CSendPipe.DoSendOperate 耗时:" + sw.ElapsedMilliseconds);

                            if (ctx.Level == 0 || state == SendState.OK)
                            {
                                ctx.IsFinish = true;

                                lock (mList.SyncRoot)
                                {
                                    mList.RemoveAt(0);
                                }
                            }
                            else if (mIsExit)
                            {
                                break;
                            }
                            else if (state == SendState.Error)
                            {
                                Thread.Sleep(1000 * ctx.Count);
                            }
                        }
                        catch (Exception e)
                        {
                            CLocalSystem.WriteErrorLog(string.Format("CSendPipe Exception: {0}", e));
                        }
                    }
                    else
                    {
                        lock (mList.SyncRoot)
                        {
                            mList.RemoveAt(0);
                        }
                    }
                }
                else
                {
                    Thread.Sleep(10);
                }
            }
            mIsExit = false;
        }