From ce701f953bd952bf8303ccb93520a8a3af33860e Mon Sep 17 00:00:00 2001 From: lu <123456> Date: 星期四, 21 八月 2025 13:45:42 +0800 Subject: [PATCH] iqc称重 --- DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs | 16 DevApp/Gs.DevApp/UserControl/UcToolBarMenu.cs | 16 DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.Designer.cs | 38 ++ DevApp/Gs.DevApp/Gs.DevApp.csproj | 6 DevApp/Gs.DevApp/App.config | 9 DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.cs | 731 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 800 insertions(+), 16 deletions(-) diff --git a/DevApp/Gs.DevApp/App.config b/DevApp/Gs.DevApp/App.config index 642d77a..199f753 100644 --- a/DevApp/Gs.DevApp/App.config +++ b/DevApp/Gs.DevApp/App.config @@ -53,13 +53,8 @@ <add key="ToastSeconds" value="5" /><!--鎻愮ず妗嗘椂闂�--> <add key="AsyncSeconds" value="2" /><!--姘存瓒呮椂鏃堕棿--> <add key="IsWater" value="0" /><!--鏄惁瑕佹按妫�鍙婂伐浣嶇爜--> - - - <!--<add key="ExecutionTime" value="5" />--> - <add key="TimingMailInterval" value="10000" /> - <add key="thisText" value="[鏂扮粶绉伴噸鏈嶅姟]" /> - <!--<add key="notifyText" value="5" />--> - <add key="ClientSettingsProvider.ServiceUri" value="" /> + <add key="IqcGetWeight" value="3000" /><!--iqc璇荤О閲嶆椂--> + <add key="TimingMailInterval" value="10000" /><!--iqc绉伴噸鏃跺埛鏂�--> </appSettings> <userSettings> <Gs.DevApp.Properties.Settings> diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs index e5fee83..a28607c 100644 --- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs +++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs @@ -26,10 +26,20 @@ /// <summary> /// 瀹氭椂鍒锋柊 /// </summary> - System.Timers.Timer timer = new System.Timers.Timer(1000); + System.Timers.Timer timer; + public Frm_MesQaItemsDetect01() { InitializeComponent(); + + #region 璁剧疆鏃堕棿 + int int32 = 3000; + string _vanishingSeconds = ConfigurationManager.AppSettings["IqcGetWeight"]; + if (!string.IsNullOrEmpty(_vanishingSeconds)) + int32 = int.Parse(_vanishingSeconds); + timer = new System.Timers.Timer(int32); + #endregion + this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick; this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; @@ -93,7 +103,7 @@ } catch (Exception ex) { - + LoggerHelper.WriteInfoLog("WorkWeight/GetIqcWeight:" + ex.Message); } }; timer.AutoReset = true; // 璁剧疆涓簍rue琛ㄧず閲嶅鎵ц锛宖alse琛ㄧず鎵ц涓�娆″悗鍋滄 @@ -168,7 +178,7 @@ }; try { - var strReturn = UtilityHelper.HttpPost("", "WorkWeight/EditIqc", JsonConvert.SerializeObject(_obj), false); + var strReturn = UtilityHelper.HttpPost("", "WorkWeight/EditIqcWeight", JsonConvert.SerializeObject(_obj), false); var dd = UtilityHelper.ReturnToDynamic(strReturn); if (dd.rtnCode <= 0) { diff --git a/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.Designer.cs b/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.Designer.cs new file mode 100644 index 0000000..71908a9 --- /dev/null +++ b/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.Designer.cs @@ -0,0 +1,38 @@ +锘縩amespace Gs.DevApp.DevFrm.QC +{ + partial class WeightIqc + { + ///// <summary> + ///// Required designer variable. + ///// </summary> + //private System.ComponentModel.IContainer components = null; + + ///// <summary> + ///// Clean up any resources being used. + ///// </summary> + ///// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + //protected override void Dispose(bool disposing) + //{ + // if (disposing && (components != null)) + // { + // components.Dispose(); + // } + // base.Dispose(disposing); + //} + + //#region Windows Form Designer generated code + + ///// <summary> + ///// Required method for Designer support - do not modify + ///// the contents of this method with the code editor. + ///// </summary> + //private void InitializeComponent() + //{ + // this.components = new System.ComponentModel.Container(); + // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + // this.Text = "WeightIqc"; + //} + + //#endregion + } +} \ No newline at end of file diff --git a/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.cs b/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.cs new file mode 100644 index 0000000..69ddbf2 --- /dev/null +++ b/DevApp/Gs.DevApp/DevFrm/QC/WeightIqc.cs @@ -0,0 +1,731 @@ +锘縰sing DevExpress.XtraEditors; +using DevExpress.XtraEditors.Controls; +using DevExpress.XtraGrid; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Base; +using DevExpress.XtraGrid.Views.Grid; +using Gs.DevApp.Entity; +using Gs.DevApp.ToolBox; +using Microsoft.Win32; +using Newtonsoft.Json; +using NModbus; +using NModbus.Serial; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Drawing; +using System.IO.Ports; +using System.Linq; +using System.Text; +using System.Threading; +using System.Windows.Forms; + +namespace Gs.DevApp.DevFrm.QC +{ + public partial class WeightIqc : DevExpress.XtraEditors.XtraForm + { + public SerialPort Sp = new SerialPort(); + private WeightIqc.HandleInterfaceUpdataDelegate interfaceUpdataHandle; + private string strLine = ""; + private string sqlWOMQAB = ""; + private Dictionary<string, Thread> dicThread = new Dictionary<string, Thread>(); + private StringBuilder sb = new StringBuilder(); + private IContainer components = (IContainer)null; + private SplitContainerControl splitContainerControl1; + private ImageComboBoxEdit cmbBaudRate; + private LabelControl labelControl1; + private TextEdit txtNum; + private LabelControl labelControl3; + private SimpleButton button2; + private SimpleButton button1; + private SimpleButton btnRefashC; + private ImageComboBoxEdit cmbSerialPortNum; + private LabelControl labelControl2; + private GridControl gridWOMQAB; + private GridView viewWOMQAB; + private GridColumn colQAB001; + private GridColumn colQAB002; + private GridColumn colQAB003; + private GridColumn colQAB005; + private GridColumn colQAB006; + private GridColumn colQAB007; + private GridColumn colQAB009; + private GridColumn colQAB010; + private GridColumn colMIH004; + private GridColumn colPAA002; + private GridColumn colQAB015; + private GridColumn colQAB025; + private GridColumn colMCA022; + private GridColumn colZT; + private GridColumn colMCA023; + private NotifyIcon notifyIcon1; + private ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.Timer timer1; + private ToolStripMenuItem showInTaskbar; + private ToolStripMenuItem exitWindow; + + public WeightIqc() + { + this.InitializeComponent(); + this.timer1.Tick += new EventHandler(this.timer1_Tick); + this.notifyIcon1.DoubleClick += new EventHandler(this.notifyIcon1_DoubleClick); + this.SizeChanged += new EventHandler(this.frmMain_SizeChanged); + this.contextMenuStrip1.ItemClicked += new ToolStripItemClickedEventHandler(this.contextMenuStrip1_ItemClicked); + this.Initialize(); + + } + + private void Initialize() + { + try + { + int int32 = 10000; + string _vanishingSeconds = ConfigurationManager.AppSettings["TimingMailInterval"]; + if (!string.IsNullOrEmpty(_vanishingSeconds)) + int32 = int.Parse(_vanishingSeconds); + string appSetting = ConfigurationManager.AppSettings["ProductName"]+"鏈嶅姟"; + this.Text = appSetting; + this.notifyIcon1.Text = appSetting; + this.timer1.Interval = int32; + this.button1.Enabled = true; + this.button2.Enabled = false; + } + catch (Exception ex) + { + int num = (int)MessageBox.Show(ex.Message); + Application.Exit(); + } + } + + private void GetComList() + { + this.cmbSerialPortNum.Properties.Items.Clear(); + RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm"); + if (registryKey == null) + return; + foreach (string valueName in registryKey.GetValueNames()) + { + string description = (string)registryKey.GetValue(valueName); + this.cmbSerialPortNum.Properties.Items.Add(new ImageComboBoxItem(description, (object)description)); + } + if (this.cmbSerialPortNum.Properties.Items.Count > 0) + this.cmbSerialPortNum.SelectedIndex = 0; + } + + public void RefreshData() + { + while (true) + { + try + { + Thread.Sleep(10000); + } + catch (Exception ex) + { + Thread.Sleep(10000); + } + } + } + + public void GetWeight() + { + ModbusFactory factory = new ModbusFactory(); + LoggerHelper.WriteInfoLog("GetWeight鍒涘缓modbus瀵硅薄"); + IModbusMaster rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp); + bool flag = true; + while (true) + { + try + { + if (!this.Sp.IsOpen) + { + LoggerHelper.WriteInfoLog("GetWeight 閲嶆柊鎵撳紑涓插彛杩炴帴"); + this.Sp.Open(); + rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp); + } + if (rtuMaster == null) + { + LoggerHelper.WriteInfoLog("GetWeight 閲嶆柊鍒涘缓modbus瀵硅薄"); + rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp); + } + byte slaveAddress3 = byte.Parse("1"); + ushort startAddress3 = ushort.Parse("0002"); + ushort numberOfPoints1 = ushort.Parse("2"); + ushort[] numArray = rtuMaster.ReadHoldingRegisters(slaveAddress3, startAddress3, numberOfPoints1); + float single = BitConverter.ToSingle(this.CombomBinaryArray(BitConverter.GetBytes(numArray[1]), BitConverter.GetBytes(numArray[0])), 0); + this.Invoke((Delegate)this.interfaceUpdataHandle, (object)single.ToString()); + byte slaveAddress4 = byte.Parse("1"); + ushort startAddress4 = ushort.Parse("0001"); + ushort numberOfPoints2 = ushort.Parse("1"); + int int32 = Convert.ToInt32(rtuMaster.ReadHoldingRegisters(slaveAddress4, startAddress4, numberOfPoints2)[0].ToString()); + string str = Convert.ToString(int32, 2).PadLeft(16 /*0x10*/, '0'); + char ch1 = str[1]; + char ch2 = str[6]; + if (ch1 == '0' && ch2 == '0') + { + flag = true; + } + else if (flag) + { + flag = false; + } + addModel(single.ToString(), int32.ToString()); + LoggerHelper.WriteInfoLog("single:" + single.ToString() + ",flag:" + flag.ToString() + ",int32:" + int32.ToString()); + Thread.Sleep(2000); + } + catch (Exception ex) + { + Thread.Sleep(2000); + } + } + } + + private void UpdateTextBox(string text) + { + try + { + if (this.txtNum.Text == text) + return; + this.txtNum.Text = text; + } + catch (Exception ex) + { + LoggerHelper.WriteErrorLog($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:{ex.Message}"); + int num = (int)MessageBox.Show(ex.Message); + } + } + + public ushort[] stringToUshort2(string inString) + { + byte[] bytes = BitConverter.GetBytes(float.Parse(inString)); + ushort uint16 = BitConverter.ToUInt16(bytes, 0); + return new ushort[2] + { + BitConverter.ToUInt16(bytes, 2), + uint16 + }; + } + + private byte[] CombomBinaryArray(byte[] srcArray1, byte[] srcArray2) + { + byte[] destinationArray = new byte[srcArray1.Length + srcArray2.Length]; + Array.Copy((Array)srcArray1, 0, (Array)destinationArray, 0, srcArray1.Length); + Array.Copy((Array)srcArray2, 0, (Array)destinationArray, srcArray1.Length, srcArray2.Length); + return destinationArray; + } + + private void button1_Click(object sender, EventArgs e) + { + try + { + DateTime now = DateTime.Now; + LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":寮�濮嬮噰闆�"); + if (this.cmbBaudRate.Text.Trim() != "" && this.cmbSerialPortNum.Text != "") + { + now = DateTime.Now; + LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":閰嶇疆涓插彛閫氫俊"); + this.interfaceUpdataHandle = new WeightIqc.HandleInterfaceUpdataDelegate(this.UpdateTextBox); + this.Sp.PortName = this.cmbSerialPortNum.Text.Trim(); + this.Sp.BaudRate = Convert.ToInt32(this.cmbBaudRate.Text.Trim()); + this.Sp.Parity = Parity.None; + this.Sp.StopBits = StopBits.One; + now = DateTime.Now; + LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":鎵撳紑涓插彛鍚岄�氫俊"); + this.Sp.Open(); + this.button1.Enabled = false; + this.button2.Enabled = true; + this.timer1.Enabled = false; + now = DateTime.Now; + LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":鍚姩鍒锋柊鏁版嵁瀹氭椂鍣�"); + this.timer1.Start(); + } + else + { + now = DateTime.Now; + LoggerHelper.WriteErrorLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":璇疯緭鍏ユ纭殑绔彛鍙峰拰娉㈢壒鐜�"); + int num = (int)MessageBox.Show("璇疯緭鍏ユ纭殑绔彛鍙峰拰娉㈢壒鐜囷紒"); + this.cmbSerialPortNum.Focus(); + } + } + catch (Exception ex) + { + LoggerHelper.WriteErrorLog($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:{ex.Message}"); + int num = (int)MessageBox.Show($"绔彛{this.cmbSerialPortNum.Text.Trim()}鎵撳紑澶辫触锛亄ex.Message}"); + } + } + + private void button2_Click(object sender, EventArgs e) + { + try + { + if (this.dicThread.Keys.Contains<string>("RefreshData")) + { + Thread thread = this.dicThread["RefreshData"]; + if (thread.IsAlive) + thread.Abort(); + this.dicThread.Remove("RefreshData"); + } + if (this.dicThread.Keys.Contains<string>("GetWeight")) + { + Thread thread = this.dicThread["GetWeight"]; + if (thread.IsAlive) + thread.Abort(); + this.dicThread.Remove("GetWeight"); + } + this.button1.Enabled = true; + this.button2.Enabled = false; + this.timer1.Stop(); + this.Sp.Close(); + } + catch (Exception ex) + { + int num = (int)MessageBox.Show(ex.Message); + Application.Exit(); + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + if (!this.dicThread.Keys.Contains<string>("RefreshData")) + { + Thread thread = new Thread(new ThreadStart(this.RefreshData)); + thread.Start(); + this.dicThread.Add("RefreshData", thread); + } + if (this.dicThread.Keys.Contains<string>("GetWeight")) + return; + Thread thread1 = new Thread(new ThreadStart(this.GetWeight)); + thread1.Start(); + this.dicThread.Add("GetWeight", thread1); + } + + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + if (Sp.IsOpen) + Sp.Close(); + if (timer1 != null) + { + timer1.Stop(); + timer1.Dispose(); + } + try + { + if (this.dicThread.Keys.Contains<string>("RefreshData")) + { + Thread thread = this.dicThread["RefreshData"]; + if (thread.IsAlive) + thread.Abort(); + this.dicThread.Remove("RefreshData"); + } + if (this.dicThread.Keys.Contains<string>("GetWeight")) + { + Thread thread = this.dicThread["GetWeight"]; + if (thread.IsAlive) + thread.Abort(); + this.dicThread.Remove("GetWeight"); + } + this.timer1.Stop(); + this.Sp.Close(); + } + catch (Exception ex) + { + int num = (int)MessageBox.Show(ex.Message); + Application.Exit(); + } + } + + private void Form1_Load(object sender, EventArgs e) => this.GetComList(); + + private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem == this.showInTaskbar) + { + if (this.WindowState != FormWindowState.Minimized) + return; + this.WindowState = FormWindowState.Normal; + this.Activate(); + this.ShowInTaskbar = true; + this.notifyIcon1.Visible = false; + } + else + { + if (e.ClickedItem != this.exitWindow) + return; + this.button2_Click((object)null, (EventArgs)null); + Environment.Exit(0); + } + } + + private void frmMain_SizeChanged(object sender, EventArgs e) + { + //if (this.WindowState != FormWindowState.Minimized) + // return; + //this.ShowInTaskbar = false; + //this.notifyIcon1.Visible = true; + } + + private void notifyIcon1_DoubleClick(object sender, EventArgs e) + { + if (this.WindowState != FormWindowState.Minimized) + return; + this.WindowState = FormWindowState.Normal; + this.Activate(); + this.ShowInTaskbar = true; + this.notifyIcon1.Visible = false; + } + + protected override void Dispose(bool disposing) + { + if (disposing && this.components != null) + this.components.Dispose(); + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.components = (IContainer)new System.ComponentModel.Container(); + GridFormatRule gridFormatRule1 = new GridFormatRule(); + FormatConditionRuleExpression conditionRuleExpression1 = new FormatConditionRuleExpression(); + GridFormatRule gridFormatRule2 = new GridFormatRule(); + FormatConditionRuleExpression conditionRuleExpression2 = new FormatConditionRuleExpression(); + ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(WeightIqc)); + this.colZT = new GridColumn(); + this.splitContainerControl1 = new SplitContainerControl(); + this.txtNum = new TextEdit(); + this.labelControl3 = new LabelControl(); + this.button2 = new SimpleButton(); + this.button1 = new SimpleButton(); + this.btnRefashC = new SimpleButton(); + this.cmbSerialPortNum = new ImageComboBoxEdit(); + this.labelControl2 = new LabelControl(); + this.cmbBaudRate = new ImageComboBoxEdit(); + this.labelControl1 = new LabelControl(); + this.gridWOMQAB = new GridControl(); + this.viewWOMQAB = new GridView(); + this.colQAB001 = new GridColumn(); + this.colQAB002 = new GridColumn(); + this.colQAB003 = new GridColumn(); + this.colQAB005 = new GridColumn(); + this.colQAB006 = new GridColumn(); + this.colQAB007 = new GridColumn(); + this.colQAB009 = new GridColumn(); + this.colQAB010 = new GridColumn(); + this.colMIH004 = new GridColumn(); + this.colPAA002 = new GridColumn(); + this.colQAB015 = new GridColumn(); + this.colQAB025 = new GridColumn(); + this.colMCA022 = new GridColumn(); + this.colMCA023 = new GridColumn(); + this.notifyIcon1 = new NotifyIcon(this.components); + this.contextMenuStrip1 = new ContextMenuStrip(this.components); + this.showInTaskbar = new ToolStripMenuItem(); + this.exitWindow = new ToolStripMenuItem(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.splitContainerControl1.BeginInit(); + this.splitContainerControl1.SuspendLayout(); + this.txtNum.Properties.BeginInit(); + this.cmbSerialPortNum.Properties.BeginInit(); + this.cmbBaudRate.Properties.BeginInit(); + this.gridWOMQAB.BeginInit(); + this.viewWOMQAB.BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + this.colZT.Caption = "鐘舵��"; + this.colZT.FieldName = "ZT"; + this.colZT.Name = "colZT"; + this.splitContainerControl1.Dock = DockStyle.Fill; + this.splitContainerControl1.Horizontal = false; + this.splitContainerControl1.Location = new Point(0, 0); + this.splitContainerControl1.Margin = new Padding(4, 4, 4, 4); + this.splitContainerControl1.Name = "splitContainerControl1"; + this.splitContainerControl1.Panel1.Controls.Add((Control)this.txtNum); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl3); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.button2); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.button1); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.btnRefashC); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.cmbSerialPortNum); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl2); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.cmbBaudRate); + this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl1); + this.splitContainerControl1.Panel1.Text = "Panel1"; + this.splitContainerControl1.Panel2.Controls.Add((Control)this.gridWOMQAB); + this.splitContainerControl1.Panel2.Text = "Panel2"; + this.splitContainerControl1.Size = new Size(859, 391); + this.splitContainerControl1.SplitterPosition = 139; + this.splitContainerControl1.TabIndex = 0; + this.splitContainerControl1.Text = "splitContainerControl1"; + this.txtNum.Location = new Point(588, 19); + this.txtNum.Margin = new Padding(4, 4, 4, 4); + this.txtNum.Name = "txtNum"; + this.txtNum.Properties.Appearance.Font = new Font("Tahoma", 24f, FontStyle.Regular, GraphicsUnit.Point, (byte)0); + this.txtNum.Properties.Appearance.Options.UseFont = true; + this.txtNum.Size = new Size(187, 54); + this.txtNum.TabIndex = 8; + this.labelControl3.Appearance.Font = new Font("Tahoma", 24f, FontStyle.Regular, GraphicsUnit.Point, (byte)0); + this.labelControl3.Appearance.Options.UseFont = true; + this.labelControl3.Location = new Point(468, 28); + this.labelControl3.Margin = new Padding(4, 4, 4, 4); + this.labelControl3.Name = "labelControl3"; + this.labelControl3.Size = new Size(120, 48 /*0x30*/); + this.labelControl3.TabIndex = 7; + this.labelControl3.Text = "閲嶉噺锛�"; + this.button2.Location = new Point(315, 48 /*0x30*/); + this.button2.Margin = new Padding(4, 4, 4, 4); + this.button2.Name = "button2"; + this.button2.Size = new Size(100, 29); + this.button2.TabIndex = 6; + this.button2.Text = "鍋滄"; + this.button2.Click += new EventHandler(this.button2_Click); + this.button1.Location = new Point(315, 8); + this.button1.Margin = new Padding(4, 4, 4, 4); + this.button1.Name = "button1"; + this.button1.Size = new Size(100, 29); + this.button1.TabIndex = 5; + this.button1.Text = "纭畾"; + this.button1.Click += new EventHandler(this.button1_Click); + this.btnRefashC.Location = new Point(213, 48 /*0x30*/); + this.btnRefashC.Margin = new Padding(4, 4, 4, 4); + this.btnRefashC.Name = "btnRefashC"; + this.btnRefashC.Size = new Size(33, 29); + this.btnRefashC.TabIndex = 4; + this.btnRefashC.Text = "R"; + this.cmbSerialPortNum.Location = new Point(72, 49); + this.cmbSerialPortNum.Margin = new Padding(4, 4, 4, 4); + this.cmbSerialPortNum.Name = "cmbSerialPortNum"; + this.cmbSerialPortNum.Properties.Buttons.AddRange(new EditorButton[1] + { + new EditorButton(ButtonPredefines.Combo) + }); + this.cmbSerialPortNum.Size = new Size(133, 24); + this.cmbSerialPortNum.TabIndex = 3; + this.labelControl2.Location = new Point(16 /*0x10*/, 52); + this.labelControl2.Margin = new Padding(4, 4, 4, 4); + this.labelControl2.Name = "labelControl2"; + this.labelControl2.Size = new Size(45, 18); + this.labelControl2.TabIndex = 2; + this.labelControl2.Text = "涓插彛鍙�"; + this.cmbBaudRate.EditValue = (object)"9600"; + this.cmbBaudRate.Location = new Point(72, 11); + this.cmbBaudRate.Margin = new Padding(4, 4, 4, 4); + this.cmbBaudRate.Name = "cmbBaudRate"; + this.cmbBaudRate.Properties.Buttons.AddRange(new EditorButton[1] + { + new EditorButton(ButtonPredefines.Combo) + }); + this.cmbBaudRate.Properties.Items.AddRange(new ImageComboBoxItem[5] + { + new ImageComboBoxItem("14400", (object) "14400", -1), + new ImageComboBoxItem("9600", (object) "9600", -1), + new ImageComboBoxItem("4800", (object) "4800", -1), + new ImageComboBoxItem("2400", (object) "2400", -1), + new ImageComboBoxItem("1200", (object) "1200", -1) + }); + this.cmbBaudRate.Size = new Size(175, 24); + this.cmbBaudRate.TabIndex = 1; + this.labelControl1.Location = new Point(16 /*0x10*/, 15); + this.labelControl1.Margin = new Padding(4, 4, 4, 4); + this.labelControl1.Name = "labelControl1"; + this.labelControl1.Size = new Size(45, 18); + this.labelControl1.TabIndex = 0; + this.labelControl1.Text = "娉㈢壒鐜�"; + this.gridWOMQAB.Dock = DockStyle.Fill; + this.gridWOMQAB.EmbeddedNavigator.Margin = new Padding(4, 4, 4, 4); + this.gridWOMQAB.Location = new Point(0, 0); + this.gridWOMQAB.MainView = (BaseView)this.viewWOMQAB; + this.gridWOMQAB.Margin = new Padding(4, 4, 4, 4); + this.gridWOMQAB.Name = "gridWOMQAB"; + this.gridWOMQAB.Size = new Size(859, 246); + this.gridWOMQAB.TabIndex = 1; + this.gridWOMQAB.ViewCollection.AddRange(new BaseView[1] + { + (BaseView) this.viewWOMQAB + }); + this.viewWOMQAB.Columns.AddRange(new GridColumn[15] + { + this.colQAB001, + this.colQAB002, + this.colQAB003, + this.colQAB005, + this.colQAB006, + this.colQAB007, + this.colQAB009, + this.colQAB010, + this.colMIH004, + this.colPAA002, + this.colQAB015, + this.colQAB025, + this.colMCA022, + this.colZT, + this.colMCA023 + }); + gridFormatRule1.ApplyToRow = true; + gridFormatRule1.Column = this.colZT; + gridFormatRule1.Name = "ZTRule1"; + conditionRuleExpression1.Appearance.BackColor = System.Drawing.Color.Red; + conditionRuleExpression1.Appearance.Options.UseBackColor = true; + conditionRuleExpression1.Expression = "ZT='N'"; + gridFormatRule1.Rule = (FormatConditionRuleBase)conditionRuleExpression1; + gridFormatRule2.ApplyToRow = true; + gridFormatRule2.Column = this.colZT; + gridFormatRule2.Name = "ZTRule2"; + conditionRuleExpression2.Appearance.BackColor = System.Drawing.Color.FromArgb(128 /*0x80*/, (int)byte.MaxValue, 128 /*0x80*/); + conditionRuleExpression2.Appearance.Options.UseBackColor = true; + conditionRuleExpression2.Expression = "ZT='Y'"; + gridFormatRule2.Rule = (FormatConditionRuleBase)conditionRuleExpression2; + this.viewWOMQAB.FormatRules.Add(gridFormatRule1); + this.viewWOMQAB.FormatRules.Add(gridFormatRule2); + this.viewWOMQAB.GridControl = this.gridWOMQAB; + this.viewWOMQAB.Name = "viewWOMQAB"; + this.viewWOMQAB.OptionsView.ColumnAutoWidth = false; + this.viewWOMQAB.OptionsView.ShowGroupPanel = false; + this.colQAB001.Caption = "ID"; + this.colQAB001.FieldName = "QAB001"; + this.colQAB001.Name = "colQAB001"; + this.colQAB002.Caption = "鏉$爜"; + this.colQAB002.FieldName = "QAB002"; + this.colQAB002.MinWidth = 150; + this.colQAB002.Name = "colQAB002"; + this.colQAB002.Visible = true; + this.colQAB002.VisibleIndex = 0; + this.colQAB002.Width = 150; + this.colQAB003.Caption = "宸ュ崟"; + this.colQAB003.FieldName = "QAB003"; + this.colQAB003.MinWidth = 100; + this.colQAB003.Name = "colQAB003"; + this.colQAB003.Visible = true; + this.colQAB003.VisibleIndex = 1; + this.colQAB003.Width = 100; + this.colQAB005.Caption = "鐗╂枡缂栫爜"; + this.colQAB005.FieldName = "QAB005"; + this.colQAB005.MinWidth = 100; + this.colQAB005.Name = "colQAB005"; + this.colQAB005.Visible = true; + this.colQAB005.VisibleIndex = 2; + this.colQAB005.Width = 100; + this.colQAB006.Caption = "鐗╂枡鍚嶇О"; + this.colQAB006.FieldName = "QAB006"; + this.colQAB006.Name = "colQAB006"; + this.colQAB006.Visible = true; + this.colQAB006.VisibleIndex = 3; + this.colQAB007.Caption = "鐗╂枡瑙勬牸"; + this.colQAB007.FieldName = "QAB007"; + this.colQAB007.MinWidth = 200; + this.colQAB007.Name = "colQAB007"; + this.colQAB007.Visible = true; + this.colQAB007.VisibleIndex = 4; + this.colQAB007.Width = 200; + this.colQAB009.Caption = "宸ュ簭缂栧彿"; + this.colQAB009.FieldName = "QAB009"; + this.colQAB009.Name = "colQAB009"; + this.colQAB009.Visible = true; + this.colQAB009.VisibleIndex = 5; + this.colQAB010.Caption = "宸ュ簭鍚嶇О"; + this.colQAB010.FieldName = "QAB010"; + this.colQAB010.Name = "colQAB010"; + this.colQAB010.Visible = true; + this.colQAB010.VisibleIndex = 6; + this.colMIH004.Caption = "绾垮埆"; + this.colMIH004.FieldName = "MIH004"; + this.colMIH004.Name = "colMIH004"; + this.colMIH004.Visible = true; + this.colMIH004.VisibleIndex = 7; + this.colPAA002.Caption = "浣滀笟浜哄憳"; + this.colPAA002.FieldName = "PAA002"; + this.colPAA002.Name = "colPAA002"; + this.colPAA002.Visible = true; + this.colPAA002.VisibleIndex = 8; + this.colQAB015.Caption = "浣滀笟鏃堕棿"; + this.colQAB015.FieldName = "QAB015"; + this.colQAB015.MinWidth = 150; + this.colQAB015.Name = "colQAB015"; + this.colQAB015.Visible = true; + this.colQAB015.VisibleIndex = 9; + this.colQAB015.Width = 150; + this.colQAB025.Caption = "瀹為檯閲嶉噺"; + this.colQAB025.FieldName = "QAB025"; + this.colQAB025.Name = "colQAB025"; + this.colQAB025.Visible = true; + this.colQAB025.VisibleIndex = 10; + this.colMCA022.Caption = "閲嶉噺涓嬮檺"; + this.colMCA022.FieldName = "MCA022"; + this.colMCA022.Name = "colMCA022"; + this.colMCA022.Visible = true; + this.colMCA022.VisibleIndex = 11; + this.colMCA023.Caption = "閲嶉噺涓婇檺"; + this.colMCA023.FieldName = "MCA023"; + this.colMCA023.Name = "colMCA023"; + this.colMCA023.Visible = true; + this.colMCA023.VisibleIndex = 12; + this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1; + // this.notifyIcon1.Icon = (Icon)componentResourceManager.GetObject("notifyIcon1.Icon"); + this.notifyIcon1.Text = "鎶�鐮旀柊闃虫柊鎶�鐢靛瓙鏈夐檺鍏徃"; + this.notifyIcon1.Visible = true; + this.contextMenuStrip1.ImageScalingSize = new Size(20, 20); + this.contextMenuStrip1.Items.AddRange(new ToolStripItem[2] + { + (ToolStripItem) this.showInTaskbar, + (ToolStripItem) this.exitWindow + }); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new Size(109, 52); + this.showInTaskbar.Name = "showInTaskbar"; + this.showInTaskbar.Size = new Size(108, 24); + this.showInTaskbar.Text = "鏄剧ず"; + this.exitWindow.Name = "exitWindow"; + this.exitWindow.Size = new Size(108, 24); + this.exitWindow.Text = "閫�鍑�"; + this.timer1.Interval = 10000; + this.AutoScaleDimensions = new SizeF(8f, 15f); + this.AutoScaleMode = AutoScaleMode.Font; + this.ClientSize = new Size(859, 391); + this.Controls.Add((Control)this.splitContainerControl1); + this.Margin = new Padding(4, 4, 4, 4); + this.Name = nameof(WeightIqc); + this.Text = "绉伴噸鍙栨暟"; + this.FormClosing += new FormClosingEventHandler(this.Form1_FormClosing); + this.Load += new EventHandler(this.Form1_Load); + this.splitContainerControl1.EndInit(); + this.splitContainerControl1.ResumeLayout(false); + this.txtNum.Properties.EndInit(); + this.cmbSerialPortNum.Properties.EndInit(); + this.cmbBaudRate.Properties.EndInit(); + this.gridWOMQAB.EndInit(); + this.viewWOMQAB.EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + } + + public delegate void HandleInterfaceUpdataDelegate(string text); + + /// <summary> + /// 涓婁紶绉伴噸鏁版嵁 + /// </summary> + /// <param name="_realWeight">鎴彇鍚庣殑鏁伴噺</param> + /// <param name="_realWeightTxt">鍘熷瓙涓�</param> + private void addModel(string _realWeight, string _realWeightTxt) + { + string _lineId = "0"; + var _obj = new + { + lineId = _lineId, + realWeight = _realWeight.Trim(), + realWeightTxt = _realWeightTxt.Trim(), + }; + try + { + string strJson = UtilityHelper.HttpPost("", "WorkWeight/EditModel", JsonConvert.SerializeObject(_obj)); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode <= 0) + { + LoggerHelper.WriteInfoLog("WorkWeight/EditModel:" + strJson); + } + } + catch (Exception ex) + { + LoggerHelper.WriteInfoLog(ex.Message); + } + } + } +} \ No newline at end of file diff --git a/DevApp/Gs.DevApp/Gs.DevApp.csproj b/DevApp/Gs.DevApp/Gs.DevApp.csproj index 80fdde8..92c2d08 100644 --- a/DevApp/Gs.DevApp/Gs.DevApp.csproj +++ b/DevApp/Gs.DevApp/Gs.DevApp.csproj @@ -662,6 +662,12 @@ <Compile Include="DevFrm\QC\Models\MesQmCheckitemDt.cs" /> <Compile Include="DevFrm\QC\Models\MesSysLookups.cs" /> <Compile Include="DevFrm\QC\Models\MesSysLookupTypes.cs" /> + <Compile Include="DevFrm\QC\WeightIqc.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="DevFrm\QC\WeightIqc.Designer.cs"> + <DependentUpon>WeightIqc.cs</DependentUpon> + </Compile> <Compile Include="DevFrm\QC\Xls.cs"> <SubType>Form</SubType> </Compile> diff --git a/DevApp/Gs.DevApp/UserControl/UcToolBarMenu.cs b/DevApp/Gs.DevApp/UserControl/UcToolBarMenu.cs index c429e15..26e02be 100644 --- a/DevApp/Gs.DevApp/UserControl/UcToolBarMenu.cs +++ b/DevApp/Gs.DevApp/UserControl/UcToolBarMenu.cs @@ -3,6 +3,7 @@ using DevExpress.XtraGrid; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraLayout; +using Gs.DevApp.DevFrm.QC; using Gs.DevApp.DevFrm.Rpt; using Gs.DevApp.DevFrm.Sys; using Gs.DevApp.DevFrm.Work; @@ -71,7 +72,7 @@ actions = lst; } - + /// <summary> /// 鍚姩绉伴噸 @@ -84,16 +85,19 @@ bool isOpen = false; foreach (Form form in Application.OpenForms) { - if (form is Frm_Work09) + if (form is WeightIqc) { isOpen = true; - form.Activate(); // 婵�娲诲凡瀛樺湪鐨勭獥浣� + //form.Activate(); // 婵�娲诲凡瀛樺湪鐨勭獥浣� + //form.MaximizeBox = true; + //form.TopMost = true; + MsgHelper.ShowInformation("宸茬粡鎵撳紑浜嗭紝璇峰嬁閲嶅鎵撳紑锛�"); break; } } if (!isOpen) { - var form = new Frm_Work09(QcSeason.iqc绉伴噸.ToString()); + var form = new WeightIqc(); form.Show(); } } @@ -460,7 +464,7 @@ lst.Add(btnShouHouFchk.Name); lst.Add(btnGongZi.Name); lst.Add(btnLianBan.Name); - // lst.Add(btnEsc.Name); + // lst.Add(btnEsc.Name); lst.Add(btnGx.Name); lst.Add(btnWeight.Name); _enabledBtn(lst); @@ -513,7 +517,7 @@ lst.Add(btnOut.Name); lst.Add(btnGongZi.Name); lst.Add(btnLianBan.Name); - // lst.Add(btnEsc.Name); + // lst.Add(btnEsc.Name); lst.Add(btnGx.Name); lst.Add(btnWeight.Name); _enabledBtn(lst); -- Gitblit v1.9.3