#0011:轨迹记录功能
This commit is contained in:
Generated
+41
-14
@@ -180,6 +180,7 @@
|
||||
this.btnSend = new System.Windows.Forms.Button();
|
||||
this.button11 = new System.Windows.Forms.Button();
|
||||
this.txtCommand = new System.Windows.Forms.TextBox();
|
||||
this.button18 = new System.Windows.Forms.Button();
|
||||
this.groupBox5 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox9 = new System.Windows.Forms.GroupBox();
|
||||
this.label56 = new System.Windows.Forms.Label();
|
||||
@@ -210,6 +211,7 @@
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.groupBox10 = new System.Windows.Forms.GroupBox();
|
||||
this.button19 = new System.Windows.Forms.Button();
|
||||
this.label48 = new System.Windows.Forms.Label();
|
||||
this.textBox4 = new System.Windows.Forms.TextBox();
|
||||
this.button10 = new System.Windows.Forms.Button();
|
||||
@@ -217,7 +219,7 @@
|
||||
this.checkBox4 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.button18 = new System.Windows.Forms.Button();
|
||||
this.button20 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.grpMotionTest.SuspendLayout();
|
||||
this.grpMst.SuspendLayout();
|
||||
@@ -1680,7 +1682,7 @@
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.button18);
|
||||
this.groupBox4.Controls.Add(this.button20);
|
||||
this.groupBox4.Controls.Add(this.button17);
|
||||
this.groupBox4.Controls.Add(this.button16);
|
||||
this.groupBox4.Controls.Add(this.button15);
|
||||
@@ -1704,13 +1706,13 @@
|
||||
this.button17.Name = "button17";
|
||||
this.button17.Size = new System.Drawing.Size(85, 30);
|
||||
this.button17.TabIndex = 14;
|
||||
this.button17.Text = "MoveM";
|
||||
this.button17.Text = "ExtAddPointM";
|
||||
this.button17.UseVisualStyleBackColor = true;
|
||||
this.button17.Click += new System.EventHandler(this.button17_Click);
|
||||
//
|
||||
// button16
|
||||
//
|
||||
this.button16.Location = new System.Drawing.Point(291, 218);
|
||||
this.button16.Location = new System.Drawing.Point(387, 218);
|
||||
this.button16.Name = "button16";
|
||||
this.button16.Size = new System.Drawing.Size(85, 30);
|
||||
this.button16.TabIndex = 13;
|
||||
@@ -1720,7 +1722,7 @@
|
||||
//
|
||||
// button15
|
||||
//
|
||||
this.button15.Location = new System.Drawing.Point(196, 218);
|
||||
this.button15.Location = new System.Drawing.Point(292, 218);
|
||||
this.button15.Name = "button15";
|
||||
this.button15.Size = new System.Drawing.Size(85, 30);
|
||||
this.button15.TabIndex = 12;
|
||||
@@ -1730,7 +1732,7 @@
|
||||
//
|
||||
// button14
|
||||
//
|
||||
this.button14.Location = new System.Drawing.Point(98, 218);
|
||||
this.button14.Location = new System.Drawing.Point(194, 218);
|
||||
this.button14.Name = "button14";
|
||||
this.button14.Size = new System.Drawing.Size(85, 30);
|
||||
this.button14.TabIndex = 11;
|
||||
@@ -1786,6 +1788,16 @@
|
||||
this.txtCommand.TabIndex = 7;
|
||||
this.txtCommand.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtCommand_KeyPress);
|
||||
//
|
||||
// button18
|
||||
//
|
||||
this.button18.Location = new System.Drawing.Point(19, 101);
|
||||
this.button18.Name = "button18";
|
||||
this.button18.Size = new System.Drawing.Size(85, 30);
|
||||
this.button18.TabIndex = 15;
|
||||
this.button18.Text = "开始记录";
|
||||
this.button18.UseVisualStyleBackColor = true;
|
||||
this.button18.Click += new System.EventHandler(this.button18_Click);
|
||||
//
|
||||
// groupBox5
|
||||
//
|
||||
this.groupBox5.Controls.Add(this.groupBox9);
|
||||
@@ -2074,6 +2086,8 @@
|
||||
//
|
||||
// groupBox10
|
||||
//
|
||||
this.groupBox10.Controls.Add(this.button19);
|
||||
this.groupBox10.Controls.Add(this.button18);
|
||||
this.groupBox10.Controls.Add(this.label48);
|
||||
this.groupBox10.Controls.Add(this.textBox4);
|
||||
this.groupBox10.Controls.Add(this.button10);
|
||||
@@ -2088,6 +2102,16 @@
|
||||
this.groupBox10.TabStop = false;
|
||||
this.groupBox10.Text = "XYZ循环";
|
||||
//
|
||||
// button19
|
||||
//
|
||||
this.button19.Location = new System.Drawing.Point(129, 101);
|
||||
this.button19.Name = "button19";
|
||||
this.button19.Size = new System.Drawing.Size(85, 30);
|
||||
this.button19.TabIndex = 16;
|
||||
this.button19.Text = "停止记录";
|
||||
this.button19.UseVisualStyleBackColor = true;
|
||||
this.button19.Click += new System.EventHandler(this.button19_Click);
|
||||
//
|
||||
// label48
|
||||
//
|
||||
this.label48.AutoSize = true;
|
||||
@@ -2112,6 +2136,7 @@
|
||||
this.button10.TabIndex = 4;
|
||||
this.button10.Text = "停止";
|
||||
this.button10.UseVisualStyleBackColor = true;
|
||||
this.button10.Click += new System.EventHandler(this.button10_Click);
|
||||
//
|
||||
// button9
|
||||
//
|
||||
@@ -2153,15 +2178,15 @@
|
||||
this.checkBox2.Text = "X";
|
||||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button18
|
||||
// button20
|
||||
//
|
||||
this.button18.Location = new System.Drawing.Point(400, 215);
|
||||
this.button18.Name = "button18";
|
||||
this.button18.Size = new System.Drawing.Size(85, 30);
|
||||
this.button18.TabIndex = 15;
|
||||
this.button18.Text = "记录";
|
||||
this.button18.UseVisualStyleBackColor = true;
|
||||
this.button18.Click += new System.EventHandler(this.button18_Click);
|
||||
this.button20.Location = new System.Drawing.Point(103, 220);
|
||||
this.button20.Name = "button20";
|
||||
this.button20.Size = new System.Drawing.Size(85, 30);
|
||||
this.button20.TabIndex = 15;
|
||||
this.button20.Text = "MultiPointM2";
|
||||
this.button20.UseVisualStyleBackColor = true;
|
||||
this.button20.Click += new System.EventHandler(this.button20_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@@ -2408,6 +2433,8 @@
|
||||
private System.Windows.Forms.Button button16;
|
||||
private System.Windows.Forms.Button button17;
|
||||
private System.Windows.Forms.Button button18;
|
||||
private System.Windows.Forms.Button button19;
|
||||
private System.Windows.Forms.Button button20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+135
-46
@@ -61,7 +61,8 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
|
||||
// 记录标志位
|
||||
private bool record = false;
|
||||
private int record_count = 0; //时间计数
|
||||
private bool record_last = false; //上一次的记录标志位
|
||||
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
@@ -287,7 +288,7 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool record_action = false;
|
||||
private void tmrMonitor_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Get selected axis number
|
||||
@@ -393,35 +394,47 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
label55.Text = point.y.ToString("0.000");
|
||||
label56.Text = point.z.ToString("0.000");
|
||||
|
||||
|
||||
if (record)
|
||||
if (record_action)
|
||||
{
|
||||
record_count++;
|
||||
pointList.Add(point);
|
||||
}
|
||||
|
||||
if (record_count > 200)
|
||||
{
|
||||
record_count = 0;
|
||||
record = false;
|
||||
|
||||
//保存数据
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "文本文件|*.txt";
|
||||
saveFileDialog.Title = "保存数据";
|
||||
saveFileDialog.ShowDialog();
|
||||
|
||||
if (saveFileDialog.FileName != "")
|
||||
{
|
||||
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
|
||||
foreach (Point p in pointList)
|
||||
{
|
||||
sw.WriteLine(p.x.ToString("0.000") + " " + p.y.ToString("0.000") + " " + p.z.ToString("0.000"));
|
||||
}
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
if (!record_last && record) //从未记录到记录
|
||||
{
|
||||
lstLog.Items.Add("开始记录");
|
||||
record_action = true;
|
||||
|
||||
}
|
||||
|
||||
//从记录到未记录
|
||||
if (record_last && !record)
|
||||
{
|
||||
lstLog.Items.Add("停止记录");
|
||||
|
||||
record_action = false;
|
||||
|
||||
|
||||
//定义文件保存位置 D:/11.txt
|
||||
string path = "D:/11.txt";
|
||||
{
|
||||
StreamWriter sw = new StreamWriter(path);
|
||||
foreach (Point p in pointList)
|
||||
{
|
||||
sw.WriteLine(p.x.ToString("0.000") + " " + p.y.ToString("0.000") + " " + p.z.ToString("0.000"));
|
||||
}
|
||||
sw.Close();
|
||||
}
|
||||
pointList.Clear();//清空数据
|
||||
lstLog.Items.Add("保存完成");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//更新记录标志位
|
||||
record_last = record;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,15 +983,16 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
// Create multi-point motion of axis 0 and 1 with default
|
||||
// velocity without
|
||||
// dwell in the points
|
||||
_ACS.MultiPointM(MotionFlags.ACSC_NONE, axes, 0);
|
||||
//_ACS.MultiPointM(MotionFlags.ACSC_NONE, axes, 0);
|
||||
// Add some points
|
||||
for (int index = 0; index < 5; index++)
|
||||
{
|
||||
|
||||
points[0] = 100 * index;
|
||||
points[1] = 100 * index;
|
||||
_ACS.AddPointM(axes, points);
|
||||
//_ACS.AddPointM(axes, points);
|
||||
|
||||
_ACS.ToPointM(MotionFlags.ACSC_AMF_VELOCITY,axes, points);
|
||||
//将点添加到 lstLog.Items
|
||||
lstLog.Items.Add("points[0]:" + points[0].ToString() + "points[1]:" + points[1].ToString());
|
||||
|
||||
@@ -1011,7 +1025,7 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
// Create the arbitrary path motion to axes 0 and 1 with
|
||||
// uniform interval 10 ms use a cubic interpolation
|
||||
// between the specified points
|
||||
_ACS.SplineM(MotionFlags.ACSC_AMF_CUBIC |MotionFlags.ACSC_AMF_WAIT, axes, 5000);
|
||||
_ACS.SplineM(MotionFlags.ACSC_AMF_CUBIC, axes, 1000);
|
||||
|
||||
// Add some points
|
||||
// 定义三维点列表
|
||||
@@ -1032,13 +1046,14 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
// 遍历列表并添加点
|
||||
for (int index = 0; index < pointsArray.GetLength(0); index++)
|
||||
{
|
||||
|
||||
|
||||
double[] speed = { 100,100,100};
|
||||
points[0] = pointsArray[index, 0];
|
||||
points[1] = pointsArray[index, 1];
|
||||
points[2] = pointsArray[index, 2];
|
||||
|
||||
// 使用AddPVPointM方法添加点
|
||||
_ACS.AddPVPointM(axes, points, points);
|
||||
_ACS.AddPVPointM(axes, points, speed);
|
||||
|
||||
// 将点信息添加到lstLog.Items
|
||||
lstLog.Items.Add($"points[0]: {points[0]} points[1]: {points[1]} points[2]: {points[2]}");
|
||||
@@ -1049,7 +1064,7 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
// End of the multi-point motion
|
||||
_ACS.EndSequenceM(axes);
|
||||
|
||||
_ACS.GoM(axes);
|
||||
//_ACS.GoM(axes);
|
||||
|
||||
|
||||
record = true;
|
||||
@@ -1118,10 +1133,48 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
|
||||
private void button18_Click(object sender, EventArgs e)
|
||||
{
|
||||
lstLog.Items.Add("记录");
|
||||
record = true;
|
||||
}
|
||||
|
||||
private void button19_Click(object sender, EventArgs e)
|
||||
{
|
||||
lstLog.Items.Add("停止记录");
|
||||
record = false;
|
||||
}
|
||||
|
||||
private void button10_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void button20_Click(object sender, EventArgs e)//MultiPointM
|
||||
{
|
||||
lstLog.Items.Add("MultiPointM");
|
||||
int timeout = 5000;
|
||||
Axis[] axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1,Axis.ACSC_NONE };
|
||||
double[] points = { 0, 0 };
|
||||
_ACS.EnableM(axes); // Enable axes 0 and 1
|
||||
// Wait axis 0 enabled during 5 sec
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_0, 1, timeout);
|
||||
// Wait axis 1 enabled during 5 sec
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_1, 1, timeout);
|
||||
// Create multi-point motion with default velocity without
|
||||
// dwell
|
||||
_ACS.MultiPointM(MotionFlags.ACSC_AMF_VELOCITY, axes, 0);
|
||||
|
||||
// Add some points
|
||||
for (int index = 0; index < 5; index++)
|
||||
{
|
||||
// Position and velocity for each point
|
||||
points[0] = 100 * index;
|
||||
points[1] = 100 * index;
|
||||
_ACS.ExtAddPointM(axes, points, 5000);
|
||||
}
|
||||
// Finish the motion
|
||||
// End of the multi-point motion
|
||||
_ACS.EndSequenceM(axes);
|
||||
}
|
||||
|
||||
private void button15_Click(object sender, EventArgs e) //ExtLine
|
||||
{
|
||||
int timeout = 5000;
|
||||
@@ -1176,34 +1229,70 @@ namespace ACS_DotNET_Library_Advanced_Demo
|
||||
lstLog.Items.Add("BlendedLine ");
|
||||
|
||||
int timeout = 5000;
|
||||
Axis[] Axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1,Axis.ACSC_AXIS_8, Axis.ACSC_NONE };
|
||||
double[] Point = { 1000, 1000 };
|
||||
_ACS.BlendedSegmentMotionAsync(MotionFlags.ACSC_NONE, Axes,
|
||||
Point,//Starting point of motion
|
||||
1000, // Segment time
|
||||
500, // Segment Acceleration time
|
||||
200, // Segment jerk time
|
||||
0);// Waiting call
|
||||
|
||||
Axis[] Axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1, Axis.ACSC_NONE };
|
||||
_ACS.EnableM(Axes); // Enable axes 0 and 1
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_0, 1, timeout);
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_1, 1, timeout);
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_8, 1, timeout);
|
||||
|
||||
double[] Point = { 100, 100 };
|
||||
_ACS.BlendedSegmentMotion(MotionFlags.ACSC_NONE, Axes,
|
||||
Point,//Starting point of motion
|
||||
1000, // Segment time
|
||||
500, // Segment Acceleration time
|
||||
200, // Segment jerk time
|
||||
0);// Waiting call
|
||||
|
||||
|
||||
|
||||
|
||||
double[] FinalPoint = { 300, 300};
|
||||
_ACS.BlendedLine(MotionFlags.ACSC_NONE, Axes,FinalPoint, 10000, 200, 300, 0);
|
||||
|
||||
|
||||
|
||||
//增加第二个点(500,400)
|
||||
double[] FinalPoint2 = { 500, 400 };
|
||||
_ACS.BlendedLine(MotionFlags.ACSC_NONE, Axes, FinalPoint2, 10000, 200, 300, 0);
|
||||
|
||||
//增加第三个点(600,100)
|
||||
double[] FinalPoint3 = { 600, 100 };
|
||||
_ACS.BlendedLine(MotionFlags.ACSC_NONE, Axes, FinalPoint3, 10000, 200, 300, 0);
|
||||
|
||||
|
||||
double[] FinalPoint = { 100, 100,-50};
|
||||
_ACS.BlendedLine(MotionFlags.ACSC_NONE, Axes,
|
||||
FinalPoint, 1000, 200, 300, 0);
|
||||
_ACS.EndSequenceM(Axes);
|
||||
|
||||
record =true;
|
||||
}
|
||||
|
||||
private void button17_Click(object sender, EventArgs e) //MoveM 方法
|
||||
private void button17_Click(object sender, EventArgs e) //ExtAddPointM 方法
|
||||
{
|
||||
lstLog.Items.Add("ExtAddPointM ");
|
||||
int timeout = 5000;
|
||||
Axis[] axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1,Axis.ACSC_NONE };
|
||||
double[] points = { 0, 0 };
|
||||
_ACS.EnableM(axes); // Enable axes 0 and 1
|
||||
// Wait axis 0 enabled during 5 sec
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_0, 1, timeout);
|
||||
// Wait axis 1 enabled during 5 sec
|
||||
_ACS.WaitMotorEnabled(Axis.ACSC_AXIS_1, 1, timeout);
|
||||
// Create multi-point motion with default velocity without
|
||||
// dwell
|
||||
_ACS.MultiPointM(MotionFlags.ACSC_AMF_VELOCITY, axes, 0);
|
||||
|
||||
// Add some points
|
||||
for (int index = 0; index < 5; index++)
|
||||
{
|
||||
// Position and velocity for each point
|
||||
points[0] = 100 * index;
|
||||
points[1] = 100 * index;
|
||||
_ACS.ExtAddPointM(axes, points, 5000);
|
||||
}
|
||||
// Finish the motion
|
||||
// End of the multi-point motion
|
||||
_ACS.EndSequenceM(axes);
|
||||
|
||||
record = true;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user