コード例 #1
0
ファイル: VideoSourceManager.cs プロジェクト: ewin66/Monitor
        public bool Init(IVideoSourceManager manager, IVideoSourceType type)
        {
            mVSManager = manager;
            mVSType    = type;

            return(DoInit());
        }
コード例 #2
0
        private void comboBox_vsType_SelectedIndexChanged(object sender, EventArgs e)
        {
            label_filename.Visible   = false;
            textBox_filename.Visible = false;
            button_file.Visible      = false;
            checkBox_cycle.Visible   = false;
            label_domain.Visible     = false;
            textBox_domain.Visible   = false;
            label_channel.Text       = "视频源通道:";

            IVideoSourceType vsType = comboBox_vsType.SelectedItem as IVideoSourceType;

            if (vsType != null)
            {
                if (vsType.Name.EndsWith("FileVideoSource"))
                {
                    label_filename.Visible   = true;
                    textBox_filename.Visible = true;
                    button_file.Visible      = true;
                    checkBox_cycle.Visible   = true;
                }
                else if (vsType.Name.StartsWith("HWNVS"))
                {
                    label_domain.Visible   = true;
                    textBox_domain.Visible = true;
                    label_channel.Text     = "摄像头编号:";
                }
            }
        }
コード例 #3
0
ファイル: AlarmRecordCtrl.cs プロジェクト: ewin66/Monitor
        private IVideoSourceConfig GetBackPlayVSConfig(IVideoSourceConfig vsConfig, IAlarmInfo alarmInfo)
        {
            CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig;

            if (newVSConfig != null)
            {
                newVSConfig.Name      = vsConfig.Name + "_BackPlay_" + newVSConfig.Handle;
                newVSConfig.StartTime = alarmInfo.AlarmTime.AddSeconds(-10);
                newVSConfig.StopTime  = alarmInfo.AlarmTime;
                newVSConfig.IsRecord  = false;
                newVSConfig.IsCycle   = false;
                newVSConfig.Enabled   = true;
            }

            IVideoSourceType vsType = vsConfig.SystemContext.VideoSourceTypeManager.GetConfig(vsConfig.Type);

            if (vsType != null)
            {
                string backPlayType = vsType.BackPlayType;
                if (!backPlayType.Equals(""))
                {
                    newVSConfig.Type     = backPlayType;
                    newVSConfig.FileName = "";
                }
            }
            return(newVSConfig);
        }
コード例 #4
0
ファイル: VideoSourceManager.cs プロジェクト: ewin66/Monitor
 public IVideoSource Open(IVideoSourceConfig config, IntPtr hWnd)
 {
     if (config != null)
     {
         IVideoSourceType type = mSystemContext.VideoSourceTypeManager.GetConfig(config.Type);
         if (type != null)
         {
             return(Open(config, type, hWnd));
         }
     }
     return(null);
 }
コード例 #5
0
ファイル: VideoSourceManager.cs プロジェクト: ewin66/Monitor
        public IVideoSource Open(IVideoSourceConfig config, IVideoSourceType type, IntPtr hWnd)
        {
            if (config != null && config.Enabled)
            {
                IVideoSource vs = GetVideoSource(config.Name);
                if (vs == null)
                {
                    IVideoSourceFactory vsFactory = GetVideoSourceFactory(type);
                    if (vsFactory != null)
                    {
                        vs = vsFactory.CreateVideoSource(config, hWnd);
                        if (vs != null)
                        {
                            lock (mVideoSources.SyncRoot)
                            {
                                if (vs.Open(null))
                                {
                                    vs.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged);
                                    vs.OnRecordProgress    += new RECORD_PROGRESS(DoRecordProgress);
                                    (vs as IKernelVideoSource).OnKernelStatus += new KERNELSTATUS_CHANGED(DoKernelStatus);

                                    mVideoSources.Add(vs.Name, vs);

                                    vs.RefreshState();
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (hWnd != IntPtr.Zero)
                    {
                        vs.HWnd = hWnd;
                    }

                    if (!vs.IsOpen)
                    {
                        vs.Open(null);
                    }
                }
                return(vs);
            }
            return(null);
        }
コード例 #6
0
        public void ShowAddDialog(IConfigManager <IVideoSourceType> manager)
        {
            Text     = "新增视频源类型";
            mIsOk    = false;
            mConfig  = null;
            mManager = manager;

            if (mManager.SystemContext.MonitorSystem.Verify(manager.TypeName, "视频源", (ushort)ACOpts.Manager_Add, false))
            {
                InitBackPlayTypeList(manager.SystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
コード例 #7
0
        public override void ShowEditDialog(IConfig config)
        {
            Text     = "编辑视频源类型 - [" + config.Name + "]";
            mIsOk    = false;
            mManager = null;
            mConfig  = config as IVideoSourceType;

            if (config.Verify(ACOpts.Manager_Modify, false))
            {
                InitBackPlayTypeList(mConfig.SystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
コード例 #8
0
ファイル: FormHKRealVSConfig.cs プロジェクト: ewin66/Monitor
        public override void ShowAddDialog(IConfigType type, IConfigManager manager)
        {
            Text     = "新增" + (type != null ? type.Desc : "视频源");
            mIsOk    = false;
            mManager = manager as IConfigManager <IVideoSourceConfig>;
            mType    = type as IVideoSourceType;
            mConfig  = null;

            if (type.Verify(ACOpts.Manager_Add, false))
            {
                InitTypeList(mManager.SystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
コード例 #9
0
ファイル: FormHKRealVSConfig.cs プロジェクト: ewin66/Monitor
        public void ShowAddDialog(IVideoSourceType type)
        {
            Text     = "新增" + (type != null ? type.Desc : "视频源");
            mIsOk    = false;
            mManager = type.SystemContext.VideoSourceConfigManager;
            mType    = type;
            mConfig  = null;

            if (type.Verify(ACOpts.Manager_Add, false))
            {
                InitTypeList(mManager.SystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
コード例 #10
0
ファイル: VideoSourceManager.cs プロジェクト: ewin66/Monitor
        public IVideoSourceFactory GetVideoSourceFactory(IVideoSourceType type)
        {
            if (type != null && type.Enabled)
            {
                string key = type.FileName + "_" + type.FactoryClass;

                lock (mVideoSourceFactorys.SyncRoot)
                {
                    CVideoSourceFactory vsFactory = mVideoSourceFactorys[key] as CVideoSourceFactory;
                    if (vsFactory == null)
                    {
                        try
                        {
                            if (!type.FactoryClass.Equals(""))
                            {
                                if (!type.FileName.Equals(""))
                                {
                                    vsFactory = CommonUtil.CreateInstance(SystemContext, type.FileName, type.FactoryClass) as CVideoSourceFactory;
                                }
                                else
                                {
                                    vsFactory = CommonUtil.CreateInstance(type.FactoryClass) as CVideoSourceFactory;
                                }
                            }

                            if (vsFactory != null && vsFactory.Init(this, type))
                            {
                                mVideoSourceFactorys.Add(key, vsFactory);
                            }
                        }
                        catch (Exception e)
                        {
                            CLocalSystem.WriteLog("Error", string.Format("创建({0})视频源工厂失败:{1}", type, e));

                            throw e;
                        }
                    }
                    return(vsFactory);
                }
            }
            return(null);
        }
コード例 #11
0
        public bool OpenVideoSource(IVideoSourceConfig config)
        {
            if (config != null)
            {
                IVideoSourceType vsType = config.SystemContext.GetVideoSourceType(config.Type);

                if (vsType != null)
                {
                    StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                    sb.Append(config.Name + "<VideoSource>");
                    sb.Append("Open<Command>");
                    sb.Append(vsType.ToXml() + "<Type>");
                    sb.Append(config.ToXml() + "<Config>");

                    IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                }
            }
            return(false);
        }
コード例 #12
0
        protected bool SetConfig()
        {
            if (mConfig == null && mManager != null)
            {
                mConfig = mManager.CreateConfigInstance();
            }

            if (mConfig != null)
            {
                (mConfig as CConfig).Name = textBox_name.Text;
                mConfig.SetValue("Name", textBox_name.Text);

                mConfig.Desc            = textBox_desc.Text;
                mConfig.FactoryClass    = textBox_factoryClass.Text;
                mConfig.ConfigFormClass = textBox_formClass.Text;
                mConfig.FileName        = textBox_fileName.Text;
                mConfig.BackPlayType    = CtrlUtil.GetComboBoxText(comboBox_backPlayType);
                mConfig.Enabled         = checkBox_enabled.Checked;

                return(true);
            }
            return(false);
        }
コード例 #13
0
        public bool InitMonitor(IMonitorConfig config)
        {
            IVisionMonitorConfig vmConfig = config as IVisionMonitorConfig;

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

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

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

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

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

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

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

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

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

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
                else
                {
                    return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                }
            }
            return(false);
        }
コード例 #14
0
        public I CreateConfigInstance(string type, string name)
        {
            if (!type.Equals(""))
            {
                if (TypeName.Equals("Actions"))
                {
                    IActionType actionType = SystemContext.ActionTypeManager.GetConfig(type);
                    if (actionType != null)
                    {
                        return(CreateConfigInstance(actionType, name));
                    }
                }
                else if (TypeName.Equals("Schedulers"))
                {
                    ISchedulerType schedulerType = SystemContext.SchedulerTypeManager.GetConfig(type);
                    if (schedulerType != null)
                    {
                        return(CreateConfigInstance(schedulerType, name));
                    }
                }
                else if (TypeName.Equals("Tasks"))
                {
                    ITaskType taskType = SystemContext.TaskTypeManager.GetConfig(type);
                    if (taskType != null)
                    {
                        return(CreateConfigInstance(taskType, name));
                    }
                }
                else if (TypeName.Equals("Monitors"))
                {
                    IMonitorType monitorType = SystemContext.MonitorTypeManager.GetConfig(type);
                    if (monitorType != null)
                    {
                        return(CreateConfigInstance(monitorType, name));
                    }
                }
                else if (TypeName.Equals("VideoSources"))
                {
                    IVideoSourceType vsType = SystemContext.VideoSourceTypeManager.GetConfig(type);
                    if (vsType != null)
                    {
                        return(CreateConfigInstance(vsType, name));
                    }
                }
            }

            IConfig config = CreateConfigInstance();

            if (config != null)
            {
                if (name != null)
                {
                    ((CConfig)config).Name = name;
                }

                ITypeConfig tc = config as ITypeConfig;
                if (tc != null)
                {
                    tc.Type = type;
                }
            }

            return((I)config);
        }
コード例 #15
0
        public bool Playback()
        {
            if (mBackPlayVS != null && mBackPlayVS.IsOpen)
            {
                mBackPlayVS.SystemContext.VideoSourceManager.Close(mBackPlayVS.Name);
            }
            else if (mCurIndex >= 0 && mCurIndex < Count)
            {
                IVisionMonitorAlarm visionAlarm = Goto(mCurIndex) as IVisionMonitorAlarm;
                if (visionAlarm != null)
                {
                    IVisionMonitor monitor = visionAlarm.Monitor as IVisionMonitor;
                    if (monitor != null)
                    {
                        IVisionMonitorConfig config = monitor.Config as IVisionMonitorConfig;
                        if (config != null)
                        {
                            IVideoSourceConfig vsConfig = monitor.SystemContext.VideoSourceConfigManager.GetConfig(config.VisionParamConfig.VSName);
                            if (vsConfig != null)
                            {
                                if (!vsConfig.IsRecord)
                                {
                                    IVideoSourceType vsType = vsConfig.SystemContext.VideoSourceTypeManager.GetConfig(vsConfig.Type);
                                    if (vsType != null)
                                    {
                                        string backPlayType = vsType.BackPlayType;

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

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

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

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

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

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

                    if (!visionAlarm.IsRecord && !visionAlarm.IsPlay)
                    {
                        return(visionAlarm.PlayAlarmRecord(HWnd));
                    }
                }
            }
            return(false);
        }
コード例 #16
0
ファイル: RemoteConfigManager.cs プロジェクト: ewin66/Monitor
        public static void AddRemoteConfig(IMonitorSystemContext context, string name, string data, bool saveConfig)
        {
            IConfig config = null;

            if (data.StartsWith("<Monitor>"))
            {
                config = context.MonitorConfigManager.GetConfig(name);
                if (config == null)
                {
                    IMonitorConfig monitorConfig = context.MonitorConfigManager.BuildConfigFromXml(data) as IMonitorConfig;
                    if (monitorConfig != null)
                    {
                        context.MonitorConfigManager.Append(monitorConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<MonitorType>"))
            {
                config = context.MonitorTypeManager.GetConfig(name);
                if (config == null)
                {
                    IMonitorType monitorType = context.MonitorTypeManager.BuildConfigFromXml(data) as IMonitorType;
                    if (monitorType != null)
                    {
                        context.MonitorTypeManager.Append(monitorType, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<VideoSource>"))
            {
                config = context.VideoSourceConfigManager.GetConfig(name);
                if (config == null)
                {
                    IVideoSourceConfig vsConfig = context.VideoSourceConfigManager.BuildConfigFromXml(data) as IVideoSourceConfig;
                    if (vsConfig != null)
                    {
                        context.VideoSourceConfigManager.Append(vsConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<VideoSourceType>"))
            {
                config = context.VideoSourceTypeManager.GetConfig(name);
                if (config == null)
                {
                    IVideoSourceType vsType = context.VideoSourceTypeManager.BuildConfigFromXml(data) as IVideoSourceType;
                    if (vsType != null)
                    {
                        context.VideoSourceTypeManager.Append(vsType, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<Action>"))
            {
                config = context.ActionConfigManager.GetConfig(name);
                if (config == null)
                {
                    IActionConfig actionConfig = context.ActionConfigManager.BuildConfigFromXml(data) as IActionConfig;
                    if (actionConfig != null)
                    {
                        context.ActionConfigManager.Append(actionConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<ActionType>"))
            {
                config = context.ActionTypeManager.GetConfig(name);
                if (config == null)
                {
                    IActionType actionType = context.ActionTypeManager.BuildConfigFromXml(data) as IActionType;
                    if (actionType != null)
                    {
                        context.ActionTypeManager.Append(actionType, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<Scheduler>"))
            {
                config = context.SchedulerConfigManager.GetConfig(name);
                if (config == null)
                {
                    ISchedulerConfig schedulerConfig = context.SchedulerConfigManager.BuildConfigFromXml(data) as ISchedulerConfig;
                    if (schedulerConfig != null)
                    {
                        context.SchedulerConfigManager.Append(schedulerConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<SchedulerType>"))
            {
                config = context.SchedulerTypeManager.GetConfig(name);
                if (config == null)
                {
                    ISchedulerType schedulerType = context.SchedulerTypeManager.BuildConfigFromXml(data) as ISchedulerType;
                    if (schedulerType != null)
                    {
                        context.SchedulerTypeManager.Append(schedulerType, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<Task>"))
            {
                config = context.TaskConfigManager.GetConfig(name);
                if (config == null)
                {
                    ITaskConfig taskConfig = context.TaskConfigManager.BuildConfigFromXml(data) as ITaskConfig;
                    if (taskConfig != null)
                    {
                        context.TaskConfigManager.Append(taskConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<TaskType>"))
            {
                config = context.TaskTypeManager.GetConfig(name);
                if (config == null)
                {
                    ITaskType taskType = context.TaskTypeManager.BuildConfigFromXml(data) as ITaskType;
                    if (taskType != null)
                    {
                        context.TaskTypeManager.Append(taskType, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<RemoteSystem>"))
            {
                config = context.RemoteSystemConfigManager.GetConfig(name);
                if (config == null)
                {
                    IRemoteSystemConfig rsConfig = context.RemoteSystemConfigManager.BuildConfigFromXml(data) as IRemoteSystemConfig;
                    if (rsConfig != null)
                    {
                        context.RemoteSystemConfigManager.Append(rsConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<Role>"))
            {
                config = context.RoleConfigManager.GetConfig(name);
                if (config == null)
                {
                    IRoleConfig roleConfig = context.RoleConfigManager.BuildConfigFromXml(data) as IRoleConfig;
                    if (roleConfig != null)
                    {
                        context.RoleConfigManager.Append(roleConfig, saveConfig);
                    }
                }
            }
            else if (data.StartsWith("<User>"))
            {
                config = context.UserConfigManager.GetConfig(name);
                if (config == null)
                {
                    IUserConfig userConfig = context.UserConfigManager.BuildConfigFromXml(data) as IUserConfig;
                    if (userConfig != null)
                    {
                        context.UserConfigManager.Append(userConfig, saveConfig);
                    }
                }
            }
        }