Example #1
0
 private void EvenAddHardware()
 {
     GlobalVariable.g_eventStationStateChanged += StationStateChangedHandler;
     alarmtimer.Elapsed += new System.Timers.ElapsedEventHandler((object senders, ElapsedEventArgs es) =>
     {
         //   if(!bStartAlarmTimer)
         {
             try
             {
                 if (IOMgr.GetInstace().GetOutputDic().ContainsKey("蜂鸣"))
                 {
                     IOMgr.GetInstace().WriteIoBit("蜂鸣", !IOMgr.GetInstace().ReadIoOutBit("蜂鸣"));
                 }
                 bStartAlarmTimer = true;
             }
             catch (Exception ex)
             {
                 return;
             }
         }
     });
     IOMgr.GetInstace().m_deltgateSystemSingl += ProcessSysIo;
     MotionMgr.GetInstace().m_eventAxisSingl  += ProcessSysIo;
     // 注册安全函数
     UserConfig.AddIoSafeOperate();
     UserConfig.AddAxisSafeOperate();
 }
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;
        }