From e254696c0b579c24481e26355e46af3727a5b123 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期四, 22 五月 2025 07:59:16 +0800
Subject: [PATCH] 称重
---
DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.cs | 90 ++++++++++------------
DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.Designer.cs | 127 ++++++++++++++++---------------
2 files changed, 107 insertions(+), 110 deletions(-)
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.Designer.cs b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.Designer.cs
index f6f0826..49f9df9 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.Designer.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.Designer.cs
@@ -44,14 +44,15 @@
this.comSjw = new DevExpress.XtraEditors.ComboBoxEdit();
this.comStopBits = new DevExpress.XtraEditors.ComboBoxEdit();
this.comParity = new DevExpress.XtraEditors.ComboBoxEdit();
+ this.txtMsg = new DevExpress.XtraEditors.MemoEdit();
this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
this.cmbBaudRate1111 = new DevExpress.XtraLayout.LayoutControlItem();
- this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem7 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem9 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
+ this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
this.gcMx1 = new DevExpress.XtraGrid.GridControl();
this.gvMx1 = new DevExpress.XtraGrid.Views.Grid.GridView();
this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -66,9 +67,8 @@
this.gridColumn11 = new DevExpress.XtraGrid.Columns.GridColumn();
this.gridColumn12 = new DevExpress.XtraGrid.Columns.GridColumn();
this.gridColumn13 = new DevExpress.XtraGrid.Columns.GridColumn();
- this.txtMsg = new DevExpress.XtraEditors.LabelControl();
this.layoutControlItem5 = new DevExpress.XtraLayout.LayoutControlItem();
- this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
+ this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
((System.ComponentModel.ISupportInitialize)(this.split1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.split1.Panel1)).BeginInit();
this.split1.Panel1.SuspendLayout();
@@ -83,18 +83,19 @@
((System.ComponentModel.ISupportInitialize)(this.comSjw.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.comStopBits.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.comParity.Properties)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.txtMsg.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cmbBaudRate1111)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gcMx1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gvMx1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
this.SuspendLayout();
//
// split1
@@ -113,13 +114,13 @@
//
this.split1.Panel2.Controls.Add(this.gcMx1);
this.split1.Panel2.Text = "Panel2";
+ this.split1.ShowSplitGlyph = DevExpress.Utils.DefaultBoolean.True;
this.split1.Size = new System.Drawing.Size(1040, 511);
- this.split1.SplitterPosition = 109;
+ this.split1.SplitterPosition = 110;
this.split1.TabIndex = 1;
//
// layoutMx1
//
- this.layoutMx1.Controls.Add(this.txtMsg);
this.layoutMx1.Controls.Add(this.comLine);
this.layoutMx1.Controls.Add(this.btnStart);
this.layoutMx1.Controls.Add(this.cmbSerialPortNum);
@@ -128,6 +129,7 @@
this.layoutMx1.Controls.Add(this.comSjw);
this.layoutMx1.Controls.Add(this.comStopBits);
this.layoutMx1.Controls.Add(this.comParity);
+ this.layoutMx1.Controls.Add(this.txtMsg);
this.layoutMx1.Dock = System.Windows.Forms.DockStyle.Fill;
this.layoutMx1.HiddenItems.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
this.layoutControlItem5});
@@ -135,14 +137,14 @@
this.layoutMx1.Name = "layoutMx1";
this.layoutMx1.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(310, 455, 812, 500);
this.layoutMx1.Root = this.Root;
- this.layoutMx1.Size = new System.Drawing.Size(1040, 109);
+ this.layoutMx1.Size = new System.Drawing.Size(1040, 110);
this.layoutMx1.TabIndex = 0;
this.layoutMx1.Text = "dataLayoutControl1";
//
// comLine
//
this.comLine.IsReadly = false;
- this.comLine.Location = new System.Drawing.Point(94, 12);
+ this.comLine.Location = new System.Drawing.Point(94, 9);
this.comLine.Name = "comLine";
this.comLine.Size = new System.Drawing.Size(164, 24);
this.comLine.TabIndex = 14;
@@ -152,7 +154,7 @@
this.btnStart.Appearance.BackColor = DevExpress.LookAndFeel.DXSkinColors.FillColors.Question;
this.btnStart.Appearance.Options.UseBackColor = true;
this.btnStart.Appearance.Options.UseFont = true;
- this.btnStart.Location = new System.Drawing.Point(512, 12);
+ this.btnStart.Location = new System.Drawing.Point(512, 9);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(246, 27);
this.btnStart.StyleController = this.layoutMx1;
@@ -162,7 +164,7 @@
//
// cmbSerialPortNum
//
- this.cmbSerialPortNum.Location = new System.Drawing.Point(344, 12);
+ this.cmbSerialPortNum.Location = new System.Drawing.Point(344, 9);
this.cmbSerialPortNum.Name = "cmbSerialPortNum";
this.cmbSerialPortNum.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@@ -175,7 +177,7 @@
// cmbBaudRate
//
this.cmbBaudRate.EditValue = "9600";
- this.cmbBaudRate.Location = new System.Drawing.Point(344, 43);
+ this.cmbBaudRate.Location = new System.Drawing.Point(344, 40);
this.cmbBaudRate.Name = "cmbBaudRate";
this.cmbBaudRate.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@@ -193,7 +195,7 @@
//
// txtNum
//
- this.txtNum.Location = new System.Drawing.Point(594, 53);
+ this.txtNum.Location = new System.Drawing.Point(594, 50);
this.txtNum.Name = "txtNum";
this.txtNum.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 15F);
this.txtNum.Properties.Appearance.Options.UseFont = true;
@@ -205,7 +207,7 @@
// comSjw
//
this.comSjw.EditValue = "8";
- this.comSjw.Location = new System.Drawing.Point(94, 43);
+ this.comSjw.Location = new System.Drawing.Point(94, 40);
this.comSjw.Name = "comSjw";
this.comSjw.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@@ -223,7 +225,7 @@
// comStopBits
//
this.comStopBits.EditValue = "1";
- this.comStopBits.Location = new System.Drawing.Point(344, 74);
+ this.comStopBits.Location = new System.Drawing.Point(344, 71);
this.comStopBits.Name = "comStopBits";
this.comStopBits.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@@ -239,7 +241,7 @@
// comParity
//
this.comParity.EditValue = "None";
- this.comParity.Location = new System.Drawing.Point(94, 74);
+ this.comParity.Location = new System.Drawing.Point(94, 71);
this.comParity.Name = "comParity";
this.comParity.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@@ -253,19 +255,27 @@
this.comParity.StyleController = this.layoutMx1;
this.comParity.TabIndex = 13;
//
+ // txtMsg
+ //
+ this.txtMsg.Location = new System.Drawing.Point(344, 74);
+ this.txtMsg.Name = "txtMsg";
+ this.txtMsg.Size = new System.Drawing.Size(663, 27);
+ this.txtMsg.StyleController = this.layoutMx1;
+ this.txtMsg.TabIndex = 15;
+ //
// Root
//
this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
this.Root.GroupBordersVisible = false;
this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
this.cmbBaudRate1111,
- this.layoutControlItem8,
this.layoutControlItem3,
this.layoutControlItem1,
this.layoutControlItem7,
this.layoutControlItem9,
this.layoutControlItem4,
- this.layoutControlItem2});
+ this.layoutControlItem2,
+ this.layoutControlItem8});
this.Root.LayoutMode = DevExpress.XtraLayout.Utils.LayoutMode.Table;
this.Root.Name = "Root";
columnDefinition1.SizeType = System.Windows.Forms.SizeType.Absolute;
@@ -301,17 +311,6 @@
this.cmbBaudRate1111.Size = new System.Drawing.Size(250, 31);
this.cmbBaudRate1111.Text = "娉㈢壒鐜�";
this.cmbBaudRate1111.TextSize = new System.Drawing.Size(70, 18);
- //
- // layoutControlItem8
- //
- this.layoutControlItem8.Control = this.comStopBits;
- this.layoutControlItem8.Location = new System.Drawing.Point(250, 62);
- this.layoutControlItem8.Name = "layoutControlItem8";
- this.layoutControlItem8.OptionsTableLayoutItem.ColumnIndex = 1;
- this.layoutControlItem8.OptionsTableLayoutItem.RowIndex = 2;
- this.layoutControlItem8.Size = new System.Drawing.Size(250, 31);
- this.layoutControlItem8.Text = "鍋滄浣�";
- this.layoutControlItem8.TextSize = new System.Drawing.Size(70, 18);
//
// layoutControlItem3
//
@@ -368,13 +367,27 @@
this.layoutControlItem4.Text = "閲嶉噺";
this.layoutControlItem4.TextSize = new System.Drawing.Size(70, 41);
//
+ // layoutControlItem2
+ //
+ this.layoutControlItem2.Control = this.btnStart;
+ this.layoutControlItem2.Location = new System.Drawing.Point(500, 0);
+ this.layoutControlItem2.MaxSize = new System.Drawing.Size(250, 31);
+ this.layoutControlItem2.MinSize = new System.Drawing.Size(41, 31);
+ this.layoutControlItem2.Name = "layoutControlItem2";
+ this.layoutControlItem2.OptionsTableLayoutItem.ColumnIndex = 2;
+ this.layoutControlItem2.Size = new System.Drawing.Size(499, 31);
+ this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
+ this.layoutControlItem2.Text = "鍚姩";
+ this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
+ this.layoutControlItem2.TextVisible = false;
+ //
// gcMx1
//
this.gcMx1.Dock = System.Windows.Forms.DockStyle.Fill;
this.gcMx1.Location = new System.Drawing.Point(0, 0);
this.gcMx1.MainView = this.gvMx1;
this.gcMx1.Name = "gcMx1";
- this.gcMx1.Size = new System.Drawing.Size(1040, 390);
+ this.gcMx1.Size = new System.Drawing.Size(1040, 389);
this.gcMx1.TabIndex = 0;
this.gcMx1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
this.gvMx1});
@@ -517,39 +530,28 @@
this.gridColumn13.VisibleIndex = 11;
this.gridColumn13.Width = 94;
//
- // txtMsg
- //
- this.txtMsg.Location = new System.Drawing.Point(512, 12);
- this.txtMsg.Name = "txtMsg";
- this.txtMsg.Size = new System.Drawing.Size(37, 18);
- this.txtMsg.StyleController = this.layoutMx1;
- this.txtMsg.TabIndex = 15;
- this.txtMsg.Text = "lbMsg";
- //
// layoutControlItem5
//
this.layoutControlItem5.Control = this.txtMsg;
- this.layoutControlItem5.Location = new System.Drawing.Point(500, 0);
+ this.layoutControlItem5.Location = new System.Drawing.Point(250, 62);
this.layoutControlItem5.Name = "layoutControlItem5";
- this.layoutControlItem5.OptionsTableLayoutItem.ColumnIndex = 2;
- this.layoutControlItem5.Size = new System.Drawing.Size(520, 29);
- this.layoutControlItem5.Text = "lbMsg";
- this.layoutControlItem5.TextSize = new System.Drawing.Size(0, 0);
- this.layoutControlItem5.TextVisible = false;
+ this.layoutControlItem5.OptionsTableLayoutItem.ColumnIndex = 1;
+ this.layoutControlItem5.OptionsTableLayoutItem.ColumnSpan = 2;
+ this.layoutControlItem5.OptionsTableLayoutItem.RowIndex = 2;
+ this.layoutControlItem5.Size = new System.Drawing.Size(749, 31);
+ this.layoutControlItem5.Text = "鏀跺垪琛�";
+ this.layoutControlItem5.TextSize = new System.Drawing.Size(70, 18);
//
- // layoutControlItem2
+ // layoutControlItem8
//
- this.layoutControlItem2.Control = this.btnStart;
- this.layoutControlItem2.Location = new System.Drawing.Point(500, 0);
- this.layoutControlItem2.MaxSize = new System.Drawing.Size(250, 31);
- this.layoutControlItem2.MinSize = new System.Drawing.Size(41, 31);
- this.layoutControlItem2.Name = "layoutControlItem2";
- this.layoutControlItem2.OptionsTableLayoutItem.ColumnIndex = 2;
- this.layoutControlItem2.Size = new System.Drawing.Size(499, 31);
- this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
- this.layoutControlItem2.Text = "鍚姩";
- this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
- this.layoutControlItem2.TextVisible = false;
+ this.layoutControlItem8.Control = this.comStopBits;
+ this.layoutControlItem8.Location = new System.Drawing.Point(250, 62);
+ this.layoutControlItem8.Name = "layoutControlItem8";
+ this.layoutControlItem8.OptionsTableLayoutItem.ColumnIndex = 1;
+ this.layoutControlItem8.OptionsTableLayoutItem.RowIndex = 2;
+ this.layoutControlItem8.Size = new System.Drawing.Size(250, 31);
+ this.layoutControlItem8.Text = "鍋滄浣�";
+ this.layoutControlItem8.TextSize = new System.Drawing.Size(70, 18);
//
// Frm_Work09
//
@@ -575,18 +577,19 @@
((System.ComponentModel.ISupportInitialize)(this.comSjw.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.comStopBits.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.comParity.Properties)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.txtMsg.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cmbBaudRate1111)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gcMx1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gvMx1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
this.ResumeLayout(false);
}
@@ -602,7 +605,6 @@
private DevExpress.XtraEditors.ComboBoxEdit comStopBits;
private DevExpress.XtraEditors.ComboBoxEdit comParity;
private DevExpress.XtraLayout.LayoutControlItem cmbBaudRate1111;
- private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
private DevExpress.XtraEditors.SimpleButton btnStart;
private DevExpress.XtraGrid.GridControl gcMx1;
private DevExpress.XtraGrid.Views.Grid.GridView gvMx1;
@@ -624,8 +626,9 @@
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem7;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem9;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
- private DevExpress.XtraEditors.LabelControl txtMsg;
- private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
+ private DevExpress.XtraEditors.MemoEdit txtMsg;
+ private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
+ private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
}
}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.cs b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.cs
index acd0cb6..b5d95cc 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work09.cs
@@ -1,6 +1,8 @@
锘縰sing System;
using System.Collections.Generic;
using System.IO.Ports;
+using System.Linq;
+using System.Threading;
using System.Timers;
using System.Windows.Forms;
using Gs.DevApp.Entity;
@@ -17,17 +19,7 @@
/// 涓插彛绫�
/// </summary>
private SerialPort Sp = new SerialPort();
- /// <summary>
- /// 鏇存柊UI濮旀墭锛屽彧瀹氫箟锛屼笉瀹炵幇
- /// </summary>
- /// <param name="text"></param>
- public delegate void HandleInterfaceUpdataDelegate(string text);
- /// <summary>
- /// 鏇存柊UI濮旀墭锛屽疄鐜�
- /// </summary>
- private HandleInterfaceUpdataDelegate interfaceUpdataHandle;
-
- System.Timers.Timer timer = new System.Timers.Timer(10000); // 1000姣闂撮殧
+ System.Timers.Timer timer = new System.Timers.Timer(10000);
public Frm_Work09()
{
InitializeComponent();
@@ -44,7 +36,6 @@
GetComList();
this.comLine.getSuppler("");
Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
-
}
/// <summary>
@@ -66,6 +57,7 @@
/// <param name="e"></param>
private void btnStart_Click(object sender, EventArgs e)
{
+ Sp.DataReceived -= new SerialDataReceivedEventHandler(Sp_DataReceived);
string _comLine = comLine.GetId();
string _cmbSerialPortNum = cmbSerialPortNum.Text.Trim();
string _cmbBaudRate = cmbBaudRate.Text.Trim();
@@ -110,7 +102,6 @@
}
try
{
- interfaceUpdataHandle = new HandleInterfaceUpdataDelegate(UpdateTextBox);//瀹炰緥鍖栧鎵樺璞�
Sp.ReceivedBytesThreshold = 1;
Sp.PortName = _cmbSerialPortNum;
Sp.BaudRate = Convert.ToInt32(_cmbBaudRate);//璁剧疆娉㈢壒鐜�
@@ -131,6 +122,8 @@
Gs.DevApp.ToolBox.MsgHelper.ShowError("鏃犳硶璇嗗埆鐨勫仠姝綅");
}
Sp.DataBits = int.Parse(_comSjw); // 璁剧疆鏁版嵁浣�
+ //Sp.ReadTimeout = 500; // 璁剧疆瓒呮椂鏃堕棿锛屼緥濡�500姣
+ //Sp.ReadBufferSize = 4096; // 璁剧疆缂撳啿鍖哄ぇ灏�
Sp.DataReceived += new SerialDataReceivedEventHandler(Sp_DataReceived);
Sp.ReceivedBytesThreshold = 1;
LogHelper.Debug(this.ToString(), "鎵撳紑涓插彛閫氫俊PortName-" + Sp.PortName.ToString() + ",BaudRate-" + Sp.BaudRate.ToString() + ",StopBits-" + Sp.StopBits.ToString() + ",Parity-" + Sp.Parity.ToString());
@@ -156,15 +149,39 @@
/// <param name="e"></param>
public void Sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
- string abc = string.Empty;
+ string _tmpStr = string.Empty;
try
{
int i = Sp.BytesToRead;
if (i > 0)
{
- abc = Sp.ReadExisting();
- LogHelper.Debug(this.ToString(), $"鐩戝惉鍒版暟鎹�:{abc}");
- this.Invoke(interfaceUpdataHandle, abc);
+ _tmpStr = Sp.ReadExisting();
+ // Thread.Sleep(1000);
+ LogHelper.Debug(this.ToString(), $"鐩戝惉鍒版暟鎹紝瀛楄妭闀垮害:{i.ToString()}锛寋_tmpStr}");
+ this.BeginInvoke(new Action(() =>
+ {
+ txtMsg.AppendLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff->瀛楄妭鏁板瓧" + i.ToString() + "->") + _tmpStr);
+ //ST,GS,+ 250.2kg
+ if (_tmpStr.Length <= 0)
+ {
+ LogHelper.Debug(this.ToString(), "_tmpStr闀垮害<=0锛岄��鍑轰笂鎶�");
+ return;
+ }
+ if (!_tmpStr.Contains("ST"))
+ {
+ LogHelper.Debug(this.ToString(), "_tmpStr閲嶉噺鐘舵�佷笉涓篠T锛岄��鍑轰笂鎶�");
+ return;
+ }
+ if (!_tmpStr.Contains("+"))
+ {
+ LogHelper.Debug(this.ToString(), "_tmpStr涓嶅寘鍚噸閲�+锛岄��鍑轰笂鎶�");
+ return;
+ }
+ string[] _ary=_tmpStr.Split('+');
+ string abc = _ary.Last();//ST,GS,
+ txtNum.Text = (abc.Trim().Replace("k", "").Replace("g", "").Replace("S","").Replace("T","").Replace("G","").Replace(",",""));
+ addModel(txtNum.Text, _tmpStr);
+ }));
}
}
catch (Exception ex)
@@ -174,33 +191,7 @@
}
}
- /// <summary>
- /// 鎺ュ彈鍒版暟鎹紝寮�濮嬪鐞嗘暟鎹�
- /// </summary>
- /// <param name="text"></param>
- private void UpdateTextBox(string text)
- {
- //ST,GS,+ 250.2kg
- string _tmpStr = text.Trim();
- if (_tmpStr.Length <= 0)
- {
- LogHelper.Debug(this.ToString(), "_tmpStr闀垮害<=0锛岄��鍑轰笂鎶�");
- return;
- }
- if (!_tmpStr.Contains("ST"))
- {
- LogHelper.Debug(this.ToString(), "_tmpStr閲嶉噺鐘舵�佷笉涓篠T锛岄��鍑轰笂鎶�");
- return;
- }
- if (!_tmpStr.Contains("+"))
- {
- LogHelper.Debug(this.ToString(), "_tmpStr閲嶉噺+锛岄��鍑轰笂鎶�");
- return;
- }
- _tmpStr = _tmpStr.Substring(7);
- txtNum.Text = _tmpStr;
- addModel(_tmpStr);
- }
+
/// <summary>
/// 鍚敤鎴栫鐢�
/// </summary>
@@ -218,13 +209,16 @@
/// <summary>
/// 涓婁紶绉伴噸鏁版嵁
/// </summary>
- private void addModel(string _realWeight)
+ /// <param name="_realWeight">鎴彇鍚庣殑鏁伴噺</param>
+ /// <param name="_realWeightTxt">鍘熷瓙涓�</param>
+ private void addModel(string _realWeight, string _realWeightTxt)
{
string _lineId = comLine.GetId();
var _obj = new
{
lineId = _lineId,
- realWeight = _realWeight,
+ realWeight = _realWeight.Trim(),
+ realWeightTxt = _realWeightTxt.Trim(),
};
try
{
@@ -269,9 +263,9 @@
}
catch (Exception ex)
{
- MessageBox.Show("gvMx1:" + ex.Message);
+ Toast vm = new Toast(-1, "gvMx1:" + ex.Message);
+ vm.Show();
}
}
-
}
}
\ No newline at end of file
--
Gitblit v1.9.3