Beispiel #1
0
 protected void DoMonitorStateChanged(MonitorState state)
 {
     try
     {
         if (OnMonitorStateChanged != null)
         {
             if (CLocalSystem.MainForm != null)
             {
                 MethodInvoker form_invoker = delegate
                 {
                     OnMonitorStateChanged(SystemContext, Name, state);
                 };
                 CLocalSystem.MainForm.Invoke(form_invoker);
             }
             else
             {
                 OnMonitorStateChanged(SystemContext, Name, state);
             }
         }
     }
     catch (Exception e)
     {
         CLocalSystem.WriteLog("Error", string.Format("CMonitor({0}).DoMonitorStateChanged Exception: {1}", Name, e));
     }
 }
Beispiel #2
0
        public FormDemo()
        {
            CLocalSystem.LocalSystemContext.IsVerify = false;
            CLocalSystem.MainForm = this;
            CLocalSystem.SystemInit();
            SystemContext.Init();

            InitializeComponent();

            //只需在主窗体调用一次
            //SystemContext.Init();

            this.OpenTableFromSql(mLoginTable, "select * from t_login_log", "", "1,10", "");

            TableUtil.SetMapInfo(mLoginTable.Columns["f_state"], "1=登录;0=注销");

            DataUIUtil.InitDataGridViewColumns(dataGridView1, mLoginTable);

            dataTreeView1.OnInitTreeNode += new MonitorLib.Ctrls.Extend.TreeNodeEventHandle(DoInitTreeNode);

            videoPlayerManageCtrl1.Init(16, 1, 2);

            videoPlayerManageCtrl1.OnActiveBoxChanging += new BoxEventHandle <VideoPlayer>(DoActiveBoxChanging);
            videoPlayerManageCtrl1.OnActiveBoxChanged  += new BoxEventHandle <VideoPlayer>(DoActiveBoxChanged);

            label_info.Text = "";

            dateTimePicker_end.Value   = DateTime.Now;
            dateTimePicker_begin.Value = dateTimePicker_end.Value.AddDays(-1);
        }
Beispiel #3
0
        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));
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
 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));
     }
 }
Beispiel #5
0
        public virtual void Reset()
        {
            CLocalSystem.WriteInfoLog(string.Format("CVideoSource({0}).Reset", Name));

            PrepStop();
            PrepClose();

            this.VideoSourceStatus = VideoSourceState.Norme;

            if (IsOpen)
            {
                if (PrepOpen(Target))
                {
                    if (IsPlay)
                    {
                        if (!PrepPlay())
                        {
                            Stop();
                        }
                    }
                }
                else
                {
                    Close();
                }
            }
        }
Beispiel #6
0
        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));
            }
        }
Beispiel #7
0
        private void AsyncDoDisconnected(IProcessor processor)
        {
            CLocalSystem.WriteInfoLog(string.Format("CRemoteManagerClient.AsyncDoDisconnected: 已经断开服务器 {0}.", processor.Name));

            try
            {
                if (OnDisconnected != null)
                {
                    if (CLocalSystem.MainForm != null)
                    {
                        MethodInvoker form_invoker = delegate
                        {
                            OnDisconnected(mSystemContext, processor);
                        };

                        CLocalSystem.MainForm.Invoke(form_invoker);
                    }
                    else
                    {
                        OnDisconnected(mSystemContext, processor);
                    }
                }
            }
            catch
            {   }
        }
Beispiel #8
0
        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));
            }
        }
Beispiel #9
0
        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));
            }
        }
Beispiel #10
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));
            }
        }
Beispiel #11
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));
                            }
                        }
                    }
                }
            }
        }
Beispiel #12
0
 private void SyncVisionUserStatisticCallback(string name, int vsfps, int vpfps, int frames)
 {
     try
     {
         if (OnVisionUserStatisticInfo != null)
         {
             if (CLocalSystem.MainForm != null)
             {
                 MethodInvoker form_invoker = delegate
                 {
                     OnVisionUserStatisticInfo(name, vsfps, vpfps, frames);
                 };
                 CLocalSystem.MainForm.Invoke(form_invoker);
             }
             else
             {
                 OnVisionUserStatisticInfo(name, vsfps, vpfps, frames);
             }
         }
     }
     catch (Exception e)
     {
         CLocalSystem.WriteLog("Error", string.Format("CVisionUser.OnVisionUserStatisticCallback Exception:{0}", e));
     }
 }
Beispiel #13
0
        private void StopMonitor()
        {
            IsActive = false;

            //CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher({0}).StopMonitor.", Name));

            if (CLocalSystem.MainForm != null)
            {
                MethodInvoker form_invoker = delegate
                {
                    IMonitor monitor = mMonitorConfig.SystemContext.MonitorManager.GetMonitor(Name);
                    if (monitor != null)
                    {
                        CLocalSystem.WriteInfoLog(string.Format("CMonitorWatcher({0}).StopMonitor.", Name));

                        DoMonitorStopBefore();

                        mMonitorConfig.SystemContext.MonitorManager.FreeMonitor(Name);

                        DoMonitorStopAfter();
                    }
                };
                CLocalSystem.MainForm.Invoke(form_invoker);
            }
        }
Beispiel #14
0
        private void StartMonitor()
        {
            IsActive = true;

            //CLocalSystem.WriteDebugLog(string.Format("CMonitorWatcher({0}).StartMonitor.", Name));

            if (CLocalSystem.MainForm != null)
            {
                MethodInvoker form_invoker = delegate
                {
                    IMonitor monitor = mMonitorConfig.SystemContext.MonitorManager.GetMonitor(Name);
                    if (monitor == null || !monitor.IsActive)
                    {
                        CLocalSystem.WriteInfoLog(string.Format("CMonitorWatcher({0}).StartMonitor.", Name));

                        DoMonitorStartBefore();

                        monitor = mMonitorConfig.SystemContext.MonitorManager.CreateMonitor(mMonitorConfig);
                        if (monitor != null)
                        {
                            monitor.Start();
                        }

                        DoMonitorStartAfter();
                    }
                };
                CLocalSystem.MainForm.Invoke(form_invoker);
            }
        }
Beispiel #15
0
 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));
             }
         }
     }
 }
Beispiel #16
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));
            }
        }
Beispiel #17
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);
            }
        }
Beispiel #18
0
        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);
        }
Beispiel #19
0
        protected bool ReceiveRemoteData(string contextname, IProcessor processor, string data)
        {
            bool result = false;

            if (!contextname.Equals(""))
            {
                IRemoteSystem[] rss = CLocalSystem.GetRemoteSystems();
                if (rss != null)
                {
                    foreach (IRemoteSystem rs in rss)
                    {
                        if (rs.SystemContext.IsInit && rs.SystemContext.Name.Equals(contextname))
                        {
                            result = true;

                            if (OnReceiveData != null)
                            {
                                if (CLocalSystem.MainForm != null)
                                {
                                    MethodInvoker form_invoker = delegate
                                    {
                                        OnReceiveData(rs.SystemContext, processor, data);
                                    };
                                    CLocalSystem.MainForm.Invoke(form_invoker);
                                }
                                else
                                {
                                    OnReceiveData(rs.SystemContext, processor, data);
                                }
                            }
                        }
                    }
                }

                if (result)
                {
                    if (OnReceiveData != null)
                    {
                        if (CLocalSystem.MainForm != null)
                        {
                            MethodInvoker form_invoker = delegate
                            {
                                OnReceiveData(CLocalSystem.LocalSystemContext, processor, data);
                            };
                            CLocalSystem.MainForm.Invoke(form_invoker);
                        }
                        else
                        {
                            OnReceiveData(CLocalSystem.LocalSystemContext, processor, data);
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #20
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);
        }
Beispiel #21
0
        private void DoDownProgress(int progress, DownState state)
        {
            CLocalSystem.WriteInfoLog(string.Format("\"{0}\"下载进度:{1}% 状态:{2}", LocalFileName, progress, state));

            if (OnDownProgress != null)
            {
                OnDownProgress(this, mProgress, state);
            }
            else if (progress == 100)
            {
                MessageBox.Show(string.Format("文件({0})下载结束!", this.LocalFileName));
            }
        }
Beispiel #22
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);
        }
Beispiel #23
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));
         }
     }
 }
Beispiel #24
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);
                }
            }
        }
Beispiel #25
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);
        }
Beispiel #26
0
        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);
        }
Beispiel #27
0
        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);
        }
Beispiel #28
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);
        }
Beispiel #29
0
 protected void ReceiveRemoteConfigData(string contextname, IProcessor processor, string data)
 {
     IRemoteSystem[] rss = CLocalSystem.GetRemoteSystems();
     if (rss != null)
     {
         foreach (IRemoteSystem rs in rss)
         {
             if (rs != null && rs.SystemContext.IsInit && rs.SystemContext.Name.Equals(contextname))
             {
                 if (processor.Host.Equals(rs.Config.IP) && processor.Port == rs.Config.Port)
                 {
                     CRemoteConfigManager.ReceiveRemoteConfigData(rs.SystemContext, data, false);
                 }
             }
         }
     }
 }
Beispiel #30
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);
        }