소스 검색

新增冷却单元禁用功能

l2736 9 달 전
부모
커밋
277f87715b

+ 29 - 26
Shaker.Model/Model/ShakerControlModel.cs

@@ -529,62 +529,65 @@ namespace Shaker.Model
         [MessagePack.Key(6)]
         public string ClientID = string.Empty;
         [MessagePack.Key(7)]
-        public PowerAmplifierModel PowerAmplifier = new PowerAmplifierModel();
+        public bool AllowCoolingWater = true;
         [MessagePack.Key(8)]
-        public PLCAnlogModel OperatingStatus = new PLCAnlogModel();
+        public PowerAmplifierModel PowerAmplifier = new PowerAmplifierModel();
         [MessagePack.Key(9)]
-        public PLCAnlogModel OutputCurrent = new PLCAnlogModel();
+        public PLCAnlogModel OperatingStatus = new PLCAnlogModel();
         [MessagePack.Key(10)]
-        public PLCAnlogModel OutputVoltage = new PLCAnlogModel();
+        public PLCAnlogModel OutputCurrent = new PLCAnlogModel();
         [MessagePack.Key(11)]
-        public PLCAnlogModel ExcitationCurrent = new PLCAnlogModel();
+        public PLCAnlogModel OutputVoltage = new PLCAnlogModel();
         [MessagePack.Key(12)]
-        public PLCAnlogModel ExcitationVoltage = new PLCAnlogModel();
+        public PLCAnlogModel ExcitationCurrent = new PLCAnlogModel();
         [MessagePack.Key(13)]
-        public PLCAnlogModel ThreePhaseVoltage = new PLCAnlogModel();
+        public PLCAnlogModel ExcitationVoltage = new PLCAnlogModel();
         [MessagePack.Key(14)]
-        public PLCAnlogModel AbutmentTemperature0 = new PLCAnlogModel();
+        public PLCAnlogModel ThreePhaseVoltage = new PLCAnlogModel();
         [MessagePack.Key(15)]
+        public PLCAnlogModel AbutmentTemperature0 = new PLCAnlogModel();
+        [MessagePack.Key(16)]
         public PLCAnlogModel AbutmentTemperature1 = new PLCAnlogModel();
         [MessagePack.IgnoreMember]
         public string AbutmentTemperatureName => AbutmentTemperature0.Name + AbutmentTemperature1.Name;
-        [MessagePack.Key(16)]
-        public PLCAnlogModel DCVoltage1 = new PLCAnlogModel();
         [MessagePack.Key(17)]
-        public PLCAnlogModel DCVoltage2 = new PLCAnlogModel();
+        public PLCAnlogModel DCVoltage1 = new PLCAnlogModel();
         [MessagePack.Key(18)]
-        public PLCAnlogModel DCVoltage3 = new PLCAnlogModel();
+        public PLCAnlogModel DCVoltage2 = new PLCAnlogModel();
         [MessagePack.Key(19)]
-        public PLCAnlogModel DCVoltage4 = new PLCAnlogModel();
+        public PLCAnlogModel DCVoltage3 = new PLCAnlogModel();
         [MessagePack.Key(20)]
-        public PLCAnlogModel ExternalCirculatingWaterPressure = new PLCAnlogModel();
+        public PLCAnlogModel DCVoltage4 = new PLCAnlogModel();
         [MessagePack.Key(21)]
-        public PLCAnlogModel ExternalCirculatingWaterFlow = new PLCAnlogModel();
+        public PLCAnlogModel ExternalCirculatingWaterPressure = new PLCAnlogModel();
         [MessagePack.Key(22)]
-        public PLCAnlogModel ExternalCirculatingWaterTemperature = new PLCAnlogModel();
+        public PLCAnlogModel ExternalCirculatingWaterFlow = new PLCAnlogModel();
         [MessagePack.Key(23)]
-        public PLCAnlogModel MovingCoilWaterSupplyPressure = new PLCAnlogModel();
+        public PLCAnlogModel ExternalCirculatingWaterTemperature = new PLCAnlogModel();
         [MessagePack.Key(24)]
-        public PLCAnlogModel MovingCoilWaterSupplyFlow = new PLCAnlogModel();
+        public PLCAnlogModel MovingCoilWaterSupplyPressure = new PLCAnlogModel();
         [MessagePack.Key(25)]
-        public PLCAnlogModel MovingCoilWaterSupplyTemperature = new PLCAnlogModel();
+        public PLCAnlogModel MovingCoilWaterSupplyFlow = new PLCAnlogModel();
         [MessagePack.Key(26)]
-        public PLCAnlogModel ExcitationWaterSupplyPressure = new PLCAnlogModel();
+        public PLCAnlogModel MovingCoilWaterSupplyTemperature = new PLCAnlogModel();
         [MessagePack.Key(27)]
-        public PLCAnlogModel ExcitationWaterSupplyFlow = new PLCAnlogModel();
+        public PLCAnlogModel ExcitationWaterSupplyPressure = new PLCAnlogModel();
         [MessagePack.Key(28)]
+        public PLCAnlogModel ExcitationWaterSupplyFlow = new PLCAnlogModel();
+        [MessagePack.Key(29)]
         public PLCAnlogModel ExcitationWaterSupplyTemperature = new PLCAnlogModel();
         [MessagePack.IgnoreMember]
         public string DCVoltageName => DCVoltage1.Name + DCVoltage2.Name + DCVoltage3.Name + DCVoltage4.Name;
-        [MessagePack.Key(29)]
-        public PLCDigitalGroupModel DigitalGroup = new PLCDigitalGroupModel();
         [MessagePack.Key(30)]
-        public PLCDigitalGroupModel DigitalGroup1 = new PLCDigitalGroupModel();
+        public PLCDigitalGroupModel DigitalGroup = new PLCDigitalGroupModel();
         [MessagePack.Key(31)]
-        public PLCDigitalGroupModel CoolingWaterDigitalGroup = new PLCDigitalGroupModel();
+        public PLCDigitalGroupModel DigitalGroup1 = new PLCDigitalGroupModel();
         [MessagePack.Key(32)]
-        public CoolingWaterModel CoolingWater = new CoolingWaterModel();
+        public PLCDigitalGroupModel CoolingWaterDigitalGroup = new PLCDigitalGroupModel();
         [MessagePack.Key(33)]
+        public CoolingWaterModel CoolingWater = new CoolingWaterModel();
+        [MessagePack.Key(34)]
         public PLCAnlogModel CoolingWaterOperatingStatus = new PLCAnlogModel();
+
     }
 }

+ 2 - 1
ShakerControl/MainWindow.xaml

@@ -512,7 +512,8 @@
                         Margin="0,4,0,0"
                         HorizontalAlignment="Right"
                         VerticalAlignment="Top"
-                        Orientation="Horizontal">
+                        Orientation="Horizontal"
+                        Visibility="{Binding MainPage.ShakerControl.AllowCoolingWater, Converter={StaticResource Boolean2VisibilityConverter}}">
                         <TextBlock
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"

+ 1 - 1
ShakerControl/View/CoolWaterView.xaml

@@ -12,7 +12,7 @@
     d:DesignWidth="800"
     DataContext="{Binding Source={StaticResource MainViewModel}, Path=Data.MainPage}"
     mc:Ignorable="d">
-    <Grid>
+    <Grid IsEnabled="{Binding ShakerControl.AllowCoolingWater}">
         <Grid.RowDefinitions>
             <RowDefinition Height="1*" />
             <RowDefinition Height="1*" />

+ 40 - 6
ShakerControl/ViewModel/ShakerControlViewModel.cs

@@ -217,15 +217,15 @@ namespace ShakerControl.ViewModel
                             PowerAmplifier.GainSwitchControl(true);
                             break;
                         case SysCmd.CoolingWaterReset:
-                            if (!CoolingWaterResetEnabled) return;
+                            if (!CoolingWaterResetEnabled || !AllowCoolingWater) return;
                             CoolingWater?.ResetCommand?.Execute(null);
                             break;
                         case SysCmd.CoolingWaterStart:
-                            if (!CoolingWaterStartEnabled) return;
+                            if (!CoolingWaterStartEnabled || !AllowCoolingWater) return;
                             CoolingWater?.StartCommand?.Execute(null);
                             break;
                         case SysCmd.CoolingWaterStop:
-                            if (!CoolingWaterStopEnabled) return;
+                            if (!CoolingWaterStopEnabled || !AllowCoolingWater) return;
                             CoolingWater?.StopCommand?.Execute(null);
                             break;
                     }
@@ -403,7 +403,7 @@ namespace ShakerControl.ViewModel
             });
             }
         }
-        
+        public bool AllowCoolingWater => Model.AllowCoolingWater;
         private Result SystemControl(Shaker.Model.SysControl gain, Apache.NMS.IPrimitiveMap properties)
         {
             if (properties.Contains(Shaker.Model.GlobalVariable.ShakerIDKey))
@@ -506,6 +506,15 @@ namespace ShakerControl.ViewModel
                                 }
                                 break;
                             case SysCmd.CoolingWaterReset:
+                                if(!AllowCoolingWater)
+                                {
+                                    SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
+                                    return (new Result()
+                                    {
+                                        Message = "当前振动台不支持冷却水控制",
+                                        Success = false,
+                                    });
+                                }
                                 if (CoolingWater == null)
                                 {
                                     SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
@@ -530,6 +539,15 @@ namespace ShakerControl.ViewModel
                                 }
                                 break;
                             case SysCmd.CoolingWaterStart:
+                                if (!AllowCoolingWater)
+                                {
+                                    SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
+                                    return (new Result()
+                                    {
+                                        Message = "当前振动台不支持冷却水控制",
+                                        Success = false,
+                                    });
+                                }
                                 if (CoolingWater == null)
                                 {
                                     SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
@@ -554,6 +572,15 @@ namespace ShakerControl.ViewModel
                                 }
                                 break;
                             case SysCmd.CoolingWaterStop:
+                                if (!AllowCoolingWater)
+                                {
+                                    SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
+                                    return (new Result()
+                                    {
+                                        Message = "当前振动台不支持冷却水控制",
+                                        Success = false,
+                                    });
+                                }
                                 if (CoolingWater == null)
                                 {
                                     SystemLog.Default.WriteLog("当前振动台不支持冷却水控制", LogType.Message);
@@ -820,14 +847,21 @@ namespace ShakerControl.ViewModel
         {
             if (!PLCControl.IsConnected) return;
             OperatingStatus = (OperatingStatus)PLCControl.ReadInt16(Model.OperatingStatus.Address);
-            CoolingWaterOperatingStatus = (CoolingWaterOperatingStatus)PLCControl.ReadInt16(Model.CoolingWaterOperatingStatus.Address);
+            if(AllowCoolingWater) CoolingWaterOperatingStatus = (CoolingWaterOperatingStatus)PLCControl.ReadInt16(Model.CoolingWaterOperatingStatus.Address);
             foreach (var item in ShakerAnlogs)
             {
                 item.ReadPlcValue();
             }
+            if(AllowCoolingWater)
+            {
+                foreach(var item in CoolingWaters)
+                {
+                    item.ReadPlcValue();
+                }
+            }
             ShakerDigitalGroup.ReadPlcValue();
             ShakerDigitalGroup1.ReadPlcValue();
-            CoolingWaterGroup.ReadPlcValue();
+            if(AllowCoolingWater) CoolingWaterGroup.ReadPlcValue();
             PowerAmplifier.ReadPlcValue();
             CoolingWater.ReadPlcValue();
         }

+ 9 - 7
ShakerManger/View/ShakerView.xaml

@@ -143,7 +143,8 @@
                                 VerticalAlignment="Center"
                                 FontSize="14"
                                 FontWeight="Normal"
-                                Text="冷却单元状态:">
+                                Text="冷却单元状态:"
+                                Visibility="{Binding AllowCoolingWater, Converter={StaticResource Boolean2VisibilityConverter}}">
                                 <TextBlock.Style>
                                     <Style TargetType="TextBlock">
                                         <Style.Triggers>
@@ -164,7 +165,8 @@
                                 Width="30"
                                 Height="30"
                                 Margin="4,0,0,0"
-                                Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}, Path=Children[2].Foreground}" />
+                                Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}, Path=Children[2].Foreground}"
+                                Visibility="{Binding AllowCoolingWater, Converter={StaticResource Boolean2VisibilityConverter}}" />
 
                         </StackPanel>
                     </StackPanel>
@@ -179,7 +181,7 @@
                         ToolTip="申请控制权限"
                         Visibility="{Binding IsRemoteControl, Converter={StaticResource Boolean2VisibilityReConverter}}">
                         <Button.Style>
-                            <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
+                            <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
                                 <Setter Property="IsEnabled">
                                     <Setter.Value>
                                         <MultiBinding Converter="{StaticResource MultiBoolConverter}">
@@ -206,7 +208,7 @@
                         ToolTip="断开连接"
                         Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
                         <Button.Style>
-                            <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
+                            <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
                                 <Setter Property="IsEnabled">
                                     <Setter.Value>
                                         <MultiBinding Converter="{StaticResource MultiBoolConverter}">
@@ -229,7 +231,7 @@
                         hc:IconElement.Width="{StaticResource buttonwidth}"
                         Cursor="Hand">
                         <Button.Style>
-                            <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
+                            <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
                                 <Style.Triggers>
                                     <DataTrigger Binding="{Binding ShakerView}" Value="{x:Static mangerdata:ShakerViewType.None}">
                                         <Setter Property="IsEnabled" Value="False" />
@@ -279,7 +281,7 @@
                         hc:IconElement.Width="{StaticResource buttonwidth}"
                         Cursor="Hand">
                         <Button.Style>
-                            <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
+                            <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
                                 <Setter Property="hc:IconElement.Geometry" Value="{StaticResource WindowMaxGeometry}" />
                                 <Setter Property="ToolTip" Value="最大化" />
                                 <Style.Triggers>
@@ -416,7 +418,7 @@
                         Content="连接功放"
                         FontSize="14">
                         <Button.Style>
-                            <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
+                            <Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
                                 <Setter Property="IsEnabled">
                                     <Setter.Value>
                                         <MultiBinding Converter="{StaticResource MultiBoolConverter}">

+ 4 - 3
ShakerManger/ViewModel/ShakerControlViewModel.cs

@@ -477,6 +477,7 @@ namespace ShakerManger.ViewModel
                 OnPropertyChanged(nameof(GainEnabled));
             }
         }
+        public bool AllowCoolingWater => Model.AllowCoolingWater;
         [AllowNull]
         public PowerAmplifierViewModel PowerAmplifier { get; init; }
         public ObservableCollection<PLCAnlogViewModel> CoolingWaterValues { get; } = new ObservableCollection<PLCAnlogViewModel>();
@@ -604,9 +605,9 @@ namespace ShakerManger.ViewModel
         public bool StopEnabled => CurrentData?.OperatingStatus == OperatingStatus.Run;
         public bool ResetEnabled => CurrentData?.OperatingStatus != OperatingStatus.Run;
 
-        public bool CoolingWaterStartEnabled => CurrentData?.CoolingWaterStatus == CoolingWaterOperatingStatus.Wait;
-        public bool CoolingWaterStopEnabled => CurrentData?.CoolingWaterStatus == CoolingWaterOperatingStatus.Run;
-        public bool CoolingWaterResetEnabled => CurrentData?.CoolingWaterStatus != CoolingWaterOperatingStatus.Run;
+        public bool CoolingWaterStartEnabled => CurrentData?.CoolingWaterStatus == CoolingWaterOperatingStatus.Wait && AllowCoolingWater;
+        public bool CoolingWaterStopEnabled => CurrentData?.CoolingWaterStatus == CoolingWaterOperatingStatus.Run && AllowCoolingWater;
+        public bool CoolingWaterResetEnabled => CurrentData?.CoolingWaterStatus != CoolingWaterOperatingStatus.Run && AllowCoolingWater;
 
         private async void CoolingWaterStart()
         {

+ 3 - 3
ShakerManger/ViewModel/ShakersViewModel.cs

@@ -266,7 +266,7 @@ namespace ShakerManger.ViewModel
         {
             foreach (var val in Shakers)
             {
-                if (!val.IsConnected || !val.IsDeviceControl) continue;
+                if (!val.IsConnected || !val.IsDeviceControl || !val.AllowCoolingWater) continue;
                 val.CoolingWaterStartNoResult();
             }
         }
@@ -275,7 +275,7 @@ namespace ShakerManger.ViewModel
         {
             foreach (var val in Shakers)
             {
-                if (!val.IsConnected || !val.IsDeviceControl) continue;
+                if (!val.IsConnected || !val.IsDeviceControl || !val.AllowCoolingWater) continue;
                 val.CoolingWaterStopNoResult();
             }
         }
@@ -283,7 +283,7 @@ namespace ShakerManger.ViewModel
         {
             foreach (var val in Shakers)
             {
-                if (!val.IsConnected || !val.IsDeviceControl) continue;
+                if (!val.IsConnected || !val.IsDeviceControl || !val.AllowCoolingWater) continue;
                 val.CoolingWaterResetNoResult();
             }
         }