From 3ea4e4fd7b92a6dfc5341af2f00f261619cc7572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?liming=20=E8=94=A1?= Date: Tue, 11 Aug 2026 18:57:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6NG=E4=B8=BA98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JinYuan.ControlCenter/ControlCenter_Plc.cs | 4 +- LargeSquareOne/FrmChannelCfg.Designer.cs | 50 +++++++++++----------- LargeSquareOne/FrmChannelCfg.cs | 21 +++++---- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/JinYuan.ControlCenter/ControlCenter_Plc.cs b/JinYuan.ControlCenter/ControlCenter_Plc.cs index 4384bb2..b324429 100644 --- a/JinYuan.ControlCenter/ControlCenter_Plc.cs +++ b/JinYuan.ControlCenter/ControlCenter_Plc.cs @@ -1957,7 +1957,7 @@ namespace JinYuan.ControlCenters var channels = CommonMethods.mesConfig.ChannelConfig.Channels; var ngChanel = channels.FirstOrDefault(x => x.Gears.Contains("NG")); - int ngVal = ngChanel == null ? 97 : ngChanel.DefaultValue; + int ngVal = ngChanel == null ? 98 : ngChanel.DefaultValue; try { @@ -2044,7 +2044,7 @@ namespace JinYuan.ControlCenters else { list[i].Remark = $"出站条码[{list[i].BarCode}]外观检OK分档,MES断连"; - listGradeResult[i] = 97; //(short)26; + listGradeResult[i] = 98; //(short)26; // list[i].Result = "MES NG"; CommonMethods.PlcLink.WriteValue("D80", 1, Data_Type.Short); //反馈MES结果 diff --git a/LargeSquareOne/FrmChannelCfg.Designer.cs b/LargeSquareOne/FrmChannelCfg.Designer.cs index 85e377f..90fc25d 100644 --- a/LargeSquareOne/FrmChannelCfg.Designer.cs +++ b/LargeSquareOne/FrmChannelCfg.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.panel1 = new JinYuan.ControlLib.PanelExt(); + this.label7 = new System.Windows.Forms.Label(); this.btnRemoveGear = new System.Windows.Forms.Button(); this.listBoxGears = new System.Windows.Forms.ListBox(); this.numChannelId = new System.Windows.Forms.NumericUpDown(); @@ -44,7 +45,6 @@ this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numChannelId)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDefaultValue)).BeginInit(); @@ -82,6 +82,16 @@ this.panel1.TabIndex = 0; this.panel1.TopGap = 0; // + // label7 + // + this.label7.AutoSize = true; + this.label7.ForeColor = System.Drawing.Color.DarkGray; + this.label7.Location = new System.Drawing.Point(882, 133); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(62, 21); + this.label7.TabIndex = 20; + this.label7.Text = "98: NG"; + // // btnRemoveGear // this.btnRemoveGear.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); @@ -101,11 +111,11 @@ this.listBoxGears.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38))))); this.listBoxGears.ForeColor = System.Drawing.Color.White; this.listBoxGears.FormattingEnabled = true; - this.listBoxGears.ItemHeight = 27; + this.listBoxGears.ItemHeight = 21; this.listBoxGears.Location = new System.Drawing.Point(674, 213); this.listBoxGears.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.listBoxGears.Name = "listBoxGears"; - this.listBoxGears.Size = new System.Drawing.Size(289, 247); + this.listBoxGears.Size = new System.Drawing.Size(289, 235); this.listBoxGears.TabIndex = 18; this.listBoxGears.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listBoxGears_MouseDoubleClick); // @@ -115,7 +125,7 @@ this.numChannelId.Location = new System.Drawing.Point(674, 60); this.numChannelId.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.numChannelId.Name = "numChannelId"; - this.numChannelId.Size = new System.Drawing.Size(180, 34); + this.numChannelId.Size = new System.Drawing.Size(180, 29); this.numChannelId.TabIndex = 17; // // listBoxChannels @@ -123,11 +133,11 @@ this.listBoxChannels.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38))))); this.listBoxChannels.ForeColor = System.Drawing.Color.White; this.listBoxChannels.FormattingEnabled = true; - this.listBoxChannels.ItemHeight = 27; + this.listBoxChannels.ItemHeight = 21; this.listBoxChannels.Location = new System.Drawing.Point(69, 62); this.listBoxChannels.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.listBoxChannels.Name = "listBoxChannels"; - this.listBoxChannels.Size = new System.Drawing.Size(367, 517); + this.listBoxChannels.Size = new System.Drawing.Size(367, 508); this.listBoxChannels.TabIndex = 16; this.listBoxChannels.SelectedIndexChanged += new System.EventHandler(this.listBoxChannels_SelectedIndexChanged); // @@ -136,7 +146,7 @@ this.numDefaultValue.Location = new System.Drawing.Point(674, 126); this.numDefaultValue.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.numDefaultValue.Name = "numDefaultValue"; - this.numDefaultValue.Size = new System.Drawing.Size(180, 34); + this.numDefaultValue.Size = new System.Drawing.Size(180, 29); this.numDefaultValue.TabIndex = 15; this.numDefaultValue.ValueChanged += new System.EventHandler(this.numDefaultValue_ValueChanged); this.numDefaultValue.Validating += new System.ComponentModel.CancelEventHandler(this.numDefaultValue_Validating); @@ -187,7 +197,7 @@ this.txtNewGear.Location = new System.Drawing.Point(674, 579); this.txtNewGear.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.txtNewGear.Name = "txtNewGear"; - this.txtNewGear.Size = new System.Drawing.Size(148, 34); + this.txtNewGear.Size = new System.Drawing.Size(148, 29); this.txtNewGear.TabIndex = 10; // // label6 @@ -197,7 +207,7 @@ this.label6.Location = new System.Drawing.Point(552, 579); this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(92, 27); + this.label6.Size = new System.Drawing.Size(74, 21); this.label6.TabIndex = 9; this.label6.Text = "新增档位"; // @@ -208,7 +218,7 @@ this.label5.Location = new System.Drawing.Point(543, 198); this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(92, 27); + this.label5.Size = new System.Drawing.Size(74, 21); this.label5.TabIndex = 7; this.label5.Text = "档位列表"; // @@ -220,7 +230,7 @@ this.label4.Location = new System.Drawing.Point(528, 126); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(107, 27); + this.label4.Size = new System.Drawing.Size(87, 21); this.label4.TabIndex = 5; this.label4.Text = "PLC档位值"; // @@ -231,7 +241,7 @@ this.label3.Location = new System.Drawing.Point(563, 62); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(72, 27); + this.label3.Size = new System.Drawing.Size(58, 21); this.label3.TabIndex = 3; this.label3.Text = "通道号"; // @@ -242,7 +252,7 @@ this.label2.Location = new System.Drawing.Point(669, 19); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(92, 27); + this.label2.Size = new System.Drawing.Size(74, 21); this.label2.TabIndex = 2; this.label2.Text = "通道详情"; // @@ -253,23 +263,13 @@ this.label1.Location = new System.Drawing.Point(64, 19); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(92, 27); + this.label1.Size = new System.Drawing.Size(74, 21); this.label1.TabIndex = 1; this.label1.Text = "通道列表"; // - // label7 - // - this.label7.AutoSize = true; - this.label7.ForeColor = System.Drawing.Color.DarkGray; - this.label7.Location = new System.Drawing.Point(882, 133); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(292, 27); - this.label7.TabIndex = 20; - this.label7.Text = "98: 扫码NG(不允许在界面配置)"; - // // FrmChannelCfg // - this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 27F); + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38))))); this.ClientSize = new System.Drawing.Size(1204, 752); diff --git a/LargeSquareOne/FrmChannelCfg.cs b/LargeSquareOne/FrmChannelCfg.cs index 6ff2a22..e4fbeb7 100644 --- a/LargeSquareOne/FrmChannelCfg.cs +++ b/LargeSquareOne/FrmChannelCfg.cs @@ -81,11 +81,14 @@ namespace LargeSquareOne // 保存 private void btnSave_Click(object sender, EventArgs e) { - // 更新当前通道数据 - if (_currentChannel != null) + var errList = _config.Channels.Where(x => x.AllContent.Contains("NG") && x.DefaultValue != 98).ToList(); + if (errList.Count > 0) { - _currentChannel.DefaultValue = (int)numDefaultValue.Value; + var errArr = errList.Select(it => it.DefaultValue).ToArray(); + MessageBox.Show($"NG写给PLC的值必须为98,不能为{string.Join(",", errArr)}"); + return; } + CommonMethods.SaveToJson(CommonMethods.ChannelPath, _config); MessageBox.Show("保存成功!"); } @@ -122,12 +125,12 @@ namespace LargeSquareOne private void numDefaultValue_Validating(object sender, CancelEventArgs e) { - if ((int)numDefaultValue.Value == 98) - { - MessageBox.Show("98: 扫码NG(不允许在界面配置)"); - e.Cancel = true; - return; - } + //if ((int)numDefaultValue.Value == 98) + //{ + // MessageBox.Show("98: 扫码NG(不允许在界面配置)"); + // e.Cancel = true; + // return; + //} } } }