private void timer1_Tick(object sender, EventArgs e) { int cmd_pos = 0, enc_pos = 0; uint motion_status = 0, io_status = 0; double cur_vel = 0.0f; CPci9014.p9014_get_motion_status(m_axis, ref motion_status); CPci9014.p9014_get_io_status(m_axis, ref io_status); CPci9014.p9014_get_current_speed(m_axis, ref cur_vel); CPci9014.p9014_get_pos(m_axis, 0, ref cmd_pos); CPci9014.p9014_get_pos(m_axis, 1, ref enc_pos); textBox6.Text = Convert.ToString(cur_vel); textBox7.Text = Convert.ToString(motion_status); textBox8.Text = Convert.ToString(cmd_pos); textBox9.Text = Convert.ToString(enc_pos); //PEL if ((io_status % 2) == 1) { textBox10.Text = "ON"; } else { textBox10.Text = "OFF"; } //MEL if (((io_status >> 1) % 2) == 1) { textBox11.Text = "ON"; } else { textBox11.Text = "OFF"; } //EMG if (((io_status >> 4) % 2) == 1) { textBox12.Text = "OFF"; } else { textBox12.Text = "ON"; } }
public override void GetIOState(PCI9014AxisInfo axinfo) { int cmd_pos = 0, enc_pos = 0; uint motion_status = 0, io_status = 0; double cur_vel = 0.0; CPci9014.p9014_get_motion_status(axinfo.No, ref motion_status); CPci9014.p9014_get_io_status(axinfo.No, ref io_status); CPci9014.p9014_get_current_speed(axinfo.No, ref cur_vel); CPci9014.p9014_get_pos(axinfo.No, 0, ref cmd_pos); //CPci9014.p9014_get_pos(axinfo.No, 1, ref enc_pos); axinfo.isBusy = motion_status == 1 ? (uint)1 : (uint)0; axinfo.fLimit = (io_status % 2) == 1 ? true : false; axinfo.rLimit = ((io_status >> 1) % 2) == 1 ? true : false; axinfo.oRG = ((io_status >> 2) % 2) == 1 ? true : false; //axinfo.Ez = ((io_status >> 3) % 2) == 1 ? true : false; axinfo.eMG = ((io_status >> 4) % 2) == 1 ? true : false; axinfo.dir = (int)io_status % 2 >> 5; axinfo.curSpeed = cur_vel; axinfo.curPos = cmd_pos; //axinfo.EncoderPos = enc_pos; }
/// <summary> /// 读取控制轴的位置计数器 /// </summary> /// <param name="axinfo"></param> /// <returns></returns> public override int GetCurrentPos(SingleDemura.PCI9014AxisInfo axinfo) { return(CPci9014.p9014_get_pos(axinfo.No, 0, ref axinfo.curPos)); }