private void button_AddUser_Click(object sender, EventArgs e) { if (textBox_UserName.Text == "" || textBox_PassWord.Text == "") { AlarmMgr.GetIntance().Warn("用户名和密码不能为空 "); return; } string str = ((UserRight)comboBox_SelRight.SelectedIndex).ToString(); int userIndex = sys.g_listUser.FindIndex(t => t._userName == textBox_UserName.Text); if (userIndex != -1) { AlarmMgr.GetIntance().Warn("用户名已存在 "); return; } dataGridView_UserList.Rows.Add(textBox_UserName.Text, str); sys.g_listUser.Add(new User() { _userName = textBox_UserName.Text, _userPassWord = textBox_PassWord.Text, _userRight = (UserRight)comboBox_SelRight.SelectedIndex }); ConfigToolMgr.GetInstance().SaveUserConfig(); }
private void button_DelUser_Click(object sender, EventArgs e) { if (dataGridView_UserList.SelectedRows.Count > 0) { /* DataGridViewSelectedRowCollection r0 =*/ bool bDel = false; string str = dataGridView_UserList.SelectedRows[0].Cells[0].Value.ToString(); User delobj = new User(); foreach (var temp in sys.g_listUser) { if (temp._userName == str) { delobj = temp; bDel = true; } } DataGridViewRow row = dataGridView_UserList.SelectedRows[0]; dataGridView_UserList.Rows.Remove(row); if (bDel) { sys.g_listUser.Remove(delobj); ConfigToolMgr.GetInstance().SaveUserConfig(); } } }
private void LoadProductFile(string strFile) { if (InvokeRequired) { this.BeginInvoke(new Action(() => LoadProductFile(strFile))); } else { label_CurrentFile.Text = "当前产品:" + strFile; //读取工站位置坐标 ConfigToolMgr.GetInstance().UpdatePointFilePath(); 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); } ConfigToolMgr.GetInstance().UpdataMoveparamconfigPath(); ConfigToolMgr.GetInstance().ReadMoveParamConfig(); ConfigToolMgr.GetInstance().ReadHomeParamConfig(); VisionMgr.GetInstance().CurrentVisionProcessDir = ParamSetMgr.GetInstance().CurrentWorkDir + "\\" + ParamSetMgr.GetInstance().CurrentProductFile + "\\" + @"Config\Vision\"; VisionMgr.GetInstance().Read(); ParamSetMgr.GetInstance().m_eventLoadProductFileUpadata?.Invoke(); //VisionMgr.GetInstance().PrItemChangedEvent GC.Collect(); } }
private APP() { MotionMgr = MotionMgr.GetInstace(); IOMgr = IOMgr.GetInstace(); AlarmMgr = AlarmMgr.GetIntance(); ConfigToolMgr = ConfigToolMgr.GetInstance(); StationMgr = StationMgr.GetInstance(); ParamSetMgr = ParamSetMgr.GetInstance(); ComMgr = ComMgr.GetInstance(); TcpMgr = TcpMgr.GetInstance(); SocketSeverMgr = SocketSeverMgr.GetInstace(); }
private void SaveMotorParam_Click(object sender, EventArgs e) { if (!Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile) || ParamSetMgr.GetInstance().CurrentProductFile == null || ParamSetMgr.GetInstance().CurrentProductFile == "") { MessageBox.Show("当前产品文件夹不存在,请创建载入或者创建当前产品", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TMovePrm prm = new TMovePrm(); THomePrm homePrm = new THomePrm(); int indexCell = 0; for (int index = 0; index < dataGridView_AxisParamSet.RowCount; index++) { int nAxisNo = Convert.ToInt32(dataGridView_AxisParamSet.Rows[index].Cells[0].Value); prm.VelH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[3].Value); prm.AccH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[4].Value); prm.DccH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[5].Value); prm.VelM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[6].Value); prm.AccM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[7].Value); prm.DccM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[8].Value); prm.VelL = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[9].Value); prm.AccL = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[10].Value); prm.DccL = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[11].Value); prm.PlusePerRote = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[12].Value); prm.AxisLeadRange = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[13].Value); MotionMgr.GetInstace().SetAxisMoveParam(nAxisNo, prm); MotionMgr.GetInstace().SetAxisName(nAxisNo, dataGridView_AxisParamSet.Rows[index].Cells[1].Value == null ? "NoNamedAxis" : dataGridView_AxisParamSet.Rows[index].Cells[1].Value.ToString()); string strAxisType = dataGridView_AxisParamSet.Rows[index].Cells[2].Value == null?MotorType.SEVER.ToString() : dataGridView_AxisParamSet.Rows[index].Cells[2].Value.ToString(); MotionMgr.GetInstace().SetMotorType(nAxisNo, (MotorType)Enum.Parse(typeof(MotorType), strAxisType)); indexCell = 2; homePrm._nHomeMode = Convert.ToInt32(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm._bHomeDir = Convert.ToBoolean(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.VelH = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.AccH = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.DccH = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.VelL = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.AccL = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm.DccL = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); homePrm._iSeachOffstPluse = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value); MotionMgr.GetInstace().SetAxisHomeParam(nAxisNo, homePrm); } ConfigToolMgr.GetInstance().SaveMoveParam(); ConfigToolMgr.GetInstance().SaveHomeParam(); }
private void BtnScarnProductDir_Click(object sender, EventArgs e) { FolderDialog openFolder = new FolderDialog(); if (openFolder.DisplayDialog() == DialogResult.OK) { textBox_ProductDir.Text = openFolder.Path.ToString(); ParamSetMgr.GetInstance().CurrentWorkDir = textBox_ProductDir.Text; ConfigToolMgr.GetInstance().SaveProductDir(); } else { textBox_ProductDir.Text = "你没有选择目录"; } }
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 }
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; }
private void roundButtonLoad_Click(object sender, EventArgs e) { if (treeView_ProdutFile.SelectedNode == null) { MessageBox.Show("请选择要载入的文件!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (treeView_ProdutFile.SelectedNode == treeView_ProdutFile.Nodes[0]) { MessageBox.Show("选择错误!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ParamSetMgr.GetInstance().CurrentWorkDir == "") { MessageBox.Show("当前产品目录文件夹为空!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool bFind = Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir); if (!bFind) { MessageBox.Show("当前产品目录文件夹不存在!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ParamSetMgr.GetInstance().CurrentProductFile == treeView_ProdutFile.SelectedNode.Text) { return; } string strOldFile = ParamSetMgr.GetInstance().CurrentProductFile; if (!File.Exists(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + treeView_ProdutFile.SelectedNode.Text + ("\\") + treeView_ProdutFile.SelectedNode.Text + (".xml"))) { return; } if (ParamSetMgr.GetInstance().CurrentProductFile != treeView_ProdutFile.SelectedNode.Text) { ParamSetMgr.GetInstance().CurrentProductFile = treeView_ProdutFile.SelectedNode.Text; } ConfigToolMgr.GetInstance().SaveProductFile(); //删除之前登陆产品文件名 if (treeView_ProdutFile.Nodes.Count > 0 && treeView_ProdutFile.Nodes[0].GetNodeCount(true) > 0) { treeView_ProdutFile.Nodes[0].Nodes[0].Remove(); } treeView_ProdutFile.Nodes[0].Nodes.Add(ParamSetMgr.GetInstance().CurrentProductFile); //删除当前登陆产品文件名 string strNewFile = ParamSetMgr.GetInstance().CurrentProductFile; for (int i = 0; i < treeView_ProdutFile.Nodes[1].Nodes.Count; i++) { if (treeView_ProdutFile.Nodes[1].Nodes[i].Text == strNewFile) { treeView_ProdutFile.Nodes[1].Nodes[i].Collapse(); treeView_ProdutFile.Nodes[1].Nodes.Remove(treeView_ProdutFile.Nodes[1].Nodes[i]); //if (treeView_ProdutFile.Nodes[1].Nodes[i].Nodes.Count > 0) //{ // foreach (TreeNode node in (treeView_ProdutFile.Nodes[1].Nodes[i].Nodes)) // { // DeleteTreeNode2(node); // } //} } } treeView_ProdutFile.Update(); if (treeView_ProdutFile.Nodes[0].FirstNode != null && treeView_ProdutFile.Nodes[0].FirstNode.Name != null && treeView_ProdutFile.Nodes[0].FirstNode.Text != "") { List <string> classList = ParamSetMgr.GetInstance().GetParamClassList(); foreach (var temp in classList) { treeView_ProdutFile.Nodes[0].Nodes[0].Nodes.Add(temp); } } treeView_ProdutFile.Nodes[0].ExpandAll(); //增加之前登陆产品文件名 treeView_ProdutFile.Nodes[1].Nodes.Add(strOldFile); }