Преглед изворни кода

50L反应釜按钮控制添加

reconfiguration
ZhaoGang пре 2 месеци
родитељ
комит
0e0ca3eb8b
6 измењених фајлова са 365 додато и 56 уклоњено
  1. +1
    -1
      BPASmartClient.Academy/50L/BoolAddEnum.cs
  2. +1
    -1
      BPASmartClient.Academy/50L/PlcControl.cs
  3. +14
    -0
      BPASmartClient.Academy/App.xaml.cs
  4. +197
    -35
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  5. +134
    -5
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs
  6. +18
    -14
      BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs

+ 1
- 1
BPASmartClient.Academy/50L/BoolAddEnum.cs Прегледај датотеку

@@ -45,7 +45,7 @@ namespace BPASmartClient.Academy._50L
[Add("DB1.DBX1002.1")]
冷凝水罐真空阀,
[Add("DB1.DBX1002.2")]
备用IN7,
空压机启动,
[Add("DB1.DBX1002.3")]
备用IN8,
[Add("DB1.DBX1002.4")]


+ 1
- 1
BPASmartClient.Academy/50L/PlcControl.cs Прегледај датотеку

@@ -15,7 +15,7 @@ namespace BPASmartClient.Academy._50L
private volatile static PlcControl _Instance;
public static PlcControl GetInstance => _Instance ?? (_Instance = new PlcControl());
private PlcControl() { }
public bool IsConnect => comm.IsConnected();
public bool IsConnect => true;
public DeviceStatus DeviceStatus { get; set; } = new DeviceStatus();
private ICommSiemens comm = CommHelper.Siemens;



+ 14
- 0
BPASmartClient.Academy/App.xaml.cs Прегледај датотеку

@@ -156,6 +156,20 @@ namespace BPASmartClient.Academy
ToggleWindowPath = num==0 ? "View.DeviceMotionView" :num==1? "View.ReactionKettle50LView": "View.DeviceMotion_2View"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备控制模板1",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = "View.DeviceMotionView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备控制模板2",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = "View.DeviceMotion_2View"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "数据曲线",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },


+ 197
- 35
BPASmartClient.Academy/View/ReactionKettle50LView.xaml Прегледај датотеку

@@ -238,9 +238,7 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="NotchedSigalInArrow" TargetType="TextBlock">

</Style>
<Style x:Key="NotchedSigalInArrow" TargetType="TextBlock" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
@@ -275,9 +273,10 @@
Content="选择设备类型"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
<Viewbox Grid.Row="1" Stretch="Uniform">
<Canvas Width="1000" Height="550">
<!--#region 控制按钮-->
<Viewbox
Grid.Row="1" Margin="10" Stretch="Uniform">
<Canvas Width="1000" Height="500">
<!--#region 开关控制按钮-->
<StackPanel
Canvas.Left="913" Canvas.Top="142" HorizontalAlignment="Center" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
@@ -321,7 +320,7 @@
Tag="卤水泵" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="921.095" Canvas.Top="331.398" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -335,7 +334,7 @@
Tag="反应釜回原点" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="815" Canvas.Top="329.953" HorizontalAlignment="Center" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -349,21 +348,21 @@
Tag="反应釜去倒料位" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="921.095" Canvas.Top="264.326" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="反应釜旋转电机点动:开" FontSize="8" Foreground="White"
Click="open_Click" Content="旋转电机点动:开" FontSize="8" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="反应釜旋转电机点动" />
<RadioButton
Width="70" Height="20" BorderThickness="0" Click="close_Click"
Content="反应釜旋转电机点动:关" FontSize="8" Foreground="White" IsChecked="True"
Content="旋转电机点动:关" FontSize="8" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="反应釜旋转电机点动" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="800" Canvas.Top="440.853" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -377,7 +376,7 @@
Tag="反应釜升温" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="886.095" Canvas.Top="440.953" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -391,11 +390,11 @@
Tag="反应釜降温" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="886.095" Canvas.Top="389.9" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="冷凝水罐降温:开" FontSize="8" Foreground="White"
Width="70" Height="20" BorderThickness="0" Click="open_Click"
Content="冷凝水罐降温:开" FontSize="8" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="冷凝水罐降温" />
<RadioButton
@@ -405,7 +404,7 @@
Tag="冷凝水罐降温" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="851.095" Canvas.Top="95.463" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -419,7 +418,7 @@
Tag="反应釜泄压阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="661.1" Canvas.Top="237.071" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -433,7 +432,7 @@
Tag="排热空气阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="660.3" Canvas.Top="149" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -447,7 +446,7 @@
Tag="热气排空阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="515.8" Canvas.Top="115.224" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -461,7 +460,7 @@
Tag="冷凝水进气阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="417.99" Canvas.Top="281.873" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -475,35 +474,35 @@
Tag="反应釜排水阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="422" Canvas.Top="370.343" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="反应釜进清水阀:开" FontSize="8" Foreground="White"
Click="open_Click" Content="进清水阀:开" FontSize="8" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="反应釜进清水阀" />
<RadioButton
Width="70" Height="20" BorderThickness="0" Click="close_Click"
Content="反应釜进清水阀:关" FontSize="8" Foreground="White" IsChecked="True"
Content="进清水阀:关" FontSize="8" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="反应釜进清水阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="402.972" Canvas.Top="449" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="反应釜压缩空气进气阀:开" FontSize="8" Foreground="White"
Click="open_Click" Content="压缩空气进气阀:开" FontSize="8" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="反应釜压缩空气进气阀" />
<RadioButton
Width="70" Height="20" BorderThickness="0" Click="close_Click"
Content="反应釜压缩空气进气阀:关" FontSize="8" Foreground="White" IsChecked="True"
Content="压缩空气进气阀:关" FontSize="8" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="反应釜压缩空气进气阀" />
</StackPanel>
<StackPanel
Canvas.Left="272" Canvas.Top="457" HorizontalAlignment="Center" VerticalAlignment="Top"
Canvas.Left="562.798" Canvas.Top="457" HorizontalAlignment="Left" VerticalAlignment="Center"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
@@ -530,16 +529,33 @@
Style="{StaticResource radiobutton}"
Tag="冷凝水罐真空阀" />
</StackPanel>
<StackPanel
Canvas.Left="100" Canvas.Top="156" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="空压机:开" FontSize="8" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="空压机启动" />
<RadioButton
Width="70" Height="20" BorderThickness="0" Click="close_Click"
Content="空压机:关" FontSize="8" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="空压机启动" />

</StackPanel>
<Button
Canvas.Left="100" Canvas.Top="264" Width="100" Height="20" Panel.ZIndex="99" BorderThickness="0" Click="open_Click"
Content="称重水罐重量清零" FontSize="8" Foreground="White"
Canvas.Left="100" Canvas.Top="264" Width="100" Height="20"
HorizontalAlignment="Left" VerticalAlignment="Center" Panel.ZIndex="99" BorderThickness="0"
Click="open_Click" Content="称重水罐重量清零" FontSize="8" Foreground="White"
Style="{StaticResource ButtonStyle}"
Tag="称重水罐重量清零" HorizontalAlignment="Left" VerticalAlignment="Center" />
Tag="称重水罐重量清零" />
<Button
Canvas.Left="63" Canvas.Top="478" Width="100" Height="20" Panel.ZIndex="99" BorderThickness="0" Click="open_Click"
Content="卤水配制罐重量清零" FontSize="8" Foreground="White"
Canvas.Left="63" Canvas.Top="478" Width="100" Height="20"
Panel.ZIndex="99" BorderThickness="0" Click="open_Click" Content="卤水配制罐重量清零"
FontSize="8" Foreground="White" RenderTransformOrigin="-3.206,-0.55"
Style="{StaticResource ButtonStyle}"
Tag="卤水配制罐重量清零" RenderTransformOrigin="-3.206,-0.55" />
Tag="卤水配制罐重量清零" />
<!--#endregion-->
<!--#region 进卤水阀、压缩空气进气阀连接处-->
<bpa:PipeLineBR
@@ -779,7 +795,7 @@
<bpa:PipeLineH
Canvas.Left="31.329" Canvas.Top="51.3" Canvas.Right="260.7" Width="709"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
LineWidth="1" />
LineWidth="1" Loaded="PipeLineH_Loaded" />
<bpa:PipeLineV
Canvas.Left="189.5" Canvas.Top="61" Width="5" Height="137"
HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1" LineWidth="1" />
@@ -870,5 +886,151 @@
<!--#endregion-->
</Canvas>
</Viewbox>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Margin="20,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="20"
Foreground="White" Text="温度控制及校准:" />
<StackPanel
Grid.Row="1" Margin="20,2,30,0" HorizontalAlignment="Left" VerticalAlignment="Bottom"
Orientation="Horizontal">
<RadioButton
x:Name="reactorHeatUp" Width="150" Height="40" Content="反应釜升温"
GroupName="heat" IsChecked="true"
Style="{StaticResource RectangleRadioButtonStyle}" />
<RadioButton
x:Name="reactorCoolDown" Width="150" Height="40" Content="反应釜降温"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
<RadioButton
x:Name="coldWaterTankCoolDown" Width="150" Height="40" Content="冷凝水罐降温"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
<RadioButton
x:Name="tempratureAdjusting" Width="150" Height="40" Content="温度校准"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
</StackPanel>
<Border
Grid.Row="2" Margin="20,0,30,10" BorderBrush="#ff2AB2E7" BorderThickness="2">
<Grid>
<!--#region 反应釜升温参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=reactorHeatUp, Path=IsChecked, Converter={StaticResource BoolToVisibilityConvert}}">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="反应釜升温设置温度:" />
<TextBox
x:Name="reactorHeatUpTemp" Width="120" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="℃" />
<RadioButton
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="TempSet_CLick" Content="启动" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="反应釜升温" />
<RadioButton
Width="100" Height="30" Margin="40,0,0,0" BorderThickness="0"
Click="TempCLose_CLick" Content="停止" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="反应釜升温" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
<!--#region 反应釜降温参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=reactorCoolDown, Path=IsChecked, Converter={StaticResource BoolToVisibilityConvert}}">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="反应釜降温设置温度:" />
<TextBox
x:Name="reactorCoolDownTemp" Width="120" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="℃" />
<RadioButton
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="TempSet_CLick" Content="启动" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="反应釜降温" />
<RadioButton
Width="100" Height="30" Margin="40,0,0,0" BorderThickness="0"
Click="TempCLose_CLick" Content="停止" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="反应釜降温" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
<!--#region 冷凝水罐降温参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=coldWaterTankCoolDown, Path=IsChecked, Converter={StaticResource BoolToVisibilityConvert}}">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="冷凝水罐降温设置温度:" />
<TextBox
x:Name="ColdWaterTankCoolDownTemp" Width="120" HorizontalAlignment="Center"
VerticalAlignment="Center" Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="℃" />
<RadioButton
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="TempSet_CLick" Content="启动" Foreground="White"
Style="{StaticResource radiobutton}"
Tag="冷凝水罐降温" />
<RadioButton
Width="100" Height="30" Margin="40,0,0,0" BorderThickness="0"
Click="TempCLose_CLick" Content="停止" Foreground="White" IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="冷凝水罐降温" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
<!--#region 温度校准参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=tempratureAdjusting, Path=IsChecked, Converter={StaticResource BoolToVisibilityConvert}}">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="反应釜温度校准:" />
<TextBox
x:Name="reactorTempAdjustValue" Width="120" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="℃" />
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="冷凝水罐温度校准:" />
<TextBox
x:Name="coldWaterTankTempAdjustValue" Width="120" HorizontalAlignment="Center"
VerticalAlignment="Center" Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="℃" />
<Button
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="TempAdjust_Click" Content="校准" Foreground="White"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
</Grid>
</Border>
</Grid>
</Grid>
</UserControl>

+ 134
- 5
BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs Прегледај датотеку

@@ -34,10 +34,6 @@ namespace BPASmartClient.Academy.View
{
}

private void PipeLineTR_Loaded(object sender, RoutedEventArgs e)
{

}

private void open_Click(object sender, RoutedEventArgs e)
{
@@ -91,7 +87,140 @@ namespace BPASmartClient.Academy.View

private void Notify(EnumPromptType promptType,string title,string msg)
{
NoticeDemoViewModel.OpenMsg(promptType, App.Current.MainWindow, title, msg);
App.Current.Dispatcher.Invoke(new Action(() =>
{
NoticeDemoViewModel.OpenMsg(promptType, App.Current.MainWindow, title, msg);
}));
}

private void auto_click(object sender, RoutedEventArgs e)
{

}

private void TempSet_CLick(object sender, RoutedEventArgs e)
{
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim()))
{
if (PlcControl.GetInstance.IsConnect)
{
var tag = button.Tag.ToString().Trim();

switch (tag)
{
case "反应釜升温":
if (float.TryParse(reactorHeatUpTemp.Text,out float reactorHeatTemp) && reactorHeatTemp <= 200f && reactorHeatTemp >= 0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜设定升温温度, MathF.Round(reactorHeatTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.反应釜升温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入反应釜升温:{reactorHeatTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
case "反应釜降温":
if (float.TryParse(reactorCoolDownTemp.Text, out float reactorCoolTemp) && reactorCoolTemp<=200f && reactorCoolTemp>=0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜设定降温温度, MathF.Round(reactorCoolTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.反应釜降温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入反应釜降温:{reactorCoolTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
case "冷凝水罐降温":
if (float.TryParse(ColdWaterTankCoolDownTemp.Text, out float CWTTemp) && CWTTemp <= 200f && CWTTemp >= 0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.冷凝水罐设定降温温度, MathF.Round(CWTTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.冷凝水罐降温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入冷凝水罐降温:{CWTTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
}
}
else
{
Notify(EnumPromptType.Error, "失败", "设备未连接");
}
}
}

private void TempCLose_CLick(object sender, RoutedEventArgs e)
{
close_Click(sender, e);
}

private void TempAdjust_Click(object sender, RoutedEventArgs e)
{
if (PlcControl.GetInstance.IsConnect)
{
if (float.TryParse(reactorTempAdjustValue.Text, out float reactorAdjustTemp))
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜温度校准, MathF.Round(reactorAdjustTemp, 2)).OnSuccess((s) =>
{
Notify(EnumPromptType.Success, $"写入校准成功", $"成功:写入反应釜温度校准:{reactorAdjustTemp}");
}).OnFailure((s) =>
{
Notify(EnumPromptType.Error, "写入校准失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入校准失败", $"【反应釜温度校准】输入的温度不是一个有效的数字");
}

if (float.TryParse(coldWaterTankTempAdjustValue.Text, out float CWTAdjustValue))
{
PlcControl.GetInstance.Write(FloatAddEnum.冷凝水罐温度校准, MathF.Round(CWTAdjustValue, 2)).OnSuccess((s) =>
{
Notify(EnumPromptType.Success, $"写入校准成功", $"成功:写入冷凝水罐温度校准:{CWTAdjustValue}");
}).OnFailure((s) =>
{
Notify(EnumPromptType.Error, "写入校准失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入校准失败", $"【冷凝水罐温度校准】输入的温度不是一个有效的数字");
}
}
else
{
Notify(EnumPromptType.Error, "校准失败", "设备未连接");
}
}

}
}

+ 18
- 14
BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs Прегледај датотеку

@@ -15,28 +15,30 @@ namespace BPASmartClient.Academy.ViewModel
{
Start = new BPARelayCommand(() =>
{
if (Name != "" && Simens_PLC.GetInstance.IsConnected)
if (Name != "" && PlcControl.GetInstance.IsConnect)
{
switch (Content)
{
case "系统启动":
IsChecked = true;
DataFeedback dataFeedback = new DataFeedback();
dataFeedback.Name = Name;
var snd = new SaveNameData(Name);
dataFeedback.ProductNumberId = snd.Id;
Sqlite.GetInstance.AddData(snd);
Simens_PLC.GetInstance.id = snd.Id;
Simens_PLC.GetInstance.dataFeedback = dataFeedback;
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true);
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true);
//DataFeedback dataFeedback = new DataFeedback();
//dataFeedback.Name = Name;
//var snd = new SaveNameData(Name);
//dataFeedback.ProductNumberId = snd.Id;
//Sqlite.GetInstance.AddData(snd);
//Simens_PLC.GetInstance.id = snd.Id;
//Simens_PLC.GetInstance.dataFeedback = dataFeedback;
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true);
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true);
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, true);
Content = "系统停止";
break;
case "系统停止":
IsChecked = false;
Simens_PLC.GetInstance.id = "";
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
//Simens_PLC.GetInstance.id = "";
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, false);
Content = "系统启动";
break;
default:
@@ -45,7 +47,7 @@ namespace BPASmartClient.Academy.ViewModel
}
else
{
if (!Simens_PLC.GetInstance.IsConnected)
if (!PlcControl.GetInstance.IsConnect)
{
MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information);
}
@@ -90,6 +92,8 @@ namespace BPASmartClient.Academy.ViewModel
get { return _isChecked; }
set { _isChecked = value; OnPropertyChanged(); }
}


public BPARelayCommand Start { get; set; }
public BPARelayCommand DataRecordCommand { get; set; }
}


Loading…
Откажи
Сачувај