private void PoseDifference_Load(object sender, EventArgs e) { FilesINI ConfigController = new FilesINI(); CurrentIP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); Control_Port = ConfigController.INIRead("UR控制参数", "RemoteControlPort", DefaultINIPath);; URRegisterHandle.RemoteIP = CurrentIP; URRegisterHandle.RemotePort = 502; URRegisterHandle.SocketTimeOut = 1000; RefPos1 = ConfigController.INIRead("UR运动参数", "BasePos1", DefaultINIPath); RefPos2 = ConfigController.INIRead("UR运动参数", "BasePos2", DefaultINIPath); RefPos3 = ConfigController.INIRead("UR运动参数", "BasePos3", DefaultINIPath); txtPose1.Text = RefPos1; txtPose2.Text = RefPos2; txtPose3.Text = RefPos3; HomeVector = RefPos1; //尝试连接,如果不能连接,则某些按钮不可用 try { URController.Creat_client(CurrentIP, Convert.ToInt32(Control_Port)); ifConnected = true; } catch { ifConnected = false; MessageBox.Show("未连接UR,某些功能不可用"); } }
private void Teach_Load(object sender, EventArgs e) { FilesINI ConfigController = new FilesINI(); string Target_IP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); string Control_Port = ConfigController.INIRead("UR控制参数", "RemoteControlPort", DefaultINIPath);; URController.Creat_client(Target_IP, Convert.ToInt32(Control_Port)); //MessageBox.Show(Target_IP + "|" + Control_Port); }
private void Register_Load(object sender, EventArgs e) { //读取配置文件的IP FilesINI ConfigController = new FilesINI(); string CurrentIP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); URRegisterHandle.RemoteIP = CurrentIP; URRegisterHandle.RemotePort = 502; URRegisterHandle.SocketTimeOut = 1000; URRegisterHandle.connectServer(); }
//加载一个INI文件,加载之后直接读取所有配置并在界面上显示 public void LoadINI(string FilePath) { try { Remote_IP.Text = ConfigController.INIRead("UR控制参数", "RemoteIP", FilePath); Control_Port.Text = ConfigController.INIRead("UR控制参数", "RemoteControlPort", FilePath); Basic_Speed.Text = ConfigController.INIRead("UR运动参数", "BasicSpeed", FilePath); Basic_Acceleration.Text = ConfigController.INIRead("UR运动参数", "BasicAcceleration", FilePath); Data_RefreshRate.Text = ConfigController.INIRead("UR运动参数", "BasicRefreshRate", FilePath); string AutoConnection = ConfigController.INIRead("UR控制参数", "IfAutoConnect", FilePath); if (AutoConnection == "YES") { AutoConnect.Checked = true; } else { AutoConnect.Checked = false; } } catch (Exception LoadError) { MessageBox.Show("配置文件异常,请重置"); } }
private void Register_Load(object sender, EventArgs e) { //读取配置文件的IP FilesINI ConfigController = new FilesINI(); string CurrentIP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); URRegisterHandle.RemoteIP = CurrentIP; URRegisterHandle.RemotePort = 502; URRegisterHandle.SocketTimeOut = 1000; //同样只是初始化的时候执行一次,由于是传统的读写寄存器,不需要保持连接,也就不需要实时的initialServer //URRegisterHandle.initialServer(); }
private void Dashboard_Load(object sender, EventArgs e) { FilesINI ConfigController = new FilesINI(); string Target_IP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); int Control_Port = 29999; //创建Dashboard客户端 URController.Creat_client(Target_IP, Control_Port); //一开始连接到UR之后UR会主动发过来一条信息 string Feedback = URController.No_command_WaitFeedback(); txtFeedback.Items.Add(Feedback); //设置这个Combobox UserRoleBox.Items.Add("程序员"); UserRoleBox.Items.Add("操作员"); UserRoleBox.Items.Add("完全锁定"); }
private void CameraCalibration_Load(object sender, EventArgs e) { CurrentIP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath); Control_Port = ConfigController.INIRead("UR控制参数", "RemoteControlPort", DefaultINIPath); //读取拍照位置的各项参数 CurrentPosStr = ConfigController.INIRead("UR运动参数", "BaseSnapPos", DefaultINIPath); txtCurrentSnapPos.Text = CurrentPosStr; //读取三个基准位置 PosInt1[0] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeX_Camera", DefaultINIPath)); PosInt1[1] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeY_Camera", DefaultINIPath)); PosInt1[2] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeZ_Camera", DefaultINIPath)); PosInt1[3] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeU_Camera", DefaultINIPath)); PosInt1[4] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeV_Camera", DefaultINIPath)); PosInt1[5] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeW_Camera", DefaultINIPath)); PosInt2[0] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeX_A_Camera", DefaultINIPath)); PosInt2[1] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeY_A_Camera", DefaultINIPath)); PosInt2[2] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeZ_A_Camera", DefaultINIPath)); PosInt2[3] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeU_A_Camera", DefaultINIPath)); PosInt2[4] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeV_A_Camera", DefaultINIPath)); PosInt2[5] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeW_A_Camera", DefaultINIPath)); PosInt3[0] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeX_B_Camera", DefaultINIPath)); PosInt3[1] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeY_B_Camera", DefaultINIPath)); PosInt3[2] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeZ_B_Camera", DefaultINIPath)); PosInt3[3] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeU_B_Camera", DefaultINIPath)); PosInt3[4] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeV_B_Camera", DefaultINIPath)); PosInt3[5] = Convert.ToDouble(ConfigController.INIRead("UR运动参数", "HomeW_B_Camera", DefaultINIPath)); //计算OA和OB的长度(空间两点的距离公式) double OALength = Math.Sqrt(Math.Pow((PosInt1[0] - PosInt2[0]), 2) + Math.Pow((PosInt1[1] - PosInt2[1]), 2) + Math.Pow((PosInt1[2] - PosInt2[2]), 2)); double OBLength = Math.Sqrt(Math.Pow((PosInt1[0] - PosInt3[0]), 2) + Math.Pow((PosInt1[1] - PosInt3[1]), 2) + Math.Pow((PosInt1[2] - PosInt3[2]), 2)); CurrentActiveOA[0] = ((PosInt2[0] - PosInt1[0]) / OALength); CurrentActiveOA[1] = ((PosInt2[1] - PosInt1[1]) / OALength); CurrentActiveOA[2] = ((PosInt2[2] - PosInt1[2]) / OALength); CurrentActiveOA[3] = ((PosInt2[3] - PosInt1[3]) / OALength); CurrentActiveOA[4] = ((PosInt2[4] - PosInt1[4]) / OALength); CurrentActiveOA[5] = ((PosInt2[5] - PosInt1[5]) / OALength); CurrentActiveOB[0] = ((PosInt3[0] - PosInt1[0]) / OBLength); CurrentActiveOB[1] = ((PosInt3[1] - PosInt1[1]) / OBLength); CurrentActiveOB[2] = ((PosInt3[2] - PosInt1[2]) / OBLength); CurrentActiveOB[3] = ((PosInt3[3] - PosInt1[3]) / OBLength); CurrentActiveOB[4] = ((PosInt3[4] - PosInt1[4]) / OBLength); CurrentActiveOB[5] = ((PosInt3[5] - PosInt1[5]) / OBLength); //读取三个特征点的像素值 txt_O_X.Text = ConfigController.INIRead("UR运动参数", "HomeX_Camera_Pixel", DefaultINIPath); txt_O_Y.Text = ConfigController.INIRead("UR运动参数", "HomeY_Camera_Pixel", DefaultINIPath); txt_A_X.Text = ConfigController.INIRead("UR运动参数", "HomeX_A_Camera_Pixel", DefaultINIPath); txt_A_Y.Text = ConfigController.INIRead("UR运动参数", "HomeY_A_Camera_Pixel", DefaultINIPath); txt_B_X.Text = ConfigController.INIRead("UR运动参数", "HomeX_B_Camera_Pixel", DefaultINIPath); txt_B_Y.Text = ConfigController.INIRead("UR运动参数", "HomeY_B_Camera_Pixel", DefaultINIPath); URRegisterHandle.RemoteIP = CurrentIP; URRegisterHandle.RemotePort = 502; URRegisterHandle.SocketTimeOut = 1000; try { URController.Creat_client(CurrentIP, Convert.ToInt32(Control_Port)); ifConnected = true; } catch { ifConnected = false; MessageBox.Show("未连接UR,某些功能不可用"); } //注册HD的委托方法 HD.OnGetMatchPatternSuccess += new HDevelopExport.GetMatchPatternSuccess(UpdateMatchValue); //这里要在线程中处理,否则窗体就卡死了 Thread thread = new Thread(new ThreadStart(threadMethod)); thread.Start(); }