Browse Source

修改电子秤对接

callm 4 years ago
parent
commit
50ab1a1962

+ 2 - 0
UAS_MES_PW/Entity/SystemInf.cs

@@ -57,6 +57,8 @@ namespace UAS_MES_NEW.Entity
         /// 是否允许打印程序
         /// </summary>
         public static bool EnablePrint;
+
+        public static string IP;
         /// <summary>
         /// 缓存数据的文件夹
         /// </summary>

+ 20 - 27
UAS_MES_PW/FunctionCode/Make/Make_ColorBoxWeigh.Designer.cs

@@ -34,8 +34,8 @@
             this.pr_code_label = new System.Windows.Forms.Label();
             this.pr_colorboxunit = new System.Windows.Forms.Label();
             this.weight_label = new System.Windows.Forms.Label();
-            this.weight = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.panel4 = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.weight = new System.Windows.Forms.Label();
             this.label15 = new System.Windows.Forms.Label();
             this.pr_detail_label = new System.Windows.Forms.Label();
             this.ma_qty_label = new System.Windows.Forms.Label();
@@ -141,30 +141,12 @@
             this.weight_label.Text = "重量";
             this.weight_label.Visible = false;
             // 
-            // weight
-            // 
-            this.weight.AllPower = null;
-            this.weight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.weight.BackColor = System.Drawing.Color.White;
-            this.weight.Font = new System.Drawing.Font("微软雅黑", 35F);
-            this.weight.ForeColor = System.Drawing.Color.Green;
-            this.weight.ID = null;
-            this.weight.Location = new System.Drawing.Point(263, 214);
-            this.weight.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.weight.Name = "weight";
-            this.weight.Power = null;
-            this.weight.Size = new System.Drawing.Size(345, 131);
-            this.weight.Str = null;
-            this.weight.Str1 = null;
-            this.weight.Str2 = null;
-            this.weight.TabIndex = 41;
-            // 
             // panel4
             // 
             this.panel4.BorderColor = System.Drawing.Color.Black;
+            this.panel4.Controls.Add(this.weight);
             this.panel4.Controls.Add(this.pr_colorboxunit);
             this.panel4.Controls.Add(this.weight_label);
-            this.panel4.Controls.Add(this.weight);
             this.panel4.Font = new System.Drawing.Font("微软雅黑", 12F);
             this.panel4.Location = new System.Drawing.Point(32, 156);
             this.panel4.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
@@ -175,6 +157,17 @@
             this.panel4.Text = "重量";
             this.panel4.TextColor = System.Drawing.Color.Black;
             // 
+            // weight
+            // 
+            this.weight.AutoSize = true;
+            this.weight.Font = new System.Drawing.Font("微软雅黑", 40F);
+            this.weight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
+            this.weight.Location = new System.Drawing.Point(148, 100);
+            this.weight.Name = "weight";
+            this.weight.Size = new System.Drawing.Size(249, 140);
+            this.weight.TabIndex = 43;
+            this.weight.Text = "";
+            // 
             // label15
             // 
             this.label15.AutoSize = true;
@@ -489,7 +482,7 @@
             // 
             this.ob_checkno_label.AutoSize = true;
             this.ob_checkno_label.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_checkno_label.Location = new System.Drawing.Point(45, 151);
+            this.ob_checkno_label.Location = new System.Drawing.Point(47, 153);
             this.ob_checkno_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_checkno_label.Name = "ob_checkno_label";
             this.ob_checkno_label.Size = new System.Drawing.Size(160, 46);
@@ -500,7 +493,7 @@
             // 
             this.ob_checkno.AutoSize = true;
             this.ob_checkno.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_checkno.Location = new System.Drawing.Point(233, 151);
+            this.ob_checkno.Location = new System.Drawing.Point(235, 153);
             this.ob_checkno.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_checkno.Name = "ob_checkno";
             this.ob_checkno.Size = new System.Drawing.Size(0, 46);
@@ -511,7 +504,7 @@
             // 
             this.ob_nowcheckqty.AutoSize = true;
             this.ob_nowcheckqty.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_nowcheckqty.Location = new System.Drawing.Point(583, 59);
+            this.ob_nowcheckqty.Location = new System.Drawing.Point(585, 61);
             this.ob_nowcheckqty.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_nowcheckqty.Name = "ob_nowcheckqty";
             this.ob_nowcheckqty.Size = new System.Drawing.Size(0, 46);
@@ -521,7 +514,7 @@
             // 
             this.ob_batchqty.AutoSize = true;
             this.ob_batchqty.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_batchqty.Location = new System.Drawing.Point(233, 59);
+            this.ob_batchqty.Location = new System.Drawing.Point(235, 61);
             this.ob_batchqty.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_batchqty.Name = "ob_batchqty";
             this.ob_batchqty.Size = new System.Drawing.Size(0, 46);
@@ -531,7 +524,7 @@
             // 
             this.ob_nowcheckqty_label.AutoSize = true;
             this.ob_nowcheckqty_label.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_nowcheckqty_label.Location = new System.Drawing.Point(395, 59);
+            this.ob_nowcheckqty_label.Location = new System.Drawing.Point(397, 61);
             this.ob_nowcheckqty_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_nowcheckqty_label.Name = "ob_nowcheckqty_label";
             this.ob_nowcheckqty_label.Size = new System.Drawing.Size(160, 46);
@@ -542,7 +535,7 @@
             // 
             this.ob_batchqty_label.AutoSize = true;
             this.ob_batchqty_label.Font = new System.Drawing.Font("微软雅黑", 13F);
-            this.ob_batchqty_label.Location = new System.Drawing.Point(45, 59);
+            this.ob_batchqty_label.Location = new System.Drawing.Point(47, 61);
             this.ob_batchqty_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ob_batchqty_label.Name = "ob_batchqty_label";
             this.ob_batchqty_label.Size = new System.Drawing.Size(160, 46);
@@ -888,7 +881,6 @@
         private System.Windows.Forms.Label pr_code_label;
         private System.Windows.Forms.Label pr_colorboxunit;
         private System.Windows.Forms.Label weight_label;
-        private CustomControl.TextBoxWithIcon.SnCollectionBox weight;
         private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder panel4;
         private System.Windows.Forms.Label label15;
         private System.Windows.Forms.Label pr_detail_label;
@@ -938,5 +930,6 @@
         public System.Windows.Forms.Label ob_checkno;
         private CustomControl.CustomCheckBox.LockCheckBox LockMakeCode;
         private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
+        private System.Windows.Forms.Label weight;
     }
 }

+ 79 - 66
UAS_MES_PW/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -1,9 +1,7 @@
-using Microsoft.Win32;
-using System;
+using System;
 using System.Data;
 using System.IO;
 using System.IO.Ports;
-using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading;
 using System.Windows.Forms;
@@ -14,6 +12,9 @@ using System.Drawing;
 using LabelManager2;
 using UAS_MES_NEW.PublicForm;
 using System.Net.Sockets;
+using System.Collections.Generic;
+using System.Net;
+
 
 namespace UAS_MES_NEW.Make
 {
@@ -21,7 +22,6 @@ namespace UAS_MES_NEW.Make
     {
         AutoSizeFormClass asc = new AutoSizeFormClass();
         ApplicationClass lbl;
-        Document doc;
         DataHelper dh;
         DataTable dt;
         LogStringBuilder sql = new LogStringBuilder();
@@ -37,7 +37,6 @@ namespace UAS_MES_NEW.Make
         //是否通过串口获取数据
         bool GetData = true;
         string LastSncode;
-        bool WeightChange = false;
 
         DataTable Dbfind;
 
@@ -47,7 +46,6 @@ namespace UAS_MES_NEW.Make
 
         Thread InitPrint;
 
-        System.DateTime[] indate;
         private bool AutoCut;
 
         public Make_ColorBoxWeigh()
@@ -108,7 +106,7 @@ namespace UAS_MES_NEW.Make
                 lbl = new ApplicationClass();
                 BaseUtil.WriteLbl();
             }
-            catch (Exception ex)
+            catch (Exception)
             {
                 OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
             }
@@ -162,11 +160,6 @@ namespace UAS_MES_NEW.Make
                             else
                                 pr_colorboxgw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_colorboxunit"].ToString();
 
-                            //如果未打开串口设置为0
-                            //if (pr_colorboxunit.Text == "kg" && !WeightChange)
-                            //{
-                            //    WeightChange = true;
-                            //}
                             //重量信息若需要检测则必须符合检测要求才更新
                             double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Replace("g", "").Trim());
                             if (PR_CHECKCOLORBOXW != "0")
@@ -290,6 +283,7 @@ namespace UAS_MES_NEW.Make
             BaseUtil.ClosePrint(lbl);
             StopWeight.PerformClick();
             InitPrint.Abort();
+            socConnection.Close();
             if (serialPort1.IsOpen)
             {
                 GetData = false;
@@ -304,7 +298,6 @@ namespace UAS_MES_NEW.Make
         {
             if (PrintLabel.Items.Count != 0)
             {
-                //doc = lbl.Documents.Open(PrintLabel.Text);
                 string oErrorMessage;
                 if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sncode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "彩盒标", "0", out oErrorMessage))
                 {
@@ -317,78 +310,98 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        TcpClient client;
-        NetworkStream ns;
-        Thread receiveThread;
+        Thread threadWatch = null; //负责监听客户端的线程
+        Socket socketWatch = null; //负责监听客户端的套接字
+        Socket socConnection;
 
         private void StartWeight_Click(object sender, EventArgs e)
         {
-            if (!SystemInf.OpenByNet)
+            try
             {
-                thread = new Thread(getSerialData);
-                try
-                {
-                    serialPort1.PortName = ComList.Text;
-                    serialPort1.BaudRate = int.Parse(BaudRate.Text);
-                    serialPort1.Open();
-                    GetData = true;
-                    thread.Start();
-                }
-                catch (Exception mes)
-                {
-                    if (BaudRate.Text == "" || ComList.Text == "")
-                        OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
-                    else
-                        OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
-                }
+                //定义一个套接字用于监听客户端发来的信息  包含3个参数(IP4寻址协议,流式连接,TCP协议)
+                socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+                //服务端发送信息 需要1个IP地址和端口号
+                IPAddress ipaddress = IPAddress.Parse("192.168.1.4");
+                //将IP地址和端口号绑定到网络节点endpoint上 
+                IPEndPoint endpoint = new IPEndPoint(ipaddress, int.Parse("2000"));
+                //监听绑定的网络节点
+                socketWatch.Bind(endpoint);
+                //将套接字的监听队列长度限制为20
+                socketWatch.Listen(20);
+                //创建一个监听线程 
+                threadWatch = new Thread(WatchConnecting);
+                //将窗体线程设置为与后台同步
+                threadWatch.IsBackground = true;
+                //启动线程
+                threadWatch.Start();
             }
-            else
+            catch (Exception ex)
             {
-                client = new TcpClient();
-                client.Connect("192.168.56.1", 8001);
-                if (client != null)
-                {
-                    ns = client.GetStream();
-                    Control.CheckForIllegalCrossThreadCalls = false;
-                    //实例化并启动接受消息线程  
-                    receiveThread = new Thread(receive_message);
-                    receiveThread.Start();
-                }
+                MessageBox.Show(ex.Message);
             }
         }
 
-        private void receive_message()
+        private void WatchConnecting()
         {
-            while (IsOnline(client))
+            socConnection = socketWatch.Accept();
+            while (socConnection.Connected)  //持续不断监听客户端发来的请求
             {
-                //try
-                //{
-                //创建接收数据的字节流  
-                byte[] getData = new byte[1024];
-                //从网络流中读取数据  
-                ns.Read(getData, 0, getData.Length);
-                //将字节数组转换成文本形式  
-                string getMsg = Encoding.Default.GetString(getData);
-                weight.Text = getMsg;
+                Thread.Sleep(100);
+                byte[] data = new byte[1024];
+                socConnection.Receive(data);
+                List<byte> arr = new List<byte>();
+                byte[] byteTemp = new byte[4];
+                byteTemp[3] = Convert.ToByte("00", 16);
+                byteTemp[2] = Convert.ToByte("00", 16);
+                byteTemp[1] = Convert.ToByte("00", 16);
+                byteTemp[0] = Convert.ToByte("00", 16);
+                for (int i = 0; i < 10; i++)
+                {
+                    if (data[i].ToString() == "0")
+                        continue;
+                    arr.Add(data[i]);
+                }
+                for (int i = 0; i < arr.Count; i++)
+                {
+                    switch (i)
+                    {
+                        case 0:
+                            byteTemp[3] = arr.ToArray()[0];
+                            break;
+                        case 1:
+                            byteTemp[2] = arr.ToArray()[1];
+                            break;
+                        case 2:
+                            byteTemp[1] = arr.ToArray()[2];
+                            break;
+                        case 3:
+                            byteTemp[0] = arr.ToArray()[3];
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                float fTemp = BitConverter.ToSingle(byteTemp, 0);
+                if (fTemp.ToString().Length > 5)
+                    weight.Text = fTemp.ToString().Substring(0, 5);
+                else
+                    weight.Text = fTemp.ToString();
             }
         }
 
-        public bool IsOnline(TcpClient c)
-        {
-            return !((c.Client.Poll(1000, SelectMode.SelectRead) && (c.Client.Available == 0)) || !c.Client.Connected);
-        }
 
 
 
         private void StopWeight_Click(object sender, EventArgs e)
         {
-            if (serialPort1.IsOpen)
-            {
-                GetData = false;
-                serialPort1.Close();
-                SystemInf.OpenPort.Remove(serialPort1.PortName);
-                thread.Abort();
-            }
+            socketWatch.Close();
+            //if (serialPort1.IsOpen)
+            //{
+            //    GetData = false;
+            //    serialPort1.Close();
+            //    SystemInf.OpenPort.Remove(serialPort1.PortName);
+            //    thread.Abort();
+            //}
         }
 
         private void pr_code_TextChanged(object sender, EventArgs e)

+ 16 - 22
UAS_MES_PW/FunctionCode/Packing/Packing_PalletWightCollection.Designer.cs

@@ -52,9 +52,9 @@
             this.OutBoxLength_label = new System.Windows.Forms.Label();
             this.PalletPreFix_label = new System.Windows.Forms.Label();
             this.panel4 = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.weight = new System.Windows.Forms.Label();
             this.pr_colorboxunit = new System.Windows.Forms.Label();
             this.weight_label = new System.Windows.Forms.Label();
-            this.weight = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.ComList = new System.Windows.Forms.Label();
             this.BaudRate = new System.Windows.Forms.Label();
             this.pr_colorboxgw_label = new System.Windows.Forms.Label();
@@ -324,9 +324,9 @@
             // panel4
             // 
             this.panel4.BorderColor = System.Drawing.Color.Black;
+            this.panel4.Controls.Add(this.weight);
             this.panel4.Controls.Add(this.pr_colorboxunit);
             this.panel4.Controls.Add(this.weight_label);
-            this.panel4.Controls.Add(this.weight);
             this.panel4.Font = new System.Drawing.Font("微软雅黑", 12F);
             this.panel4.Location = new System.Drawing.Point(1184, 328);
             this.panel4.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
@@ -338,13 +338,24 @@
             this.panel4.Text = "重量";
             this.panel4.TextColor = System.Drawing.Color.Black;
             // 
+            // weight
+            // 
+            this.weight.AutoSize = true;
+            this.weight.Font = new System.Drawing.Font("微软雅黑", 40F);
+            this.weight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
+            this.weight.Location = new System.Drawing.Point(181, 101);
+            this.weight.Name = "weight";
+            this.weight.Size = new System.Drawing.Size(367, 140);
+            this.weight.TabIndex = 43;
+            this.weight.Text = "";
+            // 
             // pr_colorboxunit
             // 
             this.pr_colorboxunit.AutoSize = true;
             this.pr_colorboxunit.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
             this.pr_colorboxunit.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.pr_colorboxunit.ForeColor = System.Drawing.SystemColors.ControlLightLight;
-            this.pr_colorboxunit.Location = new System.Drawing.Point(32, 196);
+            this.pr_colorboxunit.Location = new System.Drawing.Point(35, 199);
             this.pr_colorboxunit.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.pr_colorboxunit.Name = "pr_colorboxunit";
             this.pr_colorboxunit.Size = new System.Drawing.Size(60, 50);
@@ -358,7 +369,7 @@
             this.weight_label.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
             this.weight_label.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.weight_label.ForeColor = System.Drawing.SystemColors.ControlLightLight;
-            this.weight_label.Location = new System.Drawing.Point(32, 98);
+            this.weight_label.Location = new System.Drawing.Point(35, 101);
             this.weight_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.weight_label.Name = "weight_label";
             this.weight_label.Size = new System.Drawing.Size(98, 50);
@@ -366,23 +377,6 @@
             this.weight_label.Text = "重量";
             this.weight_label.Visible = false;
             // 
-            // weight
-            // 
-            this.weight.AllPower = null;
-            this.weight.BackColor = System.Drawing.Color.White;
-            this.weight.Font = new System.Drawing.Font("微软雅黑", 35F);
-            this.weight.ForeColor = System.Drawing.Color.Green;
-            this.weight.ID = null;
-            this.weight.Location = new System.Drawing.Point(162, 60);
-            this.weight.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.weight.Name = "weight";
-            this.weight.Power = null;
-            this.weight.Size = new System.Drawing.Size(306, 131);
-            this.weight.Str = null;
-            this.weight.Str1 = null;
-            this.weight.Str2 = null;
-            this.weight.TabIndex = 41;
-            // 
             // ComList
             // 
             this.ComList.AutoSize = true;
@@ -984,7 +978,6 @@
         private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder panel4;
         private System.Windows.Forms.Label pr_colorboxunit;
         private System.Windows.Forms.Label weight_label;
-        private CustomControl.TextBoxWithIcon.SnCollectionBox weight;
         private System.Windows.Forms.Label ComList;
         private System.Windows.Forms.Label BaudRate;
         private CustomControl.ButtonUtil.NormalButton StopWeight;
@@ -994,5 +987,6 @@
         private CustomControl.ValueLabel.ValueLabel ma_code;
         private CustomControl.ValueLabel.ValueLabel pr_code;
         private CustomControl.ButtonUtil.NormalButton RefreshWeigh;
+        private System.Windows.Forms.Label weight;
     }
 }

+ 72 - 10
UAS_MES_PW/FunctionCode/Packing/Packing_PalletWightCollection.cs

@@ -13,6 +13,8 @@ using UAS_MES_NEW.PublicForm;
 using UAS_MES_NEW.PublicMethod;
 using UAS_MES_NEW.Packing;
 using Seagull.BarTender.Print;
+using System.Net.Sockets;
+using System.Net;
 
 namespace UAS_MES_NEW.Packing
 {
@@ -702,23 +704,83 @@ namespace UAS_MES_NEW.Packing
             }
         }
 
+
+        Thread threadWatch = null; //负责监听客户端的线程
+        Socket socketWatch = null; //负责监听客户端的套接字
+        Socket socConnection;
+
         private void StartWeight_Click(object sender, EventArgs e)
         {
-            thread = new Thread(getSerialData);
             try
             {
-                GetData = true;
-                serialPort1.PortName = this.ComList.Text;
-                serialPort1.BaudRate = int.Parse(BaudRate.Text);
-                serialPort1.Open();
-                thread.Start();
+                //定义一个套接字用于监听客户端发来的信息  包含3个参数(IP4寻址协议,流式连接,TCP协议)
+                socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+                //服务端发送信息 需要1个IP地址和端口号
+                IPAddress ipaddress = IPAddress.Parse("192.168.1.4");
+                //将IP地址和端口号绑定到网络节点endpoint上 
+                IPEndPoint endpoint = new IPEndPoint(ipaddress, int.Parse("2000"));
+                //监听绑定的网络节点
+                socketWatch.Bind(endpoint);
+                //将套接字的监听队列长度限制为20
+                socketWatch.Listen(20);
+                //创建一个监听线程 
+                threadWatch = new Thread(WatchConnecting);
+                //将窗体线程设置为与后台同步
+                threadWatch.IsBackground = true;
+                //启动线程
+                threadWatch.Start();
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
             }
-            catch (Exception mes)
+        }
+
+        private void WatchConnecting()
+        {
+            socConnection = socketWatch.Accept();
+            while (socConnection.Connected)  //持续不断监听客户端发来的请求
             {
-                if (BaudRate.Text == "" || ComList.Text == "")
-                    OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
+                Thread.Sleep(100);
+                byte[] data = new byte[1024];
+                socConnection.Receive(data);
+                List<byte> arr = new List<byte>();
+                byte[] byteTemp = new byte[4];
+                byteTemp[3] = Convert.ToByte("00", 16);
+                byteTemp[2] = Convert.ToByte("00", 16);
+                byteTemp[1] = Convert.ToByte("00", 16);
+                byteTemp[0] = Convert.ToByte("00", 16);
+                for (int i = 0; i < 10; i++)
+                {
+                    if (data[i].ToString() == "0")
+                        continue;
+                    arr.Add(data[i]);
+                }
+                for (int i = 0; i < arr.Count; i++)
+                {
+                    switch (i)
+                    {
+                        case 0:
+                            byteTemp[3] = arr.ToArray()[0];
+                            break;
+                        case 1:
+                            byteTemp[2] = arr.ToArray()[1];
+                            break;
+                        case 2:
+                            byteTemp[1] = arr.ToArray()[2];
+                            break;
+                        case 3:
+                            byteTemp[0] = arr.ToArray()[3];
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                float fTemp = BitConverter.ToSingle(byteTemp, 0);
+                if (fTemp.ToString().Length > 5)
+                    weight.Text = fTemp.ToString().Substring(0, 5);
                 else
-                    OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
+                    weight.Text = fTemp.ToString();
             }
         }
 

+ 15 - 0
UAS_MES_PW/FunctionCode/Packing/Packing_PalletWightCollection.resx

@@ -1181,4 +1181,19 @@
   <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="pd_outboxcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pd_innerqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>