寸動 (Jog) 鈕:寸動運動
寸動運動使用兩個寸動鈕:向前寸動及向後寸動,鈕的行為可自訂,此範例使用方式如下:
- 寸動:按住滑鼠左鍵。
- 停止寸動:放開滑鼠左鍵,
因為不使用點擊行為,因此代碼未寫在 button_Click 方法中,而是使用 MouseDown 事件,當按住滑鼠左鍵時,JogAxis 會用來將軸向前或向後移動;當放開滑鼠鍵時,HaltAxis 則會用來停止寸動,因 MouseDown 套用至 Jog 按鈕,此按鈕的方法為 btnJOG_F_MouseDown、btnJOG_F_MouseUp,、btnJOG_B_MouseDown 和 btnJOG_B_MouseUp,其中 F 為 Jog Forward 而 B 為 Jog Backward,而指令速度從 tbCMD_VEL.Text 接收,並使用 Convert.ToDouble 轉換為雙精準浮點數字。
向前寸動
private void btnJOG_F_MouseDown(object sender, MouseEventArgs e)
{
int Mindex = lbMList.SelectedIndex;
//Commands a never-ending controlled motion at a specified velocity.
motion.JogAxis(Mindex,Convert.ToDouble(tbCMD_VEL.Text), 3600,
3600, 360000, McDirection.mcPositiveDirection);
}private void btnJOG_F_MouseUp(object sender, MouseEventArgs e)
{
int Mindex = lbMList.SelectedIndex;
//Commands a controlled motion stop.
motion.HaltAxis(Mindex, 3600, 360000, McBufferMode.mcAborting);
}
向後寸動
private void btnJOG_B_MouseDown(object sender, MouseEventArgs e)
{
int Mindex = lbMList.SelectedIndex;
//Commands a never-ending controlled motion at a specified velocity.
motion.JogAxis(Mindex, Convert.ToDouble(tbCMD_VEL.Text), 3600,
3600, 360000, McDirection.mcNegativeDirection);
}private void btnJOG_B_MouseUp(object sender, MouseEventArgs e)
{
int Mindex = lbMList.SelectedIndex;
//Commands a controlled motion stop.
motion.HaltAxis(Mindex, 3600, 360000, McBufferMode.mcAborting);
}