Quellcode durchsuchen

20250915001 键盘唤醒按钮兼容性修改,主界面布局修改,PLC操作类优化,连接失败的时候更改数值不会界面上同步。

向羽 孟 vor 7 Monaten
Ursprung
Commit
3bb923caac

+ 0 - 7
CCDCountWpf/CCDCountWpf.csproj

@@ -95,9 +95,6 @@
     <Compile Include="WpfFrom\ChangeUserWindow.xaml.cs">
       <DependentUpon>ChangeUserWindow.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WpfFrom\KeyBorad.xaml.cs">
-      <DependentUpon>KeyBorad.xaml</DependentUpon>
-    </Compile>
     <Compile Include="WpfFrom\SplashWindow.xaml.cs">
       <DependentUpon>SplashWindow.xaml</DependentUpon>
     </Compile>
@@ -127,10 +124,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WpfFrom\KeyBorad.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="WpfFrom\SplashWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 148 - 74
CCDCountWpf/PlcMessageShowBindingClass.cs

@@ -204,8 +204,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    speedModeRunningSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteSpeedModeRunningSpeed(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteSpeedModeRunningSpeed(result))
+                    {
+                        speedModeRunningSpeed = result;
+                    }
                     OnPropertyChanged("SpeedModeRunningSpeed");
                 }
             }
@@ -222,8 +224,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    jogSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteJogSpeed(result);
+                    if(PlcSettingMessageBus.pLCManagement.WriteJogSpeed(result))
+                    {
+                        jogSpeed = result;
+                    }
                     OnPropertyChanged("JogSpeed");
                 }
             }
@@ -238,8 +242,10 @@ namespace CCDCountWpf
             get { return bottValueSet; }
             set
             {
-                bottValueSet = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottValueSet(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottValueSet(value))
+                {
+                    bottValueSet = value;
+                }
                 OnPropertyChanged("BottValueSet");
             }
         }
@@ -255,8 +261,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    transferValveOpeningSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningSpeed(result);
+                    if(PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningSpeed(result))
+                    {
+                        transferValveOpeningSpeed = result;
+                    }
                     OnPropertyChanged("TransferValveOpeningSpeed");
                 }
             }
@@ -271,8 +279,10 @@ namespace CCDCountWpf
             get { return transferValveOpeningTime; }
             set
             {
-                transferValveOpeningTime = value;
-                PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningTime(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningTime(value))
+                {
+                    transferValveOpeningTime = value;
+                }
                 OnPropertyChanged("TransferValveOpeningTime");
             }
         }
@@ -286,8 +296,10 @@ namespace CCDCountWpf
             get { return bottingDecelerationValue; }
             set
             {
-                bottingDecelerationValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingDecelerationValue(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteBottingDecelerationValue(value))
+                {
+                    bottingDecelerationValue = value;
+                }
                 OnPropertyChanged("BottingDecelerationValue");
             }
         }
@@ -301,8 +313,10 @@ namespace CCDCountWpf
             get { return cacheDecelerationValue; }
             set
             {
-                cacheDecelerationValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheDecelerationValue(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteCacheDecelerationValue(value))
+                {
+                    cacheDecelerationValue = value;
+                }
                 OnPropertyChanged("CacheDecelerationValue");
             }
         }
@@ -316,8 +330,10 @@ namespace CCDCountWpf
             get { return cacheCountDelayTiming; }
             set
             {
-                cacheCountDelayTiming = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheCountDelayTiming(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteCacheCountDelayTiming(value))
+                {
+                    cacheCountDelayTiming = value;
+                }
                 OnPropertyChanged("CacheCountDelayTiming");
             }
         }
@@ -332,8 +348,10 @@ namespace CCDCountWpf
             get { return cacheShutdownValue; }
             set
             {
-                cacheShutdownValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheShutdownValue(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteCacheShutdownValue(value))
+                {
+                    cacheShutdownValue = value;
+                }
                 OnPropertyChanged("CacheShutdownValue");
             }
         }
@@ -347,8 +365,10 @@ namespace CCDCountWpf
             get { return bottingMaterialCylinderVibrationTableHighSpeedValue; }
             set
             {
-                bottingMaterialCylinderVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableHighSpeedValue(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableHighSpeedValue(value))
+                {
+                    bottingMaterialCylinderVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("BottingMaterialCylinderVibrationTableHighSpeedValue");
             }
         }
@@ -362,8 +382,10 @@ namespace CCDCountWpf
             get { return bottingFilterVibrationTableHighSpeedValue; }
             set
             {
-                bottingFilterVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableHighSpeedValue(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableHighSpeedValue(value))
+                {
+                    bottingFilterVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("BottingFilterVibrationTableHighSpeedValue");
             }
         }
@@ -377,8 +399,10 @@ namespace CCDCountWpf
             get { return bottingCountVibrationTableHighSpeedValue; }
             set
             {
-                bottingCountVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableHighSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableHighSpeedValue(value))
+                {
+                    bottingCountVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("BottingCountVibrationTableHighSpeedValue");
             }
         }
@@ -392,8 +416,10 @@ namespace CCDCountWpf
             get { return bottingMaterialCylinderVibrationTableDecelerationSpeedValue; }
             set
             {
-                bottingMaterialCylinderVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableDecelerationSpeedValue(value))
+                {
+                    bottingMaterialCylinderVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("BottingMaterialCylinderVibrationTableDecelerationSpeedValue");
             }
         }
@@ -407,8 +433,10 @@ namespace CCDCountWpf
             get { return bottingFilterVibrationTableDecelerationSpeedValue; }
             set
             {
-                bottingFilterVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableDecelerationSpeedValue(value))
+                {
+                    bottingFilterVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("BottingFilterVibrationTableDecelerationSpeedValue");
             }
         }
@@ -422,8 +450,10 @@ namespace CCDCountWpf
             get { return bottingCountVibrationTableDecelerationSpeedValue; }
             set
             {
-                bottingCountVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableDecelerationSpeedValue(value))
+                {
+                    bottingCountVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("BottingCountVibrationTableDecelerationSpeedValue");
             }
         }
@@ -437,8 +467,10 @@ namespace CCDCountWpf
             get { return cacheMaterialCylinderVibrationTableHighSpeedValue; }
             set
             {
-                cacheMaterialCylinderVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableHighSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableHighSpeedValue(value))
+                {
+                    cacheMaterialCylinderVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("CacheMaterialCylinderVibrationTableHighSpeedValue");
             }
         }
@@ -452,8 +484,10 @@ namespace CCDCountWpf
             get { return cacheFilterVibrationTableHighSpeedValue; }
             set
             {
-                cacheFilterVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableHighSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableHighSpeedValue(value))
+                {
+                    cacheFilterVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("CacheFilterVibrationTableHighSpeedValue");
             }
         }
@@ -467,8 +501,10 @@ namespace CCDCountWpf
             get { return cacheCountVibrationTableHighSpeedValue; }
             set
             {
-                cacheCountVibrationTableHighSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableHighSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableHighSpeedValue(value))
+                {
+                    cacheCountVibrationTableHighSpeedValue = value;
+                }
                 OnPropertyChanged("CacheCountVibrationTableHighSpeedValue");
             }
         }
@@ -482,8 +518,10 @@ namespace CCDCountWpf
             get { return cacheMaterialCylinderVibrationTableDecelerationSpeedValue; }
             set
             {
-                cacheMaterialCylinderVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableDecelerationSpeedValue(value))
+                {
+                    cacheMaterialCylinderVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("CacheMaterialCylinderVibrationTableDecelerationSpeedValue");
             }
         }
@@ -497,8 +535,10 @@ namespace CCDCountWpf
             get { return cacheFilterVibrationTableDecelerationSpeedValue; }
             set
             {
-                cacheFilterVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableDecelerationSpeedValue(value))
+                {
+                    cacheFilterVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("CacheFilterVibrationTableDecelerationSpeedValue");
             }
         }
@@ -512,8 +552,10 @@ namespace CCDCountWpf
             get { return cacheCountVibrationTableDecelerationSpeedValue; }
             set
             {
-                cacheCountVibrationTableDecelerationSpeedValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableDecelerationSpeedValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableDecelerationSpeedValue(value))
+                {
+                    cacheCountVibrationTableDecelerationSpeedValue = value;
+                }
                 OnPropertyChanged("CacheCountVibrationTableDecelerationSpeedValue");
             }
         }
@@ -527,8 +569,10 @@ namespace CCDCountWpf
             get { return gateOpeningDelay; }
             set
             {
-                gateOpeningDelay = value;
-                PlcSettingMessageBus.pLCManagement.WriteGateOpeningDelay(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteGateOpeningDelay(value))
+                {
+                    gateOpeningDelay = value;
+                }
                 OnPropertyChanged("GateOpeningDelay");
             }
         }
@@ -548,8 +592,10 @@ namespace CCDCountWpf
                 }
                 if (float.TryParse(value, out float result))
                 {
-                    returnToZeroOffsetValue = result;
-                    PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetValue(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetValue(result))
+                    {
+                        returnToZeroOffsetValue = result;
+                    }
                     OnPropertyChanged("ReturnToZeroOffsetValue");
                 }
             }
@@ -566,8 +612,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    returnToZeroOffsetSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetSpeed(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetSpeed(result))
+                    {
+                        returnToZeroOffsetSpeed = result;
+                    }
                     OnPropertyChanged("ReturnToZeroOffsetSpeed");
                 }
             }
@@ -584,8 +632,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    transferValveClosingSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteTransferValveClosingSpeed(result);
+                    if(PlcSettingMessageBus.pLCManagement.WriteTransferValveClosingSpeed(result))
+                    {
+                        transferValveClosingSpeed = result;
+                    }
                     OnPropertyChanged("TransferValveClosingSpeed");
                 }
             }
@@ -602,8 +652,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    transferValveOpenPosition = result;
-                    PlcSettingMessageBus.pLCManagement.WriteTransferValveOpenPosition(result);
+                    if(PlcSettingMessageBus.pLCManagement.WriteTransferValveOpenPosition(result))
+                    {
+                        transferValveOpenPosition = result;
+                    }
                     OnPropertyChanged("TransferValveOpenPosition");
                 }
             }
@@ -620,8 +672,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    transferValveClosePosition = result;
-                    PlcSettingMessageBus.pLCManagement.WriteTransferValveClosePosition(result);
+                    if(PlcSettingMessageBus.pLCManagement.WriteTransferValveClosePosition(result))
+                    {
+                        transferValveClosePosition = result;
+                    }
                     OnPropertyChanged("TransferValveClosePosition");
                 }
             }
@@ -636,8 +690,10 @@ namespace CCDCountWpf
             get { return airValveOpeningDelay; }
             set
             {
-                airValveOpeningDelay = value;
-                PlcSettingMessageBus.pLCManagement.WriteAirValveOpeningDelay(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteAirValveOpeningDelay(value))
+                {
+                    airValveOpeningDelay = value;
+                }
                 OnPropertyChanged("AirValveOpeningDelay");
             }
         }
@@ -651,8 +707,10 @@ namespace CCDCountWpf
             get { return bottlingShutdownValue; }
             set
             {
-                bottlingShutdownValue = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownValue(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownValue(value))
+                {
+                    bottlingShutdownValue = value;
+                }
                 OnPropertyChanged("BottlingShutdownValue");
             }
         }
@@ -666,8 +724,10 @@ namespace CCDCountWpf
             get { return bottlingShutdownTime; }
             set
             {
-                bottlingShutdownTime = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownTime(value);
+                if(PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownTime(value))
+                {
+                    bottlingShutdownTime = value;
+                }
                 OnPropertyChanged("BottlingShutdownTime");
             }
         }
@@ -683,8 +743,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    bottleFeedingWheelRunningSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelRunningSpeed(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelRunningSpeed(result))
+                    {
+                        bottleFeedingWheelRunningSpeed = result;
+                    }
                     OnPropertyChanged("BottleFeedingWheelRunningSpeed");
                 }
             }
@@ -701,8 +763,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    bottleFeedingWheelJogRunningSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelJogRunningSpeed(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelJogRunningSpeed(result))
+                    {
+                        bottleFeedingWheelJogRunningSpeed = result;
+                    }
                     OnPropertyChanged("BottleFeedingWheelJogRunningSpeed");
                 }
             }
@@ -719,8 +783,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    bottleFeedingWheelReturnToZeroOffsetValue = result;
-                    PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroOffsetValue(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroOffsetValue(result))
+                    {
+                        bottleFeedingWheelReturnToZeroOffsetValue = result;
+                    }
                     OnPropertyChanged("BottleFeedingWheelReturnToZeroOffsetValue");
                 }
             }
@@ -737,8 +803,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    bottleFeedingWheelReturnToZeroSpeed = result;
-                    PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroSpeed(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroSpeed(result))
+                    {
+                        bottleFeedingWheelReturnToZeroSpeed = result;
+                    }
                     OnPropertyChanged("BottleFeedingWheelReturnToZeroSpeed");
                 }
             }
@@ -755,8 +823,10 @@ namespace CCDCountWpf
             {
                 if (float.TryParse(value, out float result))
                 {
-                    bottleFeedingWheelPositionLength = result;
-                    PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPositionLength(result);
+                    if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPositionLength(result))
+                    {
+                        bottleFeedingWheelPositionLength = result;
+                    }
                     OnPropertyChanged("BottleFeedingWheelPositionLength");
                 }
             }
@@ -771,8 +841,10 @@ namespace CCDCountWpf
             get { return bottleFeedingWheelPauseTime; }
             set
             {
-                bottleFeedingWheelPauseTime = value;
-                PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPauseTime(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPauseTime(value))
+                {
+                    bottleFeedingWheelPauseTime = value;
+                }
                 OnPropertyChanged("BottleFeedingWheelPauseTime");
             }
         }
@@ -786,8 +858,10 @@ namespace CCDCountWpf
             get { return delayBlanking; }
             set
             {
-                delayBlanking = value;
-                PlcSettingMessageBus.pLCManagement.WriteDelayBlanking(value);
+                if (PlcSettingMessageBus.pLCManagement.WriteDelayBlanking(value))
+                {
+                    delayBlanking = value;
+                }
                 OnPropertyChanged("DelayBlanking");
             }
         }

+ 0 - 56
CCDCountWpf/ShowBindingClass.cs

@@ -190,62 +190,6 @@ namespace CCDCountWpf
             }
         }
 
-        // <summary>
-        /// 缩略图1
-        /// </summary>
-        private BitmapImage thumbnailImage1;
-        public BitmapImage ThumbnailImage1
-        {
-            get { return thumbnailImage1; }
-            set
-            {
-                thumbnailImage1 = value;
-                OnPropertyChanged("ThumbnailImage1");
-            }
-        }
-
-        // <summary>
-        /// 缩略图2
-        /// </summary>
-        private BitmapImage thumbnailImage2;
-        public BitmapImage ThumbnailImage2
-        {
-            get { return thumbnailImage2; }
-            set
-            {
-                thumbnailImage2 = value;
-                OnPropertyChanged("ThumbnailImage2");
-            }
-        }
-
-        // <summary>
-        /// 缩略图3
-        /// </summary>
-        private BitmapImage thumbnailImage3;
-        public BitmapImage ThumbnailImage3
-        {
-            get { return thumbnailImage3; }
-            set
-            {
-                thumbnailImage3 = value;
-                OnPropertyChanged("ThumbnailImage3");
-            }
-        }
-
-        // <summary>
-        /// 缩略图4
-        /// </summary>
-        private BitmapImage thumbnailImage4;
-        public BitmapImage ThumbnailImage4
-        {
-            get { return thumbnailImage4; }
-            set
-            {
-                thumbnailImage4 = value;
-                OnPropertyChanged("ThumbnailImage4");
-            }
-        }
-
         /// <summary>
         /// 相机运行状态字体颜色
         /// </summary>

+ 0 - 80
CCDCountWpf/WpfFrom/KeyBorad.xaml

@@ -1,80 +0,0 @@
-<Window x:Class="CCDCountWpf.WpfFrom.KeyBorad"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:CCDCountWpf.WpfFrom"
-        mc:Ignorable="d" Height="304" Width="1050">
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*"/>
-            <ColumnDefinition Width="220"/>
-        </Grid.ColumnDefinitions>
-        <Grid Grid.Column="0">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-            </Grid.RowDefinitions>
-            <Button Grid.Row="0" Content="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="0" Content="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="0" Content="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="0" Content="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="220,0,0,0"/>
-            <Button Grid.Row="0" Content="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="290,0,0,0"/>
-            <Button Grid.Row="0" Content="6" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="360,0,0,0"/>
-            <Button Grid.Row="0" Content="7" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="430,0,0,0"/>
-            <Button Grid.Row="0" Content="8" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="500,0,0,0"/>
-            <Button Grid.Row="0" Content="9" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="570,0,0,0"/>
-            <Button Grid.Row="0" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="640,0,0,0"/>
-            <Button Grid.Row="1" Content="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="1" Content="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="1" Content="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="1" Content="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="220,0,0,0"/>
-            <Button Grid.Row="1" Content="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="290,0,0,0"/>
-            <Button Grid.Row="1" Content="6" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="360,0,0,0"/>
-            <Button Grid.Row="1" Content="7" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="430,0,0,0"/>
-            <Button Grid.Row="1" Content="8" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="500,0,0,0"/>
-            <Button Grid.Row="1" Content="9" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="570,0,0,0"/>
-            <Button Grid.Row="1" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="640,0,0,0"/>
-            <Button Grid.Row="2" Content="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="2" Content="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="2" Content="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="2" Content="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="220,0,0,0"/>
-            <Button Grid.Row="2" Content="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="290,0,0,0"/>
-            <Button Grid.Row="2" Content="6" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="360,0,0,0"/>
-            <Button Grid.Row="2" Content="7" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="430,0,0,0"/>
-            <Button Grid.Row="2" Content="8" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="500,0,0,0"/>
-            <Button Grid.Row="2" Content="9" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="570,0,0,0"/>
-            <Button Grid.Row="2" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="640,0,0,0"/>
-            <Button Grid.Row="3" Content="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="3" Content="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="3" Content="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="3" Content="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="220,0,0,0"/>
-            <Button Grid.Row="3" Content="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="290,0,0,0"/>
-            <Button Grid.Row="3" Content="6" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="360,0,0,0"/>
-            <Button Grid.Row="3" Content="7" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="430,0,0,0"/>
-            <Button Grid.Row="3" Content="8" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="500,0,0,0"/>
-            <Button Grid.Row="3" Content="9" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="570,0,0,0"/>
-            <Button Grid.Row="3" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="640,0,0,0"/>
-        </Grid>
-        <Grid Grid.Column="1">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="*"/>
-            </Grid.RowDefinitions>
-            <Button Grid.Row="0" Content="7" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="0" Content="8" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="0" Content="9" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="1" Content="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="1" Content="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="1" Content="6" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="2" Content="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="10,0,0,0"/>
-            <Button Grid.Row="2" Content="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-            <Button Grid.Row="2" Content="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="150,0,0,0"/>
-            <Button Grid.Row="3" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Height="60" Margin="80,0,0,0"/>
-        </Grid>
-    </Grid>
-</Window>

+ 0 - 27
CCDCountWpf/WpfFrom/KeyBorad.xaml.cs

@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace CCDCountWpf.WpfFrom
-{
-    /// <summary>
-    /// KeyBorad.xaml 的交互逻辑
-    /// </summary>
-    public partial class KeyBorad : Window
-    {
-        public KeyBorad()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 36 - 98
CCDCountWpf/WpfFrom/MainWindow.xaml.cs

@@ -41,7 +41,7 @@ namespace CCDCountWpf
         public MainWindow()
         {
             InitializeComponent();
-            OnScreenKeyboard.KillTabTipProcess();
+            //SetupFullScreen();
             DataContext = ShowMessageBus.ShowBinding;
             if (File.Exists(".\\Config\\CCDCountConfig.xml"))
             {
@@ -70,7 +70,14 @@ namespace CCDCountWpf
         /// <param name="e"></param>
         private void ExitBtn_Click(object sender, RoutedEventArgs e)
         {
-            this.Close();
+            if (MessageBox.Show("是否退出程序?", "退出确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+            {
+                this.Close();
+            }
+            else
+            {
+                return;
+            }
         }
 
         /// <summary>
@@ -111,6 +118,7 @@ namespace CCDCountWpf
                     InitPlcManger();
                     if (PlcSettingMessageBus.pLCManagement.IsConnect)
                     {
+                        UpdatePlcPara(); 
                         ShowUri = new Uri("WpfPage\\PlcSettingPage.xaml", UriKind.Relative);
                         ShowFrame.Navigate(ShowUri);
                     }
@@ -164,7 +172,6 @@ namespace CCDCountWpf
                     item.DisposeCamera();
                 }
             }
-            OnScreenKeyboard.KillTabTipProcess();
             StopUpdataShowDataThread();
             FaultLog.FaultError -= ShowErrorMesPage;
             Environment.Exit(0);
@@ -206,9 +213,6 @@ namespace CCDCountWpf
         {
             IsShow = true;
             BitmapImage ThumbnailImage1 = null;
-            BitmapImage ThumbnailImage2 = null;
-            BitmapImage ThumbnailImage3 = null;
-            BitmapImage ThumbnailImage4 = null;
             const int targetMsPerFrame = 100; // 20FPS=50ms
             Stopwatch renderSW = new Stopwatch();
             Task.Run(async () =>
@@ -239,65 +243,9 @@ namespace CCDCountWpf
                                 return;
                             }
                             ThumbnailImage1 = ConvertToBitmapImage(image1);
+                            ShowMessageBus.ShowBinding.BitmapImage = ThumbnailImage1;
                         }
 
-                        if (MessageBus.MainThreadS.Count >= 2)
-                        {
-                            MessageBus.MainThreadS[1].GetShowImage(2000, out Bitmap image2);
-                            if (image2 == null)
-                            {
-                                LOG.log(string.Format("{0}:相机二获取图片为空", "IdentifyCameraForm-StartShowImageThread"));
-                                return;
-                            }
-                            ThumbnailImage2 = ConvertToBitmapImage(image2);
-                        }
-
-                        if (MessageBus.MainThreadS.Count >= 3)
-                        {
-                            MessageBus.MainThreadS[2].GetShowImage(2000, out Bitmap image3);
-                            if (image3 == null)
-                            {
-                                LOG.log(string.Format("{0}:相机三获取图片为空", "IdentifyCameraForm-StartShowImageThread"));
-                                return;
-                            }
-                            ThumbnailImage3 = ConvertToBitmapImage(image3);
-                        }
-
-                        if (MessageBus.MainThreadS.Count >= 4)
-                        {
-                            MessageBus.MainThreadS[3].GetShowImage(2000, out Bitmap image3);
-                            if (image3 == null)
-                            {
-                                LOG.log(string.Format("{0}:相机四获取图片为空", "IdentifyCameraForm-StartShowImageThread"));
-                                return;
-                            }
-                            ThumbnailImage3 = ConvertToBitmapImage(image3);
-                        }
-
-                        if (ThumbnailImage1 != null)
-                        {
-                            ShowMessageBus.ShowBinding.ThumbnailImage1 = ThumbnailImage1;
-                            if(MessageBus.NowLoadCameraIndex == 0)
-                                ShowMessageBus.ShowBinding.BitmapImage = ThumbnailImage1;
-                        }
-                        if (ThumbnailImage2 != null)
-                        {
-                            ShowMessageBus.ShowBinding.ThumbnailImage2 = ThumbnailImage2;
-                            if (MessageBus.NowLoadCameraIndex == 1)
-                                ShowMessageBus.ShowBinding.BitmapImage = ThumbnailImage2;
-                        }
-                        if (ThumbnailImage3 != null)
-                        {
-                            ShowMessageBus.ShowBinding.ThumbnailImage3 = ThumbnailImage3;
-                            if (MessageBus.NowLoadCameraIndex == 2)
-                                ShowMessageBus.ShowBinding.BitmapImage = ThumbnailImage3;
-                        }
-                        if (ThumbnailImage4 != null)
-                        {
-                            ShowMessageBus.ShowBinding.ThumbnailImage4 = ThumbnailImage4;
-                            if (MessageBus.NowLoadCameraIndex == 3)
-                                ShowMessageBus.ShowBinding.BitmapImage = ThumbnailImage4;
-                        }
                         if (MessageBus.NowLoadCameraIndex != -1)
                         {
                             if (MessageBus.MainThreadS[MessageBus.NowLoadCameraIndex].IsDebug)
@@ -310,32 +258,9 @@ namespace CCDCountWpf
                             }
                             else
                             {
-                                switch (MessageBus.NowLoadCameraIndex)
+                                if (ThumbnailImage1 != null)
                                 {
-                                    case 0:
-                                        if (ThumbnailImage1 != null)
-                                        {
-                                            ShowMessageBus.ShowBinding.DebugImage = ThumbnailImage1;
-                                        }
-                                        break;
-                                    case 1:
-                                        if (ThumbnailImage2 != null)
-                                        {
-                                            ShowMessageBus.ShowBinding.DebugImage = ThumbnailImage2;
-                                        }
-                                        break;
-                                    case 2:
-                                        if (ThumbnailImage3 != null)
-                                        {
-                                            ShowMessageBus.ShowBinding.DebugImage = ThumbnailImage3;
-                                        }
-                                        break;
-                                    case 3:
-                                        if (ThumbnailImage4 != null)
-                                        {
-                                            ShowMessageBus.ShowBinding.DebugImage = ThumbnailImage4;
-                                        }
-                                        break;
+                                    ShowMessageBus.ShowBinding.DebugImage = ThumbnailImage1;
                                 }
                             }
                         }
@@ -464,15 +389,7 @@ namespace CCDCountWpf
         private void ShowErrorMesPage(ErrorMesDataEventModelClass e)
         {
             ShowMessageBus.ShowBinding.ShowErrMessage = e.ErrorMesData.Message;
-            //ShowUri = new Uri("WpfPage\\MessagePage.xaml", UriKind.Relative);
-            //try
-            //{
-            //    ShowFrame.Navigate(ShowUri);
-            //}
-            //catch (Exception)
-            //{
-            //    Console.WriteLine("MianWindows-ShowErrorMesPage:显示错误信息页面失败");
-            //}
+            //MessageBox.Show(e.ErrorMesData.Message);
         }
 
         /// <summary>
@@ -649,6 +566,27 @@ namespace CCDCountWpf
             PlcSettingMessageBus.PlcMessageShowBindage.DelayBlanking = 
             ParaValue.DelayBlanking;
         }
+
+        private void SetupFullScreen()
+        {
+            // 隐藏标题栏和边框
+            this.WindowStyle = WindowStyle.None;
+
+            // 禁止调整大小
+            this.ResizeMode = ResizeMode.NoResize;
+
+            // 设置为最顶层窗口
+            this.Topmost = true;
+
+            // 最大化窗口
+            this.WindowState = WindowState.Maximized;
+
+            // 隐藏任务栏(可选)
+            this.Top = 0;
+            this.Left = 0;
+            this.Width = SystemParameters.PrimaryScreenWidth;
+            this.Height = SystemParameters.PrimaryScreenHeight;
+        }
         #endregion
 
         private void MenuBtn_Click(object sender, RoutedEventArgs e)
@@ -658,7 +596,7 @@ namespace CCDCountWpf
 
         private void KeyBoardBtn_Click(object sender, RoutedEventArgs e)
         {
-            OnScreenKeyboard.Show();
+            OnScreenKeyboard.KeyBoardShow();
         }
     }
 }

+ 1 - 2
CCDCountWpf/WpfFrom/UserLoginWindow.xaml.cs

@@ -46,7 +46,6 @@ namespace CCDCountWpf
 
         private void UserCancelBtn_Click(object sender, RoutedEventArgs e)
         {
-            OnScreenKeyboard.KillTabTipProcess();
             this.Close();
             Environment.Exit(0);
         }
@@ -73,7 +72,7 @@ namespace CCDCountWpf
 
         private void KeyBoardBtn_Click(object sender, RoutedEventArgs e)
         {
-            OnScreenKeyboard.Show();
+            OnScreenKeyboard.KeyBoardShow();
         }
     }
 }

+ 253 - 206
CCDCountWpf/WpfPage/MainPage.xaml

@@ -6,281 +6,328 @@
       xmlns:local="clr-namespace:CCDCountWpf.WpfPage"
       xmlns:BindNameSpace="clr-namespace:CCDCountWpf"
       mc:Ignorable="d"
-      Title="MainPage" Height="503" Width="876" Loaded="Page_Loaded">
+      Title="MainPage" Height="503" Width="950" Loaded="Page_Loaded">
 
     <Grid>
-        <Grid Margin="0,0,0,187" SizeChanged="Grid_SizeChanged">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition Width="*"/>
-            </Grid.ColumnDefinitions>
-            <Border Grid.Column="0" BorderBrush="Black" BorderThickness="1" Margin="2,2,2,2">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="380"/>
+        </Grid.ColumnDefinitions>
+        <Grid Margin="0,0,0,187">
+            <Border BorderBrush="Black" BorderThickness="1" Margin="2,2,2,2">
                 <Image x:Name="ShowBox"  Source="{Binding BitmapImage}" Margin="0,0,0,0"/>
             </Border>
-            <Border Grid.Column="1" BorderBrush="Black" BorderThickness="1" Margin="2,2,2,2">
-                <StackPanel  Orientation="Vertical">
-                    <Image x:Name="MiniShowImageBox1"  Source="{Binding ThumbnailImage1}" Margin="3,5,3,5" MouseDown="MiniShowImageBox1_MouseDown" Cursor="Hand" />
-                    <Image x:Name="MiniShowImageBox2"  Source="{Binding ThumbnailImage2}" Margin="3,5,3,5" MouseDown="MiniShowImageBox2_MouseDown" Cursor="Hand" />
-                    <Image x:Name="MiniShowImageBox3"  Source="{Binding ThumbnailImage3}" Margin="3,5,3,5" MouseDown="MiniShowImageBox3_MouseDown" Cursor="Hand"/>
-                    <Image x:Name="MiniShowImageBox4"  Source="{Binding ThumbnailImage4}" Margin="3,5,3,5" MouseDown="MiniShowImageBox4_MouseDown" Cursor="Hand"/>
-                </StackPanel>
-            </Border>
         </Grid>
-        
-        <Grid Margin="0,0,0,10" Height="170" VerticalAlignment="Bottom">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition Width="*"/>
-            </Grid.ColumnDefinitions>
 
-            <Border Grid.Column="0" 
+        <Border BorderBrush="Black" BorderThickness="1" Height="180" VerticalAlignment="Bottom" Padding="0,0,0,10">
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="*"/>
+                    <ColumnDefinition Width="*"/>
+                </Grid.ColumnDefinitions>
+
+                <Border Grid.Column="0" 
                     Background="#FF0087FF" 
                     CornerRadius="8"
                     BorderBrush="Gray"
                     BorderThickness="1"
                     Margin="15,10,15,0" Height="155" VerticalAlignment="Top" Cursor="">
-                <Grid>
-                    <StackPanel Orientation="Vertical" Margin="0,0,80,0">
-                        <StackPanel Orientation="Horizontal">
-                            <Label  Content="总粒数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
-                            <Label x:Name="AllActiveNumLab" Content="{Binding AllActiveNum}" HorizontalAlignment="Left" Margin="20,10,0,0"  Width="80" FontWeight="Bold" FontSize="20"  Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
-                        </StackPanel>
-                        <StackPanel Orientation="Horizontal">
-                            <Label  Content="合格数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
-                            <Label x:Name="AllOkNumLab" Content="{Binding AllOkNum}" HorizontalAlignment="Left" Margin="20,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                    <Grid>
+                        <StackPanel Orientation="Vertical" Margin="0,0,80,0">
+                            <StackPanel Orientation="Horizontal">
+                                <Label  Content="总粒数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
+                                <Label x:Name="AllActiveNumLab" Content="{Binding AllActiveNum}" HorizontalAlignment="Left" Margin="20,10,0,0"  Width="80" FontWeight="Bold" FontSize="20"  Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal">
+                                <Label  Content="合格数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
+                                <Label x:Name="AllOkNumLab" Content="{Binding AllOkNum}" HorizontalAlignment="Left" Margin="20,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal">
+                                <Label  Content="不合格数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
+                                <Label x:Name="AllNgNumLab" Content="{Binding AllNgNum}" HorizontalAlignment="Left" Margin="0,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                            </StackPanel>
                         </StackPanel>
-                        <StackPanel Orientation="Horizontal">
-                            <Label  Content="不合格数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
-                            <Label x:Name="AllNgNumLab" Content="{Binding AllNgNum}" HorizontalAlignment="Left" Margin="0,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
-                        </StackPanel>
-                    </StackPanel>
-                    <Label x:Name="CamRunStaticLab" Content="{Binding CamRunStatic}" HorizontalAlignment="Right" Margin="10,5,10,0" VerticalAlignment="Top" Background="{x:Null}" FontSize="25" Foreground="{Binding CameraStaticColor}" FontWeight="Bold" />
-                    <Button x:Name="DataClear" Content="清零" BorderThickness="1" HorizontalAlignment="Right" Margin="10,0,10,12" Width="80" Height="40" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Click="DataClear_Click" Cursor="Hand" VerticalAlignment="Bottom">
-                        <Button.Template>
-                            <ControlTemplate TargetType="Button">
-                                <Border CornerRadius="5" 
+                        <Label x:Name="CamRunStaticLab" Content="{Binding CamRunStatic}" HorizontalAlignment="Right" Margin="10,5,10,0" VerticalAlignment="Top" Background="{x:Null}" FontSize="25" Foreground="{Binding CameraStaticColor}" FontWeight="Bold" />
+                        <Button x:Name="DataClear" Content="清零" BorderThickness="1" HorizontalAlignment="Right" Margin="10,0,10,12" Width="80" Height="40" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Click="DataClear_Click" Cursor="Hand" VerticalAlignment="Bottom">
+                            <Button.Template>
+                                <ControlTemplate TargetType="Button">
+                                    <Border CornerRadius="5" 
                                     Background="{TemplateBinding Background}"
                                     BorderBrush="{TemplateBinding BorderBrush}"
                                     BorderThickness="{TemplateBinding BorderThickness}">
-                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                </Border>
-                            </ControlTemplate>
-                        </Button.Template>
-                    </Button>
-                </Grid>
-                <!-- 卡片内容 -->
-            </Border>
+                                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                    </Border>
+                                </ControlTemplate>
+                            </Button.Template>
+                        </Button>
+                    </Grid>
+                    <!-- 卡片内容 -->
+                </Border>
 
-            <Border Grid.Column="1" 
+                <Border Grid.Column="1" 
                     Background="#FF0087FF" 
                     CornerRadius="8"
                     BorderBrush="Gray"
                     BorderThickness="1"
                     Margin="15,10,15,0" Height="60" VerticalAlignment="Top">
-                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-                    <Label  Content="计数速度:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
-                    <Label x:Name="ShuLiSpeedTbx" Content="{Binding ShuLiSpeed}" HorizontalAlignment="Left" Margin="0,0,0,0" Width="60" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
-                    <Label Content="粒/秒" FontWeight="Bold" FontSize="20" Margin="0,10,0,0" Foreground="White" />
-                </StackPanel>
-            </Border>
-            <Border Grid.Column="1" 
+                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                        <Label  Content="计数速度:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
+                        <Label x:Name="ShuLiSpeedTbx" Content="{Binding ShuLiSpeed}" HorizontalAlignment="Left" Margin="0,0,0,0" Width="60" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                        <Label Content="粒/秒" FontWeight="Bold" FontSize="20" Margin="0,10,0,0" Foreground="White" />
+                    </StackPanel>
+                </Border>
+                <Border Grid.Column="1" 
                     Background="#FF0087FF" 
                     CornerRadius="8"
                     BorderBrush="Gray"
                     BorderThickness="1"
                     Margin="15,80,15,0" Height="85" VerticalAlignment="Top">
-                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                    <Button x:Name="StartIdentifyBtn" Content="开始" BorderThickness="1" HorizontalAlignment="Right" Margin="0,0,20,0" VerticalAlignment="Top" Width="100" Height="60" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand" Click="StartIdentifyBtn_Click">
-                        <Button.Template>
-                            <ControlTemplate TargetType="Button">
-                                <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
-                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                </Border>
-                            </ControlTemplate>
-                        </Button.Template>
-                    </Button>
-                    <Button x:Name="StopIdentifyBtn" Content="暂停" BorderThickness="1" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Height="60" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand" Click="StopIdentifyBtn_Click">
-                        <Button.Template>
-                            <ControlTemplate TargetType="Button">
-                                <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
-                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                </Border>
-                            </ControlTemplate>
-                        </Button.Template>
-                    </Button>
-                </StackPanel>
-            </Border>
+                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+                        <Button x:Name="StartIdentifyBtn" Content="开始" BorderThickness="1" HorizontalAlignment="Right" Margin="0,0,20,0" VerticalAlignment="Top" Width="100" Height="60" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand" Click="StartIdentifyBtn_Click">
+                            <Button.Template>
+                                <ControlTemplate TargetType="Button">
+                                    <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
+                                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                    </Border>
+                                </ControlTemplate>
+                            </Button.Template>
+                        </Button>
+                        <Button x:Name="StopIdentifyBtn" Content="暂停" BorderThickness="1" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Height="60" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand" Click="StopIdentifyBtn_Click">
+                            <Button.Template>
+                                <ControlTemplate TargetType="Button">
+                                    <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
+                                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                    </Border>
+                                </ControlTemplate>
+                            </Button.Template>
+                        </Button>
+                    </StackPanel>
+                </Border>
+            </Grid>
+        </Border>
 
-            <Border Grid.Column="2" 
-                    Background="#FF0087FF" 
+        <Border Grid.Column="1" BorderBrush="Black" BorderThickness="1">
+            <Border Background="#FF0087FF" 
                     CornerRadius="8"
                     BorderBrush="Gray"
                     BorderThickness="1"
-                    Margin="15,10,15,0" Height="155" VerticalAlignment="Top" Cursor="">
+                    Margin="15,10,15,10" Cursor="">
                 <Grid>
-                    <StackPanel Orientation="Vertical">
-                        <StackPanel Orientation="Horizontal" Margin="0,10,0,0" HorizontalAlignment="Center">
-                            <TextBlock Text="A速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
-                            <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueUpUPBtn" Content="++" Width="30" Height="30" Click="BottingMaterialCylinderVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                    <ScrollViewer VerticalScrollBarVisibility="Auto">
+                        <StackPanel Orientation="Vertical">
+                            <StackPanel Orientation="Horizontal" Margin="0,10,0,0" HorizontalAlignment="Center">
+                                <TextBlock Text="A速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
+                                <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueUpUPBtn" Content="++" Width="45" Height="45" Click="BottingMaterialCylinderVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                     Background="{TemplateBinding Background}"
                                     BorderBrush="{TemplateBinding BorderBrush}"
                                     BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn" Content="+" Width="30" Height="30" Click="BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn" Content="+" Width="45" Height="45" Click="BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                             Background="{TemplateBinding Background}"
                                             BorderBrush="{TemplateBinding BorderBrush}"
                                             BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingMaterialCylinderVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="79" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Background="{x:Null}"/>
-                            <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn" Content="-" Width="30" Click="BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingMaterialCylinderVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="79" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Background="{x:Null}"/>
+                                <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn" Content="-" Width="45" Click="BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                             Background="{TemplateBinding Background}"
                                             BorderBrush="{TemplateBinding BorderBrush}"
                                             BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="30" Click="BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="45" Click="BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                              Background="{TemplateBinding Background}"
                                              BorderBrush="{TemplateBinding BorderBrush}"
                                              BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                        </StackPanel>
-                        <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Center">
-                            <TextBlock Text="B速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
-                            <Button x:Name="BottingFilterVibrationTableHighSpeedValueUpUpBtn" Content="++" Width="30" Height="30" Click="BottingFilterVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Center">
+                                <TextBlock Text="B速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
+                                <Button x:Name="BottingFilterVibrationTableHighSpeedValueUpUpBtn" Content="++" Width="45" Height="45" Click="BottingFilterVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                         Background="{TemplateBinding Background}"
                                         BorderBrush="{TemplateBinding BorderBrush}"
                                         BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingFilterVibrationTableHighSpeedValueUpBtn" Content="+" Width="30" Height="30" Click="BottingFilterVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingFilterVibrationTableHighSpeedValueUpBtn" Content="+" Width="45" Height="45" Click="BottingFilterVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                     Background="{TemplateBinding Background}"
                                     BorderBrush="{TemplateBinding BorderBrush}"
                                     BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingFilterVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Background="{x:Null}"/>
-                            <Button x:Name="BottingFilterVibrationTableHighSpeedValueDownBtn" Content="-" Width="30" Click="BottingFilterVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingFilterVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Background="{x:Null}"/>
+                                <Button x:Name="BottingFilterVibrationTableHighSpeedValueDownBtn" Content="-" Width="45" Click="BottingFilterVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                              Background="{TemplateBinding Background}"
                                              BorderBrush="{TemplateBinding BorderBrush}"
                                              BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingFilterVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="30" Click="BottingFilterVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingFilterVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="45" Click="BottingFilterVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                              Background="{TemplateBinding Background}"
                                              BorderBrush="{TemplateBinding BorderBrush}"
                                              BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                        </StackPanel>
-                        <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Center">
-                            <TextBlock Text="C速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
-                            <Button x:Name="BottingCountVibrationTableHighSpeedValueUpUpBtn" Content="++" Width="30" Height="30" Click="BottingCountVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Center">
+                                <TextBlock Text="C速度:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
+                                <Button x:Name="BottingCountVibrationTableHighSpeedValueUpUpBtn" Content="++" Width="45" Height="45" Click="BottingCountVibrationTableHighSpeedValueUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                     Background="{TemplateBinding Background}"
                                     BorderBrush="{TemplateBinding BorderBrush}"
                                     BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingCountVibrationTableHighSpeedValueUpBtn" Content="+" Width="30" Height="30" Click="BottingCountVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingCountVibrationTableHighSpeedValueUpBtn" Content="+" Width="45" Height="45" Click="BottingCountVibrationTableHighSpeedValueUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                             Background="{TemplateBinding Background}"
                                             BorderBrush="{TemplateBinding BorderBrush}"
                                             BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingCountVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="{x:Null}" Foreground="White"/>
-                            <Button x:Name="BottingCountVibrationTableHighSpeedValueDownBtn" Content="-" Width="30" Click="BottingCountVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottingCountVibrationTableHighSpeedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="{x:Null}" Foreground="White"/>
+                                <Button x:Name="BottingCountVibrationTableHighSpeedValueDownBtn" Content="-" Width="45" Click="BottingCountVibrationTableHighSpeedValueDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                             Background="{TemplateBinding Background}"
                                             BorderBrush="{TemplateBinding BorderBrush}"
                                             BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
-                            <Button x:Name="BottingCountVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="30" Click="BottingCountVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
-                                <Button.Template>
-                                    <ControlTemplate TargetType="Button">
-                                        <Border CornerRadius="5" 
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottingCountVibrationTableHighSpeedValueDownDownBtn" Content="--" Width="45" Click="BottingCountVibrationTableHighSpeedValueDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
                                             Background="{TemplateBinding Background}"
                                             BorderBrush="{TemplateBinding BorderBrush}"
                                             BorderThickness="{TemplateBinding BorderThickness}">
-                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Button.Template>
-                            </Button>
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Center">
+                                <TextBlock Text="罐装值:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
+                                <Button x:Name="BottValueSetUpUpBtn" Content="++" Width="45" Height="45" Click="BottValueSetUpUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
+                                    Background="{TemplateBinding Background}"
+                                    BorderBrush="{TemplateBinding BorderBrush}"
+                                    BorderThickness="{TemplateBinding BorderThickness}">
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottValueSetUpBtn" Content="+" Width="45" Height="45" Click="BottValueSetUpBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
+                                            Background="{TemplateBinding Background}"
+                                            BorderBrush="{TemplateBinding BorderBrush}"
+                                            BorderThickness="{TemplateBinding BorderThickness}">
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <TextBox Text="{Binding Source={x:Static BindNameSpace:PlcSettingMessageBus.PlcMessageShowBindage},Path = BottValueSet,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" Width="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="{x:Null}" Foreground="White"/>
+                                <Button x:Name="BottValueSetDownBtn" Content="-" Width="45" Click="BottValueSetDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
+                                            Background="{TemplateBinding Background}"
+                                            BorderBrush="{TemplateBinding BorderBrush}"
+                                            BorderThickness="{TemplateBinding BorderThickness}">
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                                <Button x:Name="BottValueSetDownDownBtn" Content="--" Width="45" Click="BottValueSetDownDownBtn_Click" Background="#FF0123FF" Foreground="White">
+                                    <Button.Template>
+                                        <ControlTemplate TargetType="Button">
+                                            <Border CornerRadius="5" 
+                                            Background="{TemplateBinding Background}"
+                                            BorderBrush="{TemplateBinding BorderBrush}"
+                                            BorderThickness="{TemplateBinding BorderThickness}">
+                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                            </Border>
+                                        </ControlTemplate>
+                                    </Button.Template>
+                                </Button>
+                            </StackPanel>
                         </StackPanel>
-                    </StackPanel>
+                    </ScrollViewer>
                 </Grid>
-                <!-- 卡片内容 -->
             </Border>
-        </Grid>
-        
+        </Border>
+
     </Grid>
 </Page>

+ 44 - 20
CCDCountWpf/WpfPage/MainPage.xaml.cs

@@ -28,11 +28,6 @@ namespace CCDCountWpf.WpfPage
         {
             InitializeComponent();
             DataContext  = ShowMessageBus.ShowBinding;
-            RenderOptions.SetBitmapScalingMode(MiniShowImageBox1, BitmapScalingMode.LowQuality);
-            RenderOptions.SetBitmapScalingMode(MiniShowImageBox2, BitmapScalingMode.LowQuality);
-            RenderOptions.SetBitmapScalingMode(MiniShowImageBox3, BitmapScalingMode.LowQuality);
-            RenderOptions.SetBitmapScalingMode(MiniShowImageBox4, BitmapScalingMode.LowQuality);
-            RenderOptions.SetBitmapScalingMode(ShowBox, BitmapScalingMode.LowQuality);
         }
 
         private void DataClear_Click(object sender, RoutedEventArgs e)
@@ -69,19 +64,6 @@ namespace CCDCountWpf.WpfPage
             }
         }
 
-        private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
-        {
-            if (sender is Grid grid)
-            {
-                double columnWidth = grid.ActualHeight / 2; // 高度/2作为列宽
-                grid.ColumnDefinitions[1].Width = new GridLength(columnWidth);
-                MiniShowImageBox1.Height = columnWidth / 2 - 10;
-                MiniShowImageBox2.Height = columnWidth / 2 - 10;
-                MiniShowImageBox3.Height = columnWidth / 2 - 10;
-                MiniShowImageBox4.Height = columnWidth / 2 - 10;
-            }
-        }
-
         private void MiniShowImageBox2_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
         {
             if(MessageBus.MainThreadS.Count < 2) return;
@@ -155,7 +137,10 @@ namespace CCDCountWpf.WpfPage
             StartIdentifyBtn.Opacity = 0.5;
             StopIdentifyBtn.IsEnabled = true;
             StopIdentifyBtn.Opacity = 1;
-            PlcSettingMessageBus.pLCManagement.InitiateToTrue();
+            if(PlcSettingMessageBus.pLCManagement.IsConnect)
+            {
+                PlcSettingMessageBus.pLCManagement.InitiateToTrue();
+            }
         }
 
         private void StopIdentifyBtn_Click(object sender, RoutedEventArgs e)
@@ -165,7 +150,10 @@ namespace CCDCountWpf.WpfPage
             StartIdentifyBtn.Opacity = 1;
             StopIdentifyBtn.IsEnabled = false;
             StopIdentifyBtn.Opacity = 0.5;
-            PlcSettingMessageBus.pLCManagement.StopToTrue();
+            if (PlcSettingMessageBus.pLCManagement.IsConnect)
+            {
+                PlcSettingMessageBus.pLCManagement.StopToTrue();
+            }
         }
 
         private void BottingMaterialCylinderVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e)
@@ -275,5 +263,41 @@ namespace CCDCountWpf.WpfPage
                 PlcSettingMessageBus.PlcMessageShowBindage.BottingCountVibrationTableHighSpeedValue -= 10;
             }
         }
+
+        private void BottValueSetUpUpBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 5) >
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
+            {
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 5;
+            }
+        }
+
+        private void BottValueSetUpBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 1) >
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
+            {
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 1;
+            }
+        }
+
+        private void BottValueSetDownBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 1) <
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
+            {
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 1;
+            }
+        }
+
+        private void BottValueSetDownDownBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 5) <
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
+            {
+                PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 5;
+            }
+        }
     }
 }

+ 12 - 1
TestWork.DLL/CCDCount.DLL.csproj

@@ -23,7 +23,7 @@
     <OutputPath>bin\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
+    <WarningLevel>5</WarningLevel>
     <PlatformTarget>x64</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -101,6 +101,11 @@
     <Compile Include="FaultLogClass.cs" />
     <Compile Include="FormulationClass.cs" />
     <Compile Include="PLCManagementClass.cs" />
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
     <Compile Include="SqlDataClass\ActionMesSqliteDataClass.cs" />
     <Compile Include="SqlDataClass\UserMessSqliteDataClass.cs" />
     <Compile Include="Tools\IniFileClass.cs" />
@@ -135,6 +140,12 @@
     <None Include="app.config" />
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>

+ 120 - 118
TestWork.DLL/PLCManagementClass.cs

@@ -39,157 +39,157 @@ namespace CCDCount.DLL
         /// <summary>
         /// 归零置为True
         /// </summary>
-        public void ReturnToZeroToTrue()
+        public bool ReturnToZeroToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 0, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 0, values: true);
         }
 
         /// <summary>
         /// 归零置为False
         /// </summary>
-        public void ReturnToZeroToFalse()
+        public bool ReturnToZeroToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 0, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 0, values: false);
         }
 
         /// <summary>
         /// 复位置为True
         /// </summary>
-        public void RepositionToTrue()
+        public bool RepositionToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 1, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 1, values: true);
         }
 
         /// <summary>
         /// 复位置为False
         /// </summary>
-        public void RepositionToFalse()
+        public bool RepositionToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 1, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 1, values: false);
         }
 
         /// <summary>
         /// 轴停止置为True
         /// </summary>
-        public void ShaftStopsToTrue()
+        public bool ShaftStopsToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 2, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 2, values: true);
         }
 
         /// <summary>
         /// 轴停止置为False
         /// </summary>
-        public void ShaftStopsToFalse()
+        public bool ShaftStopsToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 2, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 2, values: false);
         }
 
         /// <summary>
         /// 正转点动置为True
         /// </summary>
-        public void ForwardRotatingJogToTrue()
+        public bool ForwardRotatingJogToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 3, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 3, values: true);
         }
 
         /// <summary>
         /// 正转点动置为False
         /// </summary>
-        public void ForwardRotatingJogToFalse()
+        public bool ForwardRotatingJogToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 3, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 3, values: false);
         }
 
         /// <summary>
         /// 反转点动置为True
         /// </summary>
-        public void ReversalReverseJogToTrue()
+        public bool ReversalReverseJogToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 4, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 4, values: true);
         }
 
         /// <summary>
         /// 反转点动置为False
         /// </summary>
-        public void ReversalReverseJogToFalse()
+        public bool ReversalReverseJogToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 4, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 4, values: false);
         }
 
         /// <summary>
         /// 速度运行设置为True
         /// </summary>
-        public void SpeedRunToTrue()
+        public bool SpeedRunToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 5, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 5, values: true);
         }
 
         /// <summary>
         /// 速度运行设置为False
         /// </summary>
-        public void SpeedRunToFalse()
+        public bool SpeedRunToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 5, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 5, values: false);
         }
 
         /// <summary>
         /// 启动设置为True
         /// </summary>
-        public void InitiateToTrue()
+        public bool InitiateToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 6, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 6, values: true);
         }
 
         /// <summary>
         /// 启动设置为False
         /// </summary>
-        public void InitiateToFalse()
+        public bool InitiateToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 6, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 6, values: false);
         }
 
         /// <summary>
         /// 停止设置为True
         /// </summary>
-        public void StopToTrue()
+        public bool StopToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 7, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 7, values: true);
         }
 
         /// <summary>
         /// 停止设置为False
         /// </summary>
-        public void StopToFalse()
+        public bool StopToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 7, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 7, values: false);
         }
 
         /// <summary>
         /// 设备运行设置为True
         /// </summary>
-        public void EquipmentOperationToTrue()
+        public bool EquipmentOperationToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 8, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 8, values: true);
         }
 
         /// <summary>
         /// 设备运行设置为False
         /// </summary>
-        public void EquipmentOperationToFalse()
+        public bool EquipmentOperationToFalse()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 8, values: false);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 8, values: false);
         }
 
         /// <summary>
         /// 写入完成设置为True
         /// </summary>
-        public void WriteDoneToTrue()
+        public bool WriteDoneToTrue()
         {
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 11, values: true);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 11, values: true);
         }
 
         /// <summary>
-        /// 写入一级震台启动为True
+        /// 切换一级震台启动状态
         /// </summary>
         public void SwitchLevelOneVibrationTable()
         {
@@ -518,268 +518,268 @@ namespace CCDCount.DLL
         /// 写入速度模式运行速度
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteSpeedModeRunningSpeed(float Value)
+        public bool WriteSpeedModeRunningSpeed(float Value)
         {
-            modbusTcpClient.WriteMultipleReals(1, 1110, new float[] { Value }, "BADC");
+            return modbusTcpClient.WriteMultipleReals(1, 1110, new float[] { Value }, "BADC");
         }
 
         /// <summary>
         /// 写入点动速度
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteJogSpeed(float Value)
+        public bool WriteJogSpeed(float Value)
         {
-            modbusTcpClient.WriteMultipleReals(1, 1114, new float[] { Value }, "BADC");
+            return modbusTcpClient.WriteMultipleReals(1, 1114, new float[] { Value }, "BADC");
         }
 
         /// <summary>
         /// 写入罐装设定值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottValueSet(UInt16 Value)
+        public bool WriteBottValueSet(UInt16 Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1118, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1118, Value);
         }
 
         /// <summary>
         /// 写入中转阀打开速度
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteTransferValveOpeningSpeed(float Value)
+        public bool WriteTransferValveOpeningSpeed(float Value)
         {
-            modbusTcpClient.WriteMultipleReals(1, 1122, new float[] { Value }, "BADC");
+            return modbusTcpClient.WriteMultipleReals(1, 1122, new float[] { Value }, "BADC");
         }
 
         /// <summary>
         /// 写入中转阀打开时间
         /// </summary>
-        public void WriteTransferValveOpeningTime(UInt32 Value)
+        public bool WriteTransferValveOpeningTime(UInt32 Value)
         {
-            modbusTcpClient.WriteSingleInt32(1, 1126, Value);
+            return modbusTcpClient.WriteSingleInt32(1, 1126, Value);
         }
 
         /// <summary>
         /// 写入罐装减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingDecelerationValue(ushort Value)
+        public bool WriteBottingDecelerationValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1130, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1130, Value);
         }
 
         /// <summary>
         /// 写入缓存减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheDecelerationValue(ushort Value)
+        public bool WriteCacheDecelerationValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1134, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1134, Value);
         }
 
         /// <summary>
         /// 写入缓存计时延时时间
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheCountDelayTiming(UInt32 Value)
+        public bool WriteCacheCountDelayTiming(UInt32 Value)
         {
-            modbusTcpClient.WriteSingleInt32(1, 1138, Value);
+            return modbusTcpClient.WriteSingleInt32(1, 1138, Value);
         }
 
         /// <summary>
         /// 写入缓存停机值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheShutdownValue(ushort Value)
+        public bool WriteCacheShutdownValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1142, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1142, Value);
         }
 
         /// <summary>
         /// 写入罐装料筒震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingMaterialCylinderVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteBottingMaterialCylinderVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1146, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1146, Value);
         }
 
         /// <summary>
         /// 写入罐装过滤震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingFilterVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteBottingFilterVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1150, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1150, Value);
         }
 
         /// <summary>
         /// 写入罐装计数震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingCountVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteBottingCountVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1154, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1154, Value);
         }
 
         /// <summary>
         /// 写入罐装料筒震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingMaterialCylinderVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteBottingMaterialCylinderVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1158, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1158, Value);
         }
 
         /// <summary>
         /// 写入罐装过滤震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingFilterVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteBottingFilterVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1162, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1162, Value);
         }
 
         /// <summary>
         /// 写入罐装计数震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottingCountVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteBottingCountVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1166, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1166, Value);
         }
 
         /// <summary>
         /// 写入缓存料筒震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheMaterialCylinderVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteCacheMaterialCylinderVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1170, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1170, Value);
         }
 
         /// <summary>
         /// 写入缓存过滤震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheFilterVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteCacheFilterVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1174, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1174, Value);
         }
 
         /// <summary>
         /// 写入缓存计数震台高速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheCountVibrationTableHighSpeedValue(ushort Value)
+        public bool WriteCacheCountVibrationTableHighSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1178, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1178, Value);
         }
 
         /// <summary>
         /// 写入缓存料筒震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheMaterialCylinderVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteCacheMaterialCylinderVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1182, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1182, Value);
         }
 
         /// <summary>
         /// 写入缓存过滤震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheFilterVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteCacheFilterVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1186, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1186, Value);
         }
 
         /// <summary>
         /// 写入缓存计数震台减速值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteCacheCountVibrationTableDecelerationSpeedValue(ushort Value)
+        public bool WriteCacheCountVibrationTableDecelerationSpeedValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1190, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1190, Value);
         }
 
         /// <summary>
         /// 写入闸门打开延时
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteGateOpeningDelay(UInt32 Value)
+        public bool WriteGateOpeningDelay(UInt32 Value)
         {
-            modbusTcpClient.WriteSingleInt32(1, 1194, Value);
+            return modbusTcpClient.WriteSingleInt32(1, 1194, Value);
         }
 
         /// <summary>
         /// 写入回零偏移值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteReturnToZeroOffsetValue(float Value)
+        public bool WriteReturnToZeroOffsetValue(float Value)
         {
-            modbusTcpClient.WriteSingleReal(1, 1198, Value);
+            return modbusTcpClient.WriteSingleReal(1, 1198, Value);
         }
 
         /// <summary>
         /// 写入回零偏移速度
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteReturnToZeroOffsetSpeed(float Value)
+        public bool WriteReturnToZeroOffsetSpeed(float Value)
         {
-            modbusTcpClient.WriteSingleReal(1, 1202, Value);
+            return modbusTcpClient.WriteSingleReal(1, 1202, Value);
         }
 
         /// <summary>
         /// 写入中转阀关闭速度
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteTransferValveClosingSpeed(float Value)
+        public bool WriteTransferValveClosingSpeed(float Value)
         {
-            modbusTcpClient.WriteSingleReal(1, 1206, Value);
+            return modbusTcpClient.WriteSingleReal(1, 1206, Value);
         }
 
         /// <summary>
         /// 写入中转阀开位置
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteTransferValveOpenPosition(float Value)
+        public bool WriteTransferValveOpenPosition(float Value)
         {
-            modbusTcpClient.WriteSingleReal(1, 1210, Value);
+            return modbusTcpClient.WriteSingleReal(1, 1210, Value);
         }
 
         /// <summary>
         /// 写入中转阀关位置
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteTransferValveClosePosition(float Value)
+        public bool WriteTransferValveClosePosition(float Value)
         {
-            modbusTcpClient.WriteSingleReal(1, 1214, Value);
+            return modbusTcpClient.WriteSingleReal(1, 1214, Value);
         }
 
         /// <summary>
         /// 写入空气阀开启延时
         /// </summary>
-        public void WriteAirValveOpeningDelay(UInt32 Value)
+        public bool WriteAirValveOpeningDelay(UInt32 Value)
         {
-            modbusTcpClient.WriteSingleInt32(1, 1218, Value);
+            return modbusTcpClient.WriteSingleInt32(1, 1218, Value);
         }
 
         /// <summary>
         /// 写入罐装停机值
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottlingShutdownValue(ushort Value)
+        public bool WriteBottlingShutdownValue(ushort Value)
         {
-            modbusTcpClient.WriteSingleRegister(1, 1230, Value);
+            return modbusTcpClient.WriteSingleRegister(1, 1230, Value);
         }
 
         /// <summary>
         /// 写入罐装停机时间
         /// </summary>
         /// <param name="Value"></param>
-        public void WriteBottlingShutdownTime(UInt32 Value)
+        public bool WriteBottlingShutdownTime(UInt32 Value)
         {
-            modbusTcpClient.WriteSingleInt32(1, 1234, Value);
+            return modbusTcpClient.WriteSingleInt32(1, 1234, Value);
         }
         /// <summary>
         /// 读取所有参数(参数数据表)
@@ -866,7 +866,7 @@ namespace CCDCount.DLL
         /// <param name="highRegister">高位寄存器</param>
         /// <param name="byteOrder">字节序</param>
         /// <returns>字节数组</returns>
-        private byte[] ConvertToByteArray(ushort lowRegister, ushort highRegister, string byteOrder)
+        private byte[] ConvertToByteArray(ushort lowRegister, ushort highRegister, string byteOrder = "BADC")
         {
             byte[] bytes = new byte[4];
 
@@ -910,87 +910,89 @@ namespace CCDCount.DLL
         /// <summary>
         /// 切换使能
         /// </summary>
-        public void SwitchEnable()
+        public bool SwitchEnable()
         {
             bool Enable = ReadEnable();
-            modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 24, values: !Enable);
+            return modbusTcpClient.WriteCoilsRegister(slaveId: 1, CoilsAddress: 24, values: !Enable);
         }
 
         /// <summary>
         /// 切换闸门点动
         /// </summary>
         /// <param name="value">闸门编号</param>
-        public void SwitchValveJog(int value)
+        public bool SwitchValveJog(int value)
         {
+            bool result = false;
             if (value >= 0 && value <= 7)
             {
                 ushort valveJog = ReadValveJog();
                 ushort mask = (ushort)(1 << value);
-                modbusTcpClient.WriteSingleRegister(slaveId: 1, registerAddress: 238, value: (ushort)(valveJog^mask));
+                result = modbusTcpClient.WriteSingleRegister(slaveId: 1, registerAddress: 238, value: (ushort)(valveJog^mask));
             }
+            return result;
         }
 
         /// <summary>
         /// 写入送瓶轮运行速度
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelRunningSpeed(float result)
+        public bool WriteBottleFeedingWheelRunningSpeed(float result)
         {
-            modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1242, value: result);
+            return modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1242, value: result);
         }
 
         /// <summary>
         /// 送瓶轮点动速度
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelJogRunningSpeed(float result)
+        public bool WriteBottleFeedingWheelJogRunningSpeed(float result)
         {
-            modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1246, value: result);
+            return modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1246, value: result);
         }
 
         /// <summary>
         /// 送瓶轮回零偏移值
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelReturnToZeroOffsetValue(float result)
+        public bool WriteBottleFeedingWheelReturnToZeroOffsetValue(float result)
         {
-            modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1250, value: result);
+            return modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1250, value: result);
         }
 
         /// <summary>
         /// 送瓶轮回零速度
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelReturnToZeroSpeed(float result)
+        public bool WriteBottleFeedingWheelReturnToZeroSpeed(float result)
         {
-            modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1254, value: result);
+            return modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1254, value: result);
         }
 
         /// <summary>
         /// 送瓶轮定位长度
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelPositionLength(float result)
+        public bool WriteBottleFeedingWheelPositionLength(float result)
         {
-            modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1258, value: result);
+            return modbusTcpClient.WriteSingleReal(slaveId: 1, startAddress: 1258, value: result);
         }
 
         /// <summary>
         /// 送瓶轮暂停时间
         /// </summary>
         /// <param name="result"></param>
-        public void WriteBottleFeedingWheelPauseTime(UInt32 result)
+        public bool WriteBottleFeedingWheelPauseTime(UInt32 result)
         {
-            modbusTcpClient.WriteSingleInt32(slaveId: 1, startAddress: 1262, value: result);
+            return modbusTcpClient.WriteSingleInt32(slaveId: 1, startAddress: 1262, value: result);
         }
 
         /// <summary>
         /// 下料延时
         /// </summary>
         /// <param name="result"></param>
-        public void WriteDelayBlanking(UInt32 result)
+        public bool WriteDelayBlanking(UInt32 result)
         {
-            modbusTcpClient.WriteSingleInt32(slaveId: 1, startAddress: 1266, value: result);
+            return modbusTcpClient.WriteSingleInt32(slaveId: 1, startAddress: 1266, value: result);
         }
 
         /// <summary>

+ 63 - 0
TestWork.DLL/Properties/Resources.Designer.cs

@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace CCDCount.DLL.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   一个强类型的资源类,用于查找本地化的字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   返回此类使用的缓存的 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CCDCount.DLL.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   重写当前线程的 CurrentUICulture 属性,对
+        ///   使用此强类型资源类的所有资源查找执行重写。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 101 - 0
TestWork.DLL/Properties/Resources.resx

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+	<!-- 
+		Microsoft ResX Schema
+
+		Version 1.3
+
+		The primary goals of this format is to allow a simple XML format 
+		that is mostly human readable. The generation and parsing of the 
+		various data types are done through the TypeConverter classes 
+		associated with the data types.
+
+		Example:
+
+		... ado.net/XML headers & schema ...
+		<resheader name="resmimetype">text/microsoft-resx</resheader>
+		<resheader name="version">1.3</resheader>
+		<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+		<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+		<data name="Name1">this is my long string</data>
+		<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+		<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+			[base64 mime encoded serialized .NET Framework object]
+		</data>
+		<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+			[base64 mime encoded string representing a byte array form of the .NET Framework object]
+		</data>
+
+		There are any number of "resheader" rows that contain simple 
+		name/value pairs.
+
+		Each data row contains a name, and value. The row also contains a 
+		type or mimetype. Type corresponds to a .NET class that support 
+		text/value conversion through the TypeConverter architecture. 
+		Classes that don't support this are serialized and stored with the 
+		mimetype set.
+
+		The mimetype is used for serialized objects, and tells the 
+		ResXResourceReader how to depersist the object. This is currently not 
+		extensible. For a given mimetype the value must be set accordingly:
+
+		Note - application/x-microsoft.net.object.binary.base64 is the format 
+		that the ResXResourceWriter will generate, however the reader can 
+		read any of the formats listed below.
+
+		mimetype: application/x-microsoft.net.object.binary.base64
+		value   : The object must be serialized with 
+			: System.Serialization.Formatters.Binary.BinaryFormatter
+			: and then encoded with base64 encoding.
+
+		mimetype: application/x-microsoft.net.object.soap.base64
+		value   : The object must be serialized with 
+			: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+			: and then encoded with base64 encoding.
+
+		mimetype: application/x-microsoft.net.object.bytearray.base64
+		value   : The object must be serialized into a byte array 
+			: using a System.ComponentModel.TypeConverter
+			: and then encoded with base64 encoding.
+	-->
+	
+	<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+		<xsd:element name="root" msdata:IsDataSet="true">
+			<xsd:complexType>
+				<xsd:choice maxOccurs="unbounded">
+					<xsd:element name="data">
+						<xsd:complexType>
+							<xsd:sequence>
+								<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+								<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+							</xsd:sequence>
+							<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+							<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+							<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+						</xsd:complexType>
+					</xsd:element>
+					<xsd:element name="resheader">
+						<xsd:complexType>
+							<xsd:sequence>
+								<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+							</xsd:sequence>
+							<xsd:attribute name="name" type="xsd:string" use="required" />
+						</xsd:complexType>
+					</xsd:element>
+				</xsd:choice>
+			</xsd:complexType>
+		</xsd:element>
+	</xsd:schema>
+	<resheader name="resmimetype">
+		<value>text/microsoft-resx</value>
+	</resheader>
+	<resheader name="version">
+		<value>1.3</value>
+	</resheader>
+	<resheader name="reader">
+		<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+	</resheader>
+	<resheader name="writer">
+		<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+	</resheader>
+</root>

+ 90 - 45
TestWork.DLL/Tools/ModbusClass.cs

@@ -62,6 +62,7 @@ namespace CCDCount.DLL.Tools
             _modbusMaster?.Dispose();
             _tcpClient?.Close();
         }
+
         /// <summary>
         /// 读取线圈(功能码01)
         /// </summary>
@@ -74,7 +75,7 @@ namespace CCDCount.DLL.Tools
         {
             if (_modbusMaster == null)
             {
-                //FaultLog.RecordErrorMessage($"读取线圈-未连接到服务器");
+                FaultLog.RecordErrorMessage($"MainThreadClass-ReadCoilsRegister failed:未连接到服务器");
                 return null;
             }
             try
@@ -102,7 +103,7 @@ namespace CCDCount.DLL.Tools
         {
             if (_modbusMaster == null)
             {
-                //FaultLog.RecordErrorMessage($"读取保持寄存器-未连接到服务器");
+                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
                 return null;
             }
             try
@@ -126,7 +127,11 @@ namespace CCDCount.DLL.Tools
         /// <returns>REAL值数组</returns>
         public float[] ReadHoldingRegistersAsReal(byte slaveId, ushort startAddress, ushort count)
         {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
+            if (_modbusMaster == null) 
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
+                return null;
+            }
 
             try
             {
@@ -171,7 +176,11 @@ namespace CCDCount.DLL.Tools
         /// <returns>REAL值数组</returns>
         public float[] ReadHoldingRegistersAsReal(byte slaveId, ushort startAddress, ushort count, string byteOrder = "BADC")
         {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
+                return null;
+            }
 
             try
             {
@@ -207,7 +216,11 @@ namespace CCDCount.DLL.Tools
         /// <returns>REAL值数组</returns>
         public UInt32[] ReadHoldingRegistersAsInt32(byte slaveId, ushort startAddress, ushort count,string byteOrder = "BADC")
         {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsInt32 failed:未连接到服务器");
+                return null;
+            }
 
             try
             {
@@ -244,18 +257,26 @@ namespace CCDCount.DLL.Tools
         /// <param name="CoilsAddress">写入地址</param>
         /// <param name="values">写入值</param>
         /// <exception cref="InvalidOperationException"></exception>
-        public void WriteCoilsRegister(byte slaveId, ushort CoilsAddress, bool values)
+        public bool WriteCoilsRegister(byte slaveId, ushort CoilsAddress, bool values)
         {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
+            bool result = false;
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister failed:未连接到服务器");
+                result = false;
+            }
             try
             {
                 _modbusMaster.WriteSingleCoil(slaveId, CoilsAddress, values);
+                result = true;
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"写入线圈失败: {ex.Message}");
                 FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister-WriteCoilsRegister failed:{ex.Message}");
+                result = false;
             }
+            return result;
         }
 
         /// <summary>
@@ -265,19 +286,56 @@ namespace CCDCount.DLL.Tools
         /// <param name="registerAddress"></param>
         /// <param name="value"></param>
         /// <exception cref="InvalidOperationException"></exception>
-        public void WriteSingleRegister(byte slaveId, ushort registerAddress, ushort value)
+        public bool WriteSingleRegister(byte slaveId, ushort registerAddress, ushort value)
         {
-
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
+            bool result = false;
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister failed:未连接到服务器");
+                result = false;
+                return result;
+            }
             try
             {
                 _modbusMaster.WriteSingleRegister(slaveId, registerAddress, value);
+                result = true;
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"写入单个寄存器失败: {ex.Message}");
                 FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister-WriteSingleRegister failed:{ex.Message}");
+                result = false;
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 写入多个寄存器(功能码16)
+        /// </summary>
+        /// <param name="slaveId"></param>
+        /// <param name="startAddress"></param>
+        /// <param name="values"></param>
+        /// <exception cref="InvalidOperationException"></exception>
+        public bool WriteMultipleRegisters(byte slaveId, ushort startAddress, ushort[] values)
+        {
+            bool result = false;
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters failed:未连接到服务器");
+                return false;
+            }
+            try
+            {
+                _modbusMaster.WriteMultipleRegisters(slaveId, startAddress, values);
+                result = true;
             }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"写入多个寄存器失败: {ex.Message}");
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters-WriteMultipleRegisters failed:{ex.Message}");
+                result = false;
+            }
+            return result;
         }
 
         /// <summary>
@@ -287,10 +345,14 @@ namespace CCDCount.DLL.Tools
         /// <param name="startAddress">起始地址</param>
         /// <param name="value">REAL值</param>
         /// <param name="byteOrder">字节序 (ABCD, CDAB, BADC, DCBA)</param>
-        public void WriteSingleReal(byte slaveId, ushort startAddress, float value, string byteOrder = "BADC")
-        {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
-
+        public bool WriteSingleReal(byte slaveId, ushort startAddress, float value, string byteOrder = "BADC")
+        { 
+            bool result = false;
+            if (_modbusMaster == null)
+            {
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:未连接到服务器");
+                return false;
+            }
             try
             {
                 // 将float转换为字节数组
@@ -299,36 +361,16 @@ namespace CCDCount.DLL.Tools
                 // 根据字节序重新排列字节
                 ushort[] registers = ConvertBytesToRegisters(bytes, byteOrder);
 
-                // 写入两个连续的寄存器
-                _modbusMaster.WriteMultipleRegisters(slaveId, startAddress, registers);
+                // 写入连续的寄存器
+                result = WriteMultipleRegisters(slaveId, startAddress, registers);
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"写入REAL值失败: {ex.Message}");
                 FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:{ex.Message}");
-                throw;
-            }
-        }
-
-        /// <summary>
-        /// 写入多个寄存器(功能码16)
-        /// </summary>
-        /// <param name="slaveId"></param>
-        /// <param name="startAddress"></param>
-        /// <param name="values"></param>
-        /// <exception cref="InvalidOperationException"></exception>
-        public void WriteMultipleRegisters(byte slaveId, ushort startAddress, ushort[] values)
-        {
-            if (_modbusMaster == null) throw new InvalidOperationException("未连接到服务器");
-            try
-            {
-                _modbusMaster.WriteMultipleRegisters(slaveId, startAddress, values);
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"写入多个寄存器失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters-WriteMultipleRegisters failed:{ex.Message}");
+                result = false;
             }
+            return result;
         }
 
         /// <summary>
@@ -338,17 +380,18 @@ namespace CCDCount.DLL.Tools
         /// <param name="startAddress">起始地址</param>
         /// <param name="values">REAL值数组</param>
         /// <param name="byteOrder">字节序 (ABCD, CDAB, BADC, DCBA)</param>
-        public void WriteMultipleReals(byte slaveId, ushort startAddress, float[] values, string byteOrder = "BADC")
+        public bool WriteMultipleReals(byte slaveId, ushort startAddress, float[] values, string byteOrder = "BADC")
         {
+            bool result = false;
             if (_modbusMaster == null)
             {
-                //FaultLog.RecordErrorMessage($"写入多个REAL值到保持寄存器-未连接到服务器");
-                return;
+                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:未连接到服务器");
+                return false;
             }
             if (values == null || values.Length == 0)
             {
                 FaultLog.RecordLogMessage("写入多个REAL值到保持寄存器-值数组不能为空",0);
-                return;
+                return false;
             }
 
             try
@@ -371,13 +414,15 @@ namespace CCDCount.DLL.Tools
 
                 // 写入所有寄存器
                 _modbusMaster.WriteMultipleRegisters(slaveId, startAddress, registers);
+                result = true;
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"写入多个REAL值失败: {ex.Message}");
                 FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:{ex.Message}");
-                throw;
+                result = false;
             }
+            return result;
         }
 
         /// <summary>
@@ -387,7 +432,7 @@ namespace CCDCount.DLL.Tools
         /// <param name="startAddress">起始地址</param>
         /// <param name="value">REAL值</param>
         /// <param name="byteOrder">字节序 (ABCD, CDAB, BADC, DCBA)</param>
-        public void WriteSingleInt32(byte slaveId, ushort startAddress, UInt32 value, string byteOrder = "BADC")
+        public bool WriteSingleInt32(byte slaveId, ushort startAddress, UInt32 value, string byteOrder = "BADC")
         {
             // 将32位整数拆分为两个16位寄存器值
             byte[] bytes = BitConverter.GetBytes(value);
@@ -399,7 +444,7 @@ namespace CCDCount.DLL.Tools
             registers[0] = regPair[0];
             registers[1] = regPair[1];
 
-            WriteMultipleRegisters(slaveId, startAddress, registers);
+            return WriteMultipleRegisters(slaveId, startAddress, registers);
         }
 
         /// <summary>

+ 170 - 56
TestWork.DLL/Tools/OnScreenKeyboardClass.cs

@@ -1,5 +1,7 @@
-using System;
+using Microsoft.Win32;
+using System;
 using System.Diagnostics;
+using System.IO;
 using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
@@ -7,106 +9,218 @@ namespace CCDCount.DLL.Tools
 {
     public static class OnScreenKeyboard
     {
-        [DllImport("user32.dll", SetLastError = true)]
-        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+        [DllImport("kernel32.dll")]
+        private static extern IntPtr GetModuleHandle(string lpModuleName);
 
         [DllImport("user32.dll")]
-        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
+        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
 
         [DllImport("user32.dll")]
-        static extern bool SetForegroundWindow(IntPtr hWnd);
+        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
 
-        [DllImport("user32.dll")]
-        static extern bool IsWindowVisible(IntPtr hWnd);
-
-        const int SW_SHOW = 5;
-        const int SW_RESTORE = 9;
-        const int SW_HIDE = 0;
-
-        public static async void Show()
+        private const int SW_SHOW = 5;
+        private const int SW_HIDE = 0;
+        /// <summary>
+        /// 启动软键盘(兼容Windows 10及以上版本)
+        /// </summary>
+        public static void KeyBoardShow()
         {
-            // 查找现有窗口
-            IntPtr keyboardWnd = FindWindow("IPTip_Main_Window", null);
-
-            // 首先确保没有旧进程
-            KillTabTipProcess();
+            try
+            {
+                // 检查是否为Windows 10或更高版本
+                if (IsWindows10OrHigher())
+                {
+                    // 尝试启动TabTip
+                    if (TryStartTabTip())
+                        return;
+                }
 
-            // 等待进程完全终止
-            await Task.Delay(300);
+                // 回退到传统osk
+                StartOnScreenKeyboard();
+            }
+            catch (Exception ex)
+            {
+                throw new InvalidOperationException("无法启动软键盘", ex);
+            }
+        }
 
-            // 启动新实例
-            if (StartNewInstance())
+        /// <summary>
+        /// 隐藏软键盘
+        /// </summary>
+        public static void KeyBoardHide()
+        {
+            try
             {
-                // 等待窗口出现(使用循环检测,而非固定延迟)
-                for (int i = 0; i < 10; i++)
+                // 隐藏TabTip窗口
+                IntPtr tabTipHwnd = FindWindow("IPTip_Main_Window", null);
+                if (tabTipHwnd != IntPtr.Zero)
                 {
-                    await Task.Delay(200);
-                    keyboardWnd = FindWindow("IPTip_Main_Window", null);
-                    if (keyboardWnd != IntPtr.Zero) break;
+                    ShowWindow(tabTipHwnd, SW_HIDE);
                 }
 
-                if (keyboardWnd != IntPtr.Zero)
+                // 隐藏OSK窗口
+                IntPtr oskHwnd = FindWindow("OSKMainClass", "屏幕键盘");
+                if (oskHwnd != IntPtr.Zero)
                 {
-                    ShowWindow(keyboardWnd, SW_RESTORE);
-                    SetForegroundWindow(keyboardWnd);
+                    ShowWindow(oskHwnd, SW_HIDE);
                 }
             }
+            catch
+            {
+                // 忽略异常
+            }
         }
 
-        private static bool StartNewInstance()
+        private static void StartOnScreenKeyboard()
         {
             try
             {
-                string[] keyboardPaths = {
-                @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe",
-                @"C:\Program Files (x86)\Common Files\Microsoft Shared\ink\TabTip.exe"
-            };
-
-                foreach (string path in keyboardPaths)
+                // 检查是否已经运行
+                Process[] oskProcesses = Process.GetProcessesByName("osk");
+                if (oskProcesses.Length > 0)
                 {
-                    if (System.IO.File.Exists(path))
+                    // 如果已经运行,尝试显示窗口
+                    IntPtr oskHwnd = FindWindow("OSKMainClass", "屏幕键盘");
+                    if (oskHwnd != IntPtr.Zero)
+                    {
+                        ShowWindow(oskHwnd, SW_SHOW);
+                        return;
+                    }
+                    else
                     {
-                        Process.Start(new ProcessStartInfo
+                        // 如果找不到窗口,杀死进程重新启动
+                        foreach (var process in oskProcesses)
                         {
-                            FileName = path,
-                            UseShellExecute = true
-                        });
-                        return true;
+                            try { process.Kill(); } catch { }
+                        }
+                    }
+                }
+
+                Process.Start("osk.exe");
+            }
+            catch (Exception ex)
+            {
+                throw new InvalidOperationException("无法启动屏幕键盘", ex);
+            }
+        }
+
+        private static bool IsWindows10OrHigher()
+        {
+            var os = Environment.OSVersion;
+            if (os.Version.Major >= 10)
+                return true;
+
+            try
+            {
+                using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
+                {
+                    var currentBuild = key?.GetValue("CurrentBuild")?.ToString();
+                    if (int.TryParse(currentBuild, out int buildNumber))
+                    {
+                        // Windows 10 build 10240及以上
+                        return buildNumber >= 10240;
                     }
                 }
             }
             catch
             {
-                // 启动失败
+                // 忽略异常
             }
-            return false;
+
+            // 兼容性检查:Windows 8.1及以后版本的Major是6,但Minor版本不同
+            return os.Version.Major == 10 || (os.Version.Major == 6 && os.Version.Minor >= 2);
         }
 
-        public static void Hide()
+        private static bool TryStartTabTip()
         {
-            IntPtr keyboardWnd = FindWindow("IPTip_Main_Window", null);
-            if (keyboardWnd != IntPtr.Zero)
+            try
+            {
+                // 检查是否已经运行
+                Process[] tabTipProcesses = Process.GetProcessesByName("TabTip");
+                if (tabTipProcesses.Length > 0)
+                {
+                    // 如果找不到窗口,杀死进程重新启动
+                    foreach (var process in tabTipProcesses)
+                    {
+                        try { process.Kill(); } catch { }
+                    }
+                }
+
+                // 方法1:通过注册表查找路径
+                string tabTipPath = GetTabTipPathFromRegistry();
+                if (!string.IsNullOrEmpty(tabTipPath) && File.Exists(tabTipPath))
+                {
+                    Process.Start(tabTipPath);
+                    return true;
+                }
+
+                // 方法2:使用默认路径
+                string defaultPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
+                if (File.Exists(defaultPath))
+                {
+                    Process.Start(defaultPath);
+                    return true;
+                }
+
+                // 方法3:通过系统路径查找
+                string systemPath = Path.Combine(Environment.SystemDirectory, "TabTip.exe");
+                if (File.Exists(systemPath))
+                {
+                    Process.Start(systemPath);
+                    return true;
+                }
+
+                // 方法4:使用modern Windows 10路径
+                string modernPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
+                    @"TabletTip\1.7\TabTip.exe");
+                if (File.Exists(modernPath))
+                {
+                    Process.Start(modernPath);
+                    return true;
+                }
+            }
+            catch (Exception ex)
             {
-                ShowWindow(keyboardWnd, SW_HIDE);
+                // 记录异常但不中断
+                System.Diagnostics.Debug.WriteLine($"启动TabTip失败: {ex.Message}");
             }
-            KillTabTipProcess();
+
+            return false;
         }
 
-        public static void KillTabTipProcess()
+        private static string GetTabTipPathFromRegistry()
         {
             try
             {
-                Process[] processes = Process.GetProcessesByName("TabTip");
-                foreach (Process process in processes)
+                using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications"))
                 {
-                    process.Kill();
-                    process.WaitForExit();
+                    if (key != null)
+                    {
+                        foreach (var subKeyName in key.GetSubKeyNames())
+                        {
+                            if (subKeyName.Contains("Microsoft.Windows.Keyboard"))
+                            {
+                                using (var subKey = key.OpenSubKey(subKeyName))
+                                {
+                                    var installPath = subKey?.GetValue("Path")?.ToString();
+                                    if (!string.IsNullOrEmpty(installPath))
+                                    {
+                                        string tabTipPath = Path.Combine(installPath, "TabTip.exe");
+                                        if (File.Exists(tabTipPath))
+                                            return tabTipPath;
+                                    }
+                                }
+                            }
+                        }
+                    }
                 }
             }
             catch
             {
-                // 忽略异常
+                // 忽略注册表访问异常
             }
+
+            return null;
         }
     }
 }