系统设置添加 称重清零

This commit is contained in:
XingCheng3
2026-05-13 00:51:52 +08:00
parent 14ff9fa4c3
commit 0ca8274260
3 changed files with 102 additions and 9 deletions

View File

@@ -39,8 +39,8 @@ namespace MesWork
tagValue = msgEvent.TagValue.ToString();
break;
}
// ── 监控变量变化记录(首次值除外,不影响主流程)──
if (!ValueT(isFirstValue))
// ── 监控变量变化记录(首次值及心跳除外,不影响主流程)──
if (!ValueT(isFirstValue) && tagTypeCodeID != 14)
{
var signalName = string.IsNullOrWhiteSpace(alarmMsg) ? tagID : alarmMsg;
SaveSignalChangeLog(opName, tagTypeCodeID, signalName, tagValue);

View File

@@ -18,10 +18,16 @@ namespace MesWork.Pages
this.components = new System.ComponentModel.Container();
this.pnl_Header = new System.Windows.Forms.Panel();
this.lbl_Title = new System.Windows.Forms.Label();
this.grp_Station1 = new System.Windows.Forms.GroupBox();
this.grp_Station2 = new System.Windows.Forms.GroupBox();
this.grp_Scanner1 = new System.Windows.Forms.GroupBox();
this.grp_Scanner2 = new System.Windows.Forms.GroupBox();
this.btn_WeightClear1 = new System.Windows.Forms.Button();
this.btn_WeightClear2 = new System.Windows.Forms.Button();
this.timer_Refresh = new System.Windows.Forms.Timer(this.components);
this.grp_Station1.SuspendLayout();
this.grp_Station2.SuspendLayout();
this.SuspendLayout();
//
// pnl_Header
@@ -42,24 +48,73 @@ namespace MesWork.Pages
this.lbl_Title.Name = "lbl_Title";
this.lbl_Title.Text = "系统设置";
//
// grp_Station1
//
this.grp_Station1.Controls.Add(this.btn_WeightClear1);
this.grp_Station1.Controls.Add(this.grp_Scanner1);
this.grp_Station1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
this.grp_Station1.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95);
this.grp_Station1.Location = new System.Drawing.Point(30, 76);
this.grp_Station1.Name = "grp_Station1";
this.grp_Station1.Size = new System.Drawing.Size(840, 310);
this.grp_Station1.Text = " 工位1 ";
//
// grp_Station2
//
this.grp_Station2.Controls.Add(this.btn_WeightClear2);
this.grp_Station2.Controls.Add(this.grp_Scanner2);
this.grp_Station2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
this.grp_Station2.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95);
this.grp_Station2.Location = new System.Drawing.Point(900, 76);
this.grp_Station2.Name = "grp_Station2";
this.grp_Station2.Size = new System.Drawing.Size(840, 310);
this.grp_Station2.Text = " 工位2 ";
//
// grp_Scanner1
//
this.grp_Scanner1.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
this.grp_Scanner1.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95);
this.grp_Scanner1.Location = new System.Drawing.Point(30, 76);
this.grp_Scanner1.Location = new System.Drawing.Point(20, 35);
this.grp_Scanner1.Name = "grp_Scanner1";
this.grp_Scanner1.Size = new System.Drawing.Size(700, 200);
this.grp_Scanner1.Size = new System.Drawing.Size(790, 200);
this.grp_Scanner1.Text = " OP10 扫码枪 ";
//
// grp_Scanner2
//
this.grp_Scanner2.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
this.grp_Scanner2.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95);
this.grp_Scanner2.Location = new System.Drawing.Point(30, 296);
this.grp_Scanner2.Location = new System.Drawing.Point(20, 35);
this.grp_Scanner2.Name = "grp_Scanner2";
this.grp_Scanner2.Size = new System.Drawing.Size(700, 200);
this.grp_Scanner2.Size = new System.Drawing.Size(790, 200);
this.grp_Scanner2.Text = " OP20 扫码枪 ";
//
// btn_WeightClear1
//
this.btn_WeightClear1.BackColor = System.Drawing.Color.FromArgb(245, 158, 11);
this.btn_WeightClear1.Cursor = System.Windows.Forms.Cursors.Hand;
this.btn_WeightClear1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_WeightClear1.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
this.btn_WeightClear1.ForeColor = System.Drawing.Color.White;
this.btn_WeightClear1.Location = new System.Drawing.Point(20, 250);
this.btn_WeightClear1.Name = "btn_WeightClear1";
this.btn_WeightClear1.Size = new System.Drawing.Size(150, 40);
this.btn_WeightClear1.Text = "称重清零";
this.btn_WeightClear1.UseVisualStyleBackColor = false;
this.btn_WeightClear1.Click += new System.EventHandler(this.btn_WeightClear1_Click);
//
// btn_WeightClear2
//
this.btn_WeightClear2.BackColor = System.Drawing.Color.FromArgb(245, 158, 11);
this.btn_WeightClear2.Cursor = System.Windows.Forms.Cursors.Hand;
this.btn_WeightClear2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_WeightClear2.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
this.btn_WeightClear2.ForeColor = System.Drawing.Color.White;
this.btn_WeightClear2.Location = new System.Drawing.Point(20, 250);
this.btn_WeightClear2.Name = "btn_WeightClear2";
this.btn_WeightClear2.Size = new System.Drawing.Size(150, 40);
this.btn_WeightClear2.Text = "称重清零";
this.btn_WeightClear2.UseVisualStyleBackColor = false;
this.btn_WeightClear2.Click += new System.EventHandler(this.btn_WeightClear2_Click);
//
// timer_Refresh
//
@@ -71,12 +126,14 @@ namespace MesWork.Pages
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250);
this.Controls.Add(this.grp_Scanner1);
this.Controls.Add(this.grp_Scanner2);
this.Controls.Add(this.grp_Station1);
this.Controls.Add(this.grp_Station2);
this.Controls.Add(this.pnl_Header);
this.Name = "UC_SystemSettings";
this.Size = new System.Drawing.Size(1820, 1000);
this.grp_Station1.ResumeLayout(false);
this.grp_Station2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -85,8 +142,12 @@ namespace MesWork.Pages
private System.Windows.Forms.Panel pnl_Header;
private System.Windows.Forms.Label lbl_Title;
private System.Windows.Forms.GroupBox grp_Station1;
private System.Windows.Forms.GroupBox grp_Station2;
private System.Windows.Forms.GroupBox grp_Scanner1;
private System.Windows.Forms.GroupBox grp_Scanner2;
private System.Windows.Forms.Button btn_WeightClear1;
private System.Windows.Forms.Button btn_WeightClear2;
private System.Windows.Forms.Timer timer_Refresh;
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MesWork.Pages
@@ -179,6 +180,37 @@ namespace MesWork.Pages
MessageBox.Show($"已手动发送条码:{barcode}\n工位{opName}", "发送成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private async void btn_WeightClear1_Click(object sender, EventArgs e)
{
await DoWeightClearAsync("OP10", btn_WeightClear1);
}
private async void btn_WeightClear2_Click(object sender, EventArgs e)
{
await DoWeightClearAsync("OP20", btn_WeightClear2);
}
private async Task DoWeightClearAsync(string opName, Button btn)
{
try
{
btn.Enabled = false;
MesWorkForm.WritePLC_IF(100017, opName, 1);
await Task.Delay(1000);
MesWorkForm.WritePLC_IF(100017, opName, 0);
MessageBox.Show($"{opName} 称重清零信号已发送", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MesWorkForm.WriteLog_Info("系统设置", $"{opName} 称重清零失败:{ex.Message}", ex);
MessageBox.Show($"{opName} 称重清零失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
btn.Enabled = true;
}
}
private void RefreshComPorts(ComboBox cmb, string opName)
{
cmb.Items.Clear();