diff --git a/HSI_HexagonMI_EF3/HSI_Motion.cpp b/HSI_HexagonMI_EF3/HSI_Motion.cpp index 58eb21d..f244464 100644 --- a/HSI_HexagonMI_EF3/HSI_Motion.cpp +++ b/HSI_HexagonMI_EF3/HSI_Motion.cpp @@ -788,8 +788,8 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly) } g_pLogger->SendAndFlushWithTime(L"[Startup] Out\n"); - //锁存模式设置,定时模式 - //if (m_IsUseRocker == 1) + //启用EF3锁存模式设置,定时模式 + if (m_IsUseEF3 ) { //设置锁存频率 1秒钟() m_cSendData[0] = 0x01; @@ -1083,10 +1083,7 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed) g_pLogger->SendAndFlushWithTime(L"[HomeMachine] bHomed No Need Reture\n"); return HSI_STATUS_NORMAL; } - if (m_IsUseEF3 == 0) //不启用EF3的情况 - { - return HSI_STATUS_NORMAL; - } + if (g_pHSI_Motion && (handleACS != ACSC_INVALID)) { //判断是否需要回家 @@ -1117,6 +1114,7 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed) CurrentHomeMachineState = E_EF3_HOME_ING; //正在回家中 //运行 ACS 控制器内 buffer6 自动回家动作 + g_pLogger->SendAndFlushWithTime(L"[HomeMachine] RunBuffer 6 \n"); //回家后,启用正负限位 if (!acsc_RunBuffer(handleACS, ACSC_BUFFER_6, nullptr, ACSC_SYNCHRONOUS)) { @@ -1144,19 +1142,22 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed) } while (!home); + if (m_IsUseEF3) //启用EF3锁存功能,需要再回家完成后,设置锁存板的位置 + { + //回家后,将锁存板的位置设置为0 + unsigned char m_cSendData[8] = { 0 }; + m_cSendData[0] = 0x01; + m_cSendData[1] = 0x06; + m_WriteByte = Send_Command(0, (const char*)m_cSendData, 2); + Sleep(5); - //回家后,将锁存板的位置设置为0 - unsigned char m_cSendData[8] = {0}; - m_cSendData[0] = 0x01; - m_cSendData[1] = 0x06; - m_WriteByte = Send_Command(0, (const char*)m_cSendData, 2); - Sleep(5); + //清除锁存板Flash区 + m_cSendData[0] = 0x01; + m_cSendData[1] = 0x04; + m_WriteByte = Send_Command(0, (const char*)m_cSendData, 2); + Sleep(5); - //清除锁存板Flash区 - m_cSendData[0] = 0x01; - m_cSendData[1] = 0x04; - m_WriteByte = Send_Command(0, (const char*)m_cSendData, 2); - Sleep(5); + } //回家表示改为1 m_Home_Machine_Axis[1] = 1; @@ -2905,7 +2906,7 @@ HSI_STATUS HSI_Motion::GetPositionXyz(UINT AxisTypes, double& PositionX, double& } //=========================================================================== -HSI_STATUS HSI_Motion::GetEncoderXyz(long* lEncoderVal) +HSI_STATUS HSI_Motion::GetEncoderXyz(long* lEncoderVal)//原读取编码器值使用串口获取EF3的光栅尺读数,待测试 { auto rStatus = HSI_STATUS_NORMAL; //读取3个轴的编码器值 @@ -2916,23 +2917,41 @@ HSI_STATUS HSI_Motion::GetEncoderXyz(long* lEncoderVal) if (m_DeviceType != 1) { if (m_IsHavePattern & 0x01) + { lEncoderVal[0] = (m_SO7_Serial.m_RecvData[1] << 24 | m_SO7_Serial.m_RecvData[2] << 16 | m_SO7_Serial .m_RecvData[3] << 8 | m_SO7_Serial.m_RecvData[4]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[0] %ld \n", lEncoderVal[0]); + } else + { lEncoderVal[0] = (m_SO7_Serial.m_RecvData[17] << 24 | m_SO7_Serial.m_RecvData[18] << 16 | m_SO7_Serial.m_RecvData[19] << 8 | m_SO7_Serial.m_RecvData[20]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[00] %ld \n", lEncoderVal[0]); + } if (m_IsHavePattern & 0x02) + { lEncoderVal[1] = (m_SO7_Serial.m_RecvData[5] << 24 | m_SO7_Serial.m_RecvData[6] << 16 | m_SO7_Serial .m_RecvData[7] << 8 | m_SO7_Serial.m_RecvData[8]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[1] %ld \n", lEncoderVal[1]); + } else + { lEncoderVal[1] = (m_SO7_Serial.m_RecvData[21] << 24 | m_SO7_Serial.m_RecvData[22] << 16 | m_SO7_Serial.m_RecvData[23] << 8 | m_SO7_Serial.m_RecvData[24]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[01] %ld \n", lEncoderVal[1]); + } if (m_IsHavePattern & 0x04) + { lEncoderVal[2] = (m_SO7_Serial.m_RecvData[9] << 24 | m_SO7_Serial.m_RecvData[10] << 16 | m_SO7_Serial.m_RecvData[11] << 8 | m_SO7_Serial.m_RecvData[12]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[2] %ld \n", lEncoderVal[2]); + } else + { lEncoderVal[2] = (m_SO7_Serial.m_RecvData[25] << 24 | m_SO7_Serial.m_RecvData[26] << 16 | m_SO7_Serial.m_RecvData[27] << 8 | m_SO7_Serial.m_RecvData[28]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[02] %ld \n", lEncoderVal[2]); + } } else { @@ -2942,6 +2961,7 @@ HSI_STATUS HSI_Motion::GetEncoderXyz(long* lEncoderVal) m_RecvData[23] << 8 | m_SO7_Serial.m_RecvData[24]); lEncoderVal[2] = (m_SO7_Serial.m_RecvData[25] << 24 | m_SO7_Serial.m_RecvData[26] << 16 | m_SO7_Serial. m_RecvData[27] << 8 | m_SO7_Serial.m_RecvData[28]); + g_pLogger->SendAndFlushWithTime(L"[GetEncoderXyz] lEncoderVal[0]= %ld,EncoderVal[1]= %ld,,EncoderVal[2]= %ld, \n", lEncoderVal[0], lEncoderVal[1], lEncoderVal[2]); } } else diff --git a/HSI_HexagonMI_EF3/version.h b/HSI_HexagonMI_EF3/version.h index 6e4dac0..96712df 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 "2024.02.28 / 15:15 " -#define HSI_FILE_CSDESCRIPTION _T("2024.02.28 / 15:15 ") +#define HSI_FILE_DESCRIPTION "2024.04.01 / 19:06 " +#define HSI_FILE_CSDESCRIPTION _T("2024.04.01 / 19:06 ") diff --git a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll index 6fb5a72..3900f21 100644 Binary files a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll and b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll differ diff --git a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb index cabcbc7..7074624 100644 Binary files a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb and b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll index 6fb5a72..3900f21 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe index c502140..2ca8d41 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb index 159a229..8301782 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb differ diff --git a/HexcalMC/MainFrom.Designer.cs b/HexcalMC/MainFrom.Designer.cs index 6ca791d..cd5089d 100644 --- a/HexcalMC/MainFrom.Designer.cs +++ b/HexcalMC/MainFrom.Designer.cs @@ -61,7 +61,6 @@ this.ribbonTab2 = new Telerik.WinControls.UI.RibbonTab(); this.radRibbonBarGroup2 = new Telerik.WinControls.UI.RadRibbonBarGroup(); this.rtb_about = new Telerik.WinControls.UI.RadButtonElement(); - this.radButtonElement3 = new Telerik.WinControls.UI.RadButtonElement(); this.radRibbonBar1 = new Telerik.WinControls.UI.RadRibbonBar(); this.radRibbonBarBackstageView1 = new Telerik.WinControls.UI.RadRibbonBarBackstageView(); this.radMenuItem2 = new Telerik.WinControls.UI.RadMenuItem(); @@ -208,7 +207,7 @@ // this.ribbonTab1.AutoEllipsis = false; this.ribbonTab1.DisabledTextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; - this.ribbonTab1.IsSelected = true; + this.ribbonTab1.IsSelected = false; this.ribbonTab1.Items.AddRange(new Telerik.WinControls.RadItem[] { this.radRibbonBarGroup1, this.radRibbonBarGroup4, @@ -415,7 +414,7 @@ // this.ribbonTab2.AutoEllipsis = false; this.ribbonTab2.DisabledTextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; - this.ribbonTab2.IsSelected = false; + this.ribbonTab2.IsSelected = true; this.ribbonTab2.Items.AddRange(new Telerik.WinControls.RadItem[] { this.radRibbonBarGroup2}); this.ribbonTab2.Name = "ribbonTab2"; @@ -429,8 +428,7 @@ this.radRibbonBarGroup2.AutoSize = false; this.radRibbonBarGroup2.Bounds = new System.Drawing.Rectangle(0, 0, 80, 100); this.radRibbonBarGroup2.Items.AddRange(new Telerik.WinControls.RadItem[] { - this.rtb_about, - this.radButtonElement3}); + this.rtb_about}); this.radRibbonBarGroup2.Margin = new System.Windows.Forms.Padding(0); this.radRibbonBarGroup2.MaxSize = new System.Drawing.Size(0, 0); this.radRibbonBarGroup2.MinSize = new System.Drawing.Size(0, 0); @@ -440,6 +438,8 @@ // // rtb_about // + this.rtb_about.AutoSize = false; + this.rtb_about.Bounds = new System.Drawing.Rectangle(0, 0, 60, 78); this.rtb_about.Image = global::HexcalMC.Properties.Resources.about; this.rtb_about.Name = "rtb_about"; this.rtb_about.Text = "鍏充簬"; @@ -449,14 +449,6 @@ this.rtb_about.UseCompatibleTextRendering = false; this.rtb_about.Click += new System.EventHandler(this.Rtb_about_Click); // - // radButtonElement3 - // - this.radButtonElement3.Image = global::HexcalMC.Properties.Resources.help; - this.radButtonElement3.Name = "radButtonElement3"; - this.radButtonElement3.Text = "甯姪"; - this.radButtonElement3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; - this.radButtonElement3.UseCompatibleTextRendering = false; - // // radRibbonBar1 // this.radRibbonBar1.BackstageControl = this.radRibbonBarBackstageView1; @@ -1355,7 +1347,6 @@ private Telerik.WinControls.UI.RibbonTab ribbonTab2; private Telerik.WinControls.UI.RadRibbonBarGroup radRibbonBarGroup2; private Telerik.WinControls.UI.RadButtonElement rtb_about; - private Telerik.WinControls.UI.RadButtonElement radButtonElement3; private Telerik.WinControls.UI.RadRibbonBar radRibbonBar1; private Telerik.WinControls.UI.RadMenuItem radMenuItem2; private Telerik.WinControls.UI.RadButtonElement radButtonElement4; diff --git a/HexcalMC/MainFrom.cs b/HexcalMC/MainFrom.cs index 65b8d4f..5b2c7ee 100644 --- a/HexcalMC/MainFrom.cs +++ b/HexcalMC/MainFrom.cs @@ -41,7 +41,8 @@ namespace HexcalMC private TcpIpServer _mTcpIpServer; //鍒涘缓tcpserver锛岀敤浜庢帴鏀秇excal浼犳潵鐨勬寚浠わ紝骞惰В鏋愪紶閫掑钩鍙 - + private int m_nTotalAxis; //瀹氫箟鎬昏酱鏁 + private Axis[] m_arrAxisList = null; public MainFrom() { InitializeComponent(); @@ -130,7 +131,7 @@ namespace HexcalMC ZMinstrokesw = FileIni.ReadDouble(StrConfigFile, "MOTOR", "Z_MINSTROKESW"); port = FileIni.ReadInt(StrConfigFile, "MOTOR", "Port"); - DebugDfn.AddLogText($"褰撳墠鐩戝惉绔彛{port}"); + DebugDfn.AddLogText($"褰撳墠鐩戝惉绔彛閰嶇疆涓: {port}"); } private void Plot2D(List pointCloud) @@ -206,8 +207,8 @@ namespace HexcalMC public static double ZMinstrokesw = -280; public static int port = 1234; //榛樿鐩戝惉绔彛 - //瀹氫箟涓涓3D鐐,瀛樺偍褰撳墠骞冲彴浣嶇疆 - private Point3D _mPoint3D; + //瀹氫箟涓涓3D鐐,瀛樺偍褰撳墠骞冲彴瀹炴椂浣嶇疆 + public Point3D _mPoint3D; #endregion @@ -552,7 +553,8 @@ namespace HexcalMC private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { // 闃叉绋嬪簭缁堟 - MessageBox.Show("鍙戠敓浜嗘湭澶勭悊鐨勫紓甯革細" + e.Exception.Message); + MessageBox.Show("鍙戠敓浜嗘湭澶勭悊鐨勫紓甯革細" + e.Exception.Message, "鎻愮ず", MessageBoxButtons.OK, + MessageBoxIcon.Information); } @@ -566,7 +568,8 @@ namespace HexcalMC private static void HandleException(Exception ex) { - MessageBox.Show($"鍙戠敓浜嗘湭澶勭悊鐨勫紓甯革細{ex.Message}"); + MessageBox.Show($"鍙戠敓浜嗘湭澶勭悊鐨勫紓甯革細{ex.Message}", "鎻愮ず", MessageBoxButtons.OK, + MessageBoxIcon.Information); } @@ -840,7 +843,7 @@ namespace HexcalMC if (_mAcsConnected) { - DisableFaultEvent(); + DisableFaultEvent(); //鍙栨秷娉ㄥ唽浜嬩欢 _acs.CloseComm(); } @@ -1255,10 +1258,10 @@ namespace HexcalMC //鍒ゆ柇閫氳瀵硅薄鏄惁瀛樺湪 if (_acs == null || !_acs.IsConnected) { - DebugDfn.AddLogText("鏈缓绔嬮氳锛岃鍦ㄤ富鐣岄潰鍏堝缓绔嬮氳"); + DebugDfn.AddLogText("鏈缓绔嬩笌杩愬姩骞冲彴閫氳锛岃鍦ㄤ富鐣岄潰鍏堝缓绔嬮氳"); // 鍦ㄥ悎閫傜殑浣嶇疆璋冪敤 MessageBox.Show() 鏂规硶 - MessageBox.Show("鏈缓绔嬮氳锛岃鍦ㄤ富鐣岄潰鍏堝缓绔嬮氳", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("鏈缓绔嬩笌杩愬姩骞冲彴閫氳锛岃鍦ㄤ富鐣岄潰鍏堝缓绔嬮氳", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } diff --git a/HexcalMC/Motion/Motion.Designer.cs b/HexcalMC/Motion/Motion.Designer.cs index 7152a05..afad344 100644 --- a/HexcalMC/Motion/Motion.Designer.cs +++ b/HexcalMC/Motion/Motion.Designer.cs @@ -173,12 +173,12 @@ this.txtCommand = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox9 = new System.Windows.Forms.GroupBox(); - this.label56 = new System.Windows.Forms.Label(); - this.label55 = new System.Windows.Forms.Label(); - this.label54 = new System.Windows.Forms.Label(); - this.label53 = new System.Windows.Forms.Label(); - this.label52 = new System.Windows.Forms.Label(); - this.label51 = new System.Windows.Forms.Label(); + this.lbl_Z_target = new System.Windows.Forms.Label(); + this.lbl_Y_target = new System.Windows.Forms.Label(); + this.lbl_X_target = new System.Windows.Forms.Label(); + this.lbl_z_current = new System.Windows.Forms.Label(); + this.lbl_Y_current = new System.Windows.Forms.Label(); + this.lbl_X_current = new System.Windows.Forms.Label(); this.label50 = new System.Windows.Forms.Label(); this.label49 = new System.Windows.Forms.Label(); this.label47 = new System.Windows.Forms.Label(); @@ -200,14 +200,6 @@ this.groupBox6 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.btn_home = new System.Windows.Forms.Button(); - this.groupBox10 = new System.Windows.Forms.GroupBox(); - this.label48 = new System.Windows.Forms.Label(); - 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.checkBox_Z = new System.Windows.Forms.CheckBox(); - this.checkBox_y = new System.Windows.Forms.CheckBox(); - this.checkBox_X = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.grpMotionTest.SuspendLayout(); this.grpMst.SuspendLayout(); @@ -225,7 +217,6 @@ this.groupBox8.SuspendLayout(); this.groupBox7.SuspendLayout(); this.groupBox6.SuspendLayout(); - this.groupBox10.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -556,10 +547,6 @@ // this.cboAxisNo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cboAxisNo.FormattingEnabled = true; - this.cboAxisNo.Items.AddRange(new object[] { - "0", - "1", - "8"}); this.cboAxisNo.Location = new System.Drawing.Point(115, 20); this.cboAxisNo.Name = "cboAxisNo"; this.cboAxisNo.Size = new System.Drawing.Size(60, 20); @@ -617,7 +604,7 @@ this.txtJogVel.Name = "txtJogVel"; this.txtJogVel.Size = new System.Drawing.Size(94, 21); this.txtJogVel.TabIndex = 1; - this.txtJogVel.Text = "0"; + this.txtJogVel.Text = "10"; this.txtJogVel.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // chkUseVel @@ -1684,82 +1671,82 @@ this.groupBox5.Controls.Add(this.groupBox6); this.groupBox5.Location = new System.Drawing.Point(919, 12); this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(298, 592); + this.groupBox5.Size = new System.Drawing.Size(298, 701); this.groupBox5.TabIndex = 8; this.groupBox5.TabStop = false; this.groupBox5.Text = "XYZ杞磋繍鍔"; // // groupBox9 // - this.groupBox9.Controls.Add(this.label56); - this.groupBox9.Controls.Add(this.label55); - this.groupBox9.Controls.Add(this.label54); - this.groupBox9.Controls.Add(this.label53); - this.groupBox9.Controls.Add(this.label52); - this.groupBox9.Controls.Add(this.label51); + this.groupBox9.Controls.Add(this.lbl_Z_target); + this.groupBox9.Controls.Add(this.lbl_Y_target); + this.groupBox9.Controls.Add(this.lbl_X_target); + this.groupBox9.Controls.Add(this.lbl_z_current); + this.groupBox9.Controls.Add(this.lbl_Y_current); + this.groupBox9.Controls.Add(this.lbl_X_current); this.groupBox9.Controls.Add(this.label50); this.groupBox9.Controls.Add(this.label49); this.groupBox9.Controls.Add(this.label47); this.groupBox9.Location = new System.Drawing.Point(6, 447); this.groupBox9.Name = "groupBox9"; - this.groupBox9.Size = new System.Drawing.Size(279, 139); + this.groupBox9.Size = new System.Drawing.Size(279, 243); this.groupBox9.TabIndex = 3; this.groupBox9.TabStop = false; this.groupBox9.Text = "褰撳墠瀹為檯浣嶇疆/瑙勫垝浣嶇疆(mm)"; // - // label56 + // lbl_Z_target // - this.label56.AutoSize = true; - this.label56.Location = new System.Drawing.Point(197, 95); - this.label56.Name = "label56"; - this.label56.Size = new System.Drawing.Size(11, 12); - this.label56.TabIndex = 8; - this.label56.Text = "0"; + this.lbl_Z_target.AutoSize = true; + this.lbl_Z_target.Location = new System.Drawing.Point(197, 95); + this.lbl_Z_target.Name = "lbl_Z_target"; + this.lbl_Z_target.Size = new System.Drawing.Size(11, 12); + this.lbl_Z_target.TabIndex = 8; + this.lbl_Z_target.Text = "0"; // - // label55 + // lbl_Y_target // - this.label55.AutoSize = true; - this.label55.Location = new System.Drawing.Point(197, 65); - this.label55.Name = "label55"; - this.label55.Size = new System.Drawing.Size(11, 12); - this.label55.TabIndex = 7; - this.label55.Text = "0"; + this.lbl_Y_target.AutoSize = true; + this.lbl_Y_target.Location = new System.Drawing.Point(197, 65); + this.lbl_Y_target.Name = "lbl_Y_target"; + this.lbl_Y_target.Size = new System.Drawing.Size(11, 12); + this.lbl_Y_target.TabIndex = 7; + this.lbl_Y_target.Text = "0"; // - // label54 + // lbl_X_target // - this.label54.AutoSize = true; - this.label54.Location = new System.Drawing.Point(197, 34); - this.label54.Name = "label54"; - this.label54.Size = new System.Drawing.Size(11, 12); - this.label54.TabIndex = 6; - this.label54.Text = "0"; + this.lbl_X_target.AutoSize = true; + this.lbl_X_target.Location = new System.Drawing.Point(197, 34); + this.lbl_X_target.Name = "lbl_X_target"; + this.lbl_X_target.Size = new System.Drawing.Size(11, 12); + this.lbl_X_target.TabIndex = 6; + this.lbl_X_target.Text = "0"; // - // label53 + // lbl_z_current // - this.label53.AutoSize = true; - this.label53.Location = new System.Drawing.Point(127, 95); - this.label53.Name = "label53"; - this.label53.Size = new System.Drawing.Size(11, 12); - this.label53.TabIndex = 5; - this.label53.Text = "0"; + this.lbl_z_current.AutoSize = true; + this.lbl_z_current.Location = new System.Drawing.Point(127, 95); + this.lbl_z_current.Name = "lbl_z_current"; + this.lbl_z_current.Size = new System.Drawing.Size(11, 12); + this.lbl_z_current.TabIndex = 5; + this.lbl_z_current.Text = "0"; // - // label52 + // lbl_Y_current // - this.label52.AutoSize = true; - this.label52.Location = new System.Drawing.Point(127, 65); - this.label52.Name = "label52"; - this.label52.Size = new System.Drawing.Size(11, 12); - this.label52.TabIndex = 4; - this.label52.Text = "0"; + this.lbl_Y_current.AutoSize = true; + this.lbl_Y_current.Location = new System.Drawing.Point(127, 65); + this.lbl_Y_current.Name = "lbl_Y_current"; + this.lbl_Y_current.Size = new System.Drawing.Size(11, 12); + this.lbl_Y_current.TabIndex = 4; + this.lbl_Y_current.Text = "0"; // - // label51 + // lbl_X_current // - this.label51.AutoSize = true; - this.label51.Location = new System.Drawing.Point(127, 34); - this.label51.Name = "label51"; - this.label51.Size = new System.Drawing.Size(11, 12); - this.label51.TabIndex = 3; - this.label51.Text = "0"; + this.lbl_X_current.AutoSize = true; + this.lbl_X_current.Location = new System.Drawing.Point(127, 34); + this.lbl_X_current.Name = "lbl_X_current"; + this.lbl_X_current.Size = new System.Drawing.Size(11, 12); + this.lbl_X_current.TabIndex = 3; + this.lbl_X_current.Text = "0"; // // label50 // @@ -1812,7 +1799,7 @@ this.btn_movepose.TabIndex = 7; this.btn_movepose.Text = "绉诲姩鍒扮洰鏍囦綅缃"; this.btn_movepose.UseVisualStyleBackColor = true; - this.btn_movepose.Click += new System.EventHandler(this.btn_movepose_Click); + this.btn_movepose.Click += new System.EventHandler(this.Btn_MovePose_Click); // // textBox_y // @@ -1820,6 +1807,7 @@ this.textBox_y.Name = "textBox_y"; this.textBox_y.Size = new System.Drawing.Size(100, 21); this.textBox_y.TabIndex = 5; + this.textBox_y.Text = "0"; // // textBox_z // @@ -1827,6 +1815,7 @@ this.textBox_z.Name = "textBox_z"; this.textBox_z.Size = new System.Drawing.Size(100, 21); this.textBox_z.TabIndex = 4; + this.textBox_z.Text = "0"; // // textBox_x // @@ -1834,6 +1823,7 @@ this.textBox_x.Name = "textBox_x"; this.textBox_x.Size = new System.Drawing.Size(100, 21); this.textBox_x.TabIndex = 3; + this.textBox_x.Text = "0"; // // label46 // @@ -1974,93 +1964,10 @@ this.btn_home.UseVisualStyleBackColor = true; this.btn_home.Click += new System.EventHandler(this.btn_home_Click); // - // groupBox10 - // - this.groupBox10.Controls.Add(this.label48); - 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.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); - this.groupBox10.TabIndex = 9; - this.groupBox10.TabStop = false; - this.groupBox10.Text = "XYZ寰幆"; - // - // label48 - // - this.label48.AutoSize = true; - 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 = "娆"; - // - // textBox_cycleTimes - // - 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(99, 60); - this.btn_halt.Name = "btn_halt"; - this.btn_halt.Size = new System.Drawing.Size(80, 30); - this.btn_halt.TabIndex = 4; - this.btn_halt.Text = "鍋滄寰幆"; - this.btn_halt.UseVisualStyleBackColor = true; - 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(80, 30); - this.btn_run.TabIndex = 3; - this.btn_run.Text = "寮濮嬪惊鐜"; - this.btn_run.UseVisualStyleBackColor = true; - this.btn_run.Click += new System.EventHandler(this.btn_run_Click); - // - // checkBox_Z - // - 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; - // - // checkBox_y - // - 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; - // - // checkBox_X - // - 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; - // // Motion // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(1226, 725); - this.Controls.Add(this.groupBox10); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); @@ -2105,8 +2012,6 @@ this.groupBox8.PerformLayout(); this.groupBox7.ResumeLayout(false); this.groupBox6.ResumeLayout(false); - this.groupBox10.ResumeLayout(false); - this.groupBox10.PerformLayout(); this.ResumeLayout(false); } @@ -2271,20 +2176,12 @@ 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.GroupBox groupBox10; - private System.Windows.Forms.Label label48; - 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 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; - private System.Windows.Forms.Label label53; - private System.Windows.Forms.Label label52; - private System.Windows.Forms.Label label51; + private System.Windows.Forms.Label lbl_Z_target; + private System.Windows.Forms.Label lbl_Y_target; + private System.Windows.Forms.Label lbl_X_target; + private System.Windows.Forms.Label lbl_z_current; + private System.Windows.Forms.Label lbl_Y_current; + private System.Windows.Forms.Label lbl_X_current; private System.Windows.Forms.Label label50; private System.Windows.Forms.Label label49; private System.Windows.Forms.Label label47; diff --git a/HexcalMC/Motion/Motion.cs b/HexcalMC/Motion/Motion.cs index 897d03e..805938f 100644 --- a/HexcalMC/Motion/Motion.cs +++ b/HexcalMC/Motion/Motion.cs @@ -21,6 +21,8 @@ namespace HexcalMC private readonly Api _acs; private readonly int _motionTimeout = 50000; //寤舵椂鏃堕棿 + private readonly MainFrom mainFrom; + private readonly Axis[] UseAxis = MainFrom.UseAxis; //鑾峰彇婵娲荤殑杞 private MotionStates _currentMotionState = MotionStates.None; //杩愬姩鐘舵 @@ -29,6 +31,10 @@ namespace HexcalMC private bool _mBConnected; private Button[] _mBtnOutput; + + + //瀹氫箟Jog杩愬姩 閫熷害 + private double _mJogVel = 10.0f; private Label[] _mLblInput; @@ -46,8 +52,6 @@ namespace HexcalMC private int _mNValues, _mNOutputState; private object _mObjReadVar; - private readonly MainFrom mainFrom; - public Motion(MainFrom mainFrom) { InitializeComponent(); @@ -247,21 +251,15 @@ namespace HexcalMC _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; - //} + 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; @@ -332,11 +330,6 @@ namespace HexcalMC } - /// - /// Terminate connections from SPiiPlus User Mode Driver - /// 缁堟鏉ヨ嚜 SPiiPlus 鐢ㄦ埛妯″紡椹卞姩绋嬪簭鐨勮繛鎺 - /// - Maximum connections up to 10 in UMD - /// private void TernminateUMD_Connection() { try @@ -462,6 +455,9 @@ namespace HexcalMC _mNOutputState = _acs.GetOutputPort(0); // _ACS.ReadVariableAsVector("OUT", -1, 0, 0, -1, -1); UpdateIoState(_mNOutputState, false); + + //鍒锋柊骞冲彴浣嶇疆 + UpdatePostion(); } catch (Exception ex) { @@ -471,8 +467,8 @@ namespace HexcalMC } } - // Update limit state - private void UpdateLimitState(int axisNo, int fault) + + private void UpdateLimitState(int axisNo, int fault) //鍒锋柊闄愪綅鐘舵 { if (axisNo < MaxUiLimitCnt) { @@ -485,8 +481,8 @@ namespace HexcalMC } } - // Update general I/O stae - private void UpdateIoState(int value, bool isInput) + + private void UpdateIoState(int value, bool isInput) //鍒锋柊IO鐘舵 { int bitUpCnt = 0x01; @@ -518,6 +514,24 @@ namespace HexcalMC } } + private void UpdatePostion() + { + Point3D _mPoint3D = mainFrom._mPoint3D; + + //鏇存柊瀹炴椂浣嶇疆 + if (_mPoint3D != null) + { + lbl_X_current.Text = _mPoint3D.X.ToString("F3"); + lbl_Y_current.Text = _mPoint3D.Y.ToString("F3"); + lbl_z_current.Text = _mPoint3D.Z.ToString("F3"); + } + + //璁剧疆鐩爣浣嶇疆 + lbl_X_target.Text = textBox_x.Text; + lbl_Y_target.Text = textBox_y.Text; + lbl_Z_target.Text = textBox_z.Text; + } + #endregion #region 鐢垫満浣胯兘 @@ -618,7 +632,7 @@ namespace HexcalMC { try { - Axis[] m_arrAxisList = new Axis[] { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1, Axis.ACSC_AXIS_8, Axis.ACSC_NONE }; + Axis[] m_arrAxisList = { Axis.ACSC_AXIS_0, Axis.ACSC_AXIS_1, Axis.ACSC_AXIS_8, Axis.ACSC_NONE }; if (_mArrAxisList != null) _acs.HaltM(m_arrAxisList); } @@ -995,7 +1009,7 @@ namespace HexcalMC #region 鎸夐挳 - private void btn_movepose_Click(object sender, EventArgs e) + private void Btn_MovePose_Click(object sender, EventArgs e) { //鍒ゆ柇鏄惁涓簍extBox_x绌 if (string.IsNullOrWhiteSpace(textBox_x.Text) || string.IsNullOrEmpty(textBox_y.Text) || @@ -1020,17 +1034,23 @@ namespace HexcalMC _point3D.Y, _point3D.Z }; + + //鍒ゆ柇鐢垫満鐘舵 + if (!mainFrom.totalAxisEnabled) + { + DebugDfn.AddLogText("瀛樺湪鐢垫満鏈娇鑳"); + + _acs.EnableM(UseAxis); + for (int i = 0; i < UseAxis.Length; i++) + { + _acs.WaitMotorEnabled(UseAxis[i], 1, _motionTimeout); //绛夊緟鐢垫満浣胯兘 + } + + DebugDfn.AddLogText("鐢垫満宸插惎鐢"); + } + //鎵ц杩愬姩鎸囦护 _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 { @@ -1050,7 +1070,7 @@ namespace HexcalMC }; //鍒ゆ柇鐢垫満鐘舵 - if (!this.mainFrom.totalAxisEnabled) + if (!mainFrom.totalAxisEnabled) { DebugDfn.AddLogText("瀛樺湪鐢垫満鏈娇鑳"); @@ -1078,18 +1098,18 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + if (_mJogVel > 0) _mJogVel = _mJogVel * -1; // Negative direction : Using - (minus) velocity + DebugDfn.AddLogText("X宸︾Щ閫熷害: " + _mJogVel); _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_1, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); } else @@ -1105,19 +1125,20 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_1, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); + + DebugDfn.AddLogText("X鍙崇Щ閫熷害: " + _mJogVel); } else { @@ -1132,19 +1153,19 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + if (_mJogVel > 0) _mJogVel = _mJogVel * -1; // Negative direction : Using - (minus) velocity _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_0, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); + DebugDfn.AddLogText("Y鍓嶇Щ閫熷害: " + _mJogVel); } else { @@ -1160,19 +1181,20 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_0, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); + + DebugDfn.AddLogText("Y鍚庣Щ閫熷害: " + _mJogVel); } else { @@ -1187,19 +1209,20 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + if (_mJogVel > 0) _mJogVel = _mJogVel * -1; // Negative direction : Using - (minus) velocity _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_8, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); + + DebugDfn.AddLogText("Z鍚戜笅閫熷害: " + _mJogVel); } else { @@ -1214,19 +1237,20 @@ namespace HexcalMC 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 + _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); + _acs.Jog( MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 閫熷害鏍囧織 Axis.ACSC_AXIS_8, // Axis number - lfVelocity // Velocity + _mJogVel // Velocity ); + + DebugDfn.AddLogText("Z鍚戜笂閫熷害: " + _mJogVel); } else { @@ -1240,43 +1264,7 @@ namespace HexcalMC } - 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 } diff --git a/HexcalMC/Motion/Motion.resx b/HexcalMC/Motion/Motion.resx index 3053904..0319670 100644 --- a/HexcalMC/Motion/Motion.resx +++ b/HexcalMC/Motion/Motion.resx @@ -1148,7 +1148,7 @@ - 25 + 86 diff --git a/HexcalMC/Properties/AssemblyInfo.cs b/HexcalMC/Properties/AssemblyInfo.cs index a09cf31..cdbfe6f 100644 --- a/HexcalMC/Properties/AssemblyInfo.cs +++ b/HexcalMC/Properties/AssemblyInfo.cs @@ -19,5 +19,5 @@ using System.Runtime.InteropServices; [assembly: Guid("6215eb36-92d3-4f96-9331-1e8cbda161f4")] -[assembly: AssemblyVersion("0.0.2")] -[assembly: AssemblyFileVersion("0.0.2")] +[assembly: AssemblyVersion("0.0.3")] +[assembly: AssemblyFileVersion("0.0.3")]