//连接PMAC private void CommunicateToPMAC_Click(object sender, EventArgs e) { PMAC.SelectDevice(0, out pmacNumber, out selectPmacSuccess); //PMAC状态查询 if (selectPmacSuccess) { PMAC.Open(pmacNumber, out openPmacSuccess); if (openPmacSuccess) { DisconnectToPMAC.Enabled = true; gBoxSetAndShow.Enabled = true; gBoxWork.Enabled = true; tmrMotorStatus.Enabled = true; flag_PMAC_Connect = false; tssLab.Text = "PMAC已连接"; getVelocity(); labSetSpeed_X.Text = motorVelocity[0]; labSetSpeed_Y.Text = motorVelocity[2]; labSetSpeed_Z.Text = (float.Parse(motorVelocity[1]) / 10).ToString(); } else { MessageBox.Show("通讯失败,重新连接"); } } else { MessageBox.Show("PMAC连接失败,请检查设备电源及连接线!"); } }
public bool ConectToPMAC() { int dev = m_nDevice; bool bSuccess = false; string str; string type; Pmac.SelectDevice(0, out dev, out bSuccess); if (bSuccess) { m_bDeviceOpen = true; if (m_bDeviceOpen) { Pmac.Close(m_nDevice); } m_nDevice = dev; m_bDPRAvailable = false; m_nDPRBase = 0; m_nDPRSize = 0; Pmac.Open(m_nDevice, out m_bDeviceOpen); if (m_bDeviceOpen) { m_bDPRAvailable = Pmac.get_DPRAvailable(m_nDevice); m_nDPRSize = Pmac.get_DPRSize(m_nDevice); Pmac.DPRAddressRange(m_nDevice, false, false, out m_nDPRBase); m_bTurbo = Pmac.get_IsTurbo(m_nDevice); // m_bFGEnabled = Pmac.get_DPRMotorRptEnabled(m_nDevice); // Setup for this device if (m_bTurbo) { type = "Turbo"; } else { type = "NO Turbo"; } str = string.Format("Device number {0:D} opened successfully." + type, m_nDevice); } else { // Disable all required str = string.Format("Device number {0:D} failed to open.", m_nDevice); } m_PMAC_msg = str; } return(bSuccess); }
//与PMAC建立通讯 private void communicatePmac_Click(object sender, EventArgs e) { PMAC.SelectDevice(0, out pmacNumber, out communicatePmacSuccess); if (communicatePmacSuccess) { PMAC.Open(pmacNumber, out openPmacSuccess); if (openPmacSuccess) { PmacStatus.Text = "PMAC已连接"; communicatePmac.Enabled = false; ExitPmac.Enabled = true; } } }
private void CommunicateToPMAC() { PMAC.SelectDevice(0, out pmacNumber, out selectPmacSuccess); //PMAC状态查询 if (selectPmacSuccess) { PMAC.Open(pmacNumber, out openPmacSuccess); if (openPmacSuccess) { MessageBox.Show("连接成功!"); flag_PMAC_Connect = false; } else { MessageBox.Show("通讯失败,重新连接"); } } else { MessageBox.Show("PMAC连接失败,请检查设备电源及连接线!"); } }
//与PMAC建立通讯 private void comunicateTSMI_Click(object sender, EventArgs e) { PMAC.SelectDevice(0, out pmacNumber, out selectPmacSuccess); if (selectPmacSuccess) { PMAC.Open(pmacNumber, out openPmacSuccess); if (openPmacSuccess) { labPmacStatus.Text = "PMAC已连接"; comunicateTSMI.Enabled = false; ExitPmac.Enabled = true; groupBox1.Enabled = true; groupBox2.Enabled = true; groupBox3.Enabled = true; groupBox4.Enabled = true; btnStart.Enabled = false; btnStop.Enabled = true; MessageBox.Show("初始速度可能很高,请记得设定速度!"); txtSetV.BackColor = Color.Red; } } }