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 CloseFrom(object sender, FormClosedEventArgs e)
 {
     UserConfig.CloseHardWork();
     System.Environment.Exit(0);
 }
Example #3
0
 public static void BandStationWithCtrl(Form_Auto formauto)
 {
     UserConfig.bandStationAndVisionCtrl("点胶站", formauto.visionControl1, 1);
 }
Example #4
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;
        }
Example #5
0
        private void Form_Auto_Load(object sender, EventArgs e)
        {
            GlobalVariable.g_eventStationStateChanged += StationStateChangedHandler;
            tabControl_Log.Controls.Clear();
            ParamSetMgr.GetInstance().m_eventChangedBoolSysVal   += Form_Auto_m_eventChangedBoolSysVal;
            ParamSetMgr.GetInstance().m_eventChangedDoubleSysVal += Form_Auto_m_eventChangedDoubleSysVal;
            ParamSetMgr.GetInstance().m_eventLoadProductFile     += LoadProductFile;
            label_CurrentFile.Text = "当前产品:" + ParamSetMgr.GetInstance().CurrentProductFile;
            foreach (var tem in StationMgr.GetInstance().GetAllStationName())
            {
                RichTxtBoxLog richTextBox = new RichTxtBoxLog();
                Control       control     = null;
                //ListLog listLog = new ListLog();
                //listLog.ItemHeight = 25;
                //listLog.HorizontalScrollbar = true;
                //listLog.ScrollAlwaysVisible = true;
                //listLog.Size = new Size(tabControl_Log.Size.Width - 20, tabControl_Log.Size.Height - 20);
                //control= (Control)listLog;

                richTextBox.Size       = new Size(tabControl_Log.Size.Width - 30, tabControl_Log.Size.Height - 30);
                richTextBox.ScrollBars = RichTextBoxScrollBars.Both;

                richTextBox.Dock          = System.Windows.Forms.DockStyle.Fill;
                richTextBox.HideSelection = false;
                richTextBox.Location      = new System.Drawing.Point(0, 0);
                richTextBox.Name          = "richTextBox1";
                richTextBox.Size          = new System.Drawing.Size(150, 150);
                richTextBox.TabIndex      = 0;
                richTextBox.Text          = "";
                richTextBox.WordWrap      = false;
                control = richTextBox;
                TabPage tabStaion = new TabPage();
                tabStaion.Name = tem;
                tabStaion.Text = tem;

                tabStaion.Controls.Add((Control)control);
                tabControl_Log.TabPages.Add(tabStaion);

                // StationMgr.GetInstance().GetStation(tem).SetShowListBox(listLog);
                // StationMgr.GetInstance().GetStation(tem).m_eventListBoxShow += ShowStationMsg;
                richTextBox.Multiline = true;

                StationMgr.GetInstance().GetStation(tem).SetShowRichTextBox(richTextBox);
                StationMgr.GetInstance().GetStation(tem).m_eventRichBoxShow += ShowStationMsgOnRichTxtBox;
                ;

                StationMgr.GetInstance().GetStation(tem).Info(tem + $" sd加载成功");
                //for (int i = 0; i < 300; i++)
                //{
                //    StationMgr.GetInstance().GetStation(tem).Info(tem + $"加载成功{i}");
                //    StationMgr.GetInstance().GetStation(tem).Err(tem + $"加载成功err{i}");
                //}
            }

            MachineStateEmg.Name   = "急停";
            MachineStateStop.Name  = "停止";
            MachineStateAuto.Name  = "自动";
            MachineStatePause.Name = "暂停";
            //添加 ------- 标志--------///
            userPanel_Flag.Visible = false;
            UserConfig.AddFlag(this);
            if (m_listFlag.Count > 0)
            {
                userPanel_Flag.Visible = true;
            }
            userPanel_Flag.Update();

            //添加 ------- 标志--------///
            //添加 ------- double param--------///
            AddDoubleRtn("产品计数", 0);
            ParamSetMgr.GetInstance().SetDoubleParam("产品计数", 0);

            AddDoubleRtn("CT", 0);
            ParamSetMgr.GetInstance().SetDoubleParam("CT", 0);

            AddDoubleRtn("UPH", 0);
            ParamSetMgr.GetInstance().SetDoubleParam("UPH", 0);

            UserConfig.InitHalconWindow(this);
            UserConfig.BandStationWithVisionCtr(this);
            UserConfig.InitCam(this);

            //默认用户登陆
            sys.g_User = sys.g_listUser.Find(t => t._userName == "admin");

            UserConfig.InitEpson4Robot();
            UserConfig.InitHardWare();
            UserConfig.CalibDataRead();
            UserConfig.ReadVisionData();
            UserConfig.UpdataTrayData();
            UserConfig.ReadAndUpdatStatisticaldata(this);
        }