예제 #1
0
        public void SetEditConfig(IConfig config)
        {
            IsChanged = false;

            if (config != null)
            {
                mType          = null;
                mConfig        = config as IMonitorConfig;
                mSystemContext = config.SystemContext;

                if (config.Verify(ACOpts.Manager_Modify, false))
                {
                    SetTabPageShowState(mConfig.SystemContext.MonitorTypeManager.GetConfig(mConfig.Type));

                    InitMonitorTypeList(mSystemContext);
                    InitVSTypeList(mSystemContext);
                    InitVSList(mSystemContext);

                    TabPage curPage = tabControl_monitor.SelectedTab;
                    tabControl_monitor.SelectedTab = tabPage_alertarea;
                    tabControl_monitor.SelectedTab = curPage;

                    InitDialog();
                }
            }
        }
예제 #2
0
        public IMonitor CreateMonitor(IMonitorConfig config, IMonitorType type)
        {
            if (config == null || !config.Enabled)
            {
                return(null);
            }

            lock (mMonitors.SyncRoot)
            {
                CMonitor monitor = mMonitors[config.Name] as CMonitor;
                if (monitor == null)
                {
                    if (type == null)
                    {
                        type = mSystemContext.MonitorTypeManager.GetConfig(config.Type);
                    }

                    if (type != null && type.Enabled && !type.MonitorClass.Equals(""))
                    {
                        if (!type.FileName.Equals(""))
                        {
                            monitor = Utils.CommonUtil.CreateInstance(SystemContext, type.FileName, type.MonitorClass) as CMonitor;
                        }
                        else
                        {
                            monitor = Utils.CommonUtil.CreateInstance(type.MonitorClass) as CMonitor;
                        }
                    }

                    if (monitor != null)
                    {
                        if (monitor.Init(this, config, type))
                        {
                            monitor.OnAlarmPrepProcess    += new MonitorAlarmPrepProcess(DoAlarmPrepProcess);
                            monitor.OnMonitorAlarm        += new MonitorAlarmEvent(DoMonitorAlarm);
                            monitor.OnTransactAlarm       += new TransactAlarm(DoTransactAlarm);
                            monitor.OnMonitorStateChanged += new MonitorStateChanged(DoMonitorStateChanged);

                            mMonitors.Add(monitor.Name, monitor);

                            monitor.RefreshState();
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    monitor.Config = config;
                }
                return(monitor);
            }
        }
예제 #3
0
 public IMonitor CreateMonitor(IMonitorConfig config)
 {
     if (config != null)
     {
         IMonitorType type = mSystemContext.MonitorTypeManager.GetConfig(config.Type);
         return(CreateMonitor(config, type));
     }
     else
     {
         return(null);
     }
 }
예제 #4
0
        public override void ShowEditDialog(IConfig config)
        {
            Text     = "编辑监控类型 - [" + config.Name + "]";
            mIsOk    = false;
            mManager = null;
            mConfig  = config as IMonitorType;

            if (config.Verify(ACOpts.Manager_Modify, false))
            {
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
예제 #5
0
        public void ShowAddDialog(IConfigManager <IMonitorType> manager)
        {
            Text     = "新增监控类型";
            mIsOk    = false;
            mConfig  = null;
            mManager = manager;

            if (mManager.SystemContext.MonitorSystem.Verify(manager.TypeName, "监控应用", (ushort)ACOpts.Manager_Add, false))
            {
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
예제 #6
0
 private void SetTabPageShowState(IMonitorType type)
 {
     //if (mSystemContext != null)
     //{
     //    if (type != null && IsVisionAnalyze(type))
     //    {
     //        panel_vs.Visible = true;
     //    }
     //    else if (type != null && IsVisionMonitor(type))
     //    {
     //        panel_vs.Visible = true;
     //    }
     //    else
     //    {
     //        panel_vs.Visible = false;
     //    }
     //}
 }
예제 #7
0
        public bool Init(IMonitorManager manager, IMonitorConfig config, IMonitorType type)
        {
            mConfig  = config;
            mManager = manager;
            mType    = type;

            if (!IsInit && Verify(ACOpts.Exec_Init))
            {
                mAlarmManager = new CMonitorAlarmManager(this);
                mAlarmManager.AlarmQueueLength   = mManager.SystemContext.AlarmQueueLength;
                mAlarmManager.AlarmCheckInterval = mManager.SystemContext.AlarmCheckInterval;
                mAlarmManager.AutoTransactDelay  = mManager.SystemContext.AlarmAutoTransactDelay;
                mAlarmManager.IsAutoTransact     = false;

                return(InternaInit(true));
            }
            return(false);
        }
예제 #8
0
 private bool IsVisionAnalyze(IMonitorType type)
 {
     if (mSystemContext != null)
     {
         bool value = type.ACEnabled;
         try
         {
             type.ACEnabled = false;
             IMonitorConfig    config       = mSystemContext.MonitorConfigManager.CreateConfigInstance(type);
             IVisionUserConfig visionConfig = config as IVisionUserConfig;
             return(visionConfig != null);
         }
         finally
         {
             type.ACEnabled = value;
         }
     }
     return(false);
 }
예제 #9
0
        public override void ShowEditDialog(IConfig config)
        {
            Text           = "编辑监控应用 - [" + config.Name + "]";
            mIsOk          = false;
            mManager       = null;
            mType          = null;
            mConfig        = config as IMonitorConfig;
            mSystemContext = config.SystemContext;

            if (config.Verify(ACOpts.Manager_Modify, false))
            {
                SetTabPageShowState(mConfig.SystemContext.MonitorTypeManager.GetConfig(mConfig.Type));

                InitTypeList(mSystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
예제 #10
0
        public void ShowAddDialog(IMonitorType type)
        {
            Text           = "新增监控应用";
            mIsOk          = false;
            mManager       = type.SystemContext.MonitorConfigManager;
            mType          = type;
            mConfig        = null;
            mSystemContext = mManager.SystemContext;

            if (type.Verify(ACOpts.Manager_Add, false))
            {
                SetTabPageShowState(mType);

                InitTypeList(mSystemContext);
                if (InitDialog())
                {
                    ShowDialog();
                }
            }
        }
예제 #11
0
 private void SetTabPageShowState(IMonitorType type)
 {
     if (mSystemContext != null)
     {
         if (type != null && IsVisionAnalyze(type))
         {
             tabPage_vision.Parent    = tabControl_monitor;
             tabPage_alertarea.Parent = tabControl_monitor;
         }
         else if (type != null && IsVisionMonitor(type))
         {
             tabPage_vision.Parent    = tabControl_monitor;
             tabPage_alertarea.Parent = null;
         }
         else
         {
             tabPage_vision.Parent    = null;
             tabPage_alertarea.Parent = null;
         }
     }
 }
예제 #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.ConfigClass     = textBox_configClass.Text;
                mConfig.ConfigFormClass = textBox_formClass.Text;
                mConfig.MonitorClass    = textBox_monitorClass.Text;
                mConfig.SetValue("KernelClass", textBox_kernelClass.Text);
                mConfig.FileName = textBox_fileName.Text;
                mConfig.Enabled  = checkBox_enabled.Checked;

                return(true);
            }
            return(false);
        }
예제 #13
0
 public CVisionMonitor(IMonitorManager manager, IMonitorConfig config, IMonitorType type)
     : base(manager, config, type)
 {
 }
예제 #14
0
 public CBlobTracker(IMonitorManager manager, IBlobTrackerConfig config, IMonitorType type)
     : base(manager, config, type)
 {
 }
예제 #15
0
 public CVisionUser(IMonitorManager manager, IVisionUserConfig config, IMonitorType type)
     : base(manager, config, type)
 {
     mSyncVisionUserStatisticCallback = new VisionUserStatisticInfo(SyncVisionUserStatisticCallback);
 }
예제 #16
0
        public CMonitor(IMonitorManager manager, IMonitorConfig config, IMonitorType type)
        {
            mDoMonitorAlarm = DoMonitorAlarm;

            Init(manager, config, type);
        }
예제 #17
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);
        }
예제 #18
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);
        }
예제 #19
0
        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);
                    }
                }
            }
        }