Commit 589d47aa 几米阳光

三个轴原点返回都改为负方向

1 个父辈 faf869d1
...@@ -172,14 +172,14 @@ ...@@ -172,14 +172,14 @@
this.打开舱门ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.打开舱门ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.关闭仓门ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.关闭仓门ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.启用调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.语言 = new System.Windows.Forms.ToolStripMenuItem(); this.语言 = new System.Windows.Forms.ToolStripMenuItem();
this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.英文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.英文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
this.德文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.德文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.启用调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(611, 535); this.groupBox1.Location = new System.Drawing.Point(611, 535);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(627, 224); this.groupBox1.Size = new System.Drawing.Size(627, 212);
this.groupBox1.TabIndex = 217; this.groupBox1.TabIndex = 217;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "伺服状态"; this.groupBox1.Text = "伺服状态";
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
this.axis_1_Alarm.IOName = ""; this.axis_1_Alarm.IOName = "";
this.axis_1_Alarm.IOValue = 0; this.axis_1_Alarm.IOValue = 0;
this.axis_1_Alarm.isCanClick = false; this.axis_1_Alarm.isCanClick = false;
this.axis_1_Alarm.Location = new System.Drawing.Point(200, 64); this.axis_1_Alarm.Location = new System.Drawing.Point(194, 60);
this.axis_1_Alarm.Name = "axis_1_Alarm"; this.axis_1_Alarm.Name = "axis_1_Alarm";
this.axis_1_Alarm.Size = new System.Drawing.Size(43, 39); this.axis_1_Alarm.Size = new System.Drawing.Size(43, 39);
this.axis_1_Alarm.TabIndex = 264; this.axis_1_Alarm.TabIndex = 264;
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
this.axis_3_Alarm.IOName = ""; this.axis_3_Alarm.IOName = "";
this.axis_3_Alarm.IOValue = 0; this.axis_3_Alarm.IOValue = 0;
this.axis_3_Alarm.isCanClick = false; this.axis_3_Alarm.isCanClick = false;
this.axis_3_Alarm.Location = new System.Drawing.Point(402, 64); this.axis_3_Alarm.Location = new System.Drawing.Point(396, 60);
this.axis_3_Alarm.Name = "axis_3_Alarm"; this.axis_3_Alarm.Name = "axis_3_Alarm";
this.axis_3_Alarm.Size = new System.Drawing.Size(43, 39); this.axis_3_Alarm.Size = new System.Drawing.Size(43, 39);
this.axis_3_Alarm.TabIndex = 266; this.axis_3_Alarm.TabIndex = 266;
...@@ -289,7 +289,7 @@ ...@@ -289,7 +289,7 @@
this.axis_2_Alarm.IOName = ""; this.axis_2_Alarm.IOName = "";
this.axis_2_Alarm.IOValue = 0; this.axis_2_Alarm.IOValue = 0;
this.axis_2_Alarm.isCanClick = false; this.axis_2_Alarm.isCanClick = false;
this.axis_2_Alarm.Location = new System.Drawing.Point(297, 64); this.axis_2_Alarm.Location = new System.Drawing.Point(291, 60);
this.axis_2_Alarm.Name = "axis_2_Alarm"; this.axis_2_Alarm.Name = "axis_2_Alarm";
this.axis_2_Alarm.Size = new System.Drawing.Size(43, 39); this.axis_2_Alarm.Size = new System.Drawing.Size(43, 39);
this.axis_2_Alarm.TabIndex = 265; this.axis_2_Alarm.TabIndex = 265;
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
// label38 // label38
// //
this.label38.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label38.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label38.Location = new System.Drawing.Point(15, 69); this.label38.Location = new System.Drawing.Point(9, 65);
this.label38.Name = "label38"; this.label38.Name = "label38";
this.label38.Size = new System.Drawing.Size(160, 17); this.label38.Size = new System.Drawing.Size(160, 17);
this.label38.TabIndex = 263; this.label38.TabIndex = 263;
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
// //
// txtMiddleTarget // txtMiddleTarget
// //
this.txtMiddleTarget.Location = new System.Drawing.Point(178, 180); this.txtMiddleTarget.Location = new System.Drawing.Point(172, 176);
this.txtMiddleTarget.Name = "txtMiddleTarget"; this.txtMiddleTarget.Name = "txtMiddleTarget";
this.txtMiddleTarget.ReadOnly = true; this.txtMiddleTarget.ReadOnly = true;
this.txtMiddleTarget.Size = new System.Drawing.Size(87, 23); this.txtMiddleTarget.Size = new System.Drawing.Size(87, 23);
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
// //
// txtInoutTarget // txtInoutTarget
// //
this.txtInoutTarget.Location = new System.Drawing.Point(379, 180); this.txtInoutTarget.Location = new System.Drawing.Point(373, 176);
this.txtInoutTarget.Name = "txtInoutTarget"; this.txtInoutTarget.Name = "txtInoutTarget";
this.txtInoutTarget.ReadOnly = true; this.txtInoutTarget.ReadOnly = true;
this.txtInoutTarget.Size = new System.Drawing.Size(87, 23); this.txtInoutTarget.Size = new System.Drawing.Size(87, 23);
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
// //
// txtUpdownTarget // txtUpdownTarget
// //
this.txtUpdownTarget.Location = new System.Drawing.Point(279, 180); this.txtUpdownTarget.Location = new System.Drawing.Point(273, 176);
this.txtUpdownTarget.Name = "txtUpdownTarget"; this.txtUpdownTarget.Name = "txtUpdownTarget";
this.txtUpdownTarget.ReadOnly = true; this.txtUpdownTarget.ReadOnly = true;
this.txtUpdownTarget.Size = new System.Drawing.Size(87, 23); this.txtUpdownTarget.Size = new System.Drawing.Size(87, 23);
...@@ -331,7 +331,7 @@ ...@@ -331,7 +331,7 @@
// label12 // label12
// //
this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label12.Location = new System.Drawing.Point(15, 183); this.label12.Location = new System.Drawing.Point(9, 179);
this.label12.Name = "label12"; this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(160, 17); this.label12.Size = new System.Drawing.Size(160, 17);
this.label12.TabIndex = 258; this.label12.TabIndex = 258;
...@@ -340,7 +340,7 @@ ...@@ -340,7 +340,7 @@
// //
// lblCountPulse1 // lblCountPulse1
// //
this.lblCountPulse1.Location = new System.Drawing.Point(178, 146); this.lblCountPulse1.Location = new System.Drawing.Point(172, 142);
this.lblCountPulse1.Name = "lblCountPulse1"; this.lblCountPulse1.Name = "lblCountPulse1";
this.lblCountPulse1.ReadOnly = true; this.lblCountPulse1.ReadOnly = true;
this.lblCountPulse1.Size = new System.Drawing.Size(87, 23); this.lblCountPulse1.Size = new System.Drawing.Size(87, 23);
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
// //
// lblOutPulse1 // lblOutPulse1
// //
this.lblOutPulse1.Location = new System.Drawing.Point(178, 112); this.lblOutPulse1.Location = new System.Drawing.Point(172, 108);
this.lblOutPulse1.Name = "lblOutPulse1"; this.lblOutPulse1.Name = "lblOutPulse1";
this.lblOutPulse1.ReadOnly = true; this.lblOutPulse1.ReadOnly = true;
this.lblOutPulse1.Size = new System.Drawing.Size(87, 23); this.lblOutPulse1.Size = new System.Drawing.Size(87, 23);
...@@ -356,7 +356,7 @@ ...@@ -356,7 +356,7 @@
// //
// lblCountPulse3 // lblCountPulse3
// //
this.lblCountPulse3.Location = new System.Drawing.Point(379, 146); this.lblCountPulse3.Location = new System.Drawing.Point(373, 142);
this.lblCountPulse3.Name = "lblCountPulse3"; this.lblCountPulse3.Name = "lblCountPulse3";
this.lblCountPulse3.ReadOnly = true; this.lblCountPulse3.ReadOnly = true;
this.lblCountPulse3.Size = new System.Drawing.Size(87, 23); this.lblCountPulse3.Size = new System.Drawing.Size(87, 23);
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
// //
// lblOutPulse3 // lblOutPulse3
// //
this.lblOutPulse3.Location = new System.Drawing.Point(379, 112); this.lblOutPulse3.Location = new System.Drawing.Point(373, 108);
this.lblOutPulse3.Name = "lblOutPulse3"; this.lblOutPulse3.Name = "lblOutPulse3";
this.lblOutPulse3.ReadOnly = true; this.lblOutPulse3.ReadOnly = true;
this.lblOutPulse3.Size = new System.Drawing.Size(87, 23); this.lblOutPulse3.Size = new System.Drawing.Size(87, 23);
...@@ -372,7 +372,7 @@ ...@@ -372,7 +372,7 @@
// //
// lblCountPulse2 // lblCountPulse2
// //
this.lblCountPulse2.Location = new System.Drawing.Point(280, 146); this.lblCountPulse2.Location = new System.Drawing.Point(274, 142);
this.lblCountPulse2.Name = "lblCountPulse2"; this.lblCountPulse2.Name = "lblCountPulse2";
this.lblCountPulse2.ReadOnly = true; this.lblCountPulse2.ReadOnly = true;
this.lblCountPulse2.Size = new System.Drawing.Size(87, 23); this.lblCountPulse2.Size = new System.Drawing.Size(87, 23);
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
// //
// lblOutPulse2 // lblOutPulse2
// //
this.lblOutPulse2.Location = new System.Drawing.Point(279, 112); this.lblOutPulse2.Location = new System.Drawing.Point(273, 108);
this.lblOutPulse2.Name = "lblOutPulse2"; this.lblOutPulse2.Name = "lblOutPulse2";
this.lblOutPulse2.ReadOnly = true; this.lblOutPulse2.ReadOnly = true;
this.lblOutPulse2.Size = new System.Drawing.Size(87, 23); this.lblOutPulse2.Size = new System.Drawing.Size(87, 23);
...@@ -389,7 +389,7 @@ ...@@ -389,7 +389,7 @@
// label4 // label4
// //
this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label4.Location = new System.Drawing.Point(370, 20); this.label4.Location = new System.Drawing.Point(364, 16);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(95, 34); this.label4.Size = new System.Drawing.Size(95, 34);
this.label4.TabIndex = 100; this.label4.TabIndex = 100;
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
// label3 // label3
// //
this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label3.Location = new System.Drawing.Point(271, 20); this.label3.Location = new System.Drawing.Point(265, 16);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(95, 34); this.label3.Size = new System.Drawing.Size(95, 34);
this.label3.TabIndex = 99; this.label3.TabIndex = 99;
...@@ -409,7 +409,7 @@ ...@@ -409,7 +409,7 @@
// label1 // label1
// //
this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.Location = new System.Drawing.Point(173, 20); this.label1.Location = new System.Drawing.Point(167, 16);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(95, 34); this.label1.Size = new System.Drawing.Size(95, 34);
this.label1.TabIndex = 97; this.label1.TabIndex = 97;
...@@ -419,7 +419,7 @@ ...@@ -419,7 +419,7 @@
// label43 // label43
// //
this.label43.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label43.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label43.Location = new System.Drawing.Point(15, 115); this.label43.Location = new System.Drawing.Point(9, 111);
this.label43.Name = "label43"; this.label43.Name = "label43";
this.label43.Size = new System.Drawing.Size(160, 17); this.label43.Size = new System.Drawing.Size(160, 17);
this.label43.TabIndex = 23; this.label43.TabIndex = 23;
...@@ -429,7 +429,7 @@ ...@@ -429,7 +429,7 @@
// label42 // label42
// //
this.label42.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label42.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label42.Location = new System.Drawing.Point(15, 149); this.label42.Location = new System.Drawing.Point(9, 145);
this.label42.Name = "label42"; this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(160, 17); this.label42.Size = new System.Drawing.Size(160, 17);
this.label42.TabIndex = 24; this.label42.TabIndex = 24;
...@@ -525,7 +525,6 @@ ...@@ -525,7 +525,6 @@
this.groupAxis.TabIndex = 216; this.groupAxis.TabIndex = 216;
this.groupAxis.TabStop = false; this.groupAxis.TabStop = false;
this.groupAxis.Text = "伺服运动"; this.groupAxis.Text = "伺服运动";
// //
// label6 // label6
// //
...@@ -687,7 +686,7 @@ ...@@ -687,7 +686,7 @@
this.btnReadPosition.Cursor = System.Windows.Forms.Cursors.Default; this.btnReadPosition.Cursor = System.Windows.Forms.Cursors.Default;
this.btnReadPosition.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnReadPosition.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnReadPosition.ForeColor = System.Drawing.SystemColors.ControlText; this.btnReadPosition.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnReadPosition.Location = new System.Drawing.Point(382, 183); this.btnReadPosition.Location = new System.Drawing.Point(382, 181);
this.btnReadPosition.Name = "btnReadPosition"; this.btnReadPosition.Name = "btnReadPosition";
this.btnReadPosition.RightToLeft = System.Windows.Forms.RightToLeft.No; this.btnReadPosition.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnReadPosition.Size = new System.Drawing.Size(115, 33); this.btnReadPosition.Size = new System.Drawing.Size(115, 33);
...@@ -1002,7 +1001,7 @@ ...@@ -1002,7 +1001,7 @@
this.richTextBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.richTextBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.richTextBox1.Location = new System.Drawing.Point(17, 651); this.richTextBox1.Location = new System.Drawing.Point(17, 651);
this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(583, 105); this.richTextBox1.Size = new System.Drawing.Size(583, 96);
this.richTextBox1.TabIndex = 256; this.richTextBox1.TabIndex = 256;
this.richTextBox1.Text = ""; this.richTextBox1.Text = "";
// //
...@@ -1784,118 +1783,130 @@ ...@@ -1784,118 +1783,130 @@
// 查看IOToolStripMenuItem // 查看IOToolStripMenuItem
// //
this.查看IOToolStripMenuItem.Name = "查看IOToolStripMenuItem"; this.查看IOToolStripMenuItem.Name = "查看IOToolStripMenuItem";
this.查看IOToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.查看IOToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.查看IOToolStripMenuItem.Text = "查看IO"; this.查看IOToolStripMenuItem.Text = "查看IO";
this.查看IOToolStripMenuItem.Click += new System.EventHandler(this.查看IOToolStripMenuItem_Click); this.查看IOToolStripMenuItem.Click += new System.EventHandler(this.查看IOToolStripMenuItem_Click);
// //
// toolStripSeparator9 // toolStripSeparator9
// //
this.toolStripSeparator9.Name = "toolStripSeparator9"; this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator9.Size = new System.Drawing.Size(173, 6);
// //
// 轴卡点动ToolStripMenuItem // 轴卡点动ToolStripMenuItem
// //
this.轴卡点动ToolStripMenuItem.Name = "轴卡点动ToolStripMenuItem"; this.轴卡点动ToolStripMenuItem.Name = "轴卡点动ToolStripMenuItem";
this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.轴卡点动ToolStripMenuItem.Text = "轴卡点动"; this.轴卡点动ToolStripMenuItem.Text = "轴卡点动";
this.轴卡点动ToolStripMenuItem.Click += new System.EventHandler(this.轴卡点动ToolStripMenuItem_Click); this.轴卡点动ToolStripMenuItem.Click += new System.EventHandler(this.轴卡点动ToolStripMenuItem_Click);
// //
// toolStripSeparator12 // toolStripSeparator12
// //
this.toolStripSeparator12.Name = "toolStripSeparator12"; this.toolStripSeparator12.Name = "toolStripSeparator12";
this.toolStripSeparator12.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator12.Size = new System.Drawing.Size(173, 6);
// //
// 扫码测试ToolStripMenuItem // 扫码测试ToolStripMenuItem
// //
this.扫码测试ToolStripMenuItem.Name = "扫码测试ToolStripMenuItem"; this.扫码测试ToolStripMenuItem.Name = "扫码测试ToolStripMenuItem";
this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.扫码测试ToolStripMenuItem.Text = "扫码测试"; this.扫码测试ToolStripMenuItem.Text = "扫码测试";
this.扫码测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码测试ToolStripMenuItem_Click); this.扫码测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码测试ToolStripMenuItem_Click);
// //
// toolStripSeparator10 // toolStripSeparator10
// //
this.toolStripSeparator10.Name = "toolStripSeparator10"; this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator10.Size = new System.Drawing.Size(173, 6);
// //
// 学习二维码ToolStripMenuItem // 学习二维码ToolStripMenuItem
// //
this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem"; this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem";
this.学习二维码ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.学习二维码ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.学习二维码ToolStripMenuItem.Text = "学习二维码"; this.学习二维码ToolStripMenuItem.Text = "学习二维码";
this.学习二维码ToolStripMenuItem.Click += new System.EventHandler(this.学习二维码ToolStripMenuItem_Click); this.学习二维码ToolStripMenuItem.Click += new System.EventHandler(this.学习二维码ToolStripMenuItem_Click);
// //
// toolStripSeparator5 // toolStripSeparator5
// //
this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator5.Size = new System.Drawing.Size(173, 6);
// //
// toolStripMenuItem3 // toolStripMenuItem3
// //
this.toolStripMenuItem3.Name = "toolStripMenuItem3"; this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 26); this.toolStripMenuItem3.Size = new System.Drawing.Size(176, 26);
this.toolStripMenuItem3.Text = "门禁功能屏蔽"; this.toolStripMenuItem3.Text = "门禁功能屏蔽";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click); this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
// //
// toolStripSeparator14 // toolStripSeparator14
// //
this.toolStripSeparator14.Name = "toolStripSeparator14"; this.toolStripSeparator14.Name = "toolStripSeparator14";
this.toolStripSeparator14.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator14.Size = new System.Drawing.Size(173, 6);
// //
// toolStripMenuItem2 // toolStripMenuItem2
// //
this.toolStripMenuItem2.Name = "toolStripMenuItem2"; this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 26); this.toolStripMenuItem2.Size = new System.Drawing.Size(176, 26);
this.toolStripMenuItem2.Text = "门禁功能打开"; this.toolStripMenuItem2.Text = "门禁功能打开";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click); this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
// //
// toolStripSeparator13 // toolStripSeparator13
// //
this.toolStripSeparator13.Name = "toolStripSeparator13"; this.toolStripSeparator13.Name = "toolStripSeparator13";
this.toolStripSeparator13.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator13.Size = new System.Drawing.Size(173, 6);
// //
// 料仓运转OFFToolStripMenuItem // 料仓运转OFFToolStripMenuItem
// //
this.料仓运转OFFToolStripMenuItem.Name = "料仓运转OFFToolStripMenuItem"; this.料仓运转OFFToolStripMenuItem.Name = "料仓运转OFFToolStripMenuItem";
this.料仓运转OFFToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.料仓运转OFFToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.料仓运转OFFToolStripMenuItem.Text = "料仓运转OFF"; this.料仓运转OFFToolStripMenuItem.Text = "料仓运转OFF";
this.料仓运转OFFToolStripMenuItem.Click += new System.EventHandler(this.料仓运转OFFToolStripMenuItem_Click); this.料仓运转OFFToolStripMenuItem.Click += new System.EventHandler(this.料仓运转OFFToolStripMenuItem_Click);
// //
// toolStripSeparator6 // toolStripSeparator6
// //
this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator6.Size = new System.Drawing.Size(173, 6);
// //
// 料仓运转ONToolStripMenuItem // 料仓运转ONToolStripMenuItem
// //
this.料仓运转ONToolStripMenuItem.Name = "料仓运转ONToolStripMenuItem"; this.料仓运转ONToolStripMenuItem.Name = "料仓运转ONToolStripMenuItem";
this.料仓运转ONToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.料仓运转ONToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.料仓运转ONToolStripMenuItem.Text = "料仓运转ON"; this.料仓运转ONToolStripMenuItem.Text = "料仓运转ON";
this.料仓运转ONToolStripMenuItem.Click += new System.EventHandler(this.料仓运转ONToolStripMenuItem_Click); this.料仓运转ONToolStripMenuItem.Click += new System.EventHandler(this.料仓运转ONToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(173, 6);
// //
// 打开舱门ToolStripMenuItem // 打开舱门ToolStripMenuItem
// //
this.打开舱门ToolStripMenuItem.Name = "打开舱门ToolStripMenuItem"; this.打开舱门ToolStripMenuItem.Name = "打开舱门ToolStripMenuItem";
this.打开舱门ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.打开舱门ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.打开舱门ToolStripMenuItem.Text = "打开仓门"; this.打开舱门ToolStripMenuItem.Text = "打开仓门";
this.打开舱门ToolStripMenuItem.Click += new System.EventHandler(this.打开舱门ToolStripMenuItem_Click); this.打开舱门ToolStripMenuItem.Click += new System.EventHandler(this.打开舱门ToolStripMenuItem_Click);
// //
// toolStripSeparator8 // toolStripSeparator8
// //
this.toolStripSeparator8.Name = "toolStripSeparator8"; this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator8.Size = new System.Drawing.Size(173, 6);
// //
// 关闭仓门ToolStripMenuItem // 关闭仓门ToolStripMenuItem
// //
this.关闭仓门ToolStripMenuItem.Name = "关闭仓门ToolStripMenuItem"; this.关闭仓门ToolStripMenuItem.Name = "关闭仓门ToolStripMenuItem";
this.关闭仓门ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.关闭仓门ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.关闭仓门ToolStripMenuItem.Text = "关闭仓门"; this.关闭仓门ToolStripMenuItem.Text = "关闭仓门";
this.关闭仓门ToolStripMenuItem.Click += new System.EventHandler(this.关闭仓门ToolStripMenuItem_Click); this.关闭仓门ToolStripMenuItem.Click += new System.EventHandler(this.关闭仓门ToolStripMenuItem_Click);
// //
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(173, 6);
//
// 启用调试ToolStripMenuItem
//
this.启用调试ToolStripMenuItem.Name = "启用调试ToolStripMenuItem";
this.启用调试ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.启用调试ToolStripMenuItem.Text = "启用调试";
this.启用调试ToolStripMenuItem.Click += new System.EventHandler(this.启用调试ToolStripMenuItem_Click);
//
// 语言 // 语言
// //
this.语言.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.语言.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
...@@ -1940,18 +1951,6 @@ ...@@ -1940,18 +1951,6 @@
this.德文ToolStripMenuItem.Visible = false; this.德文ToolStripMenuItem.Visible = false;
this.德文ToolStripMenuItem.Click += new System.EventHandler(this.德文ToolStripMenuItem_Click); this.德文ToolStripMenuItem.Click += new System.EventHandler(this.德文ToolStripMenuItem_Click);
// //
// 启用调试ToolStripMenuItem
//
this.启用调试ToolStripMenuItem.Name = "启用调试ToolStripMenuItem";
this.启用调试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.启用调试ToolStripMenuItem.Text = "启用调试";
this.启用调试ToolStripMenuItem.Click += new System.EventHandler(this.启用调试ToolStripMenuItem_Click);
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
//
// FrmStoreBox // FrmStoreBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
......
...@@ -11,7 +11,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -11,7 +11,8 @@ namespace OnlineStore.DeviceLibrary
/// 0132h 原点接近传感器输入 (HOME) 状态 ReadOnly 0: 输入 OFF 1: 输入 ON /// 0132h 原点接近传感器输入 (HOME) 状态 ReadOnly 0: 输入 OFF 1: 输入 ON
/// </summary> /// </summary>
public static string Home_Single = "0132"; public static string Home_Single = "0132";
// 0022h 负方向驱动禁止输入(NOT) ReadOnly 0: 输入 OFF、 1: 输入 ON
// 0023h 正方向驱动禁止输入(POT) ReadOnly 0: 输入 OFF、 1: 输入 ON
/// <summary> /// <summary>
///速度 4601 ///速度 4601
/// </summary> /// </summary>
...@@ -73,7 +74,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -73,7 +74,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 读线圈01 /// 读线圈01
/// </summary> /// </summary>
public static byte CMD_ReadCoil= 0x01; public static byte CMD_ReadCoil = 0x01;
/// <summary> /// <summary>
/// 写线圈 05 /// 写线圈 05
/// </summary> /// </summary>
...@@ -131,9 +132,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -131,9 +132,9 @@ namespace OnlineStore.DeviceLibrary
public static byte[] buildCheckData(byte[] sendData, int length) public static byte[] buildCheckData(byte[] sendData, int length)
{ {
ushort pChecksum = 0; ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum); AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16); string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr); byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1) if (checkByte.Length == 1)
{ {
sendData[length] = checkByte[0]; sendData[length] = checkByte[0];
...@@ -152,7 +153,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -152,7 +153,7 @@ namespace OnlineStore.DeviceLibrary
// ( 2) 读取寄存器( 03h) // ( 2) 读取寄存器( 03h)
if (cmd.Equals(CMD_ReadRegisters)) if (cmd.Equals(CMD_ReadRegisters))
{ {
return Get03WriteData(slvAddr, addr,length); return Get03WriteData(slvAddr, addr, length);
} }
else if (cmd.Equals(CMD_WriteRegisters)) else if (cmd.Equals(CMD_WriteRegisters))
{ {
...@@ -176,7 +177,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -176,7 +177,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8]; byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr; sendData[0] = (byte)slvAddr;
sendData[1] = CMD_WriteCoil; sendData[1] = CMD_WriteCoil;
byte[] addrByte = SerialBean.StringToByte(addr.ToString()); byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1) if (addrByte.Length == 1)
{ {
sendData[2] = 0x00; sendData[2] = 0x00;
...@@ -188,7 +189,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -188,7 +189,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0]; sendData[2] = addrByte[0];
} }
byte[] dataByte = SerialBean.StringToByte(dataValue); byte[] dataByte = AcSerialBean.StringToByte(dataValue);
if (dataByte.Length == 1) if (dataByte.Length == 1)
{ {
sendData[4] = 0x00; sendData[4] = 0x00;
...@@ -209,7 +210,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -209,7 +210,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8]; byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr; sendData[0] = (byte)slvAddr;
sendData[1] = CMD_ReadCoil; sendData[1] = CMD_ReadCoil;
byte[] addrByte = SerialBean.StringToByte(addr.ToString()); byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1) if (addrByte.Length == 1)
{ {
sendData[2] = 0x00; sendData[2] = 0x00;
...@@ -221,7 +222,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -221,7 +222,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0]; sendData[2] = addrByte[0];
} }
byte[] dataByte = SerialBean.StringToByte(length.ToString()); byte[] dataByte = AcSerialBean.StringToByte(length.ToString());
if (dataByte.Length == 1) if (dataByte.Length == 1)
{ {
sendData[4] = 0x00; sendData[4] = 0x00;
...@@ -249,10 +250,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -249,10 +250,10 @@ namespace OnlineStore.DeviceLibrary
//低位 //低位
//CRC 低位 //CRC 低位
//高位 //高位
byte[] sendData = new byte[8 ]; byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr; sendData[0] = (byte)slvAddr;
sendData[1] = CMD_ReadRegisters; sendData[1] = CMD_ReadRegisters;
byte[] addrByte = SerialBean.StringToByte(addr.ToString()); byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1) if (addrByte.Length == 1)
{ {
sendData[2] = 0x00; sendData[2] = 0x00;
...@@ -264,7 +265,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -264,7 +265,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0]; sendData[2] = addrByte[0];
} }
byte[] dataByte = SerialBean.StringToByte(length.ToString()); byte[] dataByte = AcSerialBean.StringToByte(length.ToString());
if (dataByte.Length == 1) if (dataByte.Length == 1)
{ {
sendData[4] = 0x00; sendData[4] = 0x00;
...@@ -276,7 +277,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -276,7 +277,7 @@ namespace OnlineStore.DeviceLibrary
sendData[5] = dataByte[0]; sendData[5] = dataByte[0];
} }
sendData = buildCheckData(sendData, sendData.Length-2); sendData = buildCheckData(sendData, sendData.Length - 2);
return sendData; return sendData;
} }
...@@ -294,7 +295,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -294,7 +295,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8]; byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr; sendData[0] = (byte)slvAddr;
sendData[1] = CMD_WriteRegisters; sendData[1] = CMD_WriteRegisters;
byte[] addrByte = SerialBean.StringToByte(addr.ToString()); byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1) if (addrByte.Length == 1)
{ {
sendData[2] = 0x00; sendData[2] = 0x00;
...@@ -306,7 +307,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -306,7 +307,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0]; sendData[2] = addrByte[0];
} }
byte[] dataByte = SerialBean.StringToByte(dataValue); byte[] dataByte = AcSerialBean.StringToByte(dataValue);
if (dataByte.Length == 1) if (dataByte.Length == 1)
{ {
sendData[4] = 0x00; sendData[4] = 0x00;
...@@ -316,6 +317,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -316,6 +317,7 @@ namespace OnlineStore.DeviceLibrary
{ {
sendData[4] = dataByte[0]; sendData[4] = dataByte[0];
sendData[5] = dataByte[1]; sendData[5] = dataByte[1];
//sendData[4] = dataByte[1]; //sendData[4] = dataByte[1];
//sendData[5] = dataByte[0]; //sendData[5] = dataByte[0];
} }
......
...@@ -13,13 +13,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -13,13 +13,13 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
public partial class ACServerManager public partial class ACServerManager
{ {
private static bool IsShowMsg = false ; public static bool IsShowMsg = false;
private static int SleepMSendons = 100; private static int SleepMSendons = 100;
private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>(); private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>();
private static string mapObj = ""; private static string mapObj = "";
private static int GetAddrValue(string portName,int slvAddr, string addr) private static int GetAddrValue(string portName, int slvAddr, string addr)
{ {
int value = -1; int value = -1;
try try
...@@ -42,7 +42,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -42,7 +42,7 @@ namespace OnlineStore.DeviceLibrary
} }
return value; return value;
} }
private static void UpdateAddrValue(string portName,int slvAddr, string addr, int value) private static void UpdateAddrValue(string portName, int slvAddr, string addr, int value)
{ {
try try
{ {
...@@ -77,7 +77,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -77,7 +77,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (serialBeanMap.ContainsKey(portName)) if (serialBeanMap.ContainsKey(portName))
{ {
return true ; return true;
} }
int ACBaudRate = ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate); int ACBaudRate = ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate);
...@@ -85,7 +85,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -85,7 +85,7 @@ namespace OnlineStore.DeviceLibrary
bool result = bean.openPort(); bool result = bean.openPort();
if (!result) if (!result)
{ {
LogUtil.info("打开串口【" + portName + "】【"+ACBaudRate+"】失败"); LogUtil.info("打开串口【" + portName + "】【" + ACBaudRate + "】失败");
return false; return false;
} }
LogUtil.info("打开串口【" + portName + "】【" + ACBaudRate + "】成功"); LogUtil.info("打开串口【" + portName + "】【" + ACBaudRate + "】成功");
...@@ -125,15 +125,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -125,15 +125,15 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!serialBeanMap.ContainsKey(portName)) if (!serialBeanMap.ContainsKey(portName))
{ {
return false ; return false;
} }
PreReadCoilAddr = ACCMDManager.ServerOn_Addr; PreReadCoilAddr = ACCMDManager.ServerOn_Addr;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1);
//SendData(portName,dataArray); //SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6); byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
int result= GetCoilData(portName, reviceData, PreReadCoilAddr); int result = GetCoilData(portName, reviceData, PreReadCoilAddr);
//TODO //TODO
return result>=1; return result >= 1;
} }
/// <summary> /// <summary>
/// 是否原点返回完成 /// 是否原点返回完成
...@@ -144,20 +144,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -144,20 +144,22 @@ namespace OnlineStore.DeviceLibrary
if (status >= 1) if (status >= 1)
{ {
return true; return true;
} return false; }
return false;
} }
public static void InitSlvAddr(string portName, int slvAddr) public static void InitSlvAddr(string portName, int slvAddr)
{ {
InitSlvAddr(portName, slvAddr, 100, 30, 30 ); InitSlvAddr(portName, slvAddr, 100, 30, 30);
//InitSlvAddr(portName, slvAddr, 100, 30, 30, 100, 50, 30); //InitSlvAddr(portName, slvAddr, 100, 30, 30, 100, 50, 30);
} }
//把数字转换为四位的字符串 //把数字转换为四位的字符串
public static string SpeedToStr(int speed,int length) public static string SpeedToStr(int speed, int length)
{ {
speed = Math.Abs(speed);
string str = String.Format("{0:X}", speed); string str = String.Format("{0:X}", speed);
return str.PadLeft(length, '0'); return str.PadLeft(length, '0');
} }
public static void InitSlvAddr(string portName, int slvAddr,int targetSpeed,int addSpeed,int delSpeed ) public static void InitSlvAddr(string portName, int slvAddr, int targetSpeed, int addSpeed, int delSpeed)
//public static void InitSlvAddr(string portName, int slvAddr,int targetSpeed,int addSpeed,int delSpeed,int homeHighSpeed,int homeLowSpeed,int homeAddSpeed) //public static void InitSlvAddr(string portName, int slvAddr,int targetSpeed,int addSpeed,int delSpeed,int homeHighSpeed,int homeLowSpeed,int homeAddSpeed)
{ {
LogUtil.info("开始初始化伺服【" + portName + "】【" + slvAddr + "】"); LogUtil.info("开始初始化伺服【" + portName + "】【" + slvAddr + "】");
...@@ -238,20 +240,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -238,20 +240,20 @@ namespace OnlineStore.DeviceLibrary
SendData(portName, dataArray); SendData(portName, dataArray);
} }
public static void RelMove(string portName, int slvAddr, int position,int targetSpeed) public static void RelMove(string portName, int slvAddr, int position, int targetSpeed)
{ {
//先更新速度 //先更新速度
string slvAddrStr = string.Format(strFromat, slvAddr); string slvAddrStr = string.Format(strFromat, slvAddr);
string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff"; string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff";
SendStrAndSleep(portName, v1,SleepMSendons); SendStrAndSleep(portName, v1, SleepMSendons);
RelMove(portName, slvAddr, position); RelMove(portName, slvAddr, position);
} }
public static void RelMove(string portName, int slvAddr, int position) public static void RelMove(string portName, int slvAddr, int position)
{ {
//int position = Convert.ToInt32(txtPosition.Text); //int position = Convert.ToInt32(txtPosition.Text);
byte[] positionData = SerialBean.StringToByte(position.ToString("X8")); byte[] positionData = AcSerialBean.StringToByte(position.ToString("X8"));
byte[] data = SerialBean.StringToByte("0110480C 000408 10000111EC78FFFF ffff"); byte[] data = AcSerialBean.StringToByte("0110480C 000408 10000111EC78FFFF ffff");
data[0] = (byte)slvAddr; data[0] = (byte)slvAddr;
data[data.Length - 1] = 0x00; data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00; data[data.Length - 2] = 0x00;
...@@ -287,10 +289,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -287,10 +289,6 @@ namespace OnlineStore.DeviceLibrary
data = ACCMDManager.buildCheckData(data, data.Length - 2); data = ACCMDManager.buildCheckData(data, data.Length - 2);
SendData(portName, data); SendData(portName, data);
System.Threading.Thread.Sleep(SleepMSendons); System.Threading.Thread.Sleep(SleepMSendons);
//运动
//data = ACCMDManager.GetWriteData(slvAddr, 06, ACCMDManager.BlockNo, ACCMDManager.Block_RelMove, 2);
//SendData(portName, data);
//Thread.Sleep(SleepMSendons);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_RelMove); UpdateBlock(portName, slvAddr, ACCMDManager.Block_RelMove);
OpenAndCloseSTB(portName, slvAddr); OpenAndCloseSTB(portName, slvAddr);
...@@ -298,27 +296,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -298,27 +296,17 @@ namespace OnlineStore.DeviceLibrary
public static void HomeMove(string portName, int slvAddr, int speed) public static void HomeMove(string portName, int slvAddr, int speed)
{ {
//默认负方向原点返回
//byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, ACCMDManager.Block_HomeMove1, 2);
//SendData(portName, data);
try try
{ {
//先判断是否在原点,如果已经在原点,先向正方向走2000 //先判断是否在原点,如果已经在原点,先向正方向走2000
int homeSingle = GetHomeSingle(portName, slvAddr); int homeSingle = GetHomeSingle(portName, slvAddr);
if (homeSingle.Equals(1)) if (homeSingle.Equals(1))
{ {
int isHomeEnd = GetHomeEndStatus(portName, slvAddr); //int isHomeEnd = GetHomeEndStatus(portName, slvAddr);
if (isHomeEnd.Equals(1)) //if (isHomeEnd.Equals(1))
{ //{
int value = 2000; int value = 2000;
//if (portName.Equals(ACStoreManager.store.Config.Middle_Axis.DeviceName) || LogUtil.info("轴【" + portName + "_" + slvAddr + "】原点返回时发现原点已亮且回过原点,需要先相对走" + value);
// portName.Equals(ACStoreManager.store.Config.InOut_Axis.DeviceName))
if(ACStoreManager.store.Config.Middle_Axis.IsSameAxis(portName, slvAddr) ||
ACStoreManager.store.Config.InOut_Axis.IsSameAxis(portName,slvAddr))
{
value = -2000;
}
LogUtil.info("轴【" + portName +"_"+ slvAddr + "】原点返回时发现原点已亮且回过原点,需要先相对走" + value);
RelMove(portName, slvAddr, value); RelMove(portName, slvAddr, value);
bool isStop = false; bool isStop = false;
for (int i = 0; i <= 10; i++) for (int i = 0; i <= 10; i++)
...@@ -336,41 +324,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -336,41 +324,29 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已等待2分钟,直接停止"); LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已等待2分钟,直接停止");
SuddenStop(portName, slvAddr); SuddenStop(portName, slvAddr);
} }
} //}
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("轴【" + portName + "_" + slvAddr + "】原点返回前验证是否在原点出错:" + ex.StackTrace); LogUtil.error("轴【" + portName + "_" + slvAddr + "】原点返回前验证是否在原点出错:" + ex.StackTrace);
} }
//旋转轴回正方向,其他轴回负方向
if (ACStoreManager.store.Config.Middle_Axis.IsSameAxis(portName, slvAddr))
{
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0);
LogUtil.info("旋转轴原点返回方向:正方向");
}
else if (ACStoreManager.store.Config.InOut_Axis.IsSameAxis(portName, slvAddr))
{
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0);
LogUtil.info("进出轴原点返回方向:正方向");
}
else
{
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove1); UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove1);
LogUtil.info("升降轴原点返回方向:反方向"); LogUtil.debug("回原点:反方向");
} //}
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr); OpenAndCloseSTB(portName, slvAddr);
} }
public static void SpeedMove(string portName, int slvAddr, int speed) public static void SpeedMove(string portName, int slvAddr, int speed)
{ {
int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr); int preSpeed = GetAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed)))) if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed))))
{ {
byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, "4601", string.Format("{0:X2}", Math.Abs(speed)), 2); string v1 = slvAddr + "064601 " + ACServerManager.SpeedToStr(speed, 4) + " ffff";
SendData(portName, data); LogUtil.debug("轴【" + portName + "_" + slvAddr + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】");
UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed)); SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
} }
if (speed > 0) if (speed > 0)
...@@ -381,6 +357,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -381,6 +357,7 @@ namespace OnlineStore.DeviceLibrary
{ {
UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove1); UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove1);
} }
//Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr); OpenAndCloseSTB(portName, slvAddr);
} }
public static void AbsMove(string portName, int slvAddr, int targetPosition, int targetSpeed) public static void AbsMove(string portName, int slvAddr, int targetPosition, int targetSpeed)
...@@ -388,13 +365,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -388,13 +365,13 @@ namespace OnlineStore.DeviceLibrary
//先更新速度 //先更新速度
string slvAddrStr = string.Format(strFromat, slvAddr); string slvAddrStr = string.Format(strFromat, slvAddr);
int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr); int preSpeed = GetAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(targetSpeed))) if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(targetSpeed)))
{ {
//速度 V1 =100 //速度 V1 =100
string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff"; string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff";
SendStrAndSleep(portName, v1, SleepMSendons); SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, targetSpeed); UpdateAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr, targetSpeed);
} }
//绝对运动 //绝对运动
AbsMove(portName, slvAddr, targetPosition); AbsMove(portName, slvAddr, targetPosition);
...@@ -402,8 +379,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -402,8 +379,8 @@ namespace OnlineStore.DeviceLibrary
public static void AbsMove(string portName, int slvAddr, int position) public static void AbsMove(string portName, int slvAddr, int position)
{ {
//int position = Convert.ToInt32(txtPosition.Text, 10); //int position = Convert.ToInt32(txtPosition.Text, 10);
byte[] positionData = SerialBean.StringToByte(position.ToString("X8")); byte[] positionData = AcSerialBean.StringToByte(position.ToString("X8"));
byte[] data = SerialBean.StringToByte("01104808 000408 10000211 EC78FFFF ffff"); byte[] data = AcSerialBean.StringToByte("01104808 000408 10000211 EC78FFFF ffff");
data[0] = (byte)slvAddr; data[0] = (byte)slvAddr;
data[data.Length - 1] = 0x00; data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00; data[data.Length - 2] = 0x00;
...@@ -440,7 +417,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -440,7 +417,6 @@ namespace OnlineStore.DeviceLibrary
SendData(portName, data); SendData(portName, data);
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_AbsMove); UpdateBlock(portName, slvAddr, ACCMDManager.Block_AbsMove);
OpenAndCloseSTB(portName, slvAddr); OpenAndCloseSTB(portName, slvAddr);
} }
} }
......
...@@ -27,131 +27,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -27,131 +27,15 @@ namespace OnlineStore.DeviceLibrary
return null; return null;
} }
//public static void RunBlock(string portName, int slvAddr, int index)
//{
// //运动
// byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, index.ToString(), 2);
// SendData(portName, data);
// Thread.Sleep(100);
// CloseSTB(portName, slvAddr);
// Thread.Sleep(100);
// OnlyOpenSTB(portName, slvAddr);
//}
public static void SendStrAndSleep(string portName, string str, int sleepS) public static void SendStrAndSleep(string portName, string str, int sleepS)
{ {
byte[] data = SerialBean.StringToByte(str); byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00; data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00; data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2); data = ACCMDManager.buildCheckData(data, data.Length - 2);
SendData(portName, data); SendData(portName, data);
System.Threading.Thread.Sleep(sleepS); System.Threading.Thread.Sleep(sleepS);
} }
//public static void SendStr(string portName, string str)
//{
// byte[] data = SerialBean.StringToByte(str);
// data[data.Length - 1] = 0x00;
// data[data.Length - 2] = 0x00;
// data = ACCMDManager.buildCheckData(data, data.Length - 2);
// SendData(portName, data);
//}
//private static void DataReceived(string portName, object sender, SerialDataReceivedEventArgs e, byte[] bits)
//{
// string strSend = "";
// for (int i = 0; i < bits.Length; i++)
// {
// strSend += string.Format("{0:X2} ", bits[i]);
// }
// if (IsShowMsg)
// {
// LogUtil.info( "串口" + portName + " 收到数据:" + strSend + "");
// }
// string str = "";
// string strFromat = "{0:X2}";
// byte slvAddr = bits[0];
// int lenth = bits[2];
// byte cmd = bits[1];
// if (cmd.Equals(ACCMDManager.CMD_ReadRegisters) && bits.Length > 6)
// {
// if (PreReadAddr.Equals(ACCMDManager.TargetPostion))
// {
// if (lenth == 4)
// {
// str = string.Format(strFromat, bits[5]) + string.Format(strFromat, bits[6]) + string.Format(strFromat, bits[3]) + string.Format(strFromat, bits[4]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.TargetPostion, value);
// }
// }
// else if (PreReadAddr.Equals(ACCMDManager.ActualPosition))
// {
// if (lenth == 4)
// {
// str = string.Format(strFromat, bits[5]) + string.Format(strFromat, bits[6]) + string.Format(strFromat, bits[3]) + string.Format(strFromat, bits[4]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.ActualPosition, value);
// }
// }
// else
// {
// for (int i = 3; i < 3 + lenth; i++)
// {
// str += string.Format("{0:X2} ", bits[i]);
// }
// str = str.Replace(" ", "");
// int value = Convert.ToInt32(str, 16);
// LogUtil.info("转换后结果:" + value + "");
// //this.richTextBox1.AppendText("转换后结果:" + value + "");
// //Console.WriteLine("转换后结果:" + value);
// }
// //MessageBox.Show("收到数据:"+value);
// }
// else if (cmd.Equals(ACCMDManager.CMD_ReadCoil) && bits.Length >= 6)
// {
// if (PreReadCoilAddr.Equals(ACCMDManager.ServerOn_Addr))
// {
// if (lenth == 1)
// {
// str = string.Format(strFromat, bits[3]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.ServerOn_Addr, value);
// }
// }
// else
// if (PreReadCoilAddr.Equals(ACCMDManager.Alarm_Status))
// {
// if (lenth == 1)
// {
// str = string.Format(strFromat, bits[3]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.Alarm_Status, value);
// }
// }
// else if (PreReadCoilAddr.Equals(ACCMDManager.BUSYStatus))
// {
// if (lenth == 1)
// {
// str = string.Format(strFromat, bits[3]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.BUSYStatus, value);
// }
// }
// else if (PreReadCoilAddr.Equals(ACCMDManager.HOME_CMP_Status))
// {
// if (lenth == 1)
// {
// str = string.Format(strFromat, bits[3]);
// int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
// SaveData(portName, slvAddr, ACCMDManager.HOME_CMP_Status, value);
// }
// }
// }
// if (strSend.Equals(""))
// {
// return;
// }
//}
public static void SaveData(string portName, byte slvAddr, string regAddr, int value) public static void SaveData(string portName, byte slvAddr, string regAddr, int value)
{ {
...@@ -173,17 +57,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -173,17 +57,17 @@ namespace OnlineStore.DeviceLibrary
LastDataMap.Add(slvAddr, map); LastDataMap.Add(slvAddr, map);
} }
} }
//public static RegisterInfo GetData(string portName, byte slvAddr, string regAddr) public static RegisterInfo GetData(string portName, byte slvAddr, string regAddr)
//{ {
// if (LastDataMap.ContainsKey(slvAddr)) if (LastDataMap.ContainsKey(slvAddr))
// { {
// if (LastDataMap[slvAddr].ContainsKey(regAddr)) if (LastDataMap[slvAddr].ContainsKey(regAddr))
// { {
// return LastDataMap[slvAddr][regAddr]; return LastDataMap[slvAddr][regAddr];
// } }
// } }
// return null; return null;
//} }
public static void SendData(string portName, byte[] data, int reviceLength) public static void SendData(string portName, byte[] data, int reviceLength)
{ {
...@@ -200,7 +84,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -200,7 +84,7 @@ namespace OnlineStore.DeviceLibrary
} }
if (IsShowMsg) if (IsShowMsg)
{ {
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + ""); LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
} }
} }
public static void SendData(string portName, byte[] data) public static void SendData(string portName, byte[] data)
...@@ -210,7 +94,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -210,7 +94,7 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
byte[] returnData = SendCommand(portName, data, 50, 8); byte[] returnData = SendCommand(portName, data, 50, 8);
if (returnData!=null) if (returnData != null)
{ {
string strSend = ""; string strSend = "";
for (int i = 0; i < returnData.Length; i++) for (int i = 0; i < returnData.Length; i++)
...@@ -231,6 +115,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -231,6 +115,10 @@ namespace OnlineStore.DeviceLibrary
/// <returns>返回值的长度</returns> /// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength) public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength)
{ {
if (outTime > 80)
{
outTime = 80;
}
byte[] returnData = null; byte[] returnData = null;
try try
...@@ -250,7 +138,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -250,7 +138,7 @@ namespace OnlineStore.DeviceLibrary
} }
if (IsShowMsg) if (IsShowMsg)
{ {
LogUtil.info( "串口" + portName + " 写入数据:" + strSend + ""); LogUtil.info("串口" + portName + " 写入数据:" + strSend + "");
} }
AcSerialBean bean = GetSerialBean(portName); AcSerialBean bean = GetSerialBean(portName);
if (bean == null) if (bean == null)
...@@ -279,7 +167,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -279,7 +167,7 @@ namespace OnlineStore.DeviceLibrary
public static void SendStr(string portName, int slvAddr, string str) public static void SendStr(string portName, int slvAddr, string str)
{ {
//string str = txtSendStr.Text; //string str = txtSendStr.Text;
byte[] data = SerialBean.StringToByte(str); byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00; data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00; data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2); data = ACCMDManager.buildCheckData(data, data.Length - 2);
...@@ -346,13 +234,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -346,13 +234,13 @@ namespace OnlineStore.DeviceLibrary
public static void UpdateBlock(string portName, int slvAddr, string blockNum) public static void UpdateBlock(string portName, int slvAddr, string blockNum)
{ {
int preNum = GetAddrValue(portName,slvAddr, ACCMDManager.BlockNo); int preNum = GetAddrValue(portName, slvAddr, ACCMDManager.BlockNo);
if (preNum.Equals(-1) || (!preNum.ToString().Equals(blockNum))) if (preNum.Equals(-1) || (!preNum.ToString().Equals(blockNum)))
{ {
byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, blockNum , 2); byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, blockNum, 2);
SendData(portName, data); SendData(portName, data);
int value = Convert.ToInt16(blockNum); int value = Convert.ToInt16(blockNum);
UpdateAddrValue(portName,slvAddr, ACCMDManager.BlockNo, value); UpdateAddrValue(portName, slvAddr, ACCMDManager.BlockNo, value);
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
} }
} }
...@@ -394,7 +282,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -394,7 +282,7 @@ namespace OnlineStore.DeviceLibrary
} }
if (IsShowMsg) if (IsShowMsg)
{ {
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + ""); LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
} }
string strFromat = "{0:X2}"; string strFromat = "{0:X2}";
byte slvAddrR = reviceData[0]; byte slvAddrR = reviceData[0];
...@@ -442,7 +330,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -442,7 +330,7 @@ namespace OnlineStore.DeviceLibrary
if (IsShowMsg) if (IsShowMsg)
{ {
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + ""); LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
} }
string strFromat = "{0:X2}"; string strFromat = "{0:X2}";
byte slvAddrR = reviceData[0]; byte slvAddrR = reviceData[0];
......
using log4net; using log4net;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO.Ports; using System.IO.Ports;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
...@@ -15,13 +16,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -15,13 +16,16 @@ namespace OnlineStore.DeviceLibrary
public class ShuoKeControls public class ShuoKeControls
{ {
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static SerialBean bean = null; private static AcSerialBean bean = null;
public static bool isRun = false; public static bool isRun = false;
private static Dictionary<int, ShuoKeInfo> shuokeMap = new Dictionary<int, ShuoKeInfo>(); private static Dictionary<int, ShuoKeInfo> shuokeMap = new Dictionary<int, ShuoKeInfo>();
public static string PortName = "";
private static int SleepMS = 50;
private static int DReviceLength = 5;
#region 串口操作 #region 串口操作
public static bool ResertInitPort(string comPortName, int baudRate, int tparity, int dataBits, StopBits stopBits) public static bool ResertInitPort(string comPortName, int baudRate, int tparity, int dataBits, StopBits stopBits)
{ {
PortName = comPortName;
if (isRun) if (isRun)
{ {
ClosePort(); ClosePort();
...@@ -36,14 +40,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -36,14 +40,15 @@ namespace OnlineStore.DeviceLibrary
} }
try try
{ {
PortName = comPortName;
Parity parity = (Parity)tparity; Parity parity = (Parity)tparity;
bean = new SerialBean(comPortName, baudRate, parity, 8, stopBits); bean = new AcSerialBean(comPortName, baudRate, parity, 8, stopBits);
bool result = bean.openPort(); bool result = bean.openPort();
if (!result) if (!result)
{ {
return false; return false;
} }
bean.DataReceived += DataReceived; //bean.DataReceived += DataReceived;
isRun = true; isRun = true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -57,11 +62,39 @@ namespace OnlineStore.DeviceLibrary ...@@ -57,11 +62,39 @@ namespace OnlineStore.DeviceLibrary
public static void ClosePort() public static void ClosePort()
{ {
isRun = false; isRun = false;
if (bean == null)
{
return;
}
bean.closePort(); bean.closePort();
LogUtil.info(LOGGER, "关闭步进控制器串口完成"); LogUtil.info(LOGGER, "关闭步进控制器串口完成");
} }
public static void SendData(byte[] data)
/// <summary>
/// 发送数据并获取返回值
/// </summary>
/// <param name="data">发送的数据</param>
/// <param name="outTime">超时时间</param>
/// <returns>返回值的长度</returns>
public static byte[] SendCommand(byte[] data, int outTime, int reviceLength)
{
if (outTime <= 0)
{
outTime = 30;
}
if (outTime > 80)
{
outTime = 80;
}
byte[] returnData = null;
try
{
if (data == null)
{ {
return returnData;
}
string strSend = ""; string strSend = "";
for (int i = 0; i < data.Length; i++) for (int i = 0; i < data.Length; i++)
{ {
...@@ -69,16 +102,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -69,16 +102,28 @@ namespace OnlineStore.DeviceLibrary
} }
if (strSend.Equals("")) if (strSend.Equals(""))
{ {
return; return returnData;
} }
if (!isRun)
LogUtil.debug("串口" + PortName + " 写入数据:" + strSend + "");
if (bean == null)
{ {
LogUtil.error(LOGGER, "电机发送数据【" + strSend + "】,当前串口未连接上,发送失败!"); LogUtil.debug(" 试图向未打开串口【" + PortName + "】写入数据:" + strSend + "。");
return; }
else
{
bean.SendCommand(data, ref returnData, outTime, reviceLength);
}
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
} }
LogUtil.debug(LOGGER, "电机发送数据【" + strSend + "】"); return returnData;
bean.SendData(data, 0, data.Length);
} }
private static void DataReceived(string portName, object sender, SerialDataReceivedEventArgs e, byte[] bits) private static void DataReceived(string portName, object sender, SerialDataReceivedEventArgs e, byte[] bits)
{ {
string strSend = ""; string strSend = "";
...@@ -93,15 +138,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -93,15 +138,15 @@ namespace OnlineStore.DeviceLibrary
//校验 //校验
ushort pChecksum = 0; ushort pChecksum = 0;
SerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum); AcSerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16); string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr); byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1) if (checkByte.Length == 1)
{ {
if (!bits[bits.Length - 2].Equals(checkByte[0])) if (!bits[bits.Length - 2].Equals(checkByte[0]))
{ {
bean.clearInBuffer(); bean.clearInBuffer();
LogUtil.info(LOGGER, "收到数据:端口号 【" + portName + "】 数据【" + strSend + "】,校验错误"); LogUtil.info(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】,校验错误");
return; return;
} }
} }
...@@ -110,33 +155,116 @@ namespace OnlineStore.DeviceLibrary ...@@ -110,33 +155,116 @@ namespace OnlineStore.DeviceLibrary
if (!bits[bits.Length - 1].Equals(checkByte[0]) || (!bits[bits.Length - 2].Equals(checkByte[1]))) if (!bits[bits.Length - 1].Equals(checkByte[0]) || (!bits[bits.Length - 2].Equals(checkByte[1])))
{ {
bean.clearInBuffer(); bean.clearInBuffer();
LogUtil.info(LOGGER, "收到数据:端口号 【" + portName + "】 数据【" + strSend + "】,校验错误"); LogUtil.info(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】,校验错误");
return; return;
} }
} }
LogUtil.debug(LOGGER, "收到数据:端口号 【" + portName + "】 数据【" + strSend + "】"); LogUtil.debug(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】");
int slvAddr = (int)bits[0]; int slvAddr = (int)bits[0];
byte cmd = bits[1]; byte cmd = bits[1];
//查询状态 //查询状态
if (cmd.Equals(ShuoKeCMD.SearchMoveStatus)) if (cmd.Equals(ShuoKeCMD.SearchMoveStatus))
{ {
ShuoKeInfo info = DataToStatus(bits);
}
else if (cmd.Equals(ShuoKeCMD.GetAbsPosition))
{
int position = DataToPosition(bits);
}
}
private static bool CheckByte(byte[] bits)
{
string strSend = "";
if (bits == null)
{
return false;
}
for (int i = 0; i < bits.Length; i++)
{
strSend += string.Format("{0:X2} ", bits[i]);
}
//校验
ushort pChecksum = 0;
AcSerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
if (!bits[bits.Length - 2].Equals(checkByte[0]))
{
bean.clearInBuffer();
LogUtil.info(LOGGER, "【" + PortName + "】收到数据【" + strSend + "】校验错误");
return false;
}
}
else
{
if (!bits[bits.Length - 1].Equals(checkByte[0]) || (!bits[bits.Length - 2].Equals(checkByte[1])))
{
bean.clearInBuffer();
LogUtil.info(LOGGER, "【" + PortName + "】收到数据【" + strSend + "】校验错误");
return false;
}
}
return true;
}
private static int DataToPosition(byte[] bits)
{
int absValue = -1;
if (!CheckByte(bits))
{
return absValue;
}
if (bits.Length >= 7)
{
int slvAddr = (int)bits[0];
byte[] positionData = new byte[4];
Array.Copy(bits, 3, positionData, 0, 4);
string a = AcSerialBean.byteToHexStr(positionData);
absValue = Convert.ToInt32(a, 16);
LogUtil.debug(LOGGER, "收到驱动器【" + slvAddr + "】绝对位置【" + absValue + "】");
if (shuokeMap.ContainsKey(slvAddr))
{
shuokeMap[slvAddr].LastPosition = absValue;
}
else
{
ShuoKeInfo info = new ShuoKeInfo(slvAddr, absValue);
shuokeMap.Add(slvAddr, info);
}
}
return absValue;
}
private static ShuoKeInfo DataToStatus(byte[] bits)
{
ShuoKeInfo info = new ShuoKeInfo(-1, -1);
if (!CheckByte(bits))
{
return info;
}
if (bits.Length >= 8)
{
//[数据1]:1表示运动中,0表示停止 //[数据1]:1表示运动中,0表示停止
//[数据2]:LL-左限位IO状态 1表示有效 0表示无效 //[数据2]:LL-左限位IO状态 1表示有效 0表示无效
//[数据3]:O-原点IO状态 1表示有效 0表示无效,,=1表示原点灭,=0表示当前原点亮 //[数据3]:O-原点IO状态 1表示有效 0表示无效,,=1表示原点灭,=0表示当前原点亮
// [数据4]:RL-右限位IO状态 1表示有效 0表示无效 // [数据4]:RL-右限位IO状态 1表示有效 0表示无效
//[数据5]:EN-使能IO状态 1表示有效 0表示无效 //[数据5]:EN-使能IO状态 1表示有效 0表示无效
int slvAddr = (int)bits[0];
byte cmd = bits[1];
int isInMove = bits[3]; int isInMove = bits[3];
int isLLimit = bits[4]; int isLLimit = bits[4];
int isOrg = bits[5]; int isOrg = bits[5];
int isRLimit = bits[6]; int isRLimit = bits[6];
int isEn = bits[7]; int isEn = bits[7];
info = new ShuoKeInfo(isInMove, slvAddr, isLLimit, isOrg, isRLimit, isEn);
try try
{ {
ShuoKeInfo info = new ShuoKeInfo(isInMove, slvAddr, isLLimit, isOrg, isRLimit, isEn);
if (shuokeMap.ContainsKey(slvAddr)) if (shuokeMap.ContainsKey(slvAddr))
{ {
info.LastPosition = shuokeMap[slvAddr].LastPosition;
shuokeMap.Remove(slvAddr); shuokeMap.Remove(slvAddr);
} }
shuokeMap.Add(slvAddr, info); shuokeMap.Add(slvAddr, info);
...@@ -147,75 +275,86 @@ namespace OnlineStore.DeviceLibrary ...@@ -147,75 +275,86 @@ namespace OnlineStore.DeviceLibrary
} }
LogUtil.debug(LOGGER, "收到驱动器【" + slvAddr + "】运动状态:运动【" + isInMove + "】左限位【" + isLLimit + "】右限位【" + isRLimit + "】原点【" + isOrg + "】使能【" + isEn + "】"); LogUtil.debug(LOGGER, "收到驱动器【" + slvAddr + "】运动状态:运动【" + isInMove + "】左限位【" + isLLimit + "】右限位【" + isRLimit + "】原点【" + isOrg + "】使能【" + isEn + "】");
} }
else if (cmd.Equals(ShuoKeCMD.GetAbsPosition)) return info;
}
public static int GetLastPosition(int slvAddr)
{ {
byte[] positionData = new byte[4]; if (shuokeMap.ContainsKey(slvAddr))
Array.Copy(bits, 3, positionData, 0, 4); {
string a = SerialBean.byteToHexStr(positionData); ShuoKeInfo info = shuokeMap[slvAddr];
int absValue = Convert.ToInt32(a, 16); return info.LastPosition;
LogUtil.info(LOGGER, "收到驱动器【" + slvAddr + "】绝对位置【" + absValue + "】");
} }
return -1;
} }
#endregion #endregion
#region 流水线逻辑判断 #region 逻辑判断
public static bool IsMoveEnd(int slvAddr,DateTime time) public static bool IsMoveEnd(int slvAddr, int targetPosition, DateTime time, out string msg)
{ {
if (shuokeMap.ContainsKey(slvAddr)) ShuoKeInfo shuokeInfo = GetStatus(slvAddr);
msg = " IsInMove【" + shuokeInfo.IsInMove + "】 ";
if (shuokeInfo.IsInMove == 0 && shuokeInfo.UpdateTime > time)
{ {
ShuoKeInfo info = shuokeMap[slvAddr]; int position = GetABSPosition(slvAddr);
if (info.IsInMove == 0 && info.UpdateTime > time) msg += "位置【" + position + "】";
if (Math.Abs(position - targetPosition) < 10 || targetPosition.Equals(-2000))
{ {
return true; return true;
} }
else
{
LogUtil.info("【" + PortName + "】 目标位置【" + targetPosition + "】当前位置【" + position + "】,已经不再运动中");
}
} }
return false; return false;
} }
public static bool IsHomeMoveEnd(int slvAddr, DateTime time) public static bool IsHomeMoveEnd(int slvAddr, DateTime time, out string msg)
{
if (shuokeMap.ContainsKey(slvAddr))
{ {
ShuoKeInfo info = shuokeMap[slvAddr]; ShuoKeInfo shuokeInfo = GetStatus(slvAddr);
if (info.IsInMove == 0 && info.UpdateTime > time&&info.Org==0) msg = " IsInMove【" + shuokeInfo.IsInMove + "】Org【" + shuokeInfo.Org + "】";
if (shuokeInfo.IsInMove.Equals(0) && shuokeInfo.Org.Equals(0) && shuokeInfo.UpdateTime > time)
{ {
return true; return true;
} }
}
return false; return false;
} }
#endregion #endregion
#region 驱动器操作方法 #region 驱动器操作方法
public static void GetStatus(int slvAddr) public static ShuoKeInfo GetStatus(int slvAddr)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.SearchMoveStatus, 0x00, 0); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.SearchMoveStatus, 0x00, 0, 10);
return DataToStatus(reviceData);
} }
public static void DStoop(int slvAddr) public static void DStoop(int slvAddr)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.DStopMove, 0x00, 0); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.DStopMove, 0x00, 0, DReviceLength);
} }
public static void SuddownStop(int slvAddr) public static void SuddownStop(int slvAddr)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.SuddownStopMove, 0x00, 0); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.SuddownStopMove, 0x00, 0, DReviceLength);
} }
public static void GetABSPosition(int slvAddr) public static int GetABSPosition(int slvAddr)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.GetAbsPosition, 0x00, 0); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.GetAbsPosition, 0x00, 0, 9);
return DataToPosition(reviceData);
} }
/// <summary>
/// // <param name="homeType">0=反方向,1=正方向</param>
/// </summary>
/// <param name="slvAddr"></param>
/// <param name="homeType">0=反方向,1=正方向</param>
public static void HomeMove(int slvAddr, byte homeType) public static void HomeMove(int slvAddr, byte homeType)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.HomeMove, 0x01, homeType); string fangx = homeType.Equals(0) ? "反方向" : "正方向";
LogUtil.info("压紧轴原点返回:" + fangx);
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.HomeMove, 0x01, homeType, DReviceLength);
} }
public static void VolMove(int slvAddr, int speed) public static void VolMove(int slvAddr, int speed)
{ {
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.VolMove, 0x04, speed); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.VolMove, 0x04, speed, DReviceLength);
} }
public static void AbsMove(int slvAddr, int TargetPosition) public static void AbsMove(int slvAddr, int TargetPosition)
...@@ -230,7 +369,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -230,7 +369,7 @@ namespace OnlineStore.DeviceLibrary
//[CRC校验1] 0xnn [CRC校验1] 0xnn //[CRC校验1] 0xnn [CRC校验1] 0xnn
//[CRC校验2] 0xnn [CRC校验2] 0xnn //[CRC校验2] 0xnn [CRC校验2] 0xnn
//数据:4BYTE,(支持32位有符号脉冲位置) //数据:4BYTE,(支持32位有符号脉冲位置)
byte[] sendData = WriteData(slvAddr, ShuoKeCMD.AbsMove, 0x04, TargetPosition); byte[] reviceData = SendData(slvAddr, ShuoKeCMD.AbsMove, 0x04, TargetPosition, DReviceLength);
} }
public static void RelativeMove(int slvAddr, int position) public static void RelativeMove(int slvAddr, int position)
...@@ -253,7 +392,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -253,7 +392,7 @@ namespace OnlineStore.DeviceLibrary
sendData[5] = 0x00; sendData[5] = 0x00;
sendData[6] = 0x00; sendData[6] = 0x00;
string speed = Convert.ToString(position, 16); string speed = Convert.ToString(position, 16);
byte[] speedByte = SerialBean.StringToByte(speed); byte[] speedByte = AcSerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++) for (int i = 0; i < speedByte.Length; i++)
{ {
...@@ -265,11 +404,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -265,11 +404,12 @@ namespace OnlineStore.DeviceLibrary
} }
sendData[3] = fangxiang; sendData[3] = fangxiang;
sendData = buildCheckData(sendData, 3 + dataLength); sendData = buildCheckData(sendData, 3 + dataLength);
SendData(sendData); byte[] reviceData = SendCommand(sendData, SleepMS, DReviceLength);
Thread.Sleep(SleepMS);
} }
public static void PositionClear(int slvAddr, byte setCMD) public static void PositionClear(int slvAddr, byte setCMD)
{ {
byte[] sendData = WriteData(slvAddr, setCMD, 0x00, 0); byte[] reviceData = SendData(slvAddr, setCMD, 0x00, 0, DReviceLength);
} }
/// <summary> /// <summary>
...@@ -280,10 +420,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,10 +420,11 @@ namespace OnlineStore.DeviceLibrary
/// <param name="speedValue">速度值</param> /// <param name="speedValue">速度值</param>
public static void SetSpeed(int slvAddr, byte setCMD, int speedValue) public static void SetSpeed(int slvAddr, byte setCMD, int speedValue)
{ {
byte[] sendData = WriteData(slvAddr, setCMD, 0x04, speedValue); byte[] reviceData = SendData(slvAddr, setCMD, 0x04, speedValue, DReviceLength);
Thread.Sleep(10);
} }
private static byte[] WriteData(int slvAddr, byte cmd, byte dataLength, int dataValue) private static byte[] SendData(int slvAddr, byte cmd, byte dataLength, int dataValue, int reviceDataLength)
{ {
byte[] sendData = new byte[5 + dataLength]; byte[] sendData = new byte[5 + dataLength];
sendData[0] = (byte)slvAddr; sendData[0] = (byte)slvAddr;
...@@ -303,7 +444,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -303,7 +444,7 @@ namespace OnlineStore.DeviceLibrary
sendData[5] = 0x00; sendData[5] = 0x00;
sendData[6] = 0x00; sendData[6] = 0x00;
string speed = Convert.ToString(dataValue, 16); string speed = Convert.ToString(dataValue, 16);
byte[] speedByte = SerialBean.StringToByte(speed); byte[] speedByte = AcSerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++) for (int i = 0; i < speedByte.Length; i++)
{ {
...@@ -315,15 +456,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -315,15 +456,16 @@ namespace OnlineStore.DeviceLibrary
} }
} }
sendData = buildCheckData(sendData, 3 + dataLength); sendData = buildCheckData(sendData, 3 + dataLength);
SendData(sendData); byte[] reviceData = SendCommand(sendData, SleepMS, reviceDataLength);
return sendData; Thread.Sleep(SleepMS);
return reviceData;
} }
private static byte[] buildCheckData(byte[] sendData, int length) private static byte[] buildCheckData(byte[] sendData, int length)
{ {
ushort pChecksum = 0; ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum); AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16); string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr); byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1) if (checkByte.Length == 1)
{ {
sendData[length] = checkByte[0]; sendData[length] = checkByte[0];
...@@ -414,16 +556,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -414,16 +556,29 @@ namespace OnlineStore.DeviceLibrary
public class ShuoKeInfo public class ShuoKeInfo
{ {
public ShuoKeInfo(int slv, int position)
{
this.IsInMove = -1;
this.SlvAddr = slv;
this.LLimit = -1;
this.RLimit = -1;
this.Org = -1;
this.En = -1;
UpdateTime = DateTime.Now;
LastPosition = position;
}
public ShuoKeInfo(int ismove, int slv, int ll, int org, int rl, int en) public ShuoKeInfo(int ismove, int slv, int ll, int org, int rl, int en)
{ {
this.IsInMove = ismove; this.IsInMove = ismove;
this.SlvAddr=slv; this.SlvAddr = slv;
this.LLimit=ll; this.LLimit = ll;
this.RLimit=rl; this.RLimit = rl;
this.Org=org; this.Org = org;
this.En=en; this.En = en;
UpdateTime=DateTime.Now; UpdateTime = DateTime.Now;
} LastPosition = 0;
}
public int LastPosition { get; set; }
/// <summary> /// <summary>
/// 驱动器地址 /// 驱动器地址
/// </summary> /// </summary>
...@@ -450,5 +605,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -450,5 +605,10 @@ namespace OnlineStore.DeviceLibrary
public int En { get; set; } public int En { get; set; }
public DateTime UpdateTime { get; set; } public DateTime UpdateTime { get; set; }
public string ToShowStr()
{
return "运动[" + IsInMove + "]左限位[" + LLimit + "]右限位[" + RLimit + "]原点[" + Org + "]使能[" + En + "][" + UpdateTime.ToShortTimeString() + "]";
}
} }
} }
...@@ -163,18 +163,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -163,18 +163,9 @@ namespace OnlineStore.DeviceLibrary
} }
else if (wait.WaitType == 5) else if (wait.WaitType == 5)
{ {
if (wait.IsHomeMove) string msg = "";
{ wait.IsEnd = ShuoKeIsEnd(wait, out msg);
wait.IsEnd = ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime); NotOkMsg = NotOkMsg + " " + msg;
}
else
{
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime);
}
if (!wait.IsEnd)
{
ShuoKeControls.GetStatus(wait.SlvAddr);
}
} }
if (wait.IsEnd) if (wait.IsEnd)
{ {
...@@ -206,7 +197,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -206,7 +197,18 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private bool ShuoKeIsEnd(WaitResultInfo wait, out string msg)
{
msg = "";
if (wait.IsHomeMove)
{
return ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime, out msg);
}
else
{
return ShuoKeControls.IsMoveEnd(wait.SlvAddr, wait.TargetPosition, StoreMove.LastSetpTime, out msg);
}
}
#endregion #endregion
#region 入库 #region 入库
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!