Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            #region 变量定义
            run = DateTime.Now;

            #endregion

            #region 初始化参数配置
            EvenAddPara();
            //读工站配置
            ConfigToolMgr.GetInstance().ReadStationConfig();
            //读取用户设置
            ConfigToolMgr.GetInstance().ReadUserConfig();
            ConfigToolMgr.GetInstance().ReadUserParam();

            //读取产品文件
            ConfigToolMgr.GetInstance().ReadProductDir_Name();

            //添加工位
            UserConfig.AddStation();
            //读取工站位置坐标
            Dictionary <string, PointInfo> dicPonit = new Dictionary <string, PointInfo>();
            foreach (var tem in StationMgr.GetInstance().GetAllStationName())
            {
                ConfigToolMgr.GetInstance().ReadPoint(tem, out dicPonit);
                StationMgr.GetInstance().GetStation(tem).SetStationPointDic(dicPonit);
            }
            GlobalVariable.g_StationState = StationState.StationStateStop;
            UserTest.algType = ParamSetMgr.GetInstance().GetStringParam("算法类型");

            #endregion


            #region 初始化硬件
            EvenAddHardware();
            ConfigToolMgr.GetInstance().ReadEthConfig();
            ConfigToolMgr.GetInstance().ReadComConfig();
            //读硬件配置 并创建IO,Motion 卡类 对象 并以默认参数配置卡
            ConfigToolMgr.GetInstance().ReadMotionCardConfig();
            ConfigToolMgr.GetInstance().ReadIoCardConfig();
            ConfigToolMgr.GetInstance().ReadIoInputConfig();
            ConfigToolMgr.GetInstance().ReadIoOutputConfig();

            //读运动配置
            ConfigToolMgr.GetInstance().ReadMoveParamConfig();
            ConfigToolMgr.GetInstance().ReadHomeParamConfig();

            //初始化IO  Motion
            if (!IOMgr.GetInstace().initAllIoCard())
            {
                MessageBox.Show("初始化IO卡失败");
                return;
            }
            if (!MotionMgr.GetInstace().OpenAllCard())
            {
                MessageBox.Show("初始化控制卡失败");
                return;
            }

            #endregion
            #region 初始化界面加载
            Ver.Text = "软件版本:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString("1.yyyy.MMdd.HHmm");
            //界面加载初始化
            this.WindowState = FormWindowState.Maximized;
            int BtnHeight = button_stop.Height + 10;
            panel_window.Location = new System.Drawing.Point(0, BtnHeight);
            panel_window.Size     = new Size(this.Width - 30, this.Height - BtnHeight - 1);
            Form_Auto autoform = new Form_Auto();
            m_dicAllWindows.Add(button_Home, autoform);
            m_dicAllWindows.Add(button_Set, new Form_Set());
            m_dicAllWindows.Add(button_vision, new Form_VisionDebug());
            m_dicAllWindows.Add(button_Param, new Form_ParamSet());
            m_dicAllWindows.Add(button_UserSMgr, new UserManger());
            m_currentForm     = autoform;
            autoform.TopLevel = false;
            autoform.Dock     = DockStyle.Fill;
            autoform.Parent   = this.panel_window;
            autoform.Show();
            //初始化登入权限
            User user  = new User();
            int  index = sys.g_listUser.FindIndex(t => t._userName == "admin");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.超级管理员
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "user");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.客户操作员
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "debug");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.调试工程师
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "engineer");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.软件工程师
                };
                sys.g_listUser.Add(user);
            }
            #endregion
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //读取网口串口配置
            ParamSetMgr.GetInstance().SetBoolParam("启用安全门", true);
            ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true);

            ConfigToolMgr.GetInstance().ReadEthConfig();
            ConfigToolMgr.GetInstance().ReadComConfig();
            //读硬件配置 并创建IO,Motion 卡类 对象 并以默认参数配置卡
            ConfigToolMgr.GetInstance().ReadMotionCardConfig();
            ConfigToolMgr.GetInstance().ReadIoCardConfig();
            ConfigToolMgr.GetInstance().ReadIoInputConfig();
            ConfigToolMgr.GetInstance().ReadIoOutputConfig();

            //读工站配置
            ConfigToolMgr.GetInstance().ReadStationConfig();

            //读取用户设置
            ConfigToolMgr.GetInstance().ReadUserConfig();
            //读取产品文件
            ConfigToolMgr.GetInstance().ReadProductDir_Name();
            //读运动配置
            ConfigToolMgr.GetInstance().ReadMoveParamConfig();
            ConfigToolMgr.GetInstance().ReadHomeParamConfig();
            ConfigToolMgr.GetInstance().ReadUserParam();

            //视觉x文件路径初始化
            VisionMgr.GetInstance().CurrentVisionProcessDir = ParamSetMgr.GetInstance().CurrentWorkDir + "\\" + ParamSetMgr.GetInstance().CurrentProductFile + "\\" + @"Config\Vision\";
            string str = VisionMgr.GetInstance().CurrentVisionProcessDir;

            //初始化 Motion IO
            MotionMgr.GetInstace().OpenAllCard();
            IOMgr.GetInstace().initAllIoCard();

            //AA参数加载

            UserConfig.BandEventOnForm1(this);

            this.WindowState = FormWindowState.Maximized;
            int BtnHeight = button_stop.Height + 10;

            panel_window.Location = new System.Drawing.Point(0, BtnHeight);

            panel_window.Size = new Size(this.Width - 30, this.Height - BtnHeight - 1);
            Form_Auto autoform = new Form_Auto();

            m_dicAllWindows.Add(button_Home, autoform);
            m_dicAllWindows.Add(button_Set, new Form_Set());
            m_dicAllWindows.Add(button_vision, new Form_VisionDebug());
            m_dicAllWindows.Add(button_Param, new Form_ParamSet());
            m_dicAllWindows.Add(button_UserSMgr, new UserManger());
            m_currentForm = autoform;

            UserConfig.AddStation();
            //读取工站位置坐标
            Dictionary <string, PointInfo> dicPonit = new Dictionary <string, PointInfo>();

            foreach (var tem in StationMgr.GetInstance().GetAllStationName())
            {
                ConfigToolMgr.GetInstance().ReadPoint(tem, out dicPonit);
                StationMgr.GetInstance().GetStation(tem).SetStationPointDic(dicPonit);
            }
            // 注册安全函数
            UserConfig.AddIoSafeOperate();
            UserConfig.AddAxisSafeOperate();

            //初始化 工站状态
            GlobalVariable.g_StationState = StationState.StationStateStop;
            IOMgr.GetInstace().m_deltgateSystemSingl += ProcessSysIo;
            MotionMgr.GetInstace().m_eventAxisSingl  += ProcessSysIo;
            autoform.TopLevel = false;
            autoform.Dock     = DockStyle.Fill;
            autoform.Parent   = this.panel_window;
            autoform.Show();

            //初始化权限
            sys.g_eventRightChanged += ChangedUserRight;
            User user  = new User();
            int  index = sys.g_listUser.FindIndex(t => t._userName == "admin");

            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.超级管理员
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "user");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.客户操作员
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "debug");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.调试工程师
                };
                sys.g_listUser.Add(user);
            }
            index = sys.g_listUser.FindIndex(t => t._userName == "engineer");
            if (index == -1)
            {
                user = new User()
                {
                    _userName = "******", _userPassWord = "******", _userRight = UserRight.软件工程师
                };
                sys.g_listUser.Add(user);
            }
            GlobalVariable.g_eventStationStateChanged += StationStateChangedHandler;
        }