Commit 5e9aeec4 刘韬

添加条码规则编辑器条码测试功能

1 个父辈 1c7c60c0
......@@ -116,6 +116,12 @@
<Compile Include="UC\ConfigControl.designer.cs">
<DependentUpon>ConfigControl.cs</DependentUpon>
</Compile>
<Compile Include="UC\ListEditControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\ListEditControl.Designer.cs">
<DependentUpon>ListEditControl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="AboutBox1.resx">
<DependentUpon>AboutBox1.cs</DependentUpon>
</EmbeddedResource>
......@@ -148,6 +154,9 @@
<EmbeddedResource Include="UC\ConfigControl.resx">
<DependentUpon>ConfigControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\ListEditControl.resx">
<DependentUpon>ListEditControl.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
......@@ -57,8 +57,9 @@ namespace AutoScanAndLabel
//
this.configControl1.Config = null;
this.configControl1.Location = new System.Drawing.Point(568, 3);
this.configControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.configControl1.Name = "configControl1";
this.configControl1.Size = new System.Drawing.Size(651, 754);
this.configControl1.Size = new System.Drawing.Size(663, 656);
this.configControl1.TabIndex = 1;
//
// AxisControl
......
......@@ -41,6 +41,7 @@ namespace AutoScanAndLabel
this.tabPage1 = new System.Windows.Forms.TabPage();
this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.btn_leftempty = new System.Windows.Forms.Button();
this.btn_maulstart = new System.Windows.Forms.Button();
this.btn_releaserightshelf = new System.Windows.Forms.Button();
this.btn_releaseleftshelf = new System.Windows.Forms.Button();
......@@ -51,7 +52,6 @@ namespace AutoScanAndLabel
this.listView1 = new System.Windows.Forms.ListView();
this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button();
this.btn_leftempty = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
......@@ -67,7 +67,7 @@ namespace AutoScanAndLabel
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(1350, 29);
this.menuStrip1.Size = new System.Drawing.Size(1008, 29);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
......@@ -133,7 +133,7 @@ namespace AutoScanAndLabel
this.tabControl1.Location = new System.Drawing.Point(0, 90);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1350, 599);
this.tabControl1.Size = new System.Drawing.Size(1008, 599);
this.tabControl1.TabIndex = 1;
//
// tabPage1
......@@ -149,7 +149,7 @@ namespace AutoScanAndLabel
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Location = new System.Drawing.Point(4, 30);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(1342, 565);
this.tabPage1.Size = new System.Drawing.Size(1000, 565);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "信息";
this.tabPage1.UseVisualStyleBackColor = true;
......@@ -177,6 +177,16 @@ namespace AutoScanAndLabel
this.cb_EnableBuzzer.UseVisualStyleBackColor = true;
this.cb_EnableBuzzer.CheckedChanged += new System.EventHandler(this.cb_EnableBuzzer_CheckedChanged);
//
// btn_leftempty
//
this.btn_leftempty.Location = new System.Drawing.Point(653, 349);
this.btn_leftempty.Name = "btn_leftempty";
this.btn_leftempty.Size = new System.Drawing.Size(91, 85);
this.btn_leftempty.TabIndex = 4;
this.btn_leftempty.Text = "左侧\r\n手动清空";
this.btn_leftempty.UseVisualStyleBackColor = true;
this.btn_leftempty.Click += new System.EventHandler(this.btn_leftempty_Click);
//
// btn_maulstart
//
this.btn_maulstart.Location = new System.Drawing.Point(763, 349);
......@@ -264,7 +274,7 @@ namespace AutoScanAndLabel
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(939, 118);
this.listView1.Size = new System.Drawing.Size(597, 118);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
//
......@@ -290,22 +300,12 @@ namespace AutoScanAndLabel
this.btn_run.UseVisualStyleBackColor = true;
this.btn_run.Click += new System.EventHandler(this.btn_run_Click);
//
// btn_leftempty
//
this.btn_leftempty.Location = new System.Drawing.Point(653, 349);
this.btn_leftempty.Name = "btn_leftempty";
this.btn_leftempty.Size = new System.Drawing.Size(91, 85);
this.btn_leftempty.TabIndex = 4;
this.btn_leftempty.Text = "左侧\r\n手动清空";
this.btn_leftempty.UseVisualStyleBackColor = true;
this.btn_leftempty.Click += new System.EventHandler(this.btn_leftempty_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1350, 689);
this.ClientSize = new System.Drawing.Size(1008, 689);
this.Controls.Add(this.btn_stop);
this.Controls.Add(this.btn_run);
this.Controls.Add(this.listView1);
......
......@@ -22,17 +22,18 @@ namespace AutoScanAndLabel
DeviceLibrary.LabelParam labelParam = new DeviceLibrary.LabelParam();
labelParam.codeInfos = new List<CodeLibrary.CodeInfo>();
//##340093060037##01410000441770##012100000224##Q3000
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("SMA5J16A-E3/61-GREE;SMA5J16A-E3/61;2108;1800;CHINA;MA703552.3", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("[)>P1PTLV7022DGKR6P2PAQ25000V00333171T0557736ZEW4WTKYD210631T1032393ASH20LRFB21LUSA22LASH23LCHNEG43Z1/260C/UNLIM;//;022121L18087KN01", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Y38072732TLP785(D4GHTR6,F (C 2000A0132G0 2000ZUY0HG1U8501F2A Y0HG1U 2124 2124TWCN 69 T2", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("[)>P1PTLV7022DGKR6P2PAQ25000V00333171T0557736ZEW4WTKYD210631T1032393ASH20LRFB21LUSA22LASH23LCHNEG43Z1/260C/UNLIM;//;022121L18087KN01", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("99700736000619EM6H38.125008625", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Y38073304TLP385(D4GREETRE (T 00003000A0149T 03000WT0HBGCC8210B3F-5595 2009 2009JPTH 00 67 91432487 02Q", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("01410000441770", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("012100000224", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Q3000", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("CK7T0H.125002115", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Y38073304TLP385(D4GREETRE (T 00003000A0149T 03000WT0HBGCC8210B3F-5595 2009 2009JPTH 00 67 91432487 02Q", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("01410000441770", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("012100000224", 0, 0));
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Q3000", 0, 0));
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("340093060037", 0, 0, "Code 128"));
DeviceLibrary.Common.codeProcess(labelParam);
DeviceLibrary.Common.codeProcess(labelParam, out string debugmsg);
Console.WriteLine(debugmsg);
_ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret)
{
......
......@@ -37,7 +37,18 @@ namespace AutoScanAndLabel
this.cb_printerselect = new System.Windows.Forms.ComboBox();
this.chbAutoRun = new System.Windows.Forms.CheckBox();
this.btn_labelDebug = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.txt_code = new System.Windows.Forms.TextBox();
this.btn_codetest = new System.Windows.Forms.Button();
this.label_matchdebugstring = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.listEditControl1 = new AutoScanAndLabel.UC.ListEditControl();
this.listEdit_pn = new AutoScanAndLabel.UC.ListEditControl();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
......@@ -59,7 +70,7 @@ namespace AutoScanAndLabel
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(19, 78);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.Size = new System.Drawing.Size(52, 15);
this.label2.TabIndex = 2;
this.label2.Text = "标签名";
//
......@@ -68,7 +79,7 @@ namespace AutoScanAndLabel
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(19, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.Size = new System.Drawing.Size(52, 15);
this.label1.TabIndex = 2;
this.label1.Text = "打印机";
//
......@@ -87,7 +98,7 @@ namespace AutoScanAndLabel
this.cb_labelselect.FormattingEnabled = true;
this.cb_labelselect.Location = new System.Drawing.Point(88, 75);
this.cb_labelselect.Name = "cb_labelselect";
this.cb_labelselect.Size = new System.Drawing.Size(198, 20);
this.cb_labelselect.Size = new System.Drawing.Size(198, 23);
this.cb_labelselect.TabIndex = 0;
this.cb_labelselect.SelectedIndexChanged += new System.EventHandler(this.cb_labelselect_SelectedIndexChanged);
//
......@@ -96,23 +107,23 @@ namespace AutoScanAndLabel
this.cb_printerselect.FormattingEnabled = true;
this.cb_printerselect.Location = new System.Drawing.Point(88, 37);
this.cb_printerselect.Name = "cb_printerselect";
this.cb_printerselect.Size = new System.Drawing.Size(198, 20);
this.cb_printerselect.Size = new System.Drawing.Size(198, 23);
this.cb_printerselect.TabIndex = 0;
this.cb_printerselect.SelectedIndexChanged += new System.EventHandler(this.cb_printerselect_SelectedIndexChanged);
//
// chbAutoRun
//
this.chbAutoRun.AutoSize = true;
this.chbAutoRun.Location = new System.Drawing.Point(3, 192);
this.chbAutoRun.Location = new System.Drawing.Point(3, 185);
this.chbAutoRun.Name = "chbAutoRun";
this.chbAutoRun.Size = new System.Drawing.Size(84, 16);
this.chbAutoRun.Size = new System.Drawing.Size(101, 19);
this.chbAutoRun.TabIndex = 1;
this.chbAutoRun.Text = "开机自启动";
this.chbAutoRun.UseVisualStyleBackColor = true;
//
// btn_labelDebug
//
this.btn_labelDebug.Location = new System.Drawing.Point(182, 192);
this.btn_labelDebug.Location = new System.Drawing.Point(182, 178);
this.btn_labelDebug.Name = "btn_labelDebug";
this.btn_labelDebug.Size = new System.Drawing.Size(140, 28);
this.btn_labelDebug.TabIndex = 2;
......@@ -121,17 +132,104 @@ namespace AutoScanAndLabel
this.btn_labelDebug.Visible = false;
this.btn_labelDebug.Click += new System.EventHandler(this.btn_labelDebug_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.listEdit_pn);
this.groupBox2.Location = new System.Drawing.Point(350, 0);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(360, 178);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "PN匹配规则";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.listEditControl1);
this.groupBox3.Location = new System.Drawing.Point(350, 185);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(360, 228);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "QTY匹配规则";
//
// txt_code
//
this.txt_code.Location = new System.Drawing.Point(6, 24);
this.txt_code.Name = "txt_code";
this.txt_code.Size = new System.Drawing.Size(264, 25);
this.txt_code.TabIndex = 5;
//
// btn_codetest
//
this.btn_codetest.Location = new System.Drawing.Point(276, 22);
this.btn_codetest.Name = "btn_codetest";
this.btn_codetest.Size = new System.Drawing.Size(75, 30);
this.btn_codetest.TabIndex = 6;
this.btn_codetest.Text = "匹配";
this.btn_codetest.UseVisualStyleBackColor = true;
this.btn_codetest.Click += new System.EventHandler(this.btn_codetest_Click);
//
// label_matchdebugstring
//
this.label_matchdebugstring.Location = new System.Drawing.Point(6, 54);
this.label_matchdebugstring.Name = "label_matchdebugstring";
this.label_matchdebugstring.Size = new System.Drawing.Size(345, 124);
this.label_matchdebugstring.TabIndex = 7;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.txt_code);
this.groupBox4.Controls.Add(this.label_matchdebugstring);
this.groupBox4.Controls.Add(this.btn_codetest);
this.groupBox4.Location = new System.Drawing.Point(353, 419);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(357, 191);
this.groupBox4.TabIndex = 8;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "条码匹配测试";
//
// listEditControl1
//
this.listEditControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listEditControl1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listEditControl1.ListFile = "config/qty.list";
this.listEditControl1.Location = new System.Drawing.Point(3, 21);
this.listEditControl1.Margin = new System.Windows.Forms.Padding(5);
this.listEditControl1.Name = "listEditControl1";
this.listEditControl1.Size = new System.Drawing.Size(354, 204);
this.listEditControl1.TabIndex = 3;
this.listEditControl1.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh);
//
// listEdit_pn
//
this.listEdit_pn.Dock = System.Windows.Forms.DockStyle.Fill;
this.listEdit_pn.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listEdit_pn.ListFile = "config/pn.list";
this.listEdit_pn.Location = new System.Drawing.Point(3, 21);
this.listEdit_pn.Margin = new System.Windows.Forms.Padding(5);
this.listEdit_pn.Name = "listEdit_pn";
this.listEdit_pn.Size = new System.Drawing.Size(354, 154);
this.listEdit_pn.TabIndex = 3;
this.listEdit_pn.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh);
//
// SettingControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.btn_labelDebug);
this.Controls.Add(this.chbAutoRun);
this.Controls.Add(this.groupBox1);
this.Name = "SettingControl";
this.Size = new System.Drawing.Size(984, 497);
this.Size = new System.Drawing.Size(1024, 740);
this.Load += new System.EventHandler(this.SettingControl_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -147,5 +245,13 @@ namespace AutoScanAndLabel
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox chbAutoRun;
private System.Windows.Forms.Button btn_labelDebug;
private UC.ListEditControl listEdit_pn;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private UC.ListEditControl listEditControl1;
private System.Windows.Forms.TextBox txt_code;
private System.Windows.Forms.Button btn_codetest;
private System.Windows.Forms.Label label_matchdebugstring;
private System.Windows.Forms.GroupBox groupBox4;
}
}
......@@ -141,5 +141,19 @@ namespace AutoScanAndLabel
p1.Y = (int)(p1.Y * RobotManage.Config.Cam_Pixel_Y_Ratio) + RobotManage.Config.Label_Y_Base;
}
private void listEdit_pn_DataRefresh(object sender, EventArgs e)
{
Common.LoadMatchList();
}
private void btn_codetest_Click(object sender, EventArgs e)
{
DeviceLibrary.LabelParam labelParam = new DeviceLibrary.LabelParam();
labelParam.codeInfos = new List<CodeLibrary.CodeInfo>();
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo(txt_code.Text, 0, 0));
Common.codeProcess(labelParam, out string debugstring);
label_matchdebugstring.Text = debugstring;
}
}
}

namespace AutoScanAndLabel.UC
{
partial class ListEditControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.btn_add = new System.Windows.Forms.Button();
this.btn_del = new System.Windows.Forms.Button();
this.btn_cel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(0, 36);
this.listBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(229, 180);
this.listBox1.TabIndex = 0;
this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(0, 4);
this.textBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(229, 26);
this.textBox1.TabIndex = 1;
//
// btn_add
//
this.btn_add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_add.Location = new System.Drawing.Point(239, 0);
this.btn_add.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btn_add.Name = "btn_add";
this.btn_add.Size = new System.Drawing.Size(100, 31);
this.btn_add.TabIndex = 2;
this.btn_add.Text = "添加/编辑";
this.btn_add.UseVisualStyleBackColor = true;
this.btn_add.Click += new System.EventHandler(this.btn_add_Click);
//
// btn_del
//
this.btn_del.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btn_del.Location = new System.Drawing.Point(239, 185);
this.btn_del.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btn_del.Name = "btn_del";
this.btn_del.Size = new System.Drawing.Size(100, 31);
this.btn_del.TabIndex = 2;
this.btn_del.Text = "删除";
this.btn_del.UseVisualStyleBackColor = true;
this.btn_del.Click += new System.EventHandler(this.btn_del_Click);
//
// btn_cel
//
this.btn_cel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_cel.Location = new System.Drawing.Point(239, 36);
this.btn_cel.Margin = new System.Windows.Forms.Padding(4);
this.btn_cel.Name = "btn_cel";
this.btn_cel.Size = new System.Drawing.Size(100, 31);
this.btn_cel.TabIndex = 2;
this.btn_cel.Text = "取消";
this.btn_cel.UseVisualStyleBackColor = true;
this.btn_cel.Click += new System.EventHandler(this.btn_cel_Click);
//
// ListEditControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btn_del);
this.Controls.Add(this.btn_cel);
this.Controls.Add(this.btn_add);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.listBox1);
this.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "ListEditControl";
this.Size = new System.Drawing.Size(339, 219);
this.Load += new System.EventHandler(this.ListEditControl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btn_add;
private System.Windows.Forms.Button btn_del;
private System.Windows.Forms.Button btn_cel;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoScanAndLabel.UC
{
[DefaultEvent("DataRefresh")]
public partial class ListEditControl : UserControl
{
public ListEditControl()
{
InitializeComponent();
}
[Category("数据"), Description("数据变更保存后触发"), Browsable(true)]
public event EventHandler DataRefresh;
List<string> stringlist = new List<string>();
[Category("数据"), Description("配置文件名"), Browsable(true)]
public string ListFile { get => listfile; set => listfile = value; }
string listfile = "";
private void btn_add_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(textBox1.Text))
return;
if (Editindex>-1)
listBox1.Items[Editindex] = textBox1.Text;
else
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
Editindex = -1;
savelist();
}
int editindex = -1;
int Editindex
{
get => editindex; set
{
editindex = value;
if (editindex < 0)
{
btn_add.Text = "添加";
btn_cel.Visible = false;
}
else {
btn_add.Text = "修改";
btn_cel.Visible = true;
}
}
}
private void btn_del_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex < 0)
return;
var rl=MessageBox.Show($"确定要删除:\"{listBox1.SelectedItem}\"?", "警告", MessageBoxButtons.YesNo);
if (rl != DialogResult.Yes)
return;
if (listBox1.SelectedIndex == editindex)
{
Editindex = -1;
textBox1.Text = "";
}
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
savelist();
}
void savelist()
{
File.WriteAllLines(listfile, listBox1.Items.OfType<string>().ToArray());
DataRefresh?.Invoke(listfile, EventArgs.Empty);
}
private void ListEditControl_Load(object sender, EventArgs e)
{
if (!File.Exists(listfile))
return;
stringlist.AddRange(File.ReadAllLines(listfile).ToList().FindAll((s)=> { return !string.IsNullOrWhiteSpace(s); }).ToArray());
listBox1.Items.AddRange(stringlist.ToArray());
Editindex = -1;
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
if (Editindex >= 0 && listBox1.SelectedIndex < 0)
{
textBox1.Text = "";
return;
}
Editindex = listBox1.SelectedIndex;
textBox1.Text = listBox1.SelectedItem.ToString();
}
private void btn_cel_Click(object sender, EventArgs e)
{
Editindex = -1;
textBox1.Text = "";
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -208,17 +208,27 @@ namespace DeviceLibrary
return p3;
}
static IdWorker id = new IdWorker(1, 1);
public static bool codeProcess(LabelParam labelParam) {
static string[] pnreglist;
static string[] qtyreglist;
public static void LoadMatchList() {
pnreglist = File.ReadAllLines("config\\pn.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
qtyreglist = File.ReadAllLines("config\\qty.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
}
public static bool codeProcess(LabelParam labelParam,out string debugmsg) {
if (pnreglist == null)
LoadMatchList();
debugmsg = "";
List<CodeInfo> newcodeInfos = new List<CodeInfo>();
labelParam.PN = "";
foreach (var ci in labelParam.codeInfos.ToArray())
{
string[] qtyreglist = new string[] {
@"^P([1-9]\d+)$",
@"^(\d+)$%Code 128",
@"^([1-9]\d{7,9})$"
};
foreach (var qtyreg in qtyreglist)
//string[] pnreglist = new string[] {
// @"^P([1-9]\d+)$",
// @"^(\d+)$%Code 128",
// @"^([1-9]\d{7,9})$"
//};
foreach (var qtyreg in pnreglist)
{
var partrules = qtyreg.Split('%');
if (partrules.Length == 2) {
......@@ -231,26 +241,27 @@ namespace DeviceLibrary
newcodeInfos.Add(ci);
//labelParam.codeInfos.Remove(ci);
labelParam.PN = m.Groups[1].Value;
debugmsg += $"匹配到PN:{labelParam.PN}\r\n命中规则:{qtyreg}\r\n";
break;
}
}
if (!string.IsNullOrEmpty(labelParam.PN))
break;
}
if (string.IsNullOrEmpty(labelParam.PN))
return false;
labelParam.QTY = 0;
foreach (var ci in labelParam.codeInfos.ToArray())
{
string[] qtyreglist = new string[] {
@"Q(\d{3,5})[^\d]",
@"^Q(\d{3,5})$",
@"\d+"+labelParam.PN+@"[\d\w]+\.\d([1-9]+0+)[1-9]+\d*$",
@"^.+?;.+?;.+?;(\d{3,5}?);.+?;.+?$",
@"^QUANTITY:(\d*)",
@"^(\d{6})\s",
@"\(T\s+(\d{8})\w",
};
//string[] qtyreglist = new string[] {
// @"Q(\d{3,5})[^\d]",
// @"^Q(\d{3,5})$",
// @"^\w+\.\d([1-9]+0+)[1-9]+\d*$",
// @"^.+?;.+?;.+?;(\d{3,5}?);.+?;.+?$",
// @"^QUANTITY:(\d*)",
// @"^(\d{6})\s",
// @"\(\w*\s+(\d+)[a-zA-Z]",
//};
foreach (var qtyreg in qtyreglist)
{
var m = Regex.Match(ci.CodeStr, qtyreg);
......@@ -259,15 +270,16 @@ namespace DeviceLibrary
newcodeInfos.Add(ci);
//labelParam.codeInfos.Remove(ci);
labelParam.QTY = int.Parse(m.Groups[1].Value);
debugmsg += $"匹配到QTY:{labelParam.QTY}\r\n命中规则:{qtyreg}\r\n";
break;
}
}
if (labelParam.QTY > 0)
break;
}
if (labelParam.QTY == 0)
if (string.IsNullOrEmpty(labelParam.PN) || labelParam.QTY == 0)
return false;
// labelParam.QTY=3000;
//labelParam.codeInfos = newcodeInfos;
labelParam.FC = "985022";
......
......@@ -95,9 +95,9 @@ namespace DeviceLibrary
RightMoveInfo.MoveParam.IsNg = false;
RightMoveInfo.MoveParam.codeInfos = x;
RightMoveInfo.MoveParam.bitmapfilename = s;
if (!Common.codeProcess(RightMoveInfo.MoveParam))
if (!Common.codeProcess(RightMoveInfo.MoveParam,out string debugmsg))
{
RightMoveInfo.log($"未识别到有效码,转入NG箱");
RightMoveInfo.log($"未识别到有效码,转入NG箱"+ debugmsg);
RightMoveInfo.log(JsonHelper.SerializeObject(x));
RightMoveInfo.MoveParam.IsNg = true;
}else
......@@ -268,7 +268,7 @@ namespace DeviceLibrary
LabelParam labelParam = new LabelParam();
labelParam.codeInfos = new List<CodeInfo>(LastCodeList);
if (!Common.codeProcess(labelParam))
if (!Common.codeProcess(labelParam, out _))
{
Task.Delay(500).Wait();
(LastCodeList2, filename) = CodeManager.CameraScan(new List<string> { Config.RightCameraName });
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!