mengshunguo 1 kuukausi sitten
vanhempi
commit
084a2f06e4
1 muutettua tiedostoa jossa 22 lisäystä ja 22 poistoa
  1. 22 22
      SCADA_DAQ/Customer/UctFrmMain.xaml.cs

+ 22 - 22
SCADA_DAQ/Customer/UctFrmMain.xaml.cs

@@ -98,7 +98,7 @@ namespace SCADA_DAQ.Customer
                 return;
             }
             var _string = $"{_long}#{_wide}";
-            Log.Info(_string);
+            Log.Info($"收到条码信息{e.Barcode},发送长宽信息{_string}");
             var _byte = ASCIIEncoding.ASCII.GetBytes(_string);
             Dispatcher.Invoke(() =>
             {
@@ -108,28 +108,28 @@ namespace SCADA_DAQ.Customer
                 LongAndWide.Text = string.Join("", ASCIIEncoding.ASCII.GetString(_byte));
                 ASCIICode.Text = string.Join(" ", _byte);
             });
-            //using (var serialcomm = new SerialPort()
-            //{
-            //    PortName = CustomerEnv.CustomerConfig.SerialModel.PortName,
-            //    BaudRate = CustomerEnv.CustomerConfig.SerialModel.BaudRate,
-            //    DataBits = CustomerEnv.CustomerConfig.SerialModel.DataBits,
-            //    StopBits = CustomerEnv.CustomerConfig.SerialModel.StopBits,
-            //    Parity = CustomerEnv.CustomerConfig.SerialModel.Parity,
-            //    ReadTimeout = CustomerEnv.CustomerConfig.SerialModel.Timeout,
-            //    ReadBufferSize = 102400
-            //})
-            //{
-            //    try
-            //    {
-            //        serialcomm.Open();
-            //        serialcomm.Write(_byte, 0, _byte.Count());
-            //    }
-            //    catch
-            //    {
+            using (var serialcomm = new SerialPort()
+            {
+                PortName = CustomerEnv.CustomerConfig.SerialModel.PortName,
+                BaudRate = CustomerEnv.CustomerConfig.SerialModel.BaudRate,
+                DataBits = CustomerEnv.CustomerConfig.SerialModel.DataBits,
+                StopBits = CustomerEnv.CustomerConfig.SerialModel.StopBits,
+                Parity = CustomerEnv.CustomerConfig.SerialModel.Parity,
+                ReadTimeout = CustomerEnv.CustomerConfig.SerialModel.Timeout,
+                ReadBufferSize = 102400
+            })
+            {
+                try
+                {
+                    serialcomm.Open();
+                    serialcomm.Write(_byte, 0, _byte.Count());
+                }
+                catch
+                {
 
-            //    }
-            //    serialcomm.Dispose();
-            //}
+                }
+                serialcomm.Dispose();
+            }
         }
 
         private void MyButton_Click(object sender, OpenFileButton.OpenFileButtonMouseEventArgs e)