Browse Source

暂存

reconfiguration
ZhaoGang 1 month ago
parent
commit
f36f283fa4
5 changed files with 231 additions and 48 deletions
  1. +3
    -0
      BPASmartClient.Academy/50L/AlarmData.cs
  2. +23
    -8
      BPASmartClient.Academy/50L/PlcControl.cs
  3. +1
    -1
      BPASmartClient.Academy/App.xaml.cs
  4. +117
    -39
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  5. +87
    -0
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs

+ 3
- 0
BPASmartClient.Academy/50L/AlarmData.cs View File

@@ -20,5 +20,8 @@ namespace BPASmartClient.Academy._50L

[Alarm("卤水泵异常")]
public bool BrinePumpError { get; set; }

[Alarm("空压机异常")]
public bool CompressorError { get; set; }
}
}

+ 23
- 8
BPASmartClient.Academy/50L/PlcControl.cs View File

@@ -18,7 +18,9 @@ namespace BPASmartClient.Academy._50L
public bool IsConnect => true;
public DeviceStatus DeviceStatus { get; set; } = new DeviceStatus();
private ICommSiemens comm = CommHelper.Siemens;

public Action<bool> IsConnectChanged { get; set; }
private bool _lastConnectState;
private volatile uint _readFailureCount;
public void Init()
{
Task.Factory.StartNew(() =>
@@ -26,6 +28,8 @@ namespace BPASmartClient.Academy._50L
CommHelper.CreateSiemens(CpuType.S7200Smart, Json<DevicePar>.Data.IpAddress).OnSuccess(s =>
{
comm = s.Content;
_lastConnectState = true;
IsConnectChanged?.Invoke(true);
Read();
});
});
@@ -35,9 +39,9 @@ namespace BPASmartClient.Academy._50L

private void Read()
{

TaskManage.GetInstance.StartLong(() =>
{
_readFailureCount = 0;
comm.Read<bool[]>("DB1.DBX2000.0", 17).OnSuccess(s =>
{
//Data[FeedbackData.旋转电机启停反馈] = s.Content[0];
@@ -59,7 +63,7 @@ namespace BPASmartClient.Academy._50L
DeviceStatus.ReactInColdValve = s.Content[4];
DeviceStatus.ReactOutColdValve = s.Content[5];
DeviceStatus.ReactDrainValve = s.Content[6];
DeviceStatus.ReactInCleanWaterValve = s.Content[7];
DeviceStatus.ReactInCleanWaterValve = s.Content[7];
#endregion

#region V2001
@@ -74,9 +78,9 @@ namespace BPASmartClient.Academy._50L
#endregion

#region V2002
DeviceStatus.ColdWaterTankVacuumValve = s.Content[16];
DeviceStatus.ColdWaterTankVacuumValve = s.Content[16];
#endregion
});
}).OnFailure((s) => { _readFailureCount++; });

comm.Read<float[]>("DB1.DBD2006", 10).OnSuccess(s =>
{
@@ -117,9 +121,9 @@ namespace BPASmartClient.Academy._50L
SqliteOperate.GetInstance.Add(sampling);
SqliteOperate.GetInstance.RealtimeChart(sampling);

});
}).OnFailure((s) => { _readFailureCount++; });

comm.Read<bool[]>("DB1.DBX1003.7", 1).OnSuccess(s => DeviceStatus.HeartBeat = s.Content[0] );
comm.Read<bool[]>("DB1.DBX1003.7", 1).OnSuccess(s => DeviceStatus.HeartBeat = s.Content[0] ).OnFailure((s) => { _readFailureCount++; });

comm.Read<bool[]>("DB1.DBX2004.0", 16).OnSuccess(s =>
{
@@ -127,12 +131,23 @@ namespace BPASmartClient.Academy._50L
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").RotatingMachinesError = s.Content[1];
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").AbnormalNegativePressureFan = s.Content[2];
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").BrinePumpError = s.Content[3];
});
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").CompressorError = s.Content[4];
}).OnFailure((s) => { _readFailureCount++; });

if (Delay.GetInstance("心跳").Start(FeedbackData.心跳.GetValue<bool>(), 3))
{
Write(BoolAddEnum.心跳, true);
}
if (_readFailureCount > 3 && _lastConnectState)
{
_lastConnectState = false;
IsConnectChanged?.Invoke(false);
}
if (_readFailureCount == 0 && !_lastConnectState)
{
_lastConnectState = true;
IsConnectChanged?.Invoke(true);
}
Thread.Sleep(10);
}, "数据获取", true);
//ThreadManage.GetInstance.StartLong(() =>


+ 1
- 1
BPASmartClient.Academy/App.xaml.cs View File

@@ -311,7 +311,7 @@ namespace BPASmartClient.Academy
break;
case ProjectType.HKYF20240916:
//SqliteOperate.GetInstance.Init();
//PlcControl.GetInstance.Init();
PlcControl.GetInstance.Init();
break;
default:
break;


+ 117
- 39
BPASmartClient.Academy/View/ReactionKettle50LView.xaml View File

@@ -248,9 +248,12 @@
</Grid.RowDefinitions>
<!--#region 设备未连接时的遮罩-->
<TextBlock
x:Name="state" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="100"
FontWeight="Black" Text="设备未连接" Visibility="Collapsed" />
x:Name="state" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"
Panel.ZIndex="299" FontSize="100" FontWeight="Black" Foreground="Red"
Text="设 备 未 连 接" Visibility="Collapsed" />
<!--#endregion-->


<StackPanel
Grid.Row="0" Height="50" Orientation="Horizontal">
<CheckBox
@@ -274,8 +277,9 @@
Style="{StaticResource ButtonStyle}" />
</StackPanel>
<Viewbox
Grid.Row="1" Margin="10" Stretch="Uniform">
<Canvas Width="1000" Height="500">
Grid.Row="1" Margin="10" Stretch="Uniform" >
<Canvas
Width="1000" Height="500" >
<!--#region 开关控制按钮-->
<StackPanel
Canvas.Left="913" Canvas.Top="142" HorizontalAlignment="Center" VerticalAlignment="Top"
@@ -363,7 +367,7 @@
</StackPanel>
<StackPanel
Canvas.Left="800" Canvas.Top="440.853" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
Panel.ZIndex="99" Orientation="Vertical" Visibility="Collapsed">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="反应釜升温:开" FontSize="8" Foreground="White"
@@ -377,7 +381,7 @@
</StackPanel>
<StackPanel
Canvas.Left="886.095" Canvas.Top="440.953" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
Panel.ZIndex="99" Orientation="Vertical" Visibility="Collapsed">
<RadioButton
Width="70" Height="20" Margin="0,0,0,2" BorderThickness="0"
Click="open_Click" Content="反应釜降温:开" FontSize="8" Foreground="White"
@@ -391,7 +395,7 @@
</StackPanel>
<StackPanel
Canvas.Left="886.095" Canvas.Top="389.9" HorizontalAlignment="Left" VerticalAlignment="Top"
Panel.ZIndex="99" Orientation="Vertical">
Panel.ZIndex="99" Orientation="Vertical" Visibility="Collapsed">
<RadioButton
Width="70" Height="20" BorderThickness="0" Click="open_Click"
Content="冷凝水罐降温:开" FontSize="8" Foreground="White"
@@ -560,7 +564,7 @@
<!--#region 进卤水阀、压缩空气进气阀连接处-->
<bpa:PipeLineBR
Canvas.Left="717.7" Canvas.Top="389.3" Canvas.Right="272.3" Width="9"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="10" Speed="1.5" />
<Image
Canvas.Left="384" Canvas.Top="59" Width="235" Height="264"
@@ -594,19 +598,19 @@
<!--#region 冷凝水罐进气阀-->
<bpa:PipeLineV
Canvas.Left="590.8" Canvas.Top="72.7" Canvas.Right="404.2" Width="5"
Height="158" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="158" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" />
<bpa:PipeLineBL
Canvas.Left="585.8" Canvas.Top="63.4" Canvas.Right="404.2" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="303.793" Canvas.Top="63.41" Canvas.Right="413.9" Width="283"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" />
<bpa:PipeLineBR
Canvas.Left="293.793" Canvas.Top="63.4" Canvas.Right="480.2" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="10" Speed="1.5" />
<bpa:HandValve
Canvas.Left="603.2" Canvas.Top="128.7" Canvas.Right="380.8" Width="16"
@@ -624,7 +628,7 @@
<!--#region 热气排空阀-->
<bpa:PipeLineTR
Canvas.Left="590.8" Canvas.Top="209.532" Canvas.Right="399.2" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="600.6" Canvas.Top="214.71" Canvas.Right="339.4" Width="78"
@@ -645,7 +649,7 @@
Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="600.3" Canvas.Top="295.5" Canvas.Right="269.7" Width="130"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" />
<bpa:PipeLineTR
Canvas.Left="590.8" Canvas.Top="290.5" Canvas.Right="399.2" Width="10"
@@ -653,7 +657,7 @@
Speed="1.5" />
<bpa:PipeLineV
Canvas.Left="590.8" Canvas.Top="230.7" Canvas.Right="404.2" Width="5"
Height="60" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="60" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" />
<bpa:HandValve
Canvas.Left="635.883" Canvas.Top="288.036" Canvas.Right="380.8" Width="16"
@@ -673,7 +677,7 @@
Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="199.1" Canvas.Top="342.5" Canvas.Right="269" Width="532"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" />
<bpa:HandValve
Canvas.Left="444.99" Canvas.Top="335" Canvas.Right="339" Width="16"
@@ -693,7 +697,7 @@
Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="199.1" Canvas.Top="366.3" Canvas.Right="260.6" Width="540"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" />
<bpa:HandValve
Canvas.Left="423.99" Canvas.Top="358.9" Canvas.Right="360" Width="16"
@@ -706,11 +710,11 @@
<!--#region 进清水阀、进卤水阀、压缩空气进气阀进连接处-->
<bpa:PipeLineV
Canvas.Left="751.7" Canvas.Top="224.571" Canvas.Right="243.3" Width="5"
Height="160" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="160" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" />
<bpa:PipeLineTL
Canvas.Left="741.7" Canvas.Top="384.3" Canvas.Right="238.3" Width="20"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="726.9" Canvas.Top="389.3" Canvas.Right="253.1" Width="20"
@@ -719,7 +723,7 @@
<!--#region 进清水阀-->
<bpa:PipeLineH
Canvas.Left="199.1" Canvas.Top="389.3" Canvas.Right="272.9" Width="528"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" />
<bpa:HandValve
Canvas.Left="399.99" Canvas.Top="381.9" Canvas.Right="384" Width="16"
@@ -730,20 +734,20 @@
TextAlignment="Center" />
<bpa:PipeLineV
Canvas.Left="717.7" Canvas.Top="399" Canvas.Right="277.3" Width="5"
Height="15" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="15" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" Speed="1.5" />
<!--#endregion-->
<!--#region 进卤水阀-->
<bpa:PipeLineV
Canvas.Left="717.7" Canvas.Top="414" Canvas.Right="277.3" Width="5"
Height="19.5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="19.5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" Speed="1.5" />
<TextBlock
Canvas.Left="583.798" Canvas.Top="446.79" Canvas.Right="240" HorizontalAlignment="Center"
VerticalAlignment="Top" FontSize="7" Foreground="White" Text="进卤水阀" />
<bpa:PipeLineTL
Canvas.Left="712.701" Canvas.Top="433.161" Canvas.Right="272.3" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="10" Speed="1.5" />
<bpa:MotorTwo
Canvas.Left="223" Canvas.Top="437" Canvas.Right="197.5" Width="25"
@@ -753,7 +757,7 @@
Height=" 20" HorizontalAlignment="Left" VerticalAlignment="Center" />
<bpa:PipeLineH
Canvas.Left="258" Canvas.Top="438" Canvas.Right="257.5" Width="455"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Center" Direction="1"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Center" d:Direction="1"
LineWidth="1" Speed="10" />
<bpa:Tanks
Canvas.Left="239" Canvas.Top="449" Canvas.Right="239.5" Width="20"
@@ -765,11 +769,11 @@
<!--#region 压缩空气进气阀-->
<bpa:PipeLineTL
Canvas.Left="712.7" Canvas.Top="410.037" Canvas.Right="277.3" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineH
Canvas.Left="199.1" Canvas.Top="415.037" Canvas.Right="286.9" Width="514"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" />
<bpa:HandValve
Canvas.Left="383.99" Canvas.Top="407.437" Canvas.Right="400" Width="16"
@@ -791,21 +795,21 @@
Speed="1.5" />
<bpa:PipeLineBL
Canvas.Left="184.502" Canvas.Top="51.3" Width="10" Height="10"
HorizontalAlignment="Center" VerticalAlignment="Top" LineWidth="10" Speed="1" />
HorizontalAlignment="Center" VerticalAlignment="Top" LineWidth="10" Speed="2" />
<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" Loaded="PipeLineH_Loaded" />
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2"
LineWidth="1" Speed="1" />
<bpa:PipeLineV
Canvas.Left="189.5" Canvas.Top="61" Width="5" Height="137"
HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1" LineWidth="1" />
HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1" LineWidth="1" />

<bpa:PipeLineH
Canvas.Left="199.1" Canvas.Top="203.154" Width="33.5" Height="5"
HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1" LineWidth="1" />
HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1" LineWidth="1" />
<bpa:PipeLineTR
Canvas.Left="189.5" Canvas.Top="198.154" Width="10" Height="10"
HorizontalAlignment="Center" VerticalAlignment="Top" Direction="2" LineWidth="10"
HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="2" LineWidth="10"
Speed="1" />
<bpa:HandValve
Canvas.Left="360" Canvas.Top="43.6" Width="16" Height="16"
@@ -823,16 +827,22 @@
HorizontalAlignment="Center" VerticalAlignment="Top" LineWidth="10" Speed="1" />
<bpa:PipeLineH
Canvas.Left="73.9" Canvas.Top="69.222" Width="167" Height="5"
HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1" LineWidth="1" />
HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
Direction="{Binding DeviceStatus.ColdWaterTankVacuumValve, Converter={StaticResource deviceConvert}, ConverterParameter=1}"
Fill="{Binding DeviceStatus.ColdWaterTankVacuumValve, Converter={StaticResource deviceConvert}, ConverterParameter=2}"
LineWidth="1" />
<CheckBox
Canvas.Left="-0.9" Canvas.Top="49.196" HorizontalAlignment="Center" VerticalAlignment="Top"
IsEnabled="False"
Style="{StaticResource wind}" />
<TextBlock
Canvas.Left="38" Canvas.Top="136.5" HorizontalAlignment="Center" VerticalAlignment="Top"
Foreground="White" Text="风机" />
<bpa:HandValve
Canvas.Left="121.876" Canvas.Top="61.412" Canvas.Right="343.4" Width="16"
Height="16" HorizontalAlignment="Center" VerticalAlignment="Top" />
Height="16" HorizontalAlignment="Center" VerticalAlignment="Top"
EdgeColor="{Binding DeviceStatus.ColdWaterTankVacuumValve, Converter={StaticResource deviceConvert}, ConverterParameter=2}"
OpenEnable="{Binding DeviceStatus.ColdWaterTankVacuumValve}" />
<TextBlock
Canvas.Left="89.876" Canvas.Top="77.521" Width="80" HorizontalAlignment="Center"
VerticalAlignment="Top" FontSize="7" Foreground="White" Text="冷凝水管负压阀"
@@ -842,7 +852,7 @@
Height="16" HorizontalAlignment="Center" VerticalAlignment="Top" />
<bpa:PipeLineH
Canvas.Left="31.329" Canvas.Top="22.031" Canvas.Right="260.7" Width="709"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="5" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" Speed="25" />
<bpa:HandValve
Canvas.Left="360" Canvas.Top="14.331" Width="16" Height="16"
@@ -864,15 +874,15 @@
Speed="1.5" />
<bpa:PipeLineV
Canvas.Left="320.8" Canvas.Top="109.369" Canvas.Right="404.2" Width="5"
Height="252" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="252" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="1" />
<bpa:PipeLineBL
Canvas.Left="315.8" Canvas.Top="100.069" Canvas.Right="404.2" Width="10"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" Direction="1"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineTL
Canvas.Left="310.7" Canvas.Top="361.298" Canvas.Right="238.3" Width="20"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Direction="1"
Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" d:Direction="1"
LineWidth="10" Speed="1.5" />
<TextBlock
Canvas.Left="863.095" Canvas.Top="143.029" Canvas.Right="312.8" Width="46"
@@ -894,7 +904,7 @@
</Grid.RowDefinitions>
<TextBlock
Margin="20,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="20"
Foreground="White" Text="温度控制及校准:" />
Foreground="White" Text="参数控制及校准:" />
<StackPanel
Grid.Row="1" Margin="20,2,30,0" HorizontalAlignment="Left" VerticalAlignment="Bottom"
Orientation="Horizontal">
@@ -914,6 +924,14 @@
x:Name="tempratureAdjusting" Width="150" Height="40" Content="温度校准"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
<RadioButton
x:Name="reactorRotateSpeed" Width="150" Height="40" Content="反应釜旋转速度"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
<RadioButton
x:Name="steamParamsSet" Width="150" Height="40" Content="蒸汽参数"
GroupName="heat"
Style="{StaticResource RectangleRadioButtonStyle}" />
</StackPanel>
<Border
Grid.Row="2" Margin="20,0,30,10" BorderBrush="#ff2AB2E7" BorderThickness="2">
@@ -1029,6 +1047,66 @@
</StackPanel>
</WrapPanel>
<!--#endregion-->
<!--#region 反应釜旋转参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=reactorRotateSpeed, 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="reactorRotateStirSpeedValue" Width="120" HorizontalAlignment="Center"
VerticalAlignment="Center" Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="限值:0-100" />
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="反应釜旋转慢速度:" />
<TextBox
x:Name="reactorRotateSlowSpeedValue" Width="120" HorizontalAlignment="Center"
VerticalAlignment="Center" Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="限值:0-100" />
<Button
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="SetReactorSpeed_Click" Content="写入" Foreground="White"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
<!--#region 蒸汽参数写入界面-->
<WrapPanel
Margin="0,15,0,0" d:Visibility="Visible"
Visibility="{Binding ElementName=steamParamsSet, 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="steamValveApertureValve" Width="120" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="%,限值:0-100" />
<TextBlock
Margin="40,0,20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="反应釜蒸汽压力上限:" />
<TextBox
x:Name="reactorSteamPressureLimitValue" Width="120" HorizontalAlignment="Center"
VerticalAlignment="Center" Text="0" />
<TextBlock
Margin="20,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="MPa,限值:-0.1至0.6" />
<Button
Width="100" Height="30" HorizontalAlignment="Right" VerticalAlignment="Center"
BorderThickness="0" Click="steamParamsSet_Click" Content="写入" Foreground="White"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
</WrapPanel>
<!--#endregion-->
</Grid>
</Border>
</Grid>


+ 87
- 0
BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs View File

@@ -32,6 +32,29 @@ namespace BPASmartClient.Academy.View

private void ReactionKettle50LView_Loaded(object sender, RoutedEventArgs e)
{
PlcControl.GetInstance.IsConnectChanged = o =>
{
App.Current.Dispatcher.Invoke(() =>
{
if (o)
{
//ooo.Opacity = 1;
//ooo.IsHitTestVisible = true;
state.Visibility = Visibility.Collapsed;
}
else
{

//ooo.Opacity = 0.5;
//ooo.IsHitTestVisible = false;
state.Text = "设 备 未 连 接";
//MessageNotify.GetInstance.ShowRunLog("设备未连接");
state.Visibility = Visibility.Visible;
state.Foreground = Brushes.Red;
}
});

};
}


@@ -222,5 +245,69 @@ namespace BPASmartClient.Academy.View
}
}

private void SetReactorSpeed_Click(object sender, RoutedEventArgs e)
{
if (PlcControl.GetInstance.IsConnect)
{
SetParamValue(reactorRotateStirSpeedValue.Text, FloatAddEnum.反应釜旋转炒制速度, 0, 100);
SetParamValue(reactorRotateSlowSpeedValue.Text, FloatAddEnum.反应釜旋转慢速度, 0, 100);
}
else
{
Notify(EnumPromptType.Error, "校准失败", "设备未连接");
}
}

private void SetParamValue(string text,FloatAddEnum floatAdd,float minValue,float maxValue)
{
if (float.TryParse(text, out float tempValue) && tempValue>=minValue && tempValue<=maxValue)
{
PlcControl.GetInstance.Write(floatAdd, MathF.Round(tempValue, 2)).OnSuccess((s) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入【{floatAdd.ToString()}】:{tempValue}");
}).OnFailure((s) =>
{
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"【{floatAdd.ToString()}】输入的温度不是一个有效的数字,限值{minValue} -- {maxValue}。");
}
}

private void steamParamsSet_Click(object sender, RoutedEventArgs e)
{
if (PlcControl.GetInstance.IsConnect)
{
SetParamValue(steamValveApertureValve.Text, FloatAddEnum.蒸汽比例阀开度, 0, 100);
SetParamValue(reactorSteamPressureLimitValue.Text, FloatAddEnum.反应釜蒸汽压力上限, -0.1F, 0.6F);
}
else
{
Notify(EnumPromptType.Error, "校准失败", "设备未连接");
}
}


private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{

}

private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{

}

private void Canvas_MouseMove(object sender, MouseEventArgs e)
{

}

private void Canvas_MouseWheel(object sender, MouseWheelEventArgs e)
{

}
}
}

Loading…
Cancel
Save