mengshunguo 1 kuukausi sitten
vanhempi
commit
8505313aad
2 muutettua tiedostoa jossa 41 lisäystä ja 32 poistoa
  1. 14 7
      SCADA_DAQ/Customer/UctFrmMain.xaml
  2. 27 25
      SCADA_DAQ/Customer/UctFrmMain.xaml.cs

+ 14 - 7
SCADA_DAQ/Customer/UctFrmMain.xaml

@@ -19,19 +19,26 @@
             <Grid.RowDefinitions>
                 <RowDefinition Height="2*"/>
                 <RowDefinition Height="1*"/>
+                <RowDefinition Height="1*"/>
             </Grid.RowDefinitions>
             <GroupBox Header="扫码信息">
                 <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
-                    <TextBlock x:Name="TextContentTime" Text="扫码时间" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="30" Foreground="Black" FontStretch="Normal"/>
-                    <TextBlock Text="" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="50" Foreground="Black" FontStretch="Normal"/>
+                    <TextBlock x:Name="TextContentTime" Text="扫码时间" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="40" Foreground="Black" FontStretch="Normal"/>
+                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="50" Foreground="Black" FontStretch="Normal"/>
                     <TextBlock x:Name="TextContent" Text="扫码内容" HorizontalAlignment="Center" VerticalAlignment="Top" 
-                    FontSize="30" Foreground="White" FontStretch="Normal" FontWeight="Black" Background="Black"/>
+                    FontSize="40" Foreground="White" FontStretch="Normal" FontWeight="Black" Background="Black"/>
                 </StackPanel>
             </GroupBox>
-            <GroupBox Grid.Row="1" Header="ASCII码信息">
-                <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
-                    <TextBlock x:Name="ASCIICode" Text="ASCII码" HorizontalAlignment="Center" VerticalAlignment="Top" 
-                     FontSize="30" Foreground="White" FontStretch="Normal" FontWeight="Black" Background="Black"/>
+            <GroupBox Grid.Row="1" Header="长宽信息">
+                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                    <TextBlock x:Name="LongAndWide" Text="长宽信息" HorizontalAlignment="Center" VerticalAlignment="Center" 
+          FontSize="40" Foreground="White" FontStretch="Normal" FontWeight="Black" Background="Black"/>
+                </StackPanel>
+            </GroupBox>
+            <GroupBox Grid.Row="2" Header="ASCII码信息">
+                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                    <TextBlock x:Name="ASCIICode" Text="ASCII码" HorizontalAlignment="Center" VerticalAlignment="Center" 
+                     FontSize="40" Foreground="White" FontStretch="Normal" FontWeight="Black" Background="Black"/>
                 </StackPanel>
             </GroupBox>
         </Grid>

+ 27 - 25
SCADA_DAQ/Customer/UctFrmMain.xaml.cs

@@ -85,13 +85,14 @@ namespace SCADA_DAQ.Customer
 
         private void BarcodeReader1_BarCodeReceived(object sender, SCADA.BarcodeReader.BarcodeReceivedEventArgs e)
         {
-            if (e.Barcode == null || e.Barcode == "" || e.Barcode == "NoRead" || e.Barcode == this.Barcode)
+            if (e.Barcode == null || e.Barcode == "" || e.Barcode == "NoRead" || e.Barcode == this.Barcode
+                || BarcodeInfo.Count == 0 || !(BarcodeInfo.ContainsKey(e.Barcode)))
             {
                 return;
             }
             this.Barcode = e.Barcode;
-            var _long = BarcodeInfo[e.Barcode]?.Long;
-            var _wide = BarcodeInfo[e.Barcode]?.Wide;
+            var _long = BarcodeInfo[e.Barcode].Long;
+            var _wide = BarcodeInfo[e.Barcode].Wide;
             if (_long == null || _wide == null)
             {
                 return;
@@ -104,30 +105,31 @@ namespace SCADA_DAQ.Customer
                 TextContent.Text = e.Barcode;
                 TextContentTime.Text = e.TimeStamp.ToLongTimeString();
                 //ASCIICode.Text = Encoding.UTF8.GetString(_byte);
-                ASCIICode.Text = string.Join(" ",Encoding.UTF8.GetString(_byte));
+                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)