增加主界面快速定位,运动界面,增加单轴JOG
This commit is contained in:
+383
-154
@@ -19,6 +19,11 @@ namespace HexcalMC
|
||||
private const int MaxUiLimitCnt = 8;
|
||||
private const int MaxUiIoCnt = 8;
|
||||
private readonly Api _acs;
|
||||
private readonly int _motionTimeout = 5000; //延时时间
|
||||
|
||||
|
||||
private readonly Axis[] UseAxis = MainFrom.UseAxis; //获取激活的轴
|
||||
private MotionStates _currentMotionState = MotionStates.None; //运动状态
|
||||
private Axis[] _mArrAxisList;
|
||||
private Array _mArrReadVector;
|
||||
|
||||
@@ -59,7 +64,7 @@ namespace HexcalMC
|
||||
_acs.SetFPosition((Axis)cboAxisNo.SelectedIndex, 0);
|
||||
}
|
||||
|
||||
#region Move to absolute position
|
||||
#region 绝对运动
|
||||
|
||||
private void BtnPTP_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -85,7 +90,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region On and Off General Output
|
||||
#region 通用IO
|
||||
|
||||
private void BtnSW_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -128,11 +133,12 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize
|
||||
#region 初始化
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
btnOpen.Enabled = true;
|
||||
//禁止通讯按钮
|
||||
btnOpen.Enabled = false;
|
||||
btnClose.Enabled = false;
|
||||
|
||||
_mLblLeftLimit = new Label[MaxUiLimitCnt]; //左限位
|
||||
@@ -213,28 +219,80 @@ namespace HexcalMC
|
||||
// secondaryForm.Show();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 初始化
|
||||
|
||||
InitMotion();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void RdoTCP_CheckedChanged(object sender, EventArgs e)
|
||||
private void Motion_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
txtIP.Enabled = true;
|
||||
txtPort.Enabled = true;
|
||||
}
|
||||
|
||||
private void RdoSimu_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
txtIP.Enabled = false;
|
||||
txtPort.Enabled = false;
|
||||
tmrMonitor.Stop();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Communication - Open / Close
|
||||
#region 通讯建立
|
||||
|
||||
private void BtnOpen_Click(object sender, EventArgs e)
|
||||
private void InitMotion()
|
||||
{
|
||||
string strTemp;
|
||||
int i;
|
||||
|
||||
//判断通讯对象是否存在
|
||||
if (_acs == null || !_acs.IsConnected)
|
||||
{
|
||||
DebugDfn.AddLogText("未建立通讯,请在主界面先建立通讯");
|
||||
|
||||
// 在合适的位置调用 MessageBox.Show() 方法
|
||||
MessageBox.Show("未建立通讯,请在主界面先建立通讯", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
_mBConnected = _acs.IsConnected;
|
||||
// Get Total number of axes
|
||||
// Using Transaction function : return string text from controller, we need to convert to integer value
|
||||
strTemp = _acs.Transaction("?SYSINFO(13)");
|
||||
_mNTotalAxis = Convert.ToInt32(strTemp.Trim());
|
||||
|
||||
// Using Sysinfo function
|
||||
//_ACS.GetSysInfo(_ACS.ACSC_SYS_NAXES_KEY, out lfTemp);
|
||||
|
||||
// When we are using multi axes command (ex) ToPointM, HaltM, ...), we need to allocate the array size more 1.
|
||||
// Because of the last delimeter (-1)
|
||||
_mArrAxisList = new Axis[_mNTotalAxis + 1];
|
||||
//for (i = 0; i < _mNTotalAxis; i++)
|
||||
//{
|
||||
// cboAxisNo.Items.Add(i.ToString());
|
||||
// _mArrAxisList[i] = (Axis)i;
|
||||
//}
|
||||
|
||||
// Insert '-1' at the last
|
||||
_mArrAxisList[_mNTotalAxis] = Axis.ACSC_NONE;
|
||||
cboAxisNo.SelectedIndex = 0;
|
||||
|
||||
// Update current motion paramter to UI.
|
||||
UpdateProfile();
|
||||
|
||||
strTemp = _acs.Transaction("?SYSINFO(10)");
|
||||
_mNTotalBuffer = Convert.ToInt32(strTemp.Trim());
|
||||
for (i = 0; i < _mNTotalBuffer; i++)
|
||||
{
|
||||
cboBufferNo.Items.Add(i.ToString());
|
||||
}
|
||||
|
||||
cboBufferNo.SelectedIndex = 0;
|
||||
|
||||
// Set updating timer
|
||||
tmrMonitor.Interval = 50;
|
||||
tmrMonitor.Start();
|
||||
}
|
||||
|
||||
private void BtnOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
//double lfTemp = 0.0f;
|
||||
|
||||
try
|
||||
@@ -251,47 +309,8 @@ namespace HexcalMC
|
||||
Convert.ToInt32(txtPort.Text.Trim())); // TCP/IP Port nubmer (default : 701)
|
||||
}
|
||||
|
||||
InitMotion();
|
||||
_mBConnected = true;
|
||||
|
||||
// Get Total number of axes
|
||||
// Using Transaction function : return string text from controller, we need to convert to integer value
|
||||
strTemp = _acs.Transaction("?SYSINFO(13)");
|
||||
_mNTotalAxis = Convert.ToInt32(strTemp.Trim());
|
||||
|
||||
// Using Sysinfo function
|
||||
//_ACS.GetSysInfo(_ACS.ACSC_SYS_NAXES_KEY, out lfTemp);
|
||||
|
||||
// When we are using multi axes command (ex) ToPointM, HaltM, ...), we need to allocate the array size more 1.
|
||||
// Because of the last delimeter (-1)
|
||||
_mArrAxisList = new Axis[_mNTotalAxis + 1];
|
||||
//for (i = 0; i < _mNTotalAxis; i++)
|
||||
//{
|
||||
// cboAxisNo.Items.Add(i.ToString());
|
||||
// _mArrAxisList[i] = (Axis)i;
|
||||
//}
|
||||
|
||||
// Insert '-1' at the last
|
||||
_mArrAxisList[_mNTotalAxis] = Axis.ACSC_NONE;
|
||||
cboAxisNo.SelectedIndex = 0;
|
||||
|
||||
// Update current motion paramter to UI.
|
||||
UpdateProfile();
|
||||
|
||||
strTemp = _acs.Transaction("?SYSINFO(10)");
|
||||
_mNTotalBuffer = Convert.ToInt32(strTemp.Trim());
|
||||
for (i = 0; i < _mNTotalBuffer; i++)
|
||||
{
|
||||
cboBufferNo.Items.Add(i.ToString());
|
||||
}
|
||||
|
||||
cboBufferNo.SelectedIndex = 0;
|
||||
|
||||
btnOpen.Enabled = false;
|
||||
btnClose.Enabled = true;
|
||||
|
||||
// Set updating timer
|
||||
tmrMonitor.Interval = 50;
|
||||
tmrMonitor.Start();
|
||||
}
|
||||
|
||||
catch (COMException comex)
|
||||
@@ -346,7 +365,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update UI data from Controller
|
||||
#region UI 刷新
|
||||
|
||||
/// <summary>
|
||||
/// Update Motion Profile from Controller
|
||||
@@ -379,17 +398,7 @@ namespace HexcalMC
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instruction 1. Using library functions - acsc_GetFPosition, acsc_GetRPosition, ....
|
||||
// Instruction 2. Read ACS variable - Already defined almost things (FPOS, RPOS, ...)
|
||||
// Motion parameters and state is array (Max length is total number of axes)
|
||||
//
|
||||
// * Library function can read only 1 axis information, so if you want to read several axes, you have to call the function many times.
|
||||
// (This may cause communication delay.)
|
||||
// Recommand (if you want to read many axes) : read/write variable using ReadVariable, ReadVariableScalar, ReadVariableVector, ReadVariableMatrix
|
||||
|
||||
//
|
||||
// Get Motor State
|
||||
// ACSPL+ Variable : MST (integer)
|
||||
_mNMotorState = _acs.GetMotorState((Axis)iAxisNo);
|
||||
|
||||
// Returned value is integer, you need to use bitmaks
|
||||
@@ -519,7 +528,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Motor Enable / Disable
|
||||
#region 电机使能
|
||||
|
||||
private void BtnEnable_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -549,7 +558,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Move to relative position (from current position)
|
||||
#region 相对移动
|
||||
|
||||
private void BtnPTP_R_Neg_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -598,7 +607,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Stop motion using deceleration (halt command)
|
||||
#region 停止运动
|
||||
|
||||
private void BtnHalt_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -633,7 +642,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region JOG Command
|
||||
#region JOG 功能
|
||||
|
||||
// Move negative direction
|
||||
private void BtnJogNeg_MouseDown(object sender, MouseEventArgs e)
|
||||
@@ -695,11 +704,39 @@ namespace HexcalMC
|
||||
private void BtnJog_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
_acs.Halt((Axis)cboAxisNo.SelectedIndex);
|
||||
|
||||
|
||||
//自定义Jog
|
||||
if (sender is Button button)
|
||||
{
|
||||
string btn_name = button.Name;
|
||||
switch (btn_name)
|
||||
{
|
||||
case "btn_X_left":
|
||||
_acs.Halt(Axis.ACSC_AXIS_1);
|
||||
break;
|
||||
case "btn_X_right":
|
||||
_acs.Halt(Axis.ACSC_AXIS_1);
|
||||
break;
|
||||
case "btn_Y_Forward":
|
||||
_acs.Halt(Axis.ACSC_AXIS_0);
|
||||
break;
|
||||
case "btn_Y_Back":
|
||||
_acs.Halt(Axis.ACSC_AXIS_0);
|
||||
break;
|
||||
case "btn_Z_Up":
|
||||
_acs.Halt(Axis.ACSC_AXIS_8);
|
||||
break;
|
||||
case "btn_Z_Down":
|
||||
_acs.Halt(Axis.ACSC_AXIS_8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Run/Stop Buffer Program
|
||||
#region 运行 Buffer Program
|
||||
|
||||
private void BtnRunBuffer_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -742,7 +779,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Change motion profile
|
||||
#region 修改运动参数
|
||||
|
||||
private void TextBoxes_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
@@ -849,7 +886,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event
|
||||
#region 事件回调
|
||||
|
||||
private void BtnEventMotionEnd_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -891,86 +928,6 @@ namespace HexcalMC
|
||||
}
|
||||
|
||||
|
||||
private void btn_movepose_Click(object sender, EventArgs e)
|
||||
{
|
||||
//判断是否为textBox_x空
|
||||
if (string.IsNullOrWhiteSpace(textBox_x.Text) || string.IsNullOrEmpty(textBox_y.Text) ||
|
||||
string.IsNullOrEmpty(textBox_z.Text))
|
||||
{
|
||||
MessageBox.Show("输入文本框为空,请修改", "警告");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取 textBox_x 的值
|
||||
double x = double.Parse(textBox_x.Text);
|
||||
double y = double.Parse(textBox_y.Text);
|
||||
double z = double.Parse(textBox_z.Text);
|
||||
Point3D _point3D = new Point3D(x, y, z);
|
||||
|
||||
|
||||
if (MainFrom.IsWithinStrokes(_point3D)) //判断点是否在行程范围内
|
||||
{
|
||||
double[] pointsArray =
|
||||
{
|
||||
_point3D.X,
|
||||
_point3D.Y,
|
||||
_point3D.Z
|
||||
};
|
||||
//执行运动指令
|
||||
_acs.ToPointM(MotionFlags.ACSC_NONE, MainFrom.UseAxis, pointsArray); //多轴运动到指定位置
|
||||
|
||||
////等待运动完成
|
||||
//for (int i = 0; i < USE_AXIS.Length; i++)
|
||||
//{
|
||||
// _acs.WaitMotionEnd(USE_AXIS[i], _motionTimeout); //等待回家完成
|
||||
//}
|
||||
|
||||
//_currentMotionState = MotionStates.InPos;
|
||||
//DebugDfn.AddLogText("运动到位");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugDfn.AddLogText("目标位置超出行程范围,请重新设置");
|
||||
MessageBox.Show("目标位置超出行程范围,请重新设置", "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_start_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_stop_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_home_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_X_left_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_X_right_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_Y_Forward_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_Y_Back_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_run_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btn_halt_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void ACS_PROGRAMEND(BufferMasks buffer)
|
||||
{
|
||||
int bit = 0x01;
|
||||
@@ -998,7 +955,7 @@ namespace HexcalMC
|
||||
|
||||
#endregion
|
||||
|
||||
#region Communication Termial - Using Transaction function
|
||||
#region 命令行响应
|
||||
|
||||
private void TxtCommand_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
@@ -1042,5 +999,277 @@ namespace HexcalMC
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 按钮
|
||||
|
||||
private void btn_movepose_Click(object sender, EventArgs e)
|
||||
{
|
||||
//判断是否为textBox_x空
|
||||
if (string.IsNullOrWhiteSpace(textBox_x.Text) || string.IsNullOrEmpty(textBox_y.Text) ||
|
||||
string.IsNullOrEmpty(textBox_z.Text))
|
||||
{
|
||||
MessageBox.Show("输入文本框为空,请修改", "警告");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取 textBox_x 的值
|
||||
double x = double.Parse(textBox_x.Text);
|
||||
double y = double.Parse(textBox_y.Text);
|
||||
double z = double.Parse(textBox_z.Text);
|
||||
Point3D _point3D = new Point3D(x, y, z);
|
||||
|
||||
|
||||
if (MainFrom.IsWithinLimit(_point3D)) //判断点是否在行程范围内
|
||||
{
|
||||
double[] pointsArray =
|
||||
{
|
||||
_point3D.X,
|
||||
_point3D.Y,
|
||||
_point3D.Z
|
||||
};
|
||||
//执行运动指令
|
||||
_acs.ToPointM(MotionFlags.ACSC_NONE, UseAxis, pointsArray); //多轴运动到指定位置
|
||||
|
||||
////等待运动完成
|
||||
//for (int i = 0; i < USE_AXIS.Length; i++)
|
||||
//{
|
||||
// _acs.WaitMotionEnd(USE_AXIS[i], _motionTimeout); //等待回家完成
|
||||
//}
|
||||
|
||||
//_currentMotionState = MotionStates.InPos;
|
||||
//DebugDfn.AddLogText("运动到位");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugDfn.AddLogText("目标位置超出行程范围,请重新设置");
|
||||
MessageBox.Show("目标位置超出行程范围,请重新设置", "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void btn_home_Click(object sender, EventArgs e) //回零
|
||||
{
|
||||
double[] pointsArray =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
//执行运动指令
|
||||
_acs.ToPointM(MotionFlags.ACSC_NONE, UseAxis, pointsArray); //多轴运动到指定位置
|
||||
|
||||
//等待运动完成
|
||||
for (int i = 0; i < UseAxis.Length-1; i++)
|
||||
{
|
||||
_acs.WaitMotionEnd(UseAxis[i], _motionTimeout); //等待回家完成
|
||||
}
|
||||
|
||||
_currentMotionState = MotionStates.InPos;
|
||||
DebugDfn.AddLogText("运动到位");
|
||||
}
|
||||
|
||||
private void btn_X_left_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_1, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_1, (double)GlobalDirection.ACSC_NEGATIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("X左移异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_X_right_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_1, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_1, (double)GlobalDirection.ACSC_POSITIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("X左移异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Y_Forward_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_0, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_0, (double)GlobalDirection.ACSC_NEGATIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("Y前移异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Y_Back_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_0, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_0, (double)GlobalDirection.ACSC_POSITIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("Y后移异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Z_Down_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_8, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_8, (double)GlobalDirection.ACSC_NEGATIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("Z向下异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Z_Up_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double lfVelocity = 0.0f;
|
||||
try
|
||||
{
|
||||
if (chkUseVel.Checked)
|
||||
{
|
||||
lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim());
|
||||
if (lfVelocity > 0) lfVelocity = lfVelocity * -1; // Negative direction : Using - (minus) velocity
|
||||
|
||||
_acs.Jog(
|
||||
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
|
||||
Axis.ACSC_AXIS_8, // Axis number
|
||||
lfVelocity // Velocity
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_acs.Jog(0, Axis.ACSC_AXIS_8, (double)GlobalDirection.ACSC_POSITIVE_DIRECTION);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DebugDfn.AddLogText("Z向上异常" + exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void btn_run_Click(object sender, EventArgs e)
|
||||
{
|
||||
//运动次数
|
||||
if (string.IsNullOrEmpty(textBox_cycleTimes.Text))
|
||||
{
|
||||
MessageBox.Show("循环次数不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
int times = Convert.ToInt32(textBox_cycleTimes.Text);
|
||||
DebugDfn.AddLogText("循环次数: " + times);
|
||||
|
||||
do
|
||||
{
|
||||
//X轴
|
||||
if (checkBox_X.Checked)
|
||||
{
|
||||
}
|
||||
|
||||
if (checkBox_y.Checked)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if (checkBox_Z.Checked)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//开始运动
|
||||
|
||||
times = times - 1;
|
||||
DebugDfn.AddLogText($"当前为第{times}循环");
|
||||
} while (times > 0);
|
||||
|
||||
DebugDfn.AddLogText("循环结束");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user