中间件界面 新增 位置刷新; 屏蔽EF3后,调整 回家到位的判断

This commit is contained in:
zhengxuan.zhang
2024-04-03 18:22:56 +08:00
parent 5bc1b4aa6d
commit de5438ad49
13 changed files with 210 additions and 311 deletions
+38 -18
View File
@@ -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
+2 -2
View File
@@ -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 ")
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -14
View File
@@ -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;
+12 -9
View File
@@ -41,7 +41,8 @@ namespace HexcalMC
private TcpIpServer _mTcpIpServer; //创建tcpserver,用于接收hexcal传来的指令,并解析传递平台
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<Point3D> 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;
}
+67 -170
View File
@@ -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;
+83 -95
View File
@@ -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
}
/// <summary>
/// Terminate connections from SPiiPlus User Mode Driver
/// 终止来自 SPiiPlus 用户模式驱动程序的连接
/// - Maximum connections up to 10 in UMD
/// </summary>
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)
{
//判断是否为textBox_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
}
+1 -1
View File
@@ -1148,7 +1148,7 @@
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
<value>86</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
+2 -2
View File
@@ -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")]