Пример #1
0
 private void MainForm_UserLoggedOut1(BaseClass sender, StateEventArgs e)
 {
     if (_currUser != null)
     {
         ClassCommonSetting.ProgramLog(LogFile.Level.Info, "用户", "注销用户:" + _currUser.Name);
     }
 }
Пример #2
0
        public MainForm() : base("CDI检测机系统", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString())
        {
            InitializeComponent();
            //Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "Main", "Run version: " + Version);
            //初始化硬件
            SplashProcessInfo = "初始化硬件...";
            HardwarePool.SystemHardware.instance.Init();
            HardwarePool.SystemHardware.instance.Open();
            SerialProtocalCollection.instance.ConnectProtocol();
            SplashProcessInfo = "加载参数,打开CDIVision...";
            ClassCommonSetting.CommonInit();
            this.LogOutTime = GetLogOutTime(ClassCommonSetting.SysParam.LogOutTime);

            //初始化工作区域
            SplashProcessInfo = "初始化工作区域...";
            zones             = ClassWorkZones.Instance;
            zones.AllZoneInit();
            SplashProcessInfo = "初始化工作流程...";
            workflow          = ClassWorkFlow.Instance;
            workflow.WorkFlowInit();
            //初始化主界面
            SplashProcessInfo = "初始化界面...";
            auto        = AutoPanel.Instance;
            setting     = new ConfigurationPanel();
            manual      = new ManualOperationPanel();
            product     = new ProductPanel();
            calibration = new CalibrationPanel();
            monitor     = new MonitorPanel();
            AddInterface(PanelType.AutoFace, auto);
            AddInterface(PanelType.SettingFace, setting);
            AddInterface(PanelType.ManualFace, manual);
            AddInterface(PanelType.ProductFace, product);
            AddInterface(PanelType.DebugFace, calibration);
            AddInterface(PanelType.MonitorFace, monitor);
            ClassCommonSetting.SysParam.AddParaInterface(product);
            ClassCommonSetting.SysParam.CurrentProductParam.SetDataToInterface(product);
            ClassCommonSetting.SysParam.CurrentProductParam.AddParaInterface(calibration);

            zones.SPC.AddGUI(auto);
            zones.SPC.AddGUI(monitor);

            //事件挂钩
            CommonFunction.SysPublisher.subscribeMeToSystemEvents(zones);
            CommonFunction.SysPublisher.subscribeMeToSystemEvents(workflow);
            zones.WorkZone外框架.HookErrorEvent();
            auto.HookErrorEvent();
            workflow.TimeUsage.AddTimeUsageGUI(auto);
            zones.AddTimeUsage(auto);
            ClassCommonSetting.SocketToAOI.subscribeMeToResponseEvents(zones.WorkZone尺寸测量);
            HookErrorEvent();
            CommonFunction.SysPublisher.subscribeMeToSystemEvents(this);
            this.UserLoggedIn     += MainForm_UserLoggedIn1;
            this.UserLoggedOut    += MainForm_UserLoggedOut1;
            product.SaveParaEvent += Product_SaveParaEvent;
            //发送事件
            CommonFunction.SysPublisher.notifyProductChangeEventSubscribers(null, new StateEventArgs(ClassCommonSetting.SysParam.CurrentProduct, ""));
        }
Пример #3
0
        public static void ShowError(string source, ErrorInfoWithPause error, ErrorReturnHandler HandleFunc = null)
        {
            if (HandleFunc != null)
            {
                error.ErrorHandle = HandleFunc;
            }
            string src = source;
            //if (isWorkFlowRunning) src = "流程:" + src;
            string err = error.Message;

            AddRetry(source, error);

            if (_errorShowPanel != null)
            {
                switch (error.Level)
                {
                case ErrorLevel.Alarm:
                    if (error.NeedRetry && error.ErrorHandle != null)
                    {
                        err += "。检查并按OK或Retry重试。";
                    }
                    if (isWorkFlowRunning && error.NeedPause)
                    {
                        err += "。流程暂停。";
                        CommonFunction.SysPublisher.notifyPauseEventSubscribers(null, new StateEventArgs("暂停", source + ": " + error.Message));
                    }
                    break;

                case ErrorLevel.Notice:
                    if (isWorkFlowRunning && error.NeedPause)
                    {
                        err += "。流程暂停。";
                        CommonFunction.SysPublisher.notifyPauseEventSubscribers(null, new StateEventArgs("暂停", source + ": " + error.Message));
                    }
                    break;

                case ErrorLevel.Error:
                case ErrorLevel.Fatal:
                    if (isWorkFlowRunning)
                    {
                        err = $"流程出错({error.Message})。流程停止。";
                        ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WorkFlow", "流程因错误停止");
                        BaseStateMachine.NotifyErrorStop(null, null);
                    }
                    break;
                }
                _errPublisher.notifyShowErrorEventSubscribers(src, err, error.Level, ClassCommonSetting.Log, error.NeedRetry, error.ErrorHandle);
                Statistic.ShowErrorHandler(source, error.Message, error.Level, null, error.NeedRetry, error.NeedPause, error.ErrorHandle);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("CDI");
            if (myProcesses.Length > 1)
            //bool flag;
            //Mutex mainMutex = new Mutex(true, "CDIMutex", out flag);
            //if (!flag)
            {
                MessageBox.Show("CDI程序正在运行。如果确认CDI程序已经退出,请检查任务管理器。");
                return;
            }
            //if (args.Length > 0 && args[0] == "/Simulation")
            //    HardwarePool.SystemHardware.instance.IsSimulation = true;

            CommonFunction.DataPath = "d:\\CDI CONFIG\\";
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "Main", "程序启动");
            Application.Run(MainForm.instance);
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "Main", "程序退出");
        }
Пример #5
0
 private void MainForm_UserLoggedIn1(BaseClass sender, StateEventArgs e)
 {
     _currUser = (UserInfo)sender;
     ClassCommonSetting.ProgramLog(LogFile.Level.Info, "用户", "登录用户:" + _currUser.Name + ",权限:" + _currUser.UserLevel);
 }