增加主界面快速定位,运动界面,增加单轴JOG

This commit is contained in:
zhengxuan.zhang
2024-03-13 10:47:20 +08:00
parent 92705068f7
commit a43ebd53fe
13 changed files with 1273 additions and 717 deletions
+100 -93
View File
@@ -184,7 +184,6 @@
this.label47 = new System.Windows.Forms.Label();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.btn_movepose = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.textBox_y = new System.Windows.Forms.TextBox();
this.textBox_z = new System.Windows.Forms.TextBox();
this.textBox_x = new System.Windows.Forms.TextBox();
@@ -192,22 +191,23 @@
this.label45 = new System.Windows.Forms.Label();
this.label44 = new System.Windows.Forms.Label();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.btn_Z_Down = new System.Windows.Forms.Button();
this.btn_Z_Up = new System.Windows.Forms.Button();
this.btn_Y_Back = new System.Windows.Forms.Button();
this.btn_X_right = new System.Windows.Forms.Button();
this.btn_X_left = new System.Windows.Forms.Button();
this.btn_Y_Forward = new System.Windows.Forms.Button();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.btn_home = new System.Windows.Forms.Button();
this.btn_stop = new System.Windows.Forms.Button();
this.btn_start = new System.Windows.Forms.Button();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.label48 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox_cycleTimes = new System.Windows.Forms.TextBox();
this.btn_halt = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox_Z = new System.Windows.Forms.CheckBox();
this.checkBox_y = new System.Windows.Forms.CheckBox();
this.checkBox_X = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.grpMotionTest.SuspendLayout();
this.grpMst.SuspendLayout();
@@ -1791,7 +1791,6 @@
// groupBox8
//
this.groupBox8.Controls.Add(this.btn_movepose);
this.groupBox8.Controls.Add(this.checkBox1);
this.groupBox8.Controls.Add(this.textBox_y);
this.groupBox8.Controls.Add(this.textBox_z);
this.groupBox8.Controls.Add(this.textBox_x);
@@ -1807,7 +1806,7 @@
//
// btn_movepose
//
this.btn_movepose.Location = new System.Drawing.Point(129, 122);
this.btn_movepose.Location = new System.Drawing.Point(157, 120);
this.btn_movepose.Name = "btn_movepose";
this.btn_movepose.Size = new System.Drawing.Size(120, 37);
this.btn_movepose.TabIndex = 7;
@@ -1815,16 +1814,6 @@
this.btn_movepose.UseVisualStyleBackColor = true;
this.btn_movepose.Click += new System.EventHandler(this.btn_movepose_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(39, 133);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(48, 16);
this.checkBox1.TabIndex = 6;
this.checkBox1.Text = "等待";
this.checkBox1.UseVisualStyleBackColor = true;
//
// textBox_y
//
this.textBox_y.Location = new System.Drawing.Point(149, 54);
@@ -1875,6 +1864,8 @@
//
// groupBox7
//
this.groupBox7.Controls.Add(this.btn_Z_Down);
this.groupBox7.Controls.Add(this.btn_Z_Up);
this.groupBox7.Controls.Add(this.btn_Y_Back);
this.groupBox7.Controls.Add(this.btn_X_right);
this.groupBox7.Controls.Add(this.btn_X_left);
@@ -1886,6 +1877,28 @@
this.groupBox7.TabStop = false;
this.groupBox7.Text = "Jog";
//
// btn_Z_Down
//
this.btn_Z_Down.Location = new System.Drawing.Point(198, 107);
this.btn_Z_Down.Name = "btn_Z_Down";
this.btn_Z_Down.Size = new System.Drawing.Size(75, 35);
this.btn_Z_Down.TabIndex = 5;
this.btn_Z_Down.Text = "Z下移";
this.btn_Z_Down.UseVisualStyleBackColor = true;
this.btn_Z_Down.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_Z_Down_MouseDown);
this.btn_Z_Down.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// btn_Z_Up
//
this.btn_Z_Up.Location = new System.Drawing.Point(198, 13);
this.btn_Z_Up.Name = "btn_Z_Up";
this.btn_Z_Up.Size = new System.Drawing.Size(75, 35);
this.btn_Z_Up.TabIndex = 4;
this.btn_Z_Up.Text = "Z上移";
this.btn_Z_Up.UseVisualStyleBackColor = true;
this.btn_Z_Up.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_Z_Up_MouseDown);
this.btn_Z_Up.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// btn_Y_Back
//
this.btn_Y_Back.Location = new System.Drawing.Point(104, 107);
@@ -1894,7 +1907,8 @@
this.btn_Y_Back.TabIndex = 3;
this.btn_Y_Back.Text = "Y后退";
this.btn_Y_Back.UseVisualStyleBackColor = true;
this.btn_Y_Back.Click += new System.EventHandler(this.btn_Y_Back_Click);
this.btn_Y_Back.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_Y_Back_MouseDown);
this.btn_Y_Back.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// btn_X_right
//
@@ -1904,7 +1918,8 @@
this.btn_X_right.TabIndex = 2;
this.btn_X_right.Text = "X右移";
this.btn_X_right.UseVisualStyleBackColor = true;
this.btn_X_right.Click += new System.EventHandler(this.btn_X_right_Click);
this.btn_X_right.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_X_right_MouseDown);
this.btn_X_right.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// btn_X_left
//
@@ -1914,7 +1929,8 @@
this.btn_X_left.TabIndex = 1;
this.btn_X_left.Text = "X左移";
this.btn_X_left.UseVisualStyleBackColor = true;
this.btn_X_left.Click += new System.EventHandler(this.btn_X_left_Click);
this.btn_X_left.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_X_left_MouseDown);
this.btn_X_left.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// btn_Y_Forward
//
@@ -1924,13 +1940,13 @@
this.btn_Y_Forward.TabIndex = 0;
this.btn_Y_Forward.Text = "Y前进";
this.btn_Y_Forward.UseVisualStyleBackColor = true;
this.btn_Y_Forward.Click += new System.EventHandler(this.btn_Y_Forward_Click);
this.btn_Y_Forward.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_Y_Forward_MouseDown);
this.btn_Y_Forward.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BtnJog_MouseUp);
//
// groupBox6
//
this.groupBox6.Controls.Add(this.button1);
this.groupBox6.Controls.Add(this.btn_home);
this.groupBox6.Controls.Add(this.btn_stop);
this.groupBox6.Controls.Add(this.btn_start);
this.groupBox6.Location = new System.Drawing.Point(6, 24);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(283, 70);
@@ -1940,7 +1956,7 @@
//
// btn_home
//
this.btn_home.Location = new System.Drawing.Point(198, 24);
this.btn_home.Location = new System.Drawing.Point(7, 24);
this.btn_home.Name = "btn_home";
this.btn_home.Size = new System.Drawing.Size(75, 30);
this.btn_home.TabIndex = 2;
@@ -1948,35 +1964,15 @@
this.btn_home.UseVisualStyleBackColor = true;
this.btn_home.Click += new System.EventHandler(this.btn_home_Click);
//
// btn_stop
//
this.btn_stop.Location = new System.Drawing.Point(104, 24);
this.btn_stop.Name = "btn_stop";
this.btn_stop.Size = new System.Drawing.Size(75, 30);
this.btn_stop.TabIndex = 1;
this.btn_stop.Text = "停止";
this.btn_stop.UseVisualStyleBackColor = true;
this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);
//
// btn_start
//
this.btn_start.Location = new System.Drawing.Point(10, 24);
this.btn_start.Name = "btn_start";
this.btn_start.Size = new System.Drawing.Size(75, 30);
this.btn_start.TabIndex = 0;
this.btn_start.Text = "开始";
this.btn_start.UseVisualStyleBackColor = true;
this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
//
// groupBox10
//
this.groupBox10.Controls.Add(this.label48);
this.groupBox10.Controls.Add(this.textBox4);
this.groupBox10.Controls.Add(this.textBox_cycleTimes);
this.groupBox10.Controls.Add(this.btn_halt);
this.groupBox10.Controls.Add(this.btn_run);
this.groupBox10.Controls.Add(this.checkBox4);
this.groupBox10.Controls.Add(this.checkBox3);
this.groupBox10.Controls.Add(this.checkBox2);
this.groupBox10.Controls.Add(this.checkBox_Z);
this.groupBox10.Controls.Add(this.checkBox_y);
this.groupBox10.Controls.Add(this.checkBox_X);
this.groupBox10.Location = new System.Drawing.Point(919, 610);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(295, 103);
@@ -1987,68 +1983,78 @@
// label48
//
this.label48.AutoSize = true;
this.label48.Location = new System.Drawing.Point(220, 65);
this.label48.Location = new System.Drawing.Point(244, 67);
this.label48.Name = "label48";
this.label48.Size = new System.Drawing.Size(17, 12);
this.label48.TabIndex = 7;
this.label48.Text = "次";
//
// textBox4
// textBox_cycleTimes
//
this.textBox4.Location = new System.Drawing.Point(179, 61);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(35, 21);
this.textBox4.TabIndex = 5;
this.textBox_cycleTimes.Location = new System.Drawing.Point(203, 63);
this.textBox_cycleTimes.Name = "textBox_cycleTimes";
this.textBox_cycleTimes.Size = new System.Drawing.Size(35, 21);
this.textBox_cycleTimes.TabIndex = 5;
//
// btn_halt
//
this.btn_halt.Location = new System.Drawing.Point(94, 60);
this.btn_halt.Location = new System.Drawing.Point(99, 60);
this.btn_halt.Name = "btn_halt";
this.btn_halt.Size = new System.Drawing.Size(60, 23);
this.btn_halt.Size = new System.Drawing.Size(80, 30);
this.btn_halt.TabIndex = 4;
this.btn_halt.Text = "停止";
this.btn_halt.Text = "停止循环";
this.btn_halt.UseVisualStyleBackColor = true;
this.btn_halt.Click += new System.EventHandler(this.btn_halt_Click);
this.btn_halt.Click += new System.EventHandler(this.BtnHallAll_Click);
//
// btn_run
//
this.btn_run.Location = new System.Drawing.Point(13, 60);
this.btn_run.Name = "btn_run";
this.btn_run.Size = new System.Drawing.Size(60, 23);
this.btn_run.Size = new System.Drawing.Size(80, 30);
this.btn_run.TabIndex = 3;
this.btn_run.Text = "运行";
this.btn_run.Text = "开始循环";
this.btn_run.UseVisualStyleBackColor = true;
this.btn_run.Click += new System.EventHandler(this.btn_run_Click);
//
// checkBox4
// checkBox_Z
//
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(184, 21);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(30, 16);
this.checkBox4.TabIndex = 2;
this.checkBox4.Text = "Z";
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox_Z.AutoSize = true;
this.checkBox_Z.Location = new System.Drawing.Point(184, 21);
this.checkBox_Z.Name = "checkBox_Z";
this.checkBox_Z.Size = new System.Drawing.Size(30, 16);
this.checkBox_Z.TabIndex = 2;
this.checkBox_Z.Text = "Z";
this.checkBox_Z.UseVisualStyleBackColor = true;
//
// checkBox3
// checkBox_y
//
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(100, 21);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(30, 16);
this.checkBox3.TabIndex = 1;
this.checkBox3.Text = "Y";
this.checkBox3.UseVisualStyleBackColor = true;
this.checkBox_y.AutoSize = true;
this.checkBox_y.Location = new System.Drawing.Point(100, 21);
this.checkBox_y.Name = "checkBox_y";
this.checkBox_y.Size = new System.Drawing.Size(30, 16);
this.checkBox_y.TabIndex = 1;
this.checkBox_y.Text = "Y";
this.checkBox_y.UseVisualStyleBackColor = true;
//
// checkBox2
// checkBox_X
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(16, 21);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(30, 16);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "X";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox_X.AutoSize = true;
this.checkBox_X.Location = new System.Drawing.Point(16, 21);
this.checkBox_X.Name = "checkBox_X";
this.checkBox_X.Size = new System.Drawing.Size(30, 16);
this.checkBox_X.TabIndex = 0;
this.checkBox_X.Text = "X";
this.checkBox_X.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(94, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 30);
this.button1.TabIndex = 3;
this.button1.Text = "立即停止";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.BtnHallAll_Click);
//
// Motion
//
@@ -2067,6 +2073,7 @@
this.Name = "Motion";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "平台运动";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Motion_FormClosed);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
@@ -2251,7 +2258,6 @@
private System.Windows.Forms.GroupBox groupBox9;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.Button btn_movepose;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.TextBox textBox_y;
private System.Windows.Forms.TextBox textBox_z;
private System.Windows.Forms.TextBox textBox_x;
@@ -2265,16 +2271,14 @@
private System.Windows.Forms.Button btn_Y_Forward;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Button btn_home;
private System.Windows.Forms.Button btn_stop;
private System.Windows.Forms.Button btn_start;
private System.Windows.Forms.GroupBox groupBox10;
private System.Windows.Forms.Label label48;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox_cycleTimes;
private System.Windows.Forms.Button btn_halt;
private System.Windows.Forms.Button btn_run;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox_Z;
private System.Windows.Forms.CheckBox checkBox_y;
private System.Windows.Forms.CheckBox checkBox_X;
private System.Windows.Forms.Label label56;
private System.Windows.Forms.Label label55;
private System.Windows.Forms.Label label54;
@@ -2284,6 +2288,9 @@
private System.Windows.Forms.Label label50;
private System.Windows.Forms.Label label49;
private System.Windows.Forms.Label label47;
private System.Windows.Forms.Button btn_Z_Down;
private System.Windows.Forms.Button btn_Z_Up;
private System.Windows.Forms.Button button1;
}
}
+383 -154
View File
@@ -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
}
}
+1 -1
View File
@@ -1148,7 +1148,7 @@
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>77</value>
<value>25</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>