diff --git a/HSI_HexagonMI_EF3/HSI_Motion.cpp b/HSI_HexagonMI_EF3/HSI_Motion.cpp index 1a51bff..a04d278 100644 --- a/HSI_HexagonMI_EF3/HSI_Motion.cpp +++ b/HSI_HexagonMI_EF3/HSI_Motion.cpp @@ -2424,6 +2424,8 @@ HSI_STATUS HSI_Motion::StopJog() g_pLogger->SendAndFlushWithTime(L"[StopJog] ACS acsc_HaltM error!\n"); ErrorsHandler(); } + // + g_pLogger->SendAndFlushWithTime(L"[StopJog] ACS acsc_HaltM success!\n"); } m_Thread_StateJOGStop = HSI_THREAD_PAUSED; @@ -5503,6 +5505,34 @@ HSI_STATUS HSI_Motion::DCCPPStartPoint(double* startPoint) return rStatus; } +//=========================================================================== +/* + * 设置扫描数据并指定三轴坐标点 + * @param AxisTypes 三轴类型(如X、Y、Z),用于指定要设置的触发轴,预留 + * @param speed 运动速度 + * @param points 三维坐标点数组 + * @param numPoints 坐标点数量 + */ +HSI_STATUS HSI_Motion::DCCScanSetDataWithPoints(UINT AxisTypes, double speed, Point3D* points, UINT numPoints) +{ + auto rStatus = HSI_STATUS_NORMAL; + // 处理传入的三维坐标点数组 + for (UINT i = 0; i < numPoints; ++i) + { + Point3D point = points[i]; + // 在这里处理每个点,例如打印或存储 + printf("Point %u: x = %f, y = %f, z = %f\n", i, point.x, point.y, point.z); + } + + // 控制平台的运动,(安全限位的问题,导入100个点,判断是否在运动空间内) + + // 其他处理逻辑 + // ... + + + return rStatus; +} + //=========================================================================== HSI_STATUS HSI_Motion::DCCScanSetDataOld(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis) { diff --git a/HSI_HexagonMI_EF3/HSI_Motion.h b/HSI_HexagonMI_EF3/HSI_Motion.h index d34ab8a..6ea475c 100644 --- a/HSI_HexagonMI_EF3/HSI_Motion.h +++ b/HSI_HexagonMI_EF3/HSI_Motion.h @@ -139,6 +139,12 @@ using TCPIP_RETURN_CODE = enum TCPIP_CONNECT_STATUS_UNKNOWN }; +struct Point3D { + double x; + double y; + double z; +}; + class HSI_Motion : public HSI { public: @@ -307,41 +313,25 @@ public: HSI_STATUS SetPositionStep(UINT AxisTypes, double Position, HSI_MOTION_MOVE_TYPE eType, double dSpeedGear); HSI_STATUS SetPositionEx(UINT AxisTypes, double Position, HSI_MOTION_MOVE_TYPE eType, double dSpeedGear); HSI_STATUS GetSpeedEx(UINT AxisTypes, double& Speed); - /** - * \brief 设置单轴运动速度 - * \param AxisTypes - * \param Speed - * \return - */ - HSI_STATUS SetSpeedEx(UINT AxisTypes, double Speed); + + HSI_STATUS SetSpeedEx(UINT AxisTypes, double Speed);//设置单轴运动速度 HSI_STATUS SetSpeedExOld(UINT AxisTypes, double Speed); HSI_STATUS GetAccelerationEx(UINT AxisTypes, double& Accel); HSI_STATUS SetAccelerationEx(UINT AxisTypes, double Accel); HSI_STATUS SetTriggerLight(int triggleNum, int delayLighting, int delayLightBefor, int triggleMode, double* Intensities); HSI_STATUS DCCPPStartPoint(double* startPoint); - /** - * \brief 下发触发间距 - * \param AxisTypes 轴 - * \param eType 等间距或者等时间 - * \param lTrigNumber 触发数量 - * \param dTrigDis 间距 - * \return - */ - HSI_STATUS DCCScanSetData(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis); + + HSI_STATUS DCCScanSetData(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis);// 下发触发间距,轴、等间距或者等时间、触发数量、间距 HSI_STATUS DCCScanSetDataOld(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis); - /** - * \brief 开始扫描 - * \return - */ - HSI_STATUS DCCScanStart(); + + HSI_STATUS DCCScanStart(); //开始扫描 HSI_STATUS DCCScanStartOld(); - /** - * \brief 停止扫描 - * \return - */ - HSI_STATUS DCCScanStop(); + + HSI_STATUS DCCScanStop(); //停止扫描 HSI_STATUS DCCScanStopOld(); + + HSI_STATUS DCCScanSetDataWithPoints(UINT AxisTypes, double speed, Point3D* points, UINT numPoints); // 直线电机平台新增,三轴轨迹规划 HSI_STATUS DCCForLightPlate(); HSI_STATUS IOStep(bool RunSts); diff --git a/HSI_HexagonMI_EF3/version.h b/HSI_HexagonMI_EF3/version.h index 96334d7..64ea463 100644 --- a/HSI_HexagonMI_EF3/version.h +++ b/HSI_HexagonMI_EF3/version.h @@ -12,5 +12,5 @@ #define HSI_VERSION_REVNUM #define HSI_VERSION_BUILD_DATE _T(__DATE__ ) #define HSI_VERSION_BUILD_TIME _T(__TIME__ ) -#define HSI_FILE_DESCRIPTION "周三 2.24.07 / 10:59 " -#define HSI_FILE_CSDESCRIPTION _T("周三 2.24.07 / 10:59 ") +#define HSI_FILE_DESCRIPTION "周四 2.24.08 / 13:09 " +#define HSI_FILE_CSDESCRIPTION _T("周四 2.24.08 / 13:09 ") diff --git a/Motion/ACS Motion/MainForm.Designer.cs b/Motion/ACS Motion/MainForm.Designer.cs index 873b8c4..a06220c 100644 --- a/Motion/ACS Motion/MainForm.Designer.cs +++ b/Motion/ACS Motion/MainForm.Designer.cs @@ -171,7 +171,14 @@ this.btnEventMotionEnd = new System.Windows.Forms.Button(); this.rtxtTerminal = new System.Windows.Forms.RichTextBox(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.button17 = new System.Windows.Forms.Button(); + this.button16 = new System.Windows.Forms.Button(); + this.button15 = new System.Windows.Forms.Button(); + this.button14 = new System.Windows.Forms.Button(); + this.button13 = new System.Windows.Forms.Button(); + this.button12 = new System.Windows.Forms.Button(); this.btnSend = new System.Windows.Forms.Button(); + this.button11 = new System.Windows.Forms.Button(); this.txtCommand = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox9 = new System.Windows.Forms.GroupBox(); @@ -210,6 +217,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.groupBox1.SuspendLayout(); this.grpMotionTest.SuspendLayout(); this.grpMst.SuspendLayout(); @@ -261,7 +269,7 @@ this.txtIP.Name = "txtIP"; this.txtIP.Size = new System.Drawing.Size(91, 21); this.txtIP.TabIndex = 16; - this.txtIP.Text = "10.0.0.100"; + this.txtIP.Text = "100.0.0.100"; // // btnClose // @@ -1672,16 +1680,84 @@ // // groupBox4 // + this.groupBox4.Controls.Add(this.button18); + this.groupBox4.Controls.Add(this.button17); + this.groupBox4.Controls.Add(this.button16); + this.groupBox4.Controls.Add(this.button15); + this.groupBox4.Controls.Add(this.button14); + this.groupBox4.Controls.Add(this.button13); + this.groupBox4.Controls.Add(this.button12); this.groupBox4.Controls.Add(this.btnSend); + this.groupBox4.Controls.Add(this.button11); this.groupBox4.Controls.Add(this.txtCommand); this.groupBox4.Controls.Add(this.rtxtTerminal); this.groupBox4.Location = new System.Drawing.Point(11, 493); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(892, 220); + this.groupBox4.Size = new System.Drawing.Size(892, 256); this.groupBox4.TabIndex = 7; this.groupBox4.TabStop = false; this.groupBox4.Text = "命令行通讯"; // + // button17 + // + this.button17.Location = new System.Drawing.Point(527, 218); + this.button17.Name = "button17"; + this.button17.Size = new System.Drawing.Size(85, 30); + this.button17.TabIndex = 14; + this.button17.Text = "MoveM"; + 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.Name = "button16"; + this.button16.Size = new System.Drawing.Size(85, 30); + this.button16.TabIndex = 13; + this.button16.Text = "BlendedLine"; + this.button16.UseVisualStyleBackColor = true; + this.button16.Click += new System.EventHandler(this.button16_Click); + // + // button15 + // + this.button15.Location = new System.Drawing.Point(196, 218); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(85, 30); + this.button15.TabIndex = 12; + this.button15.Text = "ExtLine"; + this.button15.UseVisualStyleBackColor = true; + this.button15.Click += new System.EventHandler(this.button15_Click); + // + // button14 + // + this.button14.Location = new System.Drawing.Point(98, 218); + this.button14.Name = "button14"; + this.button14.Size = new System.Drawing.Size(85, 30); + this.button14.TabIndex = 11; + this.button14.Text = "SegmentLine"; + this.button14.UseVisualStyleBackColor = true; + this.button14.Click += new System.EventHandler(this.button14_Click); + // + // button13 + // + this.button13.Location = new System.Drawing.Point(759, 218); + this.button13.Name = "button13"; + this.button13.Size = new System.Drawing.Size(85, 30); + this.button13.TabIndex = 10; + this.button13.Text = "AddPVTPointM"; + this.button13.UseVisualStyleBackColor = true; + this.button13.Click += new System.EventHandler(this.button13_Click); + // + // button12 + // + this.button12.Location = new System.Drawing.Point(628, 218); + this.button12.Name = "button12"; + this.button12.Size = new System.Drawing.Size(85, 30); + this.button12.TabIndex = 9; + this.button12.Text = "SplineM"; + this.button12.UseVisualStyleBackColor = true; + this.button12.Click += new System.EventHandler(this.button12_Click); + // // btnSend // this.btnSend.Location = new System.Drawing.Point(784, 20); @@ -1692,6 +1768,16 @@ this.btnSend.UseVisualStyleBackColor = true; this.btnSend.Click += new System.EventHandler(this.btnSend_Click); // + // button11 + // + this.button11.Location = new System.Drawing.Point(9, 218); + this.button11.Name = "button11"; + this.button11.Size = new System.Drawing.Size(85, 30); + this.button11.TabIndex = 8; + this.button11.Text = "MultiPointM"; + this.button11.UseVisualStyleBackColor = true; + this.button11.Click += new System.EventHandler(this.button11_Click); + // // txtCommand // this.txtCommand.Location = new System.Drawing.Point(9, 20); @@ -1984,6 +2070,7 @@ this.button1.TabIndex = 0; this.button1.Text = "开始"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox10 // @@ -1996,7 +2083,7 @@ this.groupBox10.Controls.Add(this.checkBox2); this.groupBox10.Location = new System.Drawing.Point(919, 610); this.groupBox10.Name = "groupBox10"; - this.groupBox10.Size = new System.Drawing.Size(295, 103); + this.groupBox10.Size = new System.Drawing.Size(295, 139); this.groupBox10.TabIndex = 9; this.groupBox10.TabStop = false; this.groupBox10.Text = "XYZ循环"; @@ -2066,10 +2153,20 @@ this.checkBox2.Text = "X"; this.checkBox2.UseVisualStyleBackColor = true; // + // button18 + // + 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); + // // MainForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.ClientSize = new System.Drawing.Size(1226, 725); + this.ClientSize = new System.Drawing.Size(1226, 761); this.Controls.Add(this.groupBox10); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); @@ -2080,6 +2177,7 @@ this.Controls.Add(this.grpMotionTest); this.Controls.Add(this.groupBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(1242, 800); this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "以色列ACS 运动控制器"; @@ -2302,6 +2400,14 @@ private System.Windows.Forms.Label label50; private System.Windows.Forms.Label label49; private System.Windows.Forms.Label label47; + private System.Windows.Forms.Button button11; + private System.Windows.Forms.Button button15; + private System.Windows.Forms.Button button14; + private System.Windows.Forms.Button button13; + private System.Windows.Forms.Button button12; + private System.Windows.Forms.Button button16; + private System.Windows.Forms.Button button17; + private System.Windows.Forms.Button button18; } } diff --git a/Motion/ACS Motion/MainForm.cs b/Motion/ACS Motion/MainForm.cs index e92bb9c..f54e1a3 100644 --- a/Motion/ACS Motion/MainForm.cs +++ b/Motion/ACS Motion/MainForm.cs @@ -15,7 +15,7 @@ namespace ACS_DotNET_Library_Advanced_Demo { public partial class MainForm : Form { - private Api _ACS; + private Api _ACS; private const int MAX_AXIS_COUNT = 32; private const int MAX_BUFFER_CNT = 64; @@ -31,7 +31,7 @@ namespace ACS_DotNET_Library_Advanced_Demo // For update values private MotorStates m_nMotorState; //运动状态 - private ProgramStates m_nProgramState; //程序状态 + private ProgramStates m_nProgramState; //程序状态 private object m_objReadVar = null; private Array m_arrReadVector = null; private double m_lfRPos, m_lfFPos, m_lfPE, m_lfFVEL; //参考位置,反馈位置 位置误差 反馈速度 double类型 @@ -44,22 +44,41 @@ namespace ACS_DotNET_Library_Advanced_Demo private Label[] m_lblOutput; private Button[] m_btnOutput; + + + //定一个point结构体,用于存储点的坐标 + public struct Point + { + public double x; + public double y; + public double z; + } + //定义一个point结构体的列表,用于存储多个点的坐标 + public List pointList = new List(); + //定一个point结构体的对象 + public Point point = new Point(); + + + // 记录标志位 + private bool record = false; + private int record_count = 0; //时间计数 + public MainForm() { InitializeComponent(); - _ACS = new Api(); //初始化 ACS运动控制类 + _ACS = new Api(); //初始化 ACS运动控制类 - // Register Event 注册时间 - _ACS.PHYSICALMOTIONEND += _ACS_PHYSICALMOTIONEND; - _ACS.PROGRAMEND += _ACS_PROGRAMEND; + // Register Event 注册时间 + _ACS.PHYSICALMOTIONEND += _ACS_PHYSICALMOTIONEND; + _ACS.PROGRAMEND += _ACS_PROGRAMEND; } #region Initialize private void Form1_Load(object sender, EventArgs e) { - rdoTCP.Checked = true; - btnOpen.Enabled = true; + rdoTCP.Checked = true; + btnOpen.Enabled = true; btnClose.Enabled = false; m_lblLeftLimit = new Label[MAX_UI_LIMIT_CNT]; //左限位 @@ -111,7 +130,7 @@ namespace ACS_DotNET_Library_Advanced_Demo m_btnOutput[5] = btnSW5; m_btnOutput[6] = btnSW6; m_btnOutput[7] = btnSW7; - + //m_nFault = new int[MAX_AXIS_COUNT]; //Array.Clear(m_nFault, 0, MAX_AXIS_COUNT); m_nOutputState = 0; @@ -131,14 +150,14 @@ namespace ACS_DotNET_Library_Advanced_Demo txtIP.Enabled = false; txtPort.Enabled = false; } - #endregion + #endregion #region Communication - Open / Close private void btnOpen_Click(object sender, EventArgs e) { string strTemp; int i; - //double lfTemp = 0.0f; + //double lfTemp = 0.0f; try { @@ -148,25 +167,25 @@ namespace ACS_DotNET_Library_Advanced_Demo _ACS.OpenCommEthernetTCP( txtIP.Text, // IP Address (Default : 10.0.0.100) Convert.ToInt32(txtPort.Text.Trim())); // TCP/IP Port nubmer (default : 701) - + } else if (rdoSimu.Checked) { // Simmulation mode - _ACS.OpenCommSimulator(); + _ACS.OpenCommSimulator(); } m_bConnected = true; // Get Total number of axes - // Using Transaction function : return string text from controller, we need to convert to integer value + // Using Transaction function : return string text from controller, we need to convert to integer value strTemp = _ACS.Transaction("?SYSINFO(13)"); m_nTotalAxis = Convert.ToInt32(strTemp.Trim()); - // Using Sysinfo function - //_ACS.GetSysInfo(_ACS.ACSC_SYS_NAXES_KEY, out lfTemp); + // 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) + // 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) m_arrAxisList = new Axis[m_nTotalAxis + 1]; for (i = 0; i < m_nTotalAxis; i++) { @@ -174,7 +193,7 @@ namespace ACS_DotNET_Library_Advanced_Demo m_arrAxisList[i] = (Axis)i; } // Insert '-1' at the last - m_arrAxisList[m_nTotalAxis] = Axis.ACSC_NONE; + m_arrAxisList[m_nTotalAxis] = Axis.ACSC_NONE; cboAxisNo.SelectedIndex = 0; // Update current motion paramter to UI. @@ -192,7 +211,7 @@ namespace ACS_DotNET_Library_Advanced_Demo tmrMonitor.Interval = 50; tmrMonitor.Start(); } - + catch (COMException comex) { MessageBox.Show("Connection fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -229,14 +248,14 @@ namespace ACS_DotNET_Library_Advanced_Demo { try { - string terminateExceptionConnName = "ACS.Framework.exe"; + string terminateExceptionConnName = "ACS.Framework.exe"; - ACSC_CONNECTION_DESC[] connectionList = _ACS.GetConnectionsList(); - for (int index = 0; index < connectionList.Length; index++) + ACSC_CONNECTION_DESC[] connectionList = _ACS.GetConnectionsList(); + for (int index = 0; index < connectionList.Length; index++) { - if (terminateExceptionConnName.CompareTo((string)connectionList[index].Application) != 0) - _ACS.TerminateConnection(connectionList[index]); + if (terminateExceptionConnName.CompareTo((string)connectionList[index].Application) != 0) + _ACS.TerminateConnection(connectionList[index]); } } catch (Exception ex) @@ -244,7 +263,7 @@ namespace ACS_DotNET_Library_Advanced_Demo System.Diagnostics.Debug.WriteLine(ex.ToString()); } } - #endregion + #endregion #region Update UI data from Controller /// @@ -254,11 +273,11 @@ namespace ACS_DotNET_Library_Advanced_Demo { if (m_bConnected) { - txtVel.Text = _ACS.GetVelocity((Axis)cboAxisNo.SelectedIndex).ToString(); - txtAcc.Text = _ACS.GetAcceleration((Axis)cboAxisNo.SelectedIndex).ToString(); - txtDec.Text = _ACS.GetDeceleration((Axis)cboAxisNo.SelectedIndex).ToString(); - txtKdec.Text = _ACS.GetKillDeceleration((Axis)cboAxisNo.SelectedIndex).ToString(); - txtJerk.Text = _ACS.GetJerk((Axis)cboAxisNo.SelectedIndex).ToString(); + txtVel.Text = _ACS.GetVelocity((Axis)cboAxisNo.SelectedIndex).ToString(); + txtAcc.Text = _ACS.GetAcceleration((Axis)cboAxisNo.SelectedIndex).ToString(); + txtDec.Text = _ACS.GetDeceleration((Axis)cboAxisNo.SelectedIndex).ToString(); + txtKdec.Text = _ACS.GetKillDeceleration((Axis)cboAxisNo.SelectedIndex).ToString(); + txtJerk.Text = _ACS.GetJerk((Axis)cboAxisNo.SelectedIndex).ToString(); } } @@ -266,62 +285,64 @@ namespace ACS_DotNET_Library_Advanced_Demo { UpdateProfile(); } + + private void tmrMonitor_Tick(object sender, EventArgs e) { - // Get selected axis number - int iAxisNo = cboAxisNo.SelectedIndex; - // Get selected buffer number - int iBufferNo = cboBufferNo.SelectedIndex; + // Get selected axis number + int iAxisNo = cboAxisNo.SelectedIndex; + // Get selected buffer number + int iBufferNo = cboBufferNo.SelectedIndex; if (m_bConnected) { 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 + // 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) - m_nMotorState = _ACS.GetMotorState((Axis)iAxisNo); + m_nMotorState = _ACS.GetMotorState((Axis)iAxisNo); // Returned value is integer, you need to use bitmaks - if ((m_nMotorState & MotorStates.ACSC_MST_MOVE) != 0) lblMoving.Image = Properties.Resources.On; else lblMoving.Image = Properties.Resources.Off; // 运动中 - if ((m_nMotorState & MotorStates.ACSC_MST_INPOS) != 0) lblInPos.Image = Properties.Resources.On; else lblInPos.Image = Properties.Resources.Off; // 就位 - if ((m_nMotorState & MotorStates.ACSC_MST_ACC) != 0) lblAcc.Image = Properties.Resources.On; else lblAcc.Image = Properties.Resources.Off; // 加速 - if ((m_nMotorState & MotorStates.ACSC_MST_ENABLE) != 0) lblEnable.Image = Properties.Resources.On; else lblEnable.Image = Properties.Resources.Off; // 使能 + if ((m_nMotorState & MotorStates.ACSC_MST_MOVE) != 0) lblMoving.Image = Properties.Resources.On; else lblMoving.Image = Properties.Resources.Off; // 运动中 + if ((m_nMotorState & MotorStates.ACSC_MST_INPOS) != 0) lblInPos.Image = Properties.Resources.On; else lblInPos.Image = Properties.Resources.Off; // 就位 + if ((m_nMotorState & MotorStates.ACSC_MST_ACC) != 0) lblAcc.Image = Properties.Resources.On; else lblAcc.Image = Properties.Resources.Off; // 加速 + if ((m_nMotorState & MotorStates.ACSC_MST_ENABLE) != 0) lblEnable.Image = Properties.Resources.On; else lblEnable.Image = Properties.Resources.Off; // 使能 // Reference position // ACSPL+ Variable : RPOS (real) - m_lfRPos = _ACS.GetRPosition((Axis)iAxisNo); // 参考位置 + m_lfRPos = _ACS.GetRPosition((Axis)iAxisNo); // 参考位置 // Feedback position (Encoder value) // ACSPL+ Variable : FPO (real) - m_lfFPos = _ACS.GetFPosition((Axis)iAxisNo); //反馈位置 + m_lfFPos = _ACS.GetFPosition((Axis)iAxisNo); //反馈位置 // PE (Position Error) - // There is no function in library. We need to use ReadVariable function - m_lfPE = (double)_ACS.ReadVariable("PE", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //位置误差 + // There is no function in library. We need to use ReadVariable function + m_lfPE = (double)_ACS.ReadVariable("PE", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //位置误差 - // Feedback Velocity - m_lfFVEL = (double)_ACS.ReadVariable("FVEL", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //实际速度 + // Feedback Velocity + m_lfFVEL = (double)_ACS.ReadVariable("FVEL", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //实际速度 txtRPOS.Text = String.Format("{0:0.0000}", m_lfRPos); txtFPOS.Text = String.Format("{0:0.0000}", m_lfFPos); - txtPE.Text = String.Format("{0:0.0000}", m_lfPE); - txtFVEL.Text = String.Format("{0:0.0000}", m_lfFVEL); + txtPE.Text = String.Format("{0:0.0000}", m_lfPE); + txtFVEL.Text = String.Format("{0:0.0000}", m_lfFVEL); // Program State 运动状态 // State : Compiled, Running, Suspended, Autoroutine is running (ON syntax) // // ACSPL+ Variable : PST (integer) - m_nProgramState = _ACS.GetProgramState((ProgramBuffer)iBufferNo); + m_nProgramState = _ACS.GetProgramState((ProgramBuffer)iBufferNo); if ((m_nProgramState & ProgramStates.ACSC_PST_RUN) != 0) { lblPRG_Status_LED.Image = Properties.Resources.On; @@ -349,11 +370,11 @@ namespace ACS_DotNET_Library_Advanced_Demo } // Read digital input/output (Port means all of bits) - // If you want to read only 1 bit (not an integer), use "GetInput" function - m_nValues = _ACS.GetInputPort(0); // _ACS.ReadVariableAsVector("IN", -1, 0, 0, -1, -1); + // If you want to read only 1 bit (not an integer), use "GetInput" function + m_nValues = _ACS.GetInputPort(0); // _ACS.ReadVariableAsVector("IN", -1, 0, 0, -1, -1); UpdateIOState(m_nValues, true); - m_nOutputState = _ACS.GetOutputPort(0); // _ACS.ReadVariableAsVector("OUT", -1, 0, 0, -1, -1); + m_nOutputState = _ACS.GetOutputPort(0); // _ACS.ReadVariableAsVector("OUT", -1, 0, 0, -1, -1); UpdateIOState(m_nOutputState, false); } catch (Exception ex) @@ -361,6 +382,46 @@ namespace ACS_DotNET_Library_Advanced_Demo MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Diagnostics.Debug.WriteLine(ex.Message); } + + //编写代码,刷新0,1,8轴的位置 + point.x = _ACS.GetRPosition((Axis)0); //参考位置 + point.y = _ACS.GetRPosition((Axis)1); //参考位置 + point.z = _ACS.GetRPosition((Axis)8); //参考位置 + + //对 point 保留3位小数 + label54.Text = point.x.ToString("0.000"); + label55.Text = point.y.ToString("0.000"); + label56.Text = point.z.ToString("0.000"); + + + if (record) + { + 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(); + } + } + + } } } @@ -369,8 +430,8 @@ namespace ACS_DotNET_Library_Advanced_Demo { if (axisNo < MAX_UI_LIMIT_CNT) { - if ((fault & (int)SafetyControlMasks.ACSC_SAFETY_LL) != 0) m_lblLeftLimit[axisNo].Image = Properties.Resources.Error; else m_lblLeftLimit[axisNo].Image = Properties.Resources.Off; - if ((fault & (int)SafetyControlMasks.ACSC_SAFETY_RL) != 0) m_lblRightLimit[axisNo].Image = Properties.Resources.Error; else m_lblRightLimit[axisNo].Image = Properties.Resources.Off; + if ((fault & (int)SafetyControlMasks.ACSC_SAFETY_LL) != 0) m_lblLeftLimit[axisNo].Image = Properties.Resources.Error; else m_lblLeftLimit[axisNo].Image = Properties.Resources.Off; + if ((fault & (int)SafetyControlMasks.ACSC_SAFETY_RL) != 0) m_lblRightLimit[axisNo].Image = Properties.Resources.Error; else m_lblRightLimit[axisNo].Image = Properties.Resources.Off; } } @@ -382,7 +443,7 @@ namespace ACS_DotNET_Library_Advanced_Demo for (int i = 0; i < MAX_UI_IO_CNT; i++) { if (isInput) - { + { // Input state if ((value & bitUpCnt) != 0) m_lblInput[i].Image = Properties.Resources.On; else m_lblInput[i].Image = Properties.Resources.Off; @@ -411,27 +472,27 @@ namespace ACS_DotNET_Library_Advanced_Demo #region Motor Enable / Disable private void btnEnable_Click(object sender, EventArgs e) { - // Enable selected axis + // Enable selected axis _ACS.Enable((Axis)cboAxisNo.SelectedIndex); - + // If you want to enable several axes, - // - // Ex) Eanble three axes (0, 1, 6) + // + // Ex) Eanble three axes (0, 1, 6) // - // int[] AxisList = new int[] { 0, 1, 6, -1 }; !!!! Important !! Must insert '-1' at the last + // int[] AxisList = new int[] { 0, 1, 6, -1 }; !!!! Important !! Must insert '-1' at the last // _ACS.EnableM(AxisList); } private void btnDisable_Click(object sender, EventArgs e) { - // Disable selected axis + // Disable selected axis _ACS.Disable((Axis)cboAxisNo.SelectedIndex); - // Disable multi axes : DisableM(int[] axisList) + // Disable multi axes : DisableM(int[] axisList) } private void btnDisableAll_Click(object sender, EventArgs e) { - // Disable all of axes + // Disable all of axes _ACS.DisableAll(); } #endregion @@ -439,12 +500,12 @@ namespace ACS_DotNET_Library_Advanced_Demo private void btnSetZero_Click(object sender, EventArgs e) { // Change current poisition as you want - // SetFPosition(Axis number, new position) + // SetFPosition(Axis number, new position) _ACS.SetFPosition((Axis)cboAxisNo.SelectedIndex, 0); } - #region Move to absolute position - private void btnPTP_Click(object sender, EventArgs e) + #region Move to absolute position + private void btnPTP_Click(object sender, EventArgs e) { double lfTargetPos = 0.0f; try @@ -453,9 +514,9 @@ namespace ACS_DotNET_Library_Advanced_Demo { lfTargetPos = Convert.ToDouble(txtPTP_Pos.Text); _ACS.ToPoint( - 0, // '0' - Absolute position - (Axis)cboAxisNo.SelectedIndex, // Axis number - lfTargetPos // Target position + 0, // '0' - Absolute position + (Axis)cboAxisNo.SelectedIndex, // Axis number + lfTargetPos // Target position ); } } @@ -467,7 +528,7 @@ namespace ACS_DotNET_Library_Advanced_Demo } #endregion - #region Move to relative position (from current position) + #region Move to relative position (from current position) private void btnPTP_R_Neg_Click(object sender, EventArgs e) { double lfTargetPos = 0.0f; @@ -476,12 +537,12 @@ namespace ACS_DotNET_Library_Advanced_Demo if (txtPTP_Pos.Text.Length > 0) { lfTargetPos = Convert.ToDouble(txtPTP_Pos.Text); - if (lfTargetPos > 0) lfTargetPos = lfTargetPos * (-1); // Target position (from current position, step move) + if (lfTargetPos > 0) lfTargetPos = lfTargetPos * (-1); // Target position (from current position, step move) _ACS.ToPoint( - MotionFlags.ACSC_AMF_RELATIVE, // Flat - (Axis)cboAxisNo.SelectedIndex, // Axis number - lfTargetPos // Move distance + MotionFlags.ACSC_AMF_RELATIVE, // Flat + (Axis)cboAxisNo.SelectedIndex, // Axis number + lfTargetPos // Move distance ); } } @@ -547,7 +608,7 @@ namespace ACS_DotNET_Library_Advanced_Demo #endregion #region JOG Command - // Move negative direction + private void btnJogNeg_MouseDown(object sender, MouseEventArgs e) { double lfVelocity = 0.0f; @@ -557,17 +618,17 @@ namespace ACS_DotNET_Library_Advanced_Demo if (chkUseVel.Checked) { lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim()); - if (lfVelocity > 0) lfVelocity = lfVelocity * (-1); // Negative direction : Using - (minus) velocity + if (lfVelocity > 0) lfVelocity = lfVelocity * (-1); // Negative direction : Using - (minus) velocity _ACS.Jog( - MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志 - (Axis)cboAxisNo.SelectedIndex, // Axis number - lfVelocity // Velocity + MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志 + (Axis)cboAxisNo.SelectedIndex, // Axis number + lfVelocity // Velocity ); } else { - _ACS.Jog(0, (Axis)cboAxisNo.SelectedIndex, (double)GlobalDirection.ACSC_NEGATIVE_DIRECTION); + _ACS.Jog(0, (Axis)cboAxisNo.SelectedIndex, (double)GlobalDirection.ACSC_NEGATIVE_DIRECTION); } } catch (Exception ex) @@ -576,7 +637,7 @@ namespace ACS_DotNET_Library_Advanced_Demo System.Diagnostics.Debug.WriteLine(ex.Message); } } - // 정방향 이동 동작 + private void btnJogPos_MouseDown(object sender, MouseEventArgs e) { double lfVelocity = 0.0f; @@ -586,7 +647,7 @@ namespace ACS_DotNET_Library_Advanced_Demo if (chkUseVel.Checked) { lfVelocity = Convert.ToDouble(txtJogVel.Text.Trim()); - if (lfVelocity < 0) lfVelocity = lfVelocity * (-1); + if (lfVelocity < 0) lfVelocity = lfVelocity * (-1); _ACS.Jog(MotionFlags.ACSC_AMF_VELOCITY, (Axis)cboAxisNo.SelectedIndex, lfVelocity); } @@ -601,7 +662,7 @@ namespace ACS_DotNET_Library_Advanced_Demo System.Diagnostics.Debug.WriteLine(ex.Message); } } - // Stop JOG motion + private void btnJog_MouseUp(object sender, MouseEventArgs e) { _ACS.Halt((Axis)cboAxisNo.SelectedIndex); @@ -644,7 +705,7 @@ namespace ACS_DotNET_Library_Advanced_Demo private void btnStopBuffer_Click(object sender, EventArgs e) { // Stop program - _ACS.StopBuffer((ProgramBuffer)cboBufferNo.SelectedIndex); + _ACS.StopBuffer((ProgramBuffer)cboBufferNo.SelectedIndex); } #endregion @@ -670,12 +731,12 @@ namespace ACS_DotNET_Library_Advanced_Demo { // Immediately change value (On the fly) : SetVelocityImm() // Affect next motion : SetVelocity() - + case 0: _ACS.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 1: _ACS.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 2: _ACS.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 3: _ACS.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 4: _ACS.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 1: _ACS.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 2: _ACS.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 3: _ACS.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 4: _ACS.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; } textBox.SelectAll(); @@ -715,11 +776,11 @@ namespace ACS_DotNET_Library_Advanced_Demo lfTemp = Convert.ToDouble(textBox.Text.Trim()); switch (textBox.TabIndex) { - case 0: _ACS.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 1: _ACS.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 2: _ACS.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 3: _ACS.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; - case 4: _ACS.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 0: _ACS.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 1: _ACS.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 2: _ACS.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 3: _ACS.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; + case 4: _ACS.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); break; } textBox.SelectAll(); @@ -748,17 +809,17 @@ namespace ACS_DotNET_Library_Advanced_Demo { // Set only 1 bit _ACS.SetOutput( - 0, // Port number - btn.TabIndex, // Bit number - 0 // 0 = OFF, 1 = ON + 0, // Port number + btn.TabIndex, // Bit number + 0 // 0 = OFF, 1 = ON ); - // If your I/O device is EtherCAT type, you cannot use this function - // You can use WriteVariable function and Command function - // - // Ex) If EtherCAT mapped variable is 'EC_DOUT' - // Want to ON bit '3' - // _ACS.Command("EC_DOUT.3=1"); + // If your I/O device is EtherCAT type, you cannot use this function + // You can use WriteVariable function and Command function + // + // Ex) If EtherCAT mapped variable is 'EC_DOUT' + // Want to ON bit '3' + // _ACS.Command("EC_DOUT.3=1"); } else { @@ -772,45 +833,45 @@ namespace ACS_DotNET_Library_Advanced_Demo } #endregion - #region Event - private void btnEventMotionEnd_Click(object sender, EventArgs e) - { - //_ACS.PHYSICALMOTIONEND +=_ACS_PHYSICALMOTIONEND; - _ACS.EnableEvent(Interrupts.ACSC_INTR_PHYSICAL_MOTION_END); - lstLog.Items.Add("PHYSICAL_MOTION_END event enabled"); - } + #region Event + private void btnEventMotionEnd_Click(object sender, EventArgs e) + { + //_ACS.PHYSICALMOTIONEND +=_ACS_PHYSICALMOTIONEND; + _ACS.EnableEvent(Interrupts.ACSC_INTR_PHYSICAL_MOTION_END); + lstLog.Items.Add("PHYSICAL_MOTION_END event enabled"); + } - void _ACS_PHYSICALMOTIONEND(AxisMasks axis) - { - int bit = 0x01; - int axisNo = 0; - // Param value is bit number - // Bit Number = Axis Number - for (int i = 0; i < 64; i++) - { - if ((int)axis == bit) - { - axisNo = i; - break; - } - bit = bit << 1; - } + void _ACS_PHYSICALMOTIONEND(AxisMasks axis) + { + int bit = 0x01; + int axisNo = 0; + // Param value is bit number + // Bit Number = Axis Number + for (int i = 0; i < 64; i++) + { + if ((int)axis == bit) + { + axisNo = i; + break; + } + bit = bit << 1; + } - // Add log to ListBox - this.Invoke((MethodInvoker)delegate - { - lstLog.Items.Add(String.Format(" - Axis {0}, Stoppped", axisNo)); - lstLog.SelectedIndex = lstLog.Items.Count - 1; - }); - - } + // Add log to ListBox + this.Invoke((MethodInvoker)delegate + { + lstLog.Items.Add(String.Format(" - Axis {0}, Stoppped", axisNo)); + lstLog.SelectedIndex = lstLog.Items.Count - 1; + }); - private void btnEventProgramEnd_Click(object sender, EventArgs e) - { - //_ACS.PROGRAMEND += _ACS_PROGRAMEND; - _ACS.EnableEvent(Interrupts.ACSC_INTR_PROGRAM_END); - lstLog.Items.Add("PROGRAM_END event enabled"); - } + } + + private void btnEventProgramEnd_Click(object sender, EventArgs e) + { + //_ACS.PROGRAMEND += _ACS_PROGRAMEND; + _ACS.EnableEvent(Interrupts.ACSC_INTR_PROGRAM_END); + lstLog.Items.Add("PROGRAM_END event enabled"); + } private void button8_Click(object sender, EventArgs e) { @@ -822,73 +883,341 @@ namespace ACS_DotNET_Library_Advanced_Demo } + + void _ACS_PROGRAMEND(BufferMasks buffer) - { - int bit = 0x01; - int bufferNo = 0; - // Param value is bit number - // Bit Number = Axis Number - for (int i = 0; i < 32; i++) - { - if ((int)buffer == bit) - { - bufferNo = i; - break; - } - bit = bit << 1; - } + { + int bit = 0x01; + int bufferNo = 0; + // Param value is bit number + // Bit Number = Axis Number + for (int i = 0; i < 32; i++) + { + if ((int)buffer == bit) + { + bufferNo = i; + break; + } + bit = bit << 1; + } - // Add log to ListBox - this.Invoke((MethodInvoker)delegate - { - lstLog.Items.Add(String.Format(" - Buffer {0}, Stoppped", bufferNo)); - lstLog.SelectedIndex = lstLog.Items.Count - 1; - }); - } - #endregion + // Add log to ListBox + this.Invoke((MethodInvoker)delegate + { + lstLog.Items.Add(String.Format(" - Buffer {0}, Stoppped", bufferNo)); + lstLog.SelectedIndex = lstLog.Items.Count - 1; + }); + } + #endregion - #region Communication Termial - Using Transaction function - private void txtCommand_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) - btnSend.PerformClick(); - } + #region Communication Termial - Using Transaction function + private void txtCommand_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == (char)Keys.Enter) + btnSend.PerformClick(); + } - private void btnSend_Click(object sender, EventArgs e) - { - string temp = string.Empty; - if (m_bConnected) - { - try - { - AppendTextToTextBox("> " + txtCommand.Text.Trim()); - temp = _ACS.Transaction(txtCommand.Text.Trim()); - } - catch (ACS.SPiiPlusNET.ACSException ex) - { - temp = String.Format("?{0}", ex.ErrorCode); - } - finally - { - if (temp.Length > 0) - { - AppendTextToTextBox(temp); - AppendTextToTextBox(":"); - } - } + private void btnSend_Click(object sender, EventArgs e) + { + string temp = string.Empty; + if (m_bConnected) + { + try + { + AppendTextToTextBox("> " + txtCommand.Text.Trim()); + temp = _ACS.Transaction(txtCommand.Text.Trim()); + } + catch (ACS.SPiiPlusNET.ACSException ex) + { + temp = String.Format("?{0}", ex.ErrorCode); + } + finally + { + if (temp.Length > 0) + { + AppendTextToTextBox(temp); + AppendTextToTextBox(":"); + } + } - txtCommand.Focus(); - txtCommand.SelectAll(); - } - } + txtCommand.Focus(); + txtCommand.SelectAll(); + } + } - private void AppendTextToTextBox(string text) - { - rtxtTerminal.AppendText(text); - rtxtTerminal.AppendText(Environment.NewLine); - rtxtTerminal.ScrollToCaret(); - } - #endregion - } + private void AppendTextToTextBox(string text) + { + rtxtTerminal.AppendText(text); + rtxtTerminal.AppendText(Environment.NewLine); + rtxtTerminal.ScrollToCaret(); + } + #endregion + + + #region 三轴插补运动 + + private void button11_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 axis 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 of axis 0 and 1 with default + // velocity without + // dwell in the points + _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); + + //将点添加到 lstLog.Items + lstLog.Items.Add("points[0]:" + points[0].ToString() + "points[1]:" + points[1].ToString()); + + } + lstLog.Items.Add("结束添加"); + // Finish the motion + // End of the multi-point motion + _ACS.EndSequenceM(axes); + lstLog.Items.Add("执行"); + record=true; + } + + + + private void button12_Click(object sender, EventArgs e) //SplineM 方法 + { + lstLog.Items.Add("SplineM"); + int timeout = 5000; + Axis[] axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1,Axis.ACSC_AXIS_8, Axis.ACSC_NONE }; + double[] points = { 0, 0 ,0}; + _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); + + + // 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); + + // Add some points + // 定义三维点列表 + int[,] pointsArray = new int[,] + { + { 0, 0, 0 }, + { 10, 20, -10 }, + { 20, 30, -40 }, + { 30, 50, -20 }, + { 40, 70, -30 }, + { 50, 80, -50 }, + { 60, 70, -60 }, + { 70, 50, -70 }, + { 80, 30, -80 }, + { 90, 10, -90 } + }; + + // 遍历列表并添加点 + for (int index = 0; index < pointsArray.GetLength(0); index++) + { + + points[0] = pointsArray[index, 0]; + points[1] = pointsArray[index, 1]; + points[2] = pointsArray[index, 2]; + + // 使用AddPVPointM方法添加点 + _ACS.AddPVPointM(axes, points, points); + + // 将点信息添加到lstLog.Items + lstLog.Items.Add($"points[0]: {points[0]} points[1]: {points[1]} points[2]: {points[2]}"); + } + + //_ACS.GoM(axes); + // Finish the motion + // End of the multi-point motion + _ACS.EndSequenceM(axes); + + _ACS.GoM(axes); + + + record = true; + + } + + + + private void button13_Click(object sender, EventArgs e) //AddPVTPointM 方法 + { + lstLog.Items.Add("AddPVTPointM"); + 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); + // PVT motion and uniform interval is not used + _ACS.SplineM(MotionFlags.ACSC_AMF_CUBIC | + MotionFlags.ACSC_AMF_VARTIME, axes, 0); + // Add some points + for (int index = 0; index < 5; index++) + { + points[0] = 100 * index; // 0, 100, 200, 300, 400 + points[1] = 50 * index; // 0, 200, 400, 600, 800 + _ACS.AddPVTPointM(axes, points, points, 1000); + } + // Finish the motion + // End of the multi-point motion + _ACS.EndSequenceM(axes); + + + record = true; + + + } + + private void button14_Click(object sender, EventArgs e)//SegmentLine,平面内 + { + lstLog.Items.Add("SegmentLine"); + int timeout = 5000; + Axis[] axes = { Axis.ACSC_AXIS_1, Axis.ACSC_AXIS_8, Axis.ACSC_NONE }; + double[] points = { 0, 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.SegmentedMotion(MotionFlags.ACSC_AMF_VELOCITY, axes, points); + + lstLog.Items.Add("SegmentLine 1"); + points[0] = 500; + points[1] = -100; + //points[2] = -100; + _ACS.SegmentLine(MotionFlags.ACSC_NONE, axes, points, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null); + _ACS.Stopper(axes); //平滑 + + points[0] = 200; + points[1] = -200; + //points[2] = -200; + _ACS.SegmentLine(MotionFlags.ACSC_NONE, axes, points, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null); + + _ACS.EndSequenceM(axes); + } + + private void button18_Click(object sender, EventArgs e) + { + lstLog.Items.Add("记录"); + record = true; + } + + private void button15_Click(object sender, EventArgs e) //ExtLine + { + int timeout = 5000; + + Axis[] axes = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1,Axis.ACSC_AXIS_8,Axis.ACSC_NONE }; + double[] points = { 0, 0, 0 }; + // Create segmented motion,coordinates of the initial point + // are(1000, 1000) + _ACS.EnableM(axes); + // 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); + + // Wait axis 8 enabled during 5 sec + _ACS.WaitMotorEnabled(Axis.ACSC_AXIS_8, 1, timeout); + _ACS.Segment(MotionFlags.ACSC_NONE, axes, points); + // Add line segment with final point (1000,-1000),vector + // velocity 25000 + points[0] = 100; + points[1] = 100; + points[2] = -10; + _ACS.ExtLine(axes, points, 25000); + _ACS.Stopper(axes); + // Add line segment with final point (-1000,-1000),vector + // velocity 25000 + points[0] = 100; + points[1] = 200; + points[2] = -100; + _ACS.ExtLine(axes, points, 25000); + _ACS.Stopper(axes); + // Add line segment with final point (-1000,1000),vector + // velocity 25000 + points[0] = 200; + points[1] = 200; + points[2] = -200; + _ACS.ExtLine(axes, points, 25000); + _ACS.Stopper(axes); + // Add line segment with final point (1000,1000), vector + // velocity 25000 + points[0] = 200; + points[1] = 100; + points[2] = -100; + _ACS.ExtLine(axes, points, 25000); + // Finish the motion + // End of the multi-point motion + _ACS.EndSequenceM(axes); + } + + private void button16_Click(object sender, EventArgs e) //BlendedLine + { + 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 + + _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[] 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 button1_Click(object sender, EventArgs e) + { + + } + + #endregion + + + + + + + } } diff --git a/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.exe b/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.exe index e62b219..dd0fcfb 100644 Binary files a/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.exe and b/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.exe differ diff --git a/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.pdb b/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.pdb index 839961b..62e6d11 100644 Binary files a/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.pdb and b/Motion/ACS Motion/bin/x64/Debug/ACS_Motion.pdb differ