diff --git a/WindowsFormsApp1/MES_PLC_Control.csproj b/WindowsFormsApp1/MES_PLC_Control.csproj index 2ccf3c2..1b2463a 100644 --- a/WindowsFormsApp1/MES_PLC_Control.csproj +++ b/WindowsFormsApp1/MES_PLC_Control.csproj @@ -111,6 +111,9 @@ + + + @@ -122,6 +125,7 @@ USER_Manage.cs + diff --git a/WindowsFormsApp1/MainForm.Designer.cs b/WindowsFormsApp1/MainForm.Designer.cs index 9982c3f..e384b47 100644 --- a/WindowsFormsApp1/MainForm.Designer.cs +++ b/WindowsFormsApp1/MainForm.Designer.cs @@ -59,8 +59,8 @@ this.groupBox3 = new System.Windows.Forms.GroupBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.操作页面 = new System.Windows.Forms.GroupBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); this.menuStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -73,6 +73,7 @@ // menuStrip1 // this.menuStrip1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.用户管理ToolStripMenuItem, @@ -84,7 +85,8 @@ this.系统参数配置ToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(2739, 39); + this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(2884, 44); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -95,34 +97,34 @@ this.切换用户ToolStripMenuItem, this.用户管理ToolStripMenuItem1}); this.用户管理ToolStripMenuItem.Name = "用户管理ToolStripMenuItem"; - this.用户管理ToolStripMenuItem.Size = new System.Drawing.Size(126, 35); + this.用户管理ToolStripMenuItem.Size = new System.Drawing.Size(145, 40); this.用户管理ToolStripMenuItem.Text = "用户管理"; // // 修改密码ToolStripMenuItem // this.修改密码ToolStripMenuItem.Name = "修改密码ToolStripMenuItem"; - this.修改密码ToolStripMenuItem.Size = new System.Drawing.Size(214, 40); + this.修改密码ToolStripMenuItem.Size = new System.Drawing.Size(247, 44); this.修改密码ToolStripMenuItem.Text = "修改密码"; this.修改密码ToolStripMenuItem.Click += new System.EventHandler(this.修改密码ToolStripMenuItem_Click); // // 切换用户ToolStripMenuItem // this.切换用户ToolStripMenuItem.Name = "切换用户ToolStripMenuItem"; - this.切换用户ToolStripMenuItem.Size = new System.Drawing.Size(214, 40); + this.切换用户ToolStripMenuItem.Size = new System.Drawing.Size(247, 44); this.切换用户ToolStripMenuItem.Text = "切换用户"; this.切换用户ToolStripMenuItem.Click += new System.EventHandler(this.切换用户ToolStripMenuItem_Click); // // 用户管理ToolStripMenuItem1 // this.用户管理ToolStripMenuItem1.Name = "用户管理ToolStripMenuItem1"; - this.用户管理ToolStripMenuItem1.Size = new System.Drawing.Size(214, 40); + this.用户管理ToolStripMenuItem1.Size = new System.Drawing.Size(247, 44); this.用户管理ToolStripMenuItem1.Text = "用户管理"; this.用户管理ToolStripMenuItem1.Click += new System.EventHandler(this.用户管理ToolStripMenuItem1_Click); // // 产线管理ToolStripMenuItem // this.产线管理ToolStripMenuItem.Name = "产线管理ToolStripMenuItem"; - this.产线管理ToolStripMenuItem.Size = new System.Drawing.Size(126, 35); + this.产线管理ToolStripMenuItem.Size = new System.Drawing.Size(145, 40); this.产线管理ToolStripMenuItem.Text = "产线管理"; this.产线管理ToolStripMenuItem.Click += new System.EventHandler(this.产线管理ToolStripMenuItem_Click); // @@ -132,34 +134,34 @@ this.pLC通讯设置ToolStripMenuItem, this.pLC地址设置ToolStripMenuItem}); this.pLC管理ToolStripMenuItem.Name = "pLC管理ToolStripMenuItem"; - this.pLC管理ToolStripMenuItem.Size = new System.Drawing.Size(121, 35); + this.pLC管理ToolStripMenuItem.Size = new System.Drawing.Size(139, 40); this.pLC管理ToolStripMenuItem.Text = "PLC管理"; // // pLC通讯设置ToolStripMenuItem // this.pLC通讯设置ToolStripMenuItem.Name = "pLC通讯设置ToolStripMenuItem"; - this.pLC通讯设置ToolStripMenuItem.Size = new System.Drawing.Size(257, 40); + this.pLC通讯设置ToolStripMenuItem.Size = new System.Drawing.Size(297, 44); this.pLC通讯设置ToolStripMenuItem.Text = "PLC通讯设置"; this.pLC通讯设置ToolStripMenuItem.Click += new System.EventHandler(this.pLC通讯设置ToolStripMenuItem_Click); // // pLC地址设置ToolStripMenuItem // this.pLC地址设置ToolStripMenuItem.Name = "pLC地址设置ToolStripMenuItem"; - this.pLC地址设置ToolStripMenuItem.Size = new System.Drawing.Size(257, 40); + this.pLC地址设置ToolStripMenuItem.Size = new System.Drawing.Size(297, 44); this.pLC地址设置ToolStripMenuItem.Text = "PLC地址设置"; this.pLC地址设置ToolStripMenuItem.Click += new System.EventHandler(this.pLC地址设置ToolStripMenuItem_Click); // // 流程管理ToolStripMenuItem // this.流程管理ToolStripMenuItem.Name = "流程管理ToolStripMenuItem"; - this.流程管理ToolStripMenuItem.Size = new System.Drawing.Size(126, 35); + this.流程管理ToolStripMenuItem.Size = new System.Drawing.Size(145, 40); this.流程管理ToolStripMenuItem.Text = "流程管理"; this.流程管理ToolStripMenuItem.Click += new System.EventHandler(this.流程管理ToolStripMenuItem_Click); // // mES接口配置ToolStripMenuItem // this.mES接口配置ToolStripMenuItem.Name = "mES接口配置ToolStripMenuItem"; - this.mES接口配置ToolStripMenuItem.Size = new System.Drawing.Size(176, 35); + this.mES接口配置ToolStripMenuItem.Size = new System.Drawing.Size(203, 40); this.mES接口配置ToolStripMenuItem.Text = "MES接口配置"; this.mES接口配置ToolStripMenuItem.Click += new System.EventHandler(this.mES接口配置ToolStripMenuItem_Click); // @@ -169,25 +171,25 @@ this.扫码枪配置ToolStripMenuItem1, this.扭力曲线配置ToolStripMenuItem}); this.扫码枪配置ToolStripMenuItem.Name = "扫码枪配置ToolStripMenuItem"; - this.扫码枪配置ToolStripMenuItem.Size = new System.Drawing.Size(174, 35); + this.扫码枪配置ToolStripMenuItem.Size = new System.Drawing.Size(201, 40); this.扫码枪配置ToolStripMenuItem.Text = "外围设备配置"; // // 扫码枪配置ToolStripMenuItem1 // this.扫码枪配置ToolStripMenuItem1.Name = "扫码枪配置ToolStripMenuItem1"; - this.扫码枪配置ToolStripMenuItem1.Size = new System.Drawing.Size(262, 40); + this.扫码枪配置ToolStripMenuItem1.Size = new System.Drawing.Size(303, 44); this.扫码枪配置ToolStripMenuItem1.Text = "扫码枪配置"; // // 扭力曲线配置ToolStripMenuItem // this.扭力曲线配置ToolStripMenuItem.Name = "扭力曲线配置ToolStripMenuItem"; - this.扭力曲线配置ToolStripMenuItem.Size = new System.Drawing.Size(262, 40); + this.扭力曲线配置ToolStripMenuItem.Size = new System.Drawing.Size(303, 44); this.扭力曲线配置ToolStripMenuItem.Text = "扭力曲线配置"; // // 系统参数配置ToolStripMenuItem // this.系统参数配置ToolStripMenuItem.Name = "系统参数配置ToolStripMenuItem"; - this.系统参数配置ToolStripMenuItem.Size = new System.Drawing.Size(174, 35); + this.系统参数配置ToolStripMenuItem.Size = new System.Drawing.Size(201, 40); this.系统参数配置ToolStripMenuItem.Text = "系统参数配置"; // // tableLayoutPanel1 @@ -200,14 +202,14 @@ this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox3, 0, 2); this.tableLayoutPanel1.Controls.Add(this.操作页面, 0, 1); - this.tableLayoutPanel1.Location = new System.Drawing.Point(18, 45); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tableLayoutPanel1.Location = new System.Drawing.Point(22, 52); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 3; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 42.85714F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 42.85714F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(2703, 1494); + this.tableLayoutPanel1.Size = new System.Drawing.Size(3304, 1743); this.tableLayoutPanel1.TabIndex = 6; // // groupBox1 @@ -217,9 +219,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.tableLayoutPanel3); this.groupBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.groupBox1.Location = new System.Drawing.Point(3, 3); + this.groupBox1.Location = new System.Drawing.Point(4, 4); + this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(2697, 207); + this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox1.Size = new System.Drawing.Size(3296, 240); this.groupBox1.TabIndex = 4; this.groupBox1.TabStop = false; this.groupBox1.Text = "处理界面"; @@ -236,14 +240,14 @@ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel2, 3, 0); this.tableLayoutPanel3.Controls.Add(this.开始处理, 1, 1); - this.tableLayoutPanel3.Location = new System.Drawing.Point(15, 36); - this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tableLayoutPanel3.Location = new System.Drawing.Point(18, 42); + this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.RowCount = 3; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(2674, 162); + this.tableLayoutPanel3.Size = new System.Drawing.Size(3268, 188); this.tableLayoutPanel3.TabIndex = 4; // // tableLayoutPanel2 @@ -258,9 +262,9 @@ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 37F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 37F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 37F)); this.tableLayoutPanel2.Controls.Add(this.label4, 3, 0); this.tableLayoutPanel2.Controls.Add(this.label3, 2, 0); this.tableLayoutPanel2.Controls.Add(this.label2, 1, 0); @@ -269,14 +273,14 @@ this.tableLayoutPanel2.Controls.Add(this.label6, 1, 1); this.tableLayoutPanel2.Controls.Add(this.label7, 2, 1); this.tableLayoutPanel2.Controls.Add(this.label8, 3, 1); - this.tableLayoutPanel2.Location = new System.Drawing.Point(269, 4); - this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tableLayoutPanel2.Location = new System.Drawing.Point(330, 5); + this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 2; this.tableLayoutPanel3.SetRowSpan(this.tableLayoutPanel2, 3); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(2401, 154); + this.tableLayoutPanel2.Size = new System.Drawing.Size(2933, 178); this.tableLayoutPanel2.TabIndex = 3; // // label4 @@ -284,10 +288,10 @@ this.label4.AutoSize = true; this.label4.Dock = System.Windows.Forms.DockStyle.Fill; this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(1445, 1); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(1764, 1); + this.label4.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(471, 75); + this.label4.Size = new System.Drawing.Size(575, 87); this.label4.TabIndex = 6; this.label4.Text = "label4"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -297,10 +301,10 @@ this.label3.AutoSize = true; this.label3.Dock = System.Windows.Forms.DockStyle.Fill; this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(965, 1); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(1178, 1); + this.label3.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(471, 75); + this.label3.Size = new System.Drawing.Size(575, 87); this.label3.TabIndex = 5; this.label3.Text = "label3"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -310,10 +314,10 @@ this.label2.AutoSize = true; this.label2.Dock = System.Windows.Forms.DockStyle.Fill; this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(485, 1); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(592, 1); + this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(471, 75); + this.label2.Size = new System.Drawing.Size(575, 87); this.label2.TabIndex = 4; this.label2.Text = "label2"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -323,10 +327,10 @@ this.label1.AutoSize = true; this.label1.Dock = System.Windows.Forms.DockStyle.Fill; this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label1.Location = new System.Drawing.Point(5, 1); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(6, 1); + this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(471, 75); + this.label1.Size = new System.Drawing.Size(575, 87); this.label1.TabIndex = 3; this.label1.Text = "label1"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -336,10 +340,10 @@ this.label5.AutoSize = true; this.label5.Dock = System.Windows.Forms.DockStyle.Fill; this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label5.Location = new System.Drawing.Point(5, 77); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Location = new System.Drawing.Point(6, 89); + this.label5.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(471, 76); + this.label5.Size = new System.Drawing.Size(575, 88); this.label5.TabIndex = 7; this.label5.Text = "label5"; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -349,10 +353,10 @@ this.label6.AutoSize = true; this.label6.Dock = System.Windows.Forms.DockStyle.Fill; this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label6.Location = new System.Drawing.Point(485, 77); - this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Location = new System.Drawing.Point(592, 89); + this.label6.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(471, 76); + this.label6.Size = new System.Drawing.Size(575, 88); this.label6.TabIndex = 8; this.label6.Text = "label6"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -362,10 +366,10 @@ this.label7.AutoSize = true; this.label7.Dock = System.Windows.Forms.DockStyle.Fill; this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label7.Location = new System.Drawing.Point(965, 77); - this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label7.Location = new System.Drawing.Point(1178, 89); + this.label7.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(471, 76); + this.label7.Size = new System.Drawing.Size(575, 88); this.label7.TabIndex = 9; this.label7.Text = "label7"; this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -375,10 +379,10 @@ this.label8.AutoSize = true; this.label8.Dock = System.Windows.Forms.DockStyle.Fill; this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label8.Location = new System.Drawing.Point(1445, 77); - this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label8.Location = new System.Drawing.Point(1764, 89); + this.label8.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(471, 76); + this.label8.Size = new System.Drawing.Size(575, 88); this.label8.TabIndex = 10; this.label8.Text = "label8"; this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -388,9 +392,10 @@ this.开始处理.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.开始处理.Dock = System.Windows.Forms.DockStyle.Fill; this.开始处理.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.开始处理.Location = new System.Drawing.Point(29, 19); + this.开始处理.Location = new System.Drawing.Point(36, 22); + this.开始处理.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.开始处理.Name = "开始处理"; - this.开始处理.Size = new System.Drawing.Size(207, 123); + this.开始处理.Size = new System.Drawing.Size(253, 142); this.开始处理.TabIndex = 1; this.开始处理.Text = "开始处理"; this.开始处理.UseVisualStyleBackColor = false; @@ -403,9 +408,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox3.Controls.Add(this.richTextBox1); this.groupBox3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.groupBox3.Location = new System.Drawing.Point(3, 856); + this.groupBox3.Location = new System.Drawing.Point(4, 999); + this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(2697, 635); + this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox3.Size = new System.Drawing.Size(3296, 740); this.groupBox3.TabIndex = 6; this.groupBox3.TabStop = false; this.groupBox3.Text = "日志页面"; @@ -416,10 +423,10 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.richTextBox1.Location = new System.Drawing.Point(15, 36); - this.richTextBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.richTextBox1.Location = new System.Drawing.Point(18, 42); + this.richTextBox1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.Size = new System.Drawing.Size(2672, 589); + this.richTextBox1.Size = new System.Drawing.Size(3265, 685); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; // @@ -431,39 +438,44 @@ this.操作页面.Controls.Add(this.label9); this.操作页面.Controls.Add(this.textBox1); this.操作页面.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.操作页面.Location = new System.Drawing.Point(3, 216); + this.操作页面.Location = new System.Drawing.Point(4, 252); + this.操作页面.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.操作页面.Name = "操作页面"; - this.操作页面.Size = new System.Drawing.Size(2697, 634); + this.操作页面.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.操作页面.Size = new System.Drawing.Size(3296, 739); this.操作页面.TabIndex = 5; this.操作页面.TabStop = false; this.操作页面.Text = "操作页面"; // - // textBox1 - // - this.textBox1.Font = new System.Drawing.Font("宋体", 26F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.textBox1.Location = new System.Drawing.Point(44, 160); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(1002, 67); - this.textBox1.TabIndex = 0; - // // label9 // this.label9.AutoSize = true; this.label9.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(36, 75); + this.label9.Location = new System.Drawing.Point(44, 64); + this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(356, 48); + this.label9.Size = new System.Drawing.Size(416, 56); this.label9.TabIndex = 1; this.label9.Text = "请扫描二维码:"; // + // textBox1 + // + this.textBox1.Font = new System.Drawing.Font("宋体", 26F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textBox1.Location = new System.Drawing.Point(54, 383); + this.textBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(1224, 77); + this.textBox1.TabIndex = 0; + // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(2739, 1557); + this.ClientSize = new System.Drawing.Size(2884, 1764); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.tableLayoutPanel1); this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; diff --git a/WindowsFormsApp1/MainForm.cs b/WindowsFormsApp1/MainForm.cs index 28a8cf0..46860e5 100644 --- a/WindowsFormsApp1/MainForm.cs +++ b/WindowsFormsApp1/MainForm.cs @@ -17,6 +17,7 @@ using HslCommunication.LogNet; using WindowsFormsApp1.db; using WindowsFormsApp1.form; using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.server; using WindowsFormsApp1.server; using static SQLite.SQLite3; @@ -67,9 +68,6 @@ namespace WindowsFormsApp1 SiemensHelp siemensHelp = Plc.plchelp; - var readlist = Init.t_Plcaddresses.FindAll(a=>a.plcid == Plc.id && a.type == "read"); - var writelist = Init.t_Plcaddresses.FindAll(a => a.plcid == Plc.id && a.type == "write"); - var openresult = siemensHelp.OpenConn(); if (!openresult.Success) { @@ -77,113 +75,92 @@ namespace WindowsFormsApp1 //LogExecute.logNet.WriteError($"{Plc.plcip}建立S7连接失败"); continue; } - var resdresult = siemensHelp.ReadAddress(readlist); + + List plcaddress = Init.t_Plcaddresses.FindAll(a => a.plcid == Plc.id); + plcdata PlcData = new plcdata(); + + var resdresult = siemensHelp.ReadAddress(plcaddress, PlcData); if (!resdresult.Success) { - label8.Text = $"PLC:{Plc.id}:{Plc.plcip}读取地址处理错误"; - //LogExecute.logNet.WriteError($"{Plc.plcip}读取地址处理错误:处理停止"); + label8.Text = $"PLC:{Plc.id}:{Plc.plcip}读取全部地址处理错误"; + LogExecute.logNet.WriteError($"{Plc.plcip}读取全部地址处理错误:处理停止"); continue; } //写入心跳 - var heartaddress = writelist.FirstOrDefault(a=>a.remark == "心跳"); - var haert = int.Parse(heartaddress.value); - if (haert == 0) - { - haert = 1; - } - else - { - haert = 0; - } - heartaddress.value = haert.ToString(); - var haertresult = siemensHelp.WriteHaert(writelist); + PlcData.Write_Heartbeat = PlcData.Write_Heartbeat == 0 ? (short)1 : (short)0; + var haertresult = siemensHelp.WriteAddress(plcaddress, PlcData); if (!haertresult.Success) { label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入心跳错误"; - //LogExecute.logNet.WriteError($"{Plc.plcip}读取地址处理错误:处理停止"); + LogExecute.logNet.WriteError($"{Plc.plcip}写入心跳错误:处理停止"); continue; } Plc.dateTime = DateTime.Now; - //判断触发字 - var status = readlist.FirstOrDefault(a=>a.remark == "触发字"); - if (status == null) - { - label8.Text = $"PLC:{Plc.id}:未找到触发字对应的字段"; - //LogExecute.logNet.WriteError($"未找到触发字对应的字段!"); - continue; - } - var nowstatus = int.Parse(status.value); + label8.Text = Plc.dateTime.ToString(); - - //测试用 - - //var writestatus = writelist.FirstOrDefault(a => a.remark == "状态字"); - //writestatus.value = nowstatus.ToString(); - - //var write1 = writelist.FirstOrDefault(a => a.remark == "反馈工艺参数10"); - //write1.value = readlist.FirstOrDefault(a => a.remark == "写入工艺参数10").value; - - //var write2 = writelist.FirstOrDefault(a => a.remark == "反馈SN/二维码"); - //write2.value = readlist.FirstOrDefault(a => a.remark == "产品SN").value; - - //var write3 = writelist.FirstOrDefault(a => a.remark == "触发备用5"); - //write3.value = readlist.FirstOrDefault(a => a.remark == "触发备用5").value; - - //var writeresult = siemensHelp.WriteAddress(writelist); - //if (!writeresult.Success) - //{ - // label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入地址处理错误"; - // //LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止"); - // continue; - //} - //continue; - //nowstatus = 3; - - - if (nowstatus == 0) + if (PlcData.Read_Trigger == 0 && PlcData.Write_Status == 0) { continue; } - var nowflow = Init.t_Flows.FirstOrDefault(a => a.hopestatus == nowstatus); + else if (PlcData.Read_Trigger != 0 && PlcData.Write_Status != 0) + { + continue; + } + else if (PlcData.Read_Trigger == 0 && PlcData.Write_Status != 0) + { + PlcData.Write_Status = 0; + var writeresult = siemensHelp.WriteAddress(plcaddress, PlcData); + if (!writeresult.Success) + { + label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入地址处理错误"; + LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止"); + } + continue; + } + + //状态+报警 + + var nowflow = Init.t_Flows.FirstOrDefault(a => a.hopestatus == PlcData.Read_Trigger); if (nowflow == null) { - label8.Text = $"PLC:{Plc.id}:未找到当前触发字{nowstatus},对应的流程"; - //LogExecute.logNet.WriteError($"未找到当前触发字{nowstatus},对应的流程!"); + label8.Text = $"PLC:{Plc.id}:未找到当前触发字{PlcData.Read_Trigger},对应的流程"; + LogExecute.logNet.WriteError($"未找到当前触发字{PlcData.Read_Trigger},对应的流程!"); continue; } var nowinterface = Init.t_Interfaces.FirstOrDefault(a => a.id == nowflow.hopeinterfaceid); if (nowinterface == null) { label8.Text = $"PLC:{Plc.id}:未找到当前期望接口ID {nowflow.hopeinterfaceid},对应的接口"; - //LogExecute.logNet.WriteError($"未找到当前期望接口ID {nowflow.hopeinterfaceid},对应的接口!"); + LogExecute.logNet.WriteError($"未找到当前期望接口ID {nowflow.hopeinterfaceid},对应的接口!"); continue; } + otherdata otherdata = new otherdata(); + otherdata.JS_SN = "12345"; + + + ApiClient apiClient = new ApiClient(); - var result = apiClient.CallFunctionByName(nowinterface.code); + var result = apiClient.CallFunctionByName(nowinterface.code,PlcData, otherdata); if (result.Success) { - var writestatus = writelist.FirstOrDefault(a => a.remark == "状态字"); - writestatus.value = nowstatus.ToString(); - - var writeresult = siemensHelp.WriteAddress(writelist); + var writeresult = siemensHelp.WriteAddress(Init.t_Plcaddresses.FindAll(a => a.plcid == Plc.id),PlcData); if (!writeresult.Success) { label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入地址处理错误"; - //LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止"); + LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止"); continue; } } else { - + label8.Text = $"MES通讯异常!"; + LogExecute.logNet.WriteError($"MES通讯异常!"); } - - } catch (Exception e) { diff --git a/WindowsFormsApp1/db/MES_PLC.db b/WindowsFormsApp1/db/MES_PLC.db index b87f88f..8ac556c 100644 Binary files a/WindowsFormsApp1/db/MES_PLC.db and b/WindowsFormsApp1/db/MES_PLC.db differ diff --git a/WindowsFormsApp1/mod/database/t_plcaddress.cs b/WindowsFormsApp1/mod/database/t_plcaddress.cs index 3114938..cd459db 100644 --- a/WindowsFormsApp1/mod/database/t_plcaddress.cs +++ b/WindowsFormsApp1/mod/database/t_plcaddress.cs @@ -13,6 +13,8 @@ namespace WindowsFormsApp1.mod [PrimaryKey, AutoIncrement] public int id { get; set; } public int plcid { get; set; } + + public string code { get; set; } public string type { get; set; } public string dbaddress { get; set; } public string addresstype { get; set; } diff --git a/WindowsFormsApp1/mod/enum/plc_emum.cs b/WindowsFormsApp1/mod/enum/plc_emum.cs new file mode 100644 index 0000000..8a79321 --- /dev/null +++ b/WindowsFormsApp1/mod/enum/plc_emum.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WindowsFormsApp1.mod +{ + public enum mesresult + { + pass, + fail, + none + }; +} diff --git a/WindowsFormsApp1/mod/server/otherdata.cs b/WindowsFormsApp1/mod/server/otherdata.cs new file mode 100644 index 0000000..38cd801 --- /dev/null +++ b/WindowsFormsApp1/mod/server/otherdata.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WindowsFormsApp1.mod.server +{ + public class otherdata + { + /// + /// MES返回的SN + /// + public string MES_SN { get; set; } + + /// + /// 文件上传地址 + /// + public string FileUploadAddress { get; set; } + + /// + /// 胶水码 + /// + public string JS_SN { get; set; } + + /// + /// 螺丝枪扭力角度 + /// + public List FinalTorqueValue { get; set; } + + /// + /// 螺丝枪扭力曲线 + /// + public List FinalTorqueCurve { get; set; } + + /// + /// 压力曲线 + /// + public List FinalPressureCurve { get; set; } + + /// + /// 气密仪参数 + /// + public Airtight FinalAirtightValue { get; set; } + } + + + public class Airtight + { + /// + /// 压力值 + /// + public string Airtight_Value { get; set; } + /// + /// 压力单位 + /// + public string Airtight_Unit { get; set; } + /// + /// 泄露值 + /// + public string Leak_Value { get; set; } + /// + /// 泄露单位 + /// + public string Leak_Unit { get; set; } + /// + /// 小泄露值 + /// + public string LLeak_Value { get; set; } + /// + /// 小泄露单位 + /// + public string LLeak_Unit { get; set; } + } +} diff --git a/WindowsFormsApp1/mod/server/plcdata.cs b/WindowsFormsApp1/mod/server/plcdata.cs new file mode 100644 index 0000000..53df93a --- /dev/null +++ b/WindowsFormsApp1/mod/server/plcdata.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static SQLite.SQLite3; + +namespace WindowsFormsApp1.mod.server +{ + public class plcdata + { + /// + /// 读取_心跳 + /// + public short Read_Heartbeat { get; set; } + /// + /// 读取_触发字 + /// + public short Read_Trigger { get; set; } + /// + /// 读取_测试结果1OK,2NG + /// + public short Read_Result { get; set; } + /// + /// 读取_设备状态字 + /// + public short Read_Status { get; set; } + /// + /// 读取_其他状态字 + /// + public short Read_Other0 { get; set; } + /// + /// 读取_其他状态字 + /// + public short Read_Other1 { get; set; } + /// + /// 读取_其他状态字 + /// + public short Read_Other2 { get; set; } + /// + /// 读取_其他状态字 + /// + public short Read_Other3 { get; set; } + /// + /// 读取_其他状态字 + /// + public short Read_Other4 { get; set; } + /// + /// 读取_产品SN/追溯码 + /// + public string Read_MaterialCode0 { get; set; } + /// + /// 读取_托盘二维码 + /// + public string Read_MaterialCode1 { get; set; } + /// + /// 读取_关键物料1 + /// + public string Read_MaterialCode2 { get; set; } + /// + /// 读取_关键物料2 + /// + public string Read_MaterialCode3 { get; set; } + /// + /// 读取_关键物料3 + /// + public string Read_MaterialCode4 { get; set; } + /// + /// 读取_写入工艺参数1 + /// + public float Read_UploadData0 { get; set; } + /// + /// 读取_写入工艺参数2 + /// + public float Read_UploadData1 { get; set; } + /// + /// 读取_写入工艺参数3 + /// + public float Read_UploadData2 { get; set; } + /// + /// 读取_写入工艺参数4 + /// + public float Read_UploadData3 { get; set; } + /// + /// 读取_写入工艺参数5 + /// + public float Read_UploadData4 { get; set; } + /// + /// 读取_写入工艺参数6 + /// + public float Read_UploadData5 { get; set; } + /// + /// 读取_写入工艺参数7 + /// + public float Read_UploadData6 { get; set; } + /// + /// 读取_写入工艺参数8 + /// + public float Read_UploadData7 { get; set; } + /// + /// 读取_写入工艺参数9 + /// + public float Read_UploadData8 { get; set; } + /// + /// 读取_写入工艺参数10 + /// + public float Read_UploadData9 { get; set; } + /// + /// 写入_心跳 + /// + public short Write_Heartbeat { get; set; } + /// + /// 写入_状态字 + /// + public short Write_Status { get; set; } + /// + /// 写入_反馈SN号/二维码 + /// + public string Write_stSN { get; set; } + /// + /// 写入_其他状态字 + /// + public short Write_Other0 { get; set; } + /// + /// 写入_其他状态字 + /// + public short Write_Other1 { get; set; } + /// + /// 写入_其他状态字 + /// + public short Write_Other2 { get; set; } + /// + /// 写入_其他状态字 + /// + public short Write_Other3 { get; set; } + /// + /// 写入_其他状态字 + /// + public short Write_Other4 { get; set; } + /// + /// 写入_反馈工艺参数1 + /// + public float Write_ReceiveData0 { get; set; } + /// + /// 写入_反馈工艺参数2 + /// + public float Write_ReceiveData1 { get; set; } + /// + /// 写入_反馈工艺参数3 + /// + public float Write_ReceiveData2 { get; set; } + /// + /// 写入_反馈工艺参数4 + /// + public float Write_ReceiveData3 { get; set; } + /// + /// 写入_反馈工艺参数5 + /// + public float Write_ReceiveData4 { get; set; } + /// + /// 写入_反馈工艺参数6 + /// + public float Write_ReceiveData5 { get; set; } + /// + /// 写入_反馈工艺参数7 + /// + public float Write_ReceiveData6 { get; set; } + /// + /// 写入_反馈工艺参数8 + /// + public float Write_ReceiveData7 { get; set; } + /// + /// 写入_反馈工艺参数9 + /// + public float Write_ReceiveData8 { get; set; } + /// + /// 写入_反馈工艺参数10 + /// + public float Write_ReceiveData9 { get; set; } + + /// + /// 读取PLC的时间 + /// + public DateTime Read_Time { get; set; } + + /// + /// 写入PLC的时间 + /// + public DateTime Write_Time2 { get; set; } + } +} diff --git a/WindowsFormsApp1/server/ApiClient.cs b/WindowsFormsApp1/server/ApiClient.cs index 8c1a9dc..a943ec7 100644 --- a/WindowsFormsApp1/server/ApiClient.cs +++ b/WindowsFormsApp1/server/ApiClient.cs @@ -5,83 +5,81 @@ using System.Reflection; using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; +using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.server; namespace WindowsFormsApp1.server { public class ApiClient { - public BllResult SN_CheckIN() + public ApiFormResult SN_CheckIN(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Carrier_Check() + public ApiFormResult Carrier_Check(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult SN_FeedingCheck() + public ApiFormResult SN_FeedingCheck(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Link_Comp() + public ApiFormResult Link_Comp(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult SN_Release() + public ApiFormResult SN_Release(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Glue_CheckOut() + public ApiFormResult Glue_CheckOut(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Get_Para() + public ApiFormResult Get_Para(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult DispatchPara() + public ApiFormResult DispatchPara(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Data_Collection() + public ApiFormResult Data_Collection(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Status() + public ApiFormResult Status(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult Alarm() + public ApiFormResult Alarm(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult OEEDataCollection() + public ApiFormResult OEEDataCollection(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass, false, "", PlcData); } - public BllResult SN_FileUpload() + public ApiFormResult SN_FileUpload(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass, false, "", PlcData); } - public BllResult Test() + public ApiFormResult Test(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass, false, "", PlcData); } - public BllResult SN_Checkout() + public ApiFormResult SN_Checkout(plcdata PlcData, otherdata OtherData) { - return BllResult.Sucess(); + return ApiFormResult.Sucess(mesresult.pass, false, "", PlcData); } - public BllResult Initialization() + public ApiFormResult Initialization(plcdata PlcData, otherdata OtherData) { - //1.获取PLC参数,扫码器参数 - - //2、调用接口 - - //3.给PLC的 writeaddress赋值 - - return BllResult.Sucess("Initialization"); + PlcData.Write_Status = 3; + return ApiFormResult.Sucess(mesresult.pass,false,"", PlcData); } - public BllResult CallFunctionByName(string functionName) + public ApiFormResult CallFunctionByName(string functionName, plcdata plcdata,otherdata otherdata) { // 获取当前类的类型 Type type = this.GetType(); @@ -92,12 +90,12 @@ namespace WindowsFormsApp1.server if (methodInfo != null) { // 调用该方法 - return (BllResult)methodInfo.Invoke(this, null); + return (ApiFormResult)methodInfo.Invoke(this, new object[] { plcdata, otherdata }); } else { - Console.WriteLine($"Method '{functionName}' not found."); - return BllResult.Error(); + LogExecute.logNet.WriteError($"未找到对应的函数{functionName}"); + return ApiFormResult.Error(mesresult.none, false, $"未找到对应的函数{functionName}", null); } } } diff --git a/WindowsFormsApp1/server/ApiFormResult.cs b/WindowsFormsApp1/server/ApiFormResult.cs new file mode 100644 index 0000000..1fc996f --- /dev/null +++ b/WindowsFormsApp1/server/ApiFormResult.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.server; + +namespace WindowsFormsApp1.server +{ + public class ApiFormResult + { + private ApiFormResult(bool success, mesresult mesresult, bool isShow, string msg, plcdata data) + { + Success = success; + Msg = msg; + Data = data; + Mesresult = mesresult; + IsShow = isShow; + } + + public bool Success { get; set; } + public string Msg { get; set; } + public plcdata Data { get; set; } + + public mesresult Mesresult { get; set; } + + public bool IsShow { get; set; } + + public static ApiFormResult Sucess(mesresult mesresult, bool isShow, string msg, plcdata data) + { + return new ApiFormResult(true, mesresult, isShow, msg, data); + } + + + public static ApiFormResult Error(mesresult mesresult, bool isShow, string msg, plcdata data) + { + return new ApiFormResult(false, mesresult, isShow, msg, data); + } + + } +} diff --git a/WindowsFormsApp1/server/SiemensHelp.cs b/WindowsFormsApp1/server/SiemensHelp.cs index fc38794..a214768 100644 --- a/WindowsFormsApp1/server/SiemensHelp.cs +++ b/WindowsFormsApp1/server/SiemensHelp.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; using HslCommunication.Profinet.Siemens; using HslCommunication; using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.server; +using System.Collections; +using System.Xml.Linq; namespace WindowsFormsApp1.server { @@ -121,7 +124,7 @@ namespace WindowsFormsApp1.server } } - public BllResult ReadAddress(List address) + public BllResult ReadAddress(List address,plcdata PlcData) { var ulist = address.GroupBy(a => a.dbaddress).ToList(); foreach (var u in ulist) @@ -132,6 +135,17 @@ namespace WindowsFormsApp1.server return BllResult.Error(readresult.Msg); } } + + foreach (var p in PlcData.GetType().GetProperties()) + { + var vlaue = address.FirstOrDefault(a => a.code == p.Name); + if (vlaue != null) + { + var per = PlcData.GetType().GetProperty(p.Name); + per.SetValue(PlcData, Convert.ChangeType(vlaue.value, per.PropertyType), null); + } + } + PlcData.Read_Time = DateTime.Now; return BllResult.Sucess(address, "成功"); } @@ -158,9 +172,23 @@ namespace WindowsFormsApp1.server } } - public BllResult WriteAddress(List address) + public BllResult WriteAddress(List address, plcdata PlcData) { - var ulist = address.FindAll(a=>a.remark != "心跳").GroupBy(a => a.dbaddress).ToList(); + List writeaddress = new List(); + + //address = address.FindAll(a => a.code != "Write_Heartbeat"); + foreach (var add in address) + { + foreach (var p in PlcData.GetType().GetProperties()) + { + if (add.code == p.Name) + { + add.value = PlcData.GetType().GetProperty(p.Name).GetValue(PlcData).ToString(); + writeaddress.Add(add); + } + } + } + var ulist = writeaddress.GroupBy(a => a.dbaddress).ToList(); foreach (var u in ulist) { var readresult = WriteOneDB(u.ToList()); @@ -172,16 +200,33 @@ namespace WindowsFormsApp1.server return BllResult.Sucess(address, "成功"); } - public BllResult WriteHaert(List address) - { - var ulist = address.FindAll(a => a.remark == "心跳"); - var readresult = WriteOneDB(ulist); - if (!readresult.Success) - { - return BllResult.Error(readresult.Msg); - } - return BllResult.Sucess(address, "成功"); - } + //public BllResult WriteHaert(List address, plcdata PlcData) + //{ + // List writeaddress = new List(); + + // address = address.FindAll(a=>a.code == "Write_Heartbeat"); + // foreach (var add in address) + // { + // foreach (var p in PlcData.GetType().GetProperties()) + // { + // if(add.code == p.Name) + // { + // add.value = PlcData.GetType().GetProperty(p.Name).GetValue(PlcData).ToString(); + // writeaddress.Add(add); + // } + // } + // } + // var ulist = writeaddress.GroupBy(a => a.dbaddress).ToList(); + // foreach (var u in ulist) + // { + // var readresult = WriteOneDB(u.ToList()); + // if (!readresult.Success) + // { + // return BllResult.Error(readresult.Msg); + // } + // } + // return BllResult.Sucess(address, "成功"); + //} private BllResult TransforWCSDataToAddressData(List address, OperateResult read) {