Commit 27e78cae 几米阳光

修改扫码方式。修改硕科通信代码。

1 个父辈 b6fa137c
此文件类型无法预览
此文件类型无法预览
...@@ -73,12 +73,6 @@ ...@@ -73,12 +73,6 @@
<Compile Include="FrmBase.Designer.cs"> <Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon> <DependentUpon>FrmBase.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmCamera.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmCamera.Designer.cs">
<DependentUpon>FrmCamera.cs</DependentUpon>
</Compile>
<Compile Include="FrmIOStatus.cs"> <Compile Include="FrmIOStatus.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -106,9 +100,6 @@ ...@@ -106,9 +100,6 @@
<EmbeddedResource Include="FrmBase.resx"> <EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon> <DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmCamera.resx">
<DependentUpon>FrmCamera.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmIOStatus.resx"> <EmbeddedResource Include="FrmIOStatus.resx">
<DependentUpon>FrmIOStatus.cs</DependentUpon> <DependentUpon>FrmIOStatus.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
this.txtPwd.PasswordChar = '*'; this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(215, 33); this.txtPwd.Size = new System.Drawing.Size(215, 33);
this.txtPwd.TabIndex = 276; this.txtPwd.TabIndex = 276;
this.txtPwd.Text = "123456";
this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown); this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown);
// //
// FrmPwd // FrmPwd
......
...@@ -160,8 +160,6 @@ ...@@ -160,8 +160,6 @@
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.扫码测试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.扫码测试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.摄像机调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
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.配置信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.轴运动配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.轴运动配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
...@@ -197,6 +195,7 @@ ...@@ -197,6 +195,7 @@
this.btnLineAbsMove = new System.Windows.Forms.Button(); this.btnLineAbsMove = new System.Windows.Forms.Button();
this.label25 = new System.Windows.Forms.Label(); this.label25 = new System.Windows.Forms.Label();
this.comboBoxPortName = new System.Windows.Forms.ComboBox(); this.comboBoxPortName = new System.Windows.Forms.ComboBox();
this.lblShuoKeMsg = new System.Windows.Forms.Label();
this.groupBox5.SuspendLayout(); this.groupBox5.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
...@@ -753,7 +752,7 @@ ...@@ -753,7 +752,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(7, 525); this.richTextBox1.Location = new System.Drawing.Point(7, 525);
this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(496, 229); this.richTextBox1.Size = new System.Drawing.Size(496, 214);
this.richTextBox1.TabIndex = 256; this.richTextBox1.TabIndex = 256;
this.richTextBox1.Text = ""; this.richTextBox1.Text = "";
// //
...@@ -783,7 +782,7 @@ ...@@ -783,7 +782,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(510, 361); this.groupBox1.Location = new System.Drawing.Point(510, 361);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(512, 199); this.groupBox1.Size = new System.Drawing.Size(512, 174);
this.groupBox1.TabIndex = 217; this.groupBox1.TabIndex = 217;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "伺服状态"; this.groupBox1.Text = "伺服状态";
...@@ -793,7 +792,7 @@ ...@@ -793,7 +792,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(127, 49); this.axis_1_Alarm.Location = new System.Drawing.Point(127, 40);
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;
...@@ -803,7 +802,7 @@ ...@@ -803,7 +802,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(329, 49); this.axis_3_Alarm.Location = new System.Drawing.Point(329, 40);
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;
...@@ -813,7 +812,7 @@ ...@@ -813,7 +812,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(224, 49); this.axis_2_Alarm.Location = new System.Drawing.Point(224, 40);
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;
...@@ -822,7 +821,7 @@ ...@@ -822,7 +821,7 @@
// //
this.label38.AutoSize = true; this.label38.AutoSize = true;
this.label38.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label38.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label38.Location = new System.Drawing.Point(49, 49); this.label38.Location = new System.Drawing.Point(49, 40);
this.label38.Name = "label38"; this.label38.Name = "label38";
this.label38.Size = new System.Drawing.Size(46, 17); this.label38.Size = new System.Drawing.Size(46, 17);
this.label38.TabIndex = 263; this.label38.TabIndex = 263;
...@@ -830,7 +829,7 @@ ...@@ -830,7 +829,7 @@
// //
// txtMiddleTarget // txtMiddleTarget
// //
this.txtMiddleTarget.Location = new System.Drawing.Point(105, 161); this.txtMiddleTarget.Location = new System.Drawing.Point(105, 144);
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);
...@@ -838,7 +837,7 @@ ...@@ -838,7 +837,7 @@
// //
// txtInoutTarget // txtInoutTarget
// //
this.txtInoutTarget.Location = new System.Drawing.Point(306, 161); this.txtInoutTarget.Location = new System.Drawing.Point(306, 144);
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);
...@@ -846,7 +845,7 @@ ...@@ -846,7 +845,7 @@
// //
// txtUpdownTarget // txtUpdownTarget
// //
this.txtUpdownTarget.Location = new System.Drawing.Point(206, 161); this.txtUpdownTarget.Location = new System.Drawing.Point(206, 144);
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);
...@@ -856,7 +855,7 @@ ...@@ -856,7 +855,7 @@
// //
this.label12.AutoSize = true; this.label12.AutoSize = true;
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(7, 164); this.label12.Location = new System.Drawing.Point(7, 147);
this.label12.Name = "label12"; this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(92, 17); this.label12.Size = new System.Drawing.Size(92, 17);
this.label12.TabIndex = 258; this.label12.TabIndex = 258;
...@@ -864,7 +863,7 @@ ...@@ -864,7 +863,7 @@
// //
// lblCountPulse1 // lblCountPulse1
// //
this.lblCountPulse1.Location = new System.Drawing.Point(105, 129); this.lblCountPulse1.Location = new System.Drawing.Point(105, 116);
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);
...@@ -872,7 +871,7 @@ ...@@ -872,7 +871,7 @@
// //
// lblOutPulse1 // lblOutPulse1
// //
this.lblOutPulse1.Location = new System.Drawing.Point(105, 97); this.lblOutPulse1.Location = new System.Drawing.Point(105, 88);
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);
...@@ -880,7 +879,7 @@ ...@@ -880,7 +879,7 @@
// //
// lblCountPulse3 // lblCountPulse3
// //
this.lblCountPulse3.Location = new System.Drawing.Point(306, 129); this.lblCountPulse3.Location = new System.Drawing.Point(306, 116);
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);
...@@ -888,7 +887,7 @@ ...@@ -888,7 +887,7 @@
// //
// lblOutPulse3 // lblOutPulse3
// //
this.lblOutPulse3.Location = new System.Drawing.Point(306, 97); this.lblOutPulse3.Location = new System.Drawing.Point(306, 88);
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);
...@@ -896,7 +895,7 @@ ...@@ -896,7 +895,7 @@
// //
// lblCountPulse2 // lblCountPulse2
// //
this.lblCountPulse2.Location = new System.Drawing.Point(207, 129); this.lblCountPulse2.Location = new System.Drawing.Point(207, 116);
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);
...@@ -904,7 +903,7 @@ ...@@ -904,7 +903,7 @@
// //
// lblOutPulse2 // lblOutPulse2
// //
this.lblOutPulse2.Location = new System.Drawing.Point(206, 97); this.lblOutPulse2.Location = new System.Drawing.Point(206, 88);
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);
...@@ -914,7 +913,7 @@ ...@@ -914,7 +913,7 @@
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label4.Location = new System.Drawing.Point(303, 20); this.label4.Location = new System.Drawing.Point(303, 15);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 17); this.label4.Size = new System.Drawing.Size(80, 17);
this.label4.TabIndex = 100; this.label4.TabIndex = 100;
...@@ -924,7 +923,7 @@ ...@@ -924,7 +923,7 @@
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label3.Location = new System.Drawing.Point(204, 20); this.label3.Location = new System.Drawing.Point(204, 15);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 17); this.label3.Size = new System.Drawing.Size(80, 17);
this.label3.TabIndex = 99; this.label3.TabIndex = 99;
...@@ -934,7 +933,7 @@ ...@@ -934,7 +933,7 @@
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.Location = new System.Drawing.Point(106, 20); this.label1.Location = new System.Drawing.Point(106, 15);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 17); this.label1.Size = new System.Drawing.Size(80, 17);
this.label1.TabIndex = 97; this.label1.TabIndex = 97;
...@@ -944,7 +943,7 @@ ...@@ -944,7 +943,7 @@
// //
this.label43.AutoSize = true; this.label43.AutoSize = true;
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, 99); this.label43.Location = new System.Drawing.Point(15, 90);
this.label43.Name = "label43"; this.label43.Name = "label43";
this.label43.Size = new System.Drawing.Size(80, 17); this.label43.Size = new System.Drawing.Size(80, 17);
this.label43.TabIndex = 23; this.label43.TabIndex = 23;
...@@ -954,7 +953,7 @@ ...@@ -954,7 +953,7 @@
// //
this.label42.AutoSize = true; this.label42.AutoSize = true;
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, 130); this.label42.Location = new System.Drawing.Point(15, 117);
this.label42.Name = "label42"; this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(80, 17); this.label42.Size = new System.Drawing.Size(80, 17);
this.label42.TabIndex = 24; this.label42.TabIndex = 24;
...@@ -1690,55 +1689,55 @@ ...@@ -1690,55 +1689,55 @@
// 启动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(144, 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);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(141, 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(144, 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);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(141, 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(144, 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);
// //
// toolStripSeparator3 // toolStripSeparator3
// //
this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator3.Size = new System.Drawing.Size(141, 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(144, 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);
// //
// toolStripSeparator4 // toolStripSeparator4
// //
this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator4.Size = new System.Drawing.Size(141, 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(144, 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);
// //
...@@ -1820,8 +1819,6 @@ ...@@ -1820,8 +1819,6 @@
this.toolStripSeparator9, this.toolStripSeparator9,
this.扫码测试ToolStripMenuItem, this.扫码测试ToolStripMenuItem,
this.toolStripSeparator10, this.toolStripSeparator10,
this.摄像机调试ToolStripMenuItem,
this.toolStripSeparator11,
this.学习二维码ToolStripMenuItem}); this.学习二维码ToolStripMenuItem});
this.设备调试ToolStripMenuItem.Name = "设备调试ToolStripMenuItem"; this.设备调试ToolStripMenuItem.Name = "设备调试ToolStripMenuItem";
this.设备调试ToolStripMenuItem.Size = new System.Drawing.Size(86, 25); this.设备调试ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
...@@ -1851,18 +1848,6 @@ ...@@ -1851,18 +1848,6 @@
this.toolStripSeparator10.Name = "toolStripSeparator10"; this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6);
// //
// 摄像机调试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);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
this.toolStripSeparator11.Size = new System.Drawing.Size(177, 6);
//
// 学习二维码ToolStripMenuItem // 学习二维码ToolStripMenuItem
// //
this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem"; this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem";
...@@ -1982,6 +1967,7 @@ ...@@ -1982,6 +1967,7 @@
// //
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.lblShuoKeMsg);
this.groupBox4.Controls.Add(this.btnRelMove); this.groupBox4.Controls.Add(this.btnRelMove);
this.groupBox4.Controls.Add(this.txtAddr); this.groupBox4.Controls.Add(this.txtAddr);
this.groupBox4.Controls.Add(this.label18); this.groupBox4.Controls.Add(this.label18);
...@@ -2003,9 +1989,9 @@ ...@@ -2003,9 +1989,9 @@
this.groupBox4.Controls.Add(this.label25); this.groupBox4.Controls.Add(this.label25);
this.groupBox4.Controls.Add(this.comboBoxPortName); this.groupBox4.Controls.Add(this.comboBoxPortName);
this.groupBox4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.groupBox4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox4.Location = new System.Drawing.Point(510, 562); this.groupBox4.Location = new System.Drawing.Point(510, 537);
this.groupBox4.Name = "groupBox4"; this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(512, 160); this.groupBox4.Size = new System.Drawing.Size(512, 200);
this.groupBox4.TabIndex = 271; this.groupBox4.TabIndex = 271;
this.groupBox4.TabStop = false; this.groupBox4.TabStop = false;
this.groupBox4.Text = "压紧轴"; this.groupBox4.Text = "压紧轴";
...@@ -2203,6 +2189,16 @@ ...@@ -2203,6 +2189,16 @@
this.comboBoxPortName.Size = new System.Drawing.Size(103, 25); this.comboBoxPortName.Size = new System.Drawing.Size(103, 25);
this.comboBoxPortName.TabIndex = 0; this.comboBoxPortName.TabIndex = 0;
// //
// lblShuoKeMsg
//
this.lblShuoKeMsg.AutoSize = true;
this.lblShuoKeMsg.ForeColor = System.Drawing.Color.Green;
this.lblShuoKeMsg.Location = new System.Drawing.Point(19, 170);
this.lblShuoKeMsg.Name = "lblShuoKeMsg";
this.lblShuoKeMsg.Size = new System.Drawing.Size(80, 17);
this.lblShuoKeMsg.TabIndex = 97;
this.lblShuoKeMsg.Text = "步进电机信息";
//
// FrmStoreBox // FrmStoreBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
...@@ -2379,7 +2375,6 @@ ...@@ -2379,7 +2375,6 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 摄像机调试ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 学习二维码ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 学习二维码ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
...@@ -2387,7 +2382,6 @@ ...@@ -2387,7 +2382,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; private System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
...@@ -2418,6 +2412,7 @@ ...@@ -2418,6 +2412,7 @@
private System.Windows.Forms.Button btnLineAbsMove; private System.Windows.Forms.Button btnLineAbsMove;
private System.Windows.Forms.Label label25; private System.Windows.Forms.Label label25;
private System.Windows.Forms.ComboBox comboBoxPortName; private System.Windows.Forms.ComboBox comboBoxPortName;
private System.Windows.Forms.Label lblShuoKeMsg;
} }
} }
...@@ -999,13 +999,12 @@ namespace OnlineStore.ACSingleStore ...@@ -999,13 +999,12 @@ namespace OnlineStore.ACSingleStore
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = ""; string message = "";
string outMsg = ""; string outMsg = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg); List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList) foreach (string str in codeList)
{ {
string code = HDevelopExport.SubStrCode(str); message = message + str + "##";
message = message + code + "##";
} }
LogUtil.info("扫码测试收到二维码【"+outMsg+"】:" + message); LogUtil.info("扫码测试收到二维码【" + outMsg + "】:" + message);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
} }
...@@ -1307,20 +1306,13 @@ namespace OnlineStore.ACSingleStore ...@@ -1307,20 +1306,13 @@ namespace OnlineStore.ACSingleStore
} }
} }
private void 摄像机调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmCamera frm = new FrmCamera(store);
frm.ShowDialog();
}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e) private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName); CodeLibrary.FrmCodeDecode frm = new FrmCodeDecode();
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType); frm.ShowDialog();
HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
FrmCodeLearn learn = new FrmCodeLearn();
learn.ShowDialog();
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
} }
...@@ -1349,7 +1341,8 @@ namespace OnlineStore.ACSingleStore ...@@ -1349,7 +1341,8 @@ namespace OnlineStore.ACSingleStore
} }
private void btnGetPosition_Click(object sender, EventArgs e) private void btnGetPosition_Click(object sender, EventArgs e)
{ {
ShuoKeControls.GetABSPosition(store.Config.CompressAxis_Slv); int value = ShuoKeControls.GetABSPosition(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = DateTime.Now.ToLongTimeString() + "实时位置:" + value;
} }
private void btnStop_Click(object sender, EventArgs e) private void btnStop_Click(object sender, EventArgs e)
{ {
...@@ -1373,10 +1366,11 @@ namespace OnlineStore.ACSingleStore ...@@ -1373,10 +1366,11 @@ namespace OnlineStore.ACSingleStore
{ {
int posi = FormUtil.GetIntValue(txtLinePosition); int posi = FormUtil.GetIntValue(txtLinePosition);
ShuoKeControls.RelativeMove(this.store.Config.CompressAxis_Slv, posi); ShuoKeControls.RelativeMove(this.store.Config.CompressAxis_Slv, posi);
} }
private void btnStatusSearch_Click(object sender, EventArgs e) private void btnStatusSearch_Click(object sender, EventArgs e)
{ {
ShuoKeControls.GetStatus(store.Config.CompressAxis_Slv); ShuoKeInfo info = ShuoKeControls.GetStatus(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = info.ToShowStr();
} }
private void FormComStatus(bool isOpen) private void FormComStatus(bool isOpen)
{ {
......
...@@ -3,13 +3,9 @@ ...@@ -3,13 +3,9 @@
1.使用硕科步进电机作为压紧轴 1.使用硕科步进电机作为压紧轴
2.温湿度修改为com通信 2.温湿度修改为com通信
3.增加安全光栅信号,当叉子出料过程中,遮挡光栅会暂停进出轴移动,光栅正常时再恢复移动 3.增加安全光栅信号,当叉子出料过程中,遮挡光栅会暂停进出轴移动,光栅正常时再恢复移动
4.增加模拟量IO 4.增加模拟量IO
20181107 20181107
1.出库时等待10秒钟,或等待拿走料盘(高度=0)才算出库结束 1.出库时等待10秒钟,或等待拿走料盘(高度=0)才算出库结束
20181108 20181108
// 机器状态 顶灯显示 // 机器状态 顶灯显示
// 绿 黄 红 // 绿 黄 红
...@@ -36,10 +32,11 @@ ...@@ -36,10 +32,11 @@
在原来认为高度是8的基础上,再判断三个测高如果有一个高度>=9,则认定为12的料盘。 在原来认为高度是8的基础上,再判断三个测高如果有一个高度>=9,则认定为12的料盘。
20181213 20181213
在RC26联电项目基础上拉取分支,作为RC33珠海料仓项目。 在RC26联电项目基础上拉取分支,作为RC33珠海料仓项目。
需要修改内容:扫码改为通用扫码类型。
硕科改为实时返回数据的通讯方式。
硕科压紧轴需要增加机构检测信号的处理。
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" /> <Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" /> <Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\ACStoreManager.cs" /> <Compile Include="acSingleStore\ACStoreManager.cs" />
<Compile Include="halcon\HDevelopExport.cs" /> <Compile Include="halcon\CodeManager.cs" />
<Compile Include="KangNaiDe\AITcpClient.cs" /> <Compile Include="KangNaiDe\AITcpClient.cs" />
<Compile Include="KangNaiDe\KNDAIManager.cs" /> <Compile Include="KangNaiDe\KNDAIManager.cs" />
<Compile Include="KangNaiDe\KNDManager.cs" /> <Compile Include="KangNaiDe\KNDManager.cs" />
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<Compile Include="PanasonicServo\ACCMDManager.cs" /> <Compile Include="PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" /> <Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" /> <Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="ShuoKe\ShuoKeController.cs" />
<Compile Include="store\LineMoveP.cs" /> <Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs"> <Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
...@@ -75,7 +76,6 @@ ...@@ -75,7 +76,6 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShuoKe\ShuoKeControls.cs" />
<Compile Include="store\model\AxisAlarmInfo.cs" /> <Compile Include="store\model\AxisAlarmInfo.cs" />
<Compile Include="store\model\FixtureCodeInfo.cs" /> <Compile Include="store\model\FixtureCodeInfo.cs" />
<Compile Include="store\KTK_DeviceBase.cs" /> <Compile Include="store\KTK_DeviceBase.cs" />
......
...@@ -315,8 +315,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -315,8 +315,11 @@ namespace OnlineStore.DeviceLibrary
} }
else if (dataByte.Length == 2) else if (dataByte.Length == 2)
{ {
sendData[4] = dataByte[1]; sendData[4] = dataByte[0];
sendData[5] = dataByte[0]; sendData[5] = dataByte[1];
//sendData[4] = dataByte[1];
//sendData[5] = dataByte[0];
} }
sendData = buildCheckData(sendData, sendData.Length - 2); sendData = buildCheckData(sendData, sendData.Length - 2);
......
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 硕科控制模块代码
/// </summary>
public class ShuoKeControls
{
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static AcSerialBean bean = null;
public static bool isRun = false;
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 串口操作
public static bool ResertInitPort(string comPortName, int baudRate, int tparity, int dataBits, StopBits stopBits)
{
PortName = comPortName;
if (isRun)
{
ClosePort();
}
return InitPort(comPortName, baudRate, tparity, dataBits, stopBits);
}
public static bool InitPort(string comPortName, int baudRate, int tparity, int dataBits, StopBits stopBits)
{
if (isRun)
{
return true;
}
try
{
PortName = comPortName;
Parity parity = (Parity)tparity;
bean = new AcSerialBean(comPortName, baudRate, parity, 8, stopBits);
bool result = bean.openPort();
if (!result)
{
return false;
}
//bean.DataReceived += DataReceived;
isRun = true;
}
catch (Exception ex)
{
isRun = false;
LogUtil.error(LOGGER, "打开步进控制器串口失败:" + ex.ToString());
return false;
}
return true;
}
public static void ClosePort()
{
isRun = false;
bean.closePort();
LogUtil.info(LOGGER, "关闭步进控制器串口完成");
}
/// <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 = "";
for (int i = 0; i < data.Length; i++)
{
strSend += string.Format("{0:X2} ", data[i]);
}
if (strSend.Equals(""))
{
return returnData;
}
LogUtil.debug("串口" + PortName + " 写入数据:" + strSend + "");
if (bean == null)
{
LogUtil.debug(" 试图向未打开串口【" + PortName + "】写入数据:" + strSend + "。");
}
else
{
bean.SendCommand(data, ref returnData, outTime, reviceLength);
}
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
}
return returnData;
}
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 (strSend.Equals(""))
{
return;
}
//校验
ushort pChecksum = 0;
SerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
if (!bits[bits.Length - 2].Equals(checkByte[0]))
{
bean.clearInBuffer();
LogUtil.info(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】,校验错误");
return;
}
}
else
{
if (!bits[bits.Length - 1].Equals(checkByte[0]) || (!bits[bits.Length - 2].Equals(checkByte[1])))
{
bean.clearInBuffer();
LogUtil.info(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】,校验错误");
return;
}
}
LogUtil.debug(LOGGER, " 【" + portName + "】 收到数据【" + strSend + "】");
int slvAddr = (int)bits[0];
byte cmd = bits[1];
//查询状态
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 = "";
for (int i = 0; i < bits.Length; i++)
{
strSend += string.Format("{0:X2} ", bits[i]);
}
//校验
ushort pChecksum = 0;
SerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.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 = SerialBean.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表示停止
//[数据2]:LL-左限位IO状态 1表示有效 0表示无效
//[数据3]:O-原点IO状态 1表示有效 0表示无效,,=1表示原点灭,=0表示当前原点亮
// [数据4]:RL-右限位IO状态 1表示有效 0表示无效
//[数据5]:EN-使能IO状态 1表示有效 0表示无效
int slvAddr = (int)bits[0];
byte cmd = bits[1];
int isInMove = bits[3];
int isLLimit = bits[4];
int isOrg = bits[5];
int isRLimit = bits[6];
int isEn = bits[7];
info = new ShuoKeInfo(isInMove, slvAddr, isLLimit, isOrg, isRLimit, isEn);
try
{
if (shuokeMap.ContainsKey(slvAddr))
{
info.LastPosition = shuokeMap[slvAddr].LastPosition;
shuokeMap.Remove(slvAddr);
}
shuokeMap.Add(slvAddr, info);
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "记录状态出错:" + ex.ToString());
}
LogUtil.debug(LOGGER, "收到驱动器【" + slvAddr + "】运动状态:运动【" + isInMove + "】左限位【" + isLLimit + "】右限位【" + isRLimit + "】原点【" + isOrg + "】使能【" + isEn + "】");
}
return info;
}
public static int GetLastPosition(int slvAddr)
{
if (shuokeMap.ContainsKey(slvAddr))
{
ShuoKeInfo info = shuokeMap[slvAddr];
return info.LastPosition;
}
return -1;
}
#endregion
#region 逻辑判断
public static bool IsMoveEnd(int slvAddr, int targetPosition,DateTime time, out ShuoKeInfo shuokeInfo)
{
shuokeInfo = GetStatus(slvAddr);
if (shuokeInfo.IsInMove == 0 && shuokeInfo.UpdateTime > time)
{
int position = GetABSPosition(slvAddr);
if (Math.Abs(position - targetPosition) < 10)
{
return true;
}
else
{
LogUtil.info("【" + PortName + "】 目标位置【"+targetPosition+"】当前位置【"+position+"】,已经不再运动中");
}
}
return false;
}
public static bool IsHomeMoveEnd(int slvAddr, DateTime time, out ShuoKeInfo shuokeInfo)
{
shuokeInfo = GetStatus(slvAddr);
if (shuokeInfo.IsInMove == 0 && shuokeInfo.UpdateTime > time && shuokeInfo.Org == 0)
{
return true;
}
return false;
}
#endregion
#region 驱动器操作方法
public static ShuoKeInfo GetStatus(int slvAddr)
{
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.SearchMoveStatus, 0x00, 0,10);
return DataToStatus(reviceData);
}
public static void DStoop(int slvAddr)
{
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.DStopMove, 0x00, 0,DReviceLength);
}
public static void SuddownStop(int slvAddr)
{
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.SuddownStopMove, 0x00, 0, DReviceLength);
}
public static int GetABSPosition(int slvAddr)
{
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.GetAbsPosition, 0x00, 0, 9);
return DataToPosition(reviceData);
}
// <param name="homeType">0=反方向,1=正方向</param>
public static void HomeMove(int slvAddr, byte homeType)
{
string fangx = homeType.Equals(0) ? "反方向" : "正方向";
LogUtil.info("压紧轴原点返回:" + fangx);
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.HomeMove, 0x01, homeType, DReviceLength);
}
public static void SetConfigSpeed(AC_SA_Config Config)
{
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetAddSpeed, Config.CompressAxis_AddSpeed);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetDelSpeed, Config.CompressAxis_DelSpeed);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetEndSpeed, Config.CompressAxis_EndSpeed);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetHomeSpeed, Config.CompressAxis_HomeSpeed);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetMaxSpeed, Config.CompressAxis_MaxSpeed);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetStartSpeed, Config.CompressAxis_StartSpeed);
}
public static void VolMove(int slvAddr, int speed)
{
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.VolMove, 0x04, speed, DReviceLength);
}
public static void AbsMove(int slvAddr, int TargetPosition)
{
// 47、设置绝对位置并开始运动:不支持广播(开环的32位脉冲统计长度)
//正负数表示绝对位置,如果已经到位置,则不做运动。(M4505S特有命令)
//发送: 应答:
//[设备地址] 0x01 [设备地址] 0x01
//[命令] 0x50 [命令] 0x50
//[数据长度] 4 [数据长度] 0
//[数据] xxxxxxxx [数据] 无
//[CRC校验1] 0xnn [CRC校验1] 0xnn
//[CRC校验2] 0xnn [CRC校验2] 0xnn
//数据:4BYTE,(支持32位有符号脉冲位置)
byte[] reviceData = SendData(slvAddr, ShuoKeCMD.AbsMove, 0x04, TargetPosition, DReviceLength);
}
public static void RelativeMove(int slvAddr, int position)
{
//1是正方向
byte fangxiang = 0x01;
if (position < 0)
{
fangxiang = 0x00;
position = Math.Abs(position);
}
byte dataLength = 0x04;
byte[] sendData = new byte[5 + dataLength];
sendData[0] = (byte)slvAddr;
sendData[1] = ShuoKeCMD.RelativeMove;
sendData[2] = dataLength;
sendData[3] = 0x00;
sendData[4] = 0x00;
sendData[5] = 0x00;
sendData[6] = 0x00;
string speed = Convert.ToString(position, 16);
byte[] speedByte = SerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++)
{
if (i >= 4)
{
break;
}
sendData[6 - (speedByte.Length - 1 - i)] = speedByte[i];
}
sendData[3] = fangxiang;
sendData = buildCheckData(sendData, 3 + dataLength);
byte[] reviceData = SendCommand(sendData,SleepMS,DReviceLength);
}
public static void PositionClear(int slvAddr, byte setCMD)
{
byte[] reviceData = SendData(slvAddr, setCMD, 0x00, 0, DReviceLength);
}
/// <summary>
/// 设置电机的速度
/// </summary>
/// <param name="slvAddr">电机地址</param>
/// <param name="setCMD">设置速度的命令号</param>
/// <param name="speedValue">速度值</param>
public static void SetSpeed(int slvAddr, byte setCMD, int speedValue)
{
byte[] reviceData = SendData(slvAddr, setCMD, 0x04, speedValue, DReviceLength);
Thread.Sleep(10);
}
private static byte[] SendData(int slvAddr, byte cmd, byte dataLength, int dataValue, int reviceDataLength)
{
byte[] sendData = new byte[5 + dataLength];
sendData[0] = (byte)slvAddr;
sendData[1] = cmd;
sendData[2] = dataLength;
if (dataLength.Equals(0x00))
{
}
else if (dataLength.Equals(0x01))
{
sendData[3] = (byte)dataValue;
}
else if (dataLength.Equals(0x04))
{
sendData[3] = 0x00;
sendData[4] = 0x00;
sendData[5] = 0x00;
sendData[6] = 0x00;
string speed = Convert.ToString(dataValue, 16);
byte[] speedByte = SerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++)
{
if (i >= 4)
{
break;
}
sendData[6 - (speedByte.Length - 1 - i)] = speedByte[i];
}
}
sendData = buildCheckData(sendData, 3 + dataLength);
byte[] reviceData = SendCommand(sendData, SleepMS, reviceDataLength);
return reviceData;
}
private static byte[] buildCheckData(byte[] sendData, int length)
{
ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
sendData[length] = checkByte[0];
sendData[length + 1] = 0x00;
}
else
{
sendData[length + 1] = checkByte[0];
sendData[length] = checkByte[1];
}
return sendData;
}
#endregion
}
public class ShuoKeCMD
{
/// <summary>
/// 设置运动初速度://SndHex:01 25 04 00 00 00 64 FC DE
/// </summary>
public static byte SetStartSpeed = 0x25;
/// <summary>
/// 设置运动最大速度://SndHex:01 27 04 00 00 27 10 E6 EB
/// </summary>
public static byte SetMaxSpeed = 0x27;
/// <summary>
/// 设置运动末速度://SndHex:01 29 04 00 00 03 E8 FD 47
/// </summary>
public static byte SetEndSpeed = 0x29;
/// <summary>
/// 设置运动加速度://SndHex:01 2B 04 00 00 13 88 F1 4D
/// </summary>
public static byte SetAddSpeed = 0x2B;
/// <summary>
/// 设置运动减速度://SndHex:01 2D 04 00 00 03 E8 FC C3
/// </summary>
public static byte SetDelSpeed = 0x2D;
/// <summary>
/// 设置归零运动速度://SndHex:01 2F 04 00 00 27 10 E7 A3
/// </summary>
public static byte SetHomeSpeed = 0x2F;
/// <summary>
/// //查找原点命令:
//SndHex:01 3E 01 00 61 84
/// </summary>
public static byte HomeMove = 0x3E;
/// <summary>
/// 绝对位置运动//SndHex:01 50 04 FF FF D8 F0 AC 30
/// </summary>
public static byte AbsMove = 0x50;
/// <summary>
/// 急停命令://SndHex:01 3C 00 31 00
/// </summary>
public static byte SuddownStopMove = 0x3C;
/// <summary>
/// 减速停止命令://SndHex:01 3D 00 30 90
/// </summary>
public static byte DStopMove = 0x3D;
/// <summary>
/// 绝对位置清零: //SndHex:01 38 00 33 C0
/// </summary>
public static byte AbsPositionClear = 0x38;
/// <summary>
/// 相对位置清零: //SndHex:01 3A 00 32 A0
/// </summary>
public static byte RelPositionClear = 0x3A;
/// <summary>
/// 查询运动状态://SndHex:01 3B 00 33 30
/// </summary>
public static byte SearchMoveStatus = 0x3B;
/// <summary>
//查询设备地址://SndHex:00 21 00 69 90
/// </summary>
public static byte SearchSlvAddr = 0x21;
/// <summary>
/// 设置32位运动速度,并恒速运动:SndHex:01 33 04 00 00 27 10 E5 FF
/// </summary>
public static byte VolMove = 0x33;
/// <summary>
/// 查询绝对位置
/// </summary>
public static byte GetAbsPosition = 0x37;
/// <summary>
/// 相对位置运动
/// </summary>
public static byte RelativeMove = 0x32;
}
public class ShuoKeInfo
{
public ShuoKeInfo(int slv, int position)
{
this.IsInMove = 0;
this.SlvAddr = slv;
this.LLimit = 0;
this.RLimit = 0;
this.Org = 0;
this.En = 0;
UpdateTime = DateTime.Now;
LastPosition = position;
}
public ShuoKeInfo(int ismove, int slv, int ll, int org, int rl, int en)
{
this.IsInMove = ismove;
this.SlvAddr = slv;
this.LLimit = ll;
this.RLimit = rl;
this.Org = org;
this.En = en;
UpdateTime = DateTime.Now;
LastPosition = 0;
}
public int LastPosition { get; set; }
/// <summary>
/// 驱动器地址
/// </summary>
public int SlvAddr { get; set; }
/// <summary>
/// 是否在运动中
/// </summary>
public int IsInMove { get; set; }
/// <summary>
/// 左极限
/// </summary>
public int LLimit { get; set; }
/// <summary>
/// 右极限
/// </summary>
public int RLimit { get; set; }
/// <summary>
/// 原点信号是否有效
/// </summary>
public int Org { get; set; }
/// <summary>
/// 使能是否有效
/// </summary>
public int En { get; set; }
public DateTime UpdateTime { get; set; }
public string ToShowStr()
{
return "运动[" + IsInMove + "]左限位[" + LLimit + "]右限位[" + RLimit + "]原点[" + Org + "]使能[" + En + "][" + UpdateTime.ToShortTimeString() + "]";
}
}
}
...@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary
//初始化摄像机配置 //初始化摄像机配置
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName); string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType); string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDevelopExport.LoadConfig(nameStr,codeStr); CodeManager.LoadConfig(nameStr,codeStr);
//初始化 //连接设备 //初始化 //连接设备
KNDManager.ConnectionKND(Config.DIODeviceNameList); KNDManager.ConnectionKND(Config.DIODeviceNameList);
...@@ -190,10 +190,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -190,10 +190,7 @@ namespace OnlineStore.DeviceLibrary
//启动温湿度服务器 //启动温湿度服务器
//HumitureServer.StartTemperateServer(Config.TemperateServer_Port); //HumitureServer.StartTemperateServer(Config.TemperateServer_Port);
HumitureController.Init(Config.Humiture_Port); HumitureController.Init(Config.Humiture_Port);
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
ReturnHome(); ReturnHome();
StartTime = DateTime.Now; StartTime = DateTime.Now;
mainTimer.Enabled = true; mainTimer.Enabled = true;
...@@ -283,10 +280,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -283,10 +280,7 @@ namespace OnlineStore.DeviceLibrary
autoNext = false; autoNext = false;
} }
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
...@@ -690,8 +684,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -690,8 +684,7 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ShuoKeControls.ClosePort(); ShuoKeControls.ClosePort();
} }
HDevelopExport.CloseAllCamera();
HumitureServer.StopTemperateServer(); HumitureServer.StopTemperateServer();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString()); LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
...@@ -1339,7 +1332,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1339,7 +1332,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "StopMove"); LogUtil.info(LOGGER, StoreName + "StopMove");
KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW); KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW); KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
HDevelopExport.CloseAllCamera();
isInPro = false; isInPro = false;
} }
...@@ -1499,12 +1492,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -1499,12 +1492,16 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string outMsg = ""; string outMsg = "";
string message = ""; string message = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg); List<string> codeList = CodeManager.CameraScan();
if (codeList.Count <= 0)
{
codeList = CodeManager.CameraScan();
}
//= 1 + 123.4x100.5 - 7x12 = CODE //= 1 + 123.4x100.5 - 7x12 = CODE
foreach (string str in codeList) foreach (string str in codeList)
{ {
string code = HDevelopExport.SubStrCode(str); string code = str;
code = "=1+0x0-7x" + height + " =" + code; code = "=1+0x0-7x" + height + " =" + code;
message = message + code + spiltStr; message = message + code + spiltStr;
} }
......
...@@ -180,7 +180,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -180,7 +180,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime, out info); wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr,wait.TargetPosition, StoreMove.LastSetpTime, out info);
} }
if (!wait.IsEnd) if (!wait.IsEnd)
{ {
...@@ -192,7 +192,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -192,7 +192,7 @@ namespace OnlineStore.DeviceLibrary
NotOkMsg += "" +info.ToShowStr(); NotOkMsg += "" +info.ToShowStr();
} }
ShuoKeControls.GetStatus(wait.SlvAddr); //ShuoKeControls.GetStatus(wait.SlvAddr);
} }
} }
if (wait.IsEnd) if (wait.IsEnd)
......
using CodeLibrary;
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class CodeManager
{
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
/// <param name="nameStr">摄像机名称,多个用#分割</param>
/// <param name="codeStr">二维码类型,多个用#分割</param>
public static void LoadConfig(string nameStr, string codeStr)
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
try
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
LogUtil.info("加载到配置摄像机名称:" + str.Trim());
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
LogUtil.info("加载到配置二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
foreach(string str in names)
{
LogUtil.info("加载到HIK相机:" + str.Trim());
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string str in names)
{
LogUtil.info("加载到Balser相机:" + str.Trim());
}
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if(hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
}
else
{
LogUtil.info("未找到摄像机【"+cameraName+"】无法获取图片");
}
return bitm;
}
public static List<string> CameraScan( )
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
try
{
foreach (string cameraName in cameraNameList)
{
Bitmap bitmap = GetCamerImage(cameraName);
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
}
else
{
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
allCodeList.AddRange(cc);
}
}
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList;
}
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
return filePath;
}
else
{
return "";
}
}
}
}
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary
{
public class HDevelopCodeLearn
{
public static HWindow hv_ExpDefaultWinHandle;
public static HTuple hv_AcqHandle = null;
public static void HDevelopStop()
{
//MessageBox.Show("Press button to continue", "Program stop");
}
public static void InitHalcon()
{
// Default settings used in HDevelop
HOperatorSet.SetSystem("width", 512);
HOperatorSet.SetSystem("height", 512);
}
public static void RunHalcon(HWindow Window, string camerName, string codeType, string paramPath, int codeCount)
{
InitHalcon();
hv_ExpDefaultWinHandle = Window;
action(camerName, codeType, paramPath, codeCount);
}
private static bool OpenCamera(string cameraName)
{
try
{ //[1] HD USB Camera
HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1,
"default", -1, "false", "default", cameraName, 0, -1, out hv_AcqHandle);
//HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb",
// -1, "false", "default", "[1] HD USB Camera", 0, -1, out hv_AcqHandle);
return true;
}
catch (Exception ex)
{
LogUtil.error("打开摄像机失败:" + ex.ToString() + ",调用关闭摄像头");
CloseCamera(cameraName);
return false;
}
}
private static void CloseCamera(string cameraName)
{
try
{
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
hv_AcqHandle = null;
}
catch (Exception ex)
{
LogUtil.error("关闭摄像机失败:" + ex.ToString());
}
}
public static bool IsRun = false;
// Main procedure
private static bool action(string cameraName, string codeType, string paramPath, int codeCount)
{
IsRun = true;
IsLearnEnd = false;
IsTestEnd = false;
try
{
HTuple hv_code_type = codeType;
HTuple hv_model_path = paramPath;
HObject ho_Image = null, ho_SymbolXLDs = null;
HTuple hv_train_first = null, /*hv_AcqHandle = null,*/ hv_DataCodeHandle = null;
HTuple hv_ResultHandles = new HTuple(), hv_DecodedDataStrings = new HTuple();
HTuple hv_GenParamNames = new HTuple(), hv_ModelBeforeTraining = new HTuple();
// Initialize local and output iconic variables
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet.GenEmptyObj(out ho_SymbolXLDs);
//Image Acquisition 04: Code generated by Image Acquisition 04
//Image Acquisition 01: Code generated by Image Acquisition 01
//hv_code_type = "Data Matrix ECC 200";
//hv_model_path = ("E:/BaiduNetdiskDownload/" + hv_code_type) + ".dcm";
hv_train_first = 1;
if (!OpenCamera(cameraName))
{
return false ;
}
//HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
HOperatorSet.CreateDataCode2dModel(hv_code_type, new HTuple(), new HTuple(),
out hv_DataCodeHandle);
//set_data_code_2d_param (DataCodeHandle, 'strict_model', 'yes')
//set_data_code_2d_param (DataCodeHandle, 'persistence', 0)
//set_data_code_2d_param (DataCodeHandle, 'polarity', 'light_on_dark')
List<string> findCode = new List<string>();
if ((int)(hv_train_first) != 0)
{
while (findCode.Count < codeCount&&IsLearnEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"train", "all", out hv_ResultHandles, out hv_DecodedDataStrings);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
HOperatorSet.QueryDataCode2dParams(hv_DataCodeHandle, "get_model_params",
out hv_GenParamNames);
HOperatorSet.GetDataCode2dParam(hv_DataCodeHandle, hv_GenParamNames, out hv_ModelBeforeTraining);
HDevelopStop();
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
LogUtil.info("["+cameraName + "][" + codeType + "]学习【" + str+"】");
findCode.Add(str);
}
}
}
ShowImage(ho_Image,ho_SymbolXLDs);
}
Thread.Sleep(500);
}
//*参数写入文件
LogUtil.info("["+cameraName + "][" + codeType + "]保存参数到文件【" + paramPath+"】");
HOperatorSet.WriteDataCode2dModel(hv_DataCodeHandle, hv_model_path);
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
}
//Read the previously saved data code model
findCode = new List<string>();
HOperatorSet.ReadDataCode2dModel(hv_model_path, out hv_DataCodeHandle);
while (findCode.Count < codeCount&&IsTestEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"stop_after_result_num", 5, out hv_ResultHandles, out hv_DecodedDataStrings);
ShowImage(ho_Image,ho_SymbolXLDs);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
findCode.Add(str);
LogUtil.info("[" + cameraName + "][" + codeType + "]检测到【" + str + "】");
}
}
}
}
Thread.Sleep(500);
}
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
CloseCamera(cameraName);
ho_Image.Dispose();
ho_SymbolXLDs.Dispose();
IsRun = false;
return true;
}catch(Exception ex)
{
LogUtil.error("出错了:" + ex.ToString());
CloseCamera(cameraName);
IsRun = false;
return false;
}
}
public static bool IsTestEnd = false;
public static bool IsLearnEnd = false;
public static void StopLearn()
{
IsTestEnd = true;
IsLearnEnd = true;
}
private static int dWidth = 0;
private static int dHeight = 0;
private static void ShowImage(HObject ho_Image,HObject ho_SymbolXLDs)
{
if (dWidth <= 0)
{
HTuple width, height;
//int dWidth = 0; int dHeight = 0;
HOperatorSet.GetImageSize(ho_Image, out width, out height);
dWidth = (int)width.D;
dHeight = (int)height.D;
hv_ExpDefaultWinHandle.SetPart(0, 0, dHeight, dWidth);
}
HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle);
HOperatorSet.DispObj(ho_SymbolXLDs, hv_ExpDefaultWinHandle);
}
}
}
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class HDevelopExport
{
/// <summary>
/// 摄像机类别,只保存已经打开的摄像机
/// </summary>
public static Dictionary<string, HTuple> cameraHtuple = new Dictionary<string, HTuple>();
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
/// <param name="nameStr">摄像机名称,多个用#分割</param>
/// <param name="codeStr">二维码类型,多个用#分割</param>
public static void LoadConfig(string nameStr, string codeStr)
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
try
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
LogUtil.info("加载到摄像机名称:" + str.Trim());
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
LogUtil.info("加载到二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
/// <summary>
/// 扫取二维码,会打开摄像机,正常情况下不关闭摄像机
/// </summary>
/// <returns></returns>
public static List<string> CameraScan(out string msg)
{
List<string> allCodeList = new List<string>();
msg = "";
try
{
//HDevelopExport.CloseAllCamera();
//打开所有摄像机
HDevelopExport.OpenAllCamera();
foreach (string cameraName in HDevelopExport.cameraNameList)
{
HObject ho_Image = HDevelopExport.GrabImage(cameraName);
List<string> codeList = HDevelopExport.GetCode(ho_Image);
//if (codeList.Count > 0)
//{
// Bitmap bitmap = HObject2Bpp24(ho_Image);
// if (Exist(bitmap))
// {
// msg = "盘尺寸错误";
// LogUtil.error("盘尺寸错误!");
// }
// bitmap = null;
//}
allCodeList.AddRange(codeList);
}
}
catch (Exception ex)
{
LogUtil.error("从摄像机获取二维码出错:" + ex.ToString());
LogUtil.error("关闭摄像机");
HDevelopExport.CloseAllCamera();
}
return allCodeList;
}
/// <summary>
/// 料盘是否存在,true在,false不在
/// </summary>
/// <param name="bmp"></param>
/// <returns></returns>
private static bool Exist(Bitmap bmp)
{
//8个点,距离边界1/10
Point[] pt = new Point[8];
int w = bmp.Width / 10;
int h = bmp.Height / 10;
pt[0] = new Point(10, 20); //左上1
pt[1] = new Point(20, 10); //左上2
pt[2] = new Point(bmp.Width - 10, 20); //右上1
pt[3] = new Point(bmp.Width - 20, 10); //右上2
pt[4] = new Point(10, bmp.Height - 20); //左下1
pt[5] = new Point(20, bmp.Height - 10); //左下2
pt[6] = new Point(bmp.Width - 10, bmp.Height - 20); //右下1
pt[7] = new Point(bmp.Width - 20, bmp.Height - 10); //右下2
//数量
int count = 0;
//颜色的范围,小于即不存在
Color range = Color.FromArgb(50, 50, 50);
for (int i = 0; i < pt.Length; i++)
{
Color cc = bmp.GetPixel(pt[i].X, pt[i].Y);
if (cc.R < range.R && cc.G < range.G && cc.B < range.B)
count++;
}
if (count >= 7) //满7个即可
return false;
else
return true;
}
public static Bitmap HObject2Bpp24(HObject image)
{
Bitmap res = null;
try
{
HTuple hred, hgreen, hblue, type, width, height;
HOperatorSet.GetImagePointer3(image, out hred, out hgreen, out hblue, out type, out width, out height);
res = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Rectangle rect = new Rectangle(0, 0, width, height);
BitmapData bitmapData = res.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
unsafe
{
byte* bptr = (byte*)bitmapData.Scan0;
byte* r = ((byte*)hred.I);
byte* g = ((byte*)hgreen.I);
byte* b = ((byte*)hblue.I);
for (int i = 0; i < width * height; i++)
{
bptr[i * 4] = (b)[i];
bptr[i * 4 + 1] = (g)[i];
bptr[i * 4 + 2] = (r)[i];
bptr[i * 4 + 3] = 255;
}
}
res.UnlockBits(bitmapData);
}catch(Exception ex)
{
LogUtil.info("Hobject to BitMap 出错"+ex.ToString());
}
return res;
}
public static List<string> GetCode(HObject ho_Image, string symbolType)
{
List<string> list = new List<string>();
string[] array = GetQrCode(ho_Image, symbolType);
if (array != null)
{
list.AddRange(array);
}
return list;
}
public static List<string> GetCode(HObject ho_Image)
{
List<string> list = new List<string>();
foreach (string codeType in codeTypeList)
{
string[] array = GetQrCode(ho_Image, codeType);
if (array != null)
{
list.AddRange(array);
}
}
return list;
}
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
return filePath;
}
else
{
return "";
}
}
// Procedures
//private static HTuple hv_DataCodeHandle = null;
private static string[] GetQrCode(HObject ho_Image, string symbolType)
{
try
{
DateTime date = DateTime.Now;
// Local iconic variables
HObject ho_SymbolXLDs;
// Local control variables
HTuple hv_ResultHandles = null;
//HTuple hv_DataCodeHandle = null, hv_ResultHandles = null;
HTuple hv_DecodedDataStrings = null;
HTuple hv_Area = null;
HTuple hv_Row1 = null;
HTuple hv_Column = null;
HTuple hv_PointOrder = null;
HTuple hv_DataCodeHandle = null;
// Initialize local and output iconic variables
HOperatorSet.GenEmptyObj(out ho_SymbolXLDs);
//LogUtil.info("GetQrCode:结束HOperatorSet.GenEmptyObj,已耗时:" + (DateTime.Now - date).ToString());
HOperatorSet.CreateDataCode2dModel(symbolType, "default_parameters", "maximum_recognition",
out hv_DataCodeHandle);
string hv_model_path = GetCodeParamFilePath(symbolType);
if (!hv_model_path.Equals(""))
{
HOperatorSet.ReadDataCode2dModel(hv_model_path, out hv_DataCodeHandle);
}
else
{
if (symbolType.Equals("Data Matrix ECC 200"))
{
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "timeout", 500);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "mirrored", "no");
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "contrast_min", 50);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "symbol_cols_min", 40);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "symbol_rows_min", 40);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "symbol_cols_max", 40);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "symbol_rows_max", 40);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "symbol_shape", "square");
}
else
{
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "timeout", 300);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "mirrored", "no");
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "model_type", 2);
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "module_gap_max", "no");
}
}
//LogUtil.info("GetQrCode:结束HOperatorSet.CreateDataCode2dModel,已耗时:" + (DateTime.Now - date).ToString());
ho_SymbolXLDs.Dispose();
LogUtil.debug("GetQrCode:结束ho_SymbolXLDs.Dispose,已耗时:" + (DateTime.Now - date).ToString());
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle, "stop_after_result_num",
3, out hv_ResultHandles, out hv_DecodedDataStrings);
LogUtil.debug("GetQrCode:结束HOperatorSet.FindDataCode2d,已耗时:" + (DateTime.Now - date).ToString());
HOperatorSet.AreaCenterXld(ho_SymbolXLDs, out hv_Area, out hv_Row1, out hv_Column,
out hv_PointOrder);
//LogUtil.info("GetQrCode:结束HOperatorSet.AreaCenterXld,已耗时:" + (DateTime.Now - date).ToString());
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
//LogUtil.info("GetQrCode:结束HOperatorSet.ClearDataCode2dModel,已耗时:" + (DateTime.Now - date).ToString());
string[] resultList = hv_DecodedDataStrings.SArr;
if (resultList.Length > 0)
{
for (int i = 0; i < hv_DecodedDataStrings.SArr.Length; i++)
{
try
{
int x = (int)Math.Round(hv_Column.DArr[i]);
int y = (int)Math.Round(hv_Row1.DArr[i]);
string str = "=" + x + "x" + y + "=" + hv_DecodedDataStrings.SArr[i];
hv_DecodedDataStrings[i] = str;
}
catch (Exception ex)
{
LogUtil.error("处理二维码出错:索引=" + i + "," + resultList.ToString());
}
}
}
LogUtil.debug("GetQrCode:结束处理二维码,已耗时:" + (DateTime.Now - date).ToString());
return resultList;
}
catch (Exception ex)
{
return new string[] { };
}
}
public static void OpenAllCamera()
{
foreach (string camera in cameraNameList)
{
OpenCamera(camera);
}
}
public static void CloseAllCamera()
{
foreach (string camera in cameraNameList)
{
CloseCamera(camera);
}
}
/// <summary>
/// 截取二维码,不需要位置
/// </summary>
public static string SubStrCode(string str)
{
string[] array = str.Split('=');
if (array.Length >= 3)
{
return array[2];
}
return "";
}
public static void OpenCamera(string cameraAddr)
{
try
{
//Local iconic variables
HTuple hv_AcqHandle = null;
if (cameraHtuple.ContainsKey(cameraAddr))
{
return;
//CloseCamera(cameraAddr);
}
// HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb",
//-1, "false", "default", "[0] Integrated Camera", 0, -1, out hv_AcqHandle);
HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1,
"default", -1, "false", "default", cameraAddr, 0,
-1, out hv_AcqHandle);
//003053242c50_Basler_acA250014gm
//HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
cameraHtuple.Add(cameraAddr, hv_AcqHandle);
// IsOpen = true;
}
catch (Exception ex)
{
LogUtil.error("打开摄像机失败:" + ex.ToString() + ",调用关闭摄像头");
CloseCamera(cameraAddr);
}
}
public static void CloseCamera(string cameraStr)
{
try
{
if (cameraHtuple.ContainsKey(cameraStr))
{
HTuple hv_AcqHandle = cameraHtuple[cameraStr];
if (hv_AcqHandle != null)
{
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
hv_AcqHandle = null;
}
cameraHtuple.Remove(cameraStr);
//IsOpen = false;
}
}
catch (Exception ex)
{
LogUtil.error("关闭摄像机失败:" + ex.ToString());
}
}
public static HObject GrabImage(string cameraStr)
{
HObject ho_Image = null;
try
{
if (cameraHtuple.ContainsKey(cameraStr))
{
HTuple hv_AcqHandle = cameraHtuple[cameraStr];
HOperatorSet.GenEmptyObj(out ho_Image);
ho_Image.Dispose();
// HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle,-1);
HOperatorSet.GrabImage(out ho_Image, hv_AcqHandle);
}
}
catch (Exception ex)
{
LogUtil.error("获取摄像机【" + cameraStr + "】的图片出错:" + ex.ToString());
}
return ho_Image;
}
public static bool IsOpen(string cameraStr)
{
return cameraHtuple.ContainsKey(cameraStr);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!