Browse Source

实时曲线修改添加参照功能

HK研究所反应釜三屏显示
ZhaoGang 2 weeks ago
parent
commit
f993b9f8a8
11 changed files with 729 additions and 327 deletions
  1. +17
    -17
      BPASmartClient.Academy/50L/PlcControl.cs
  2. +5
    -2
      BPASmartClient.Academy/50L/SqliteOperate.cs
  3. +462
    -290
      BPASmartClient.Academy/View/DeviceChart50LView.xaml
  4. +21
    -2
      BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs
  5. +5
    -5
      BPASmartClient.Academy/View/DeviceControlView.xaml
  6. +7
    -7
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  7. +2
    -1
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs
  8. +201
    -1
      BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs
  9. +5
    -1
      BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs
  10. +3
    -1
      BPASmartClient.Academy/ViewModel/HistoryChart50LViewModel.cs
  11. +1
    -0
      BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs

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

@@ -24,6 +24,7 @@ namespace BPASmartClient.Academy._50L
public ConcurrentDictionary<string, string> AlarmInfo { get; private set; } = new ConcurrentDictionary<string, string>();
private ICommSiemens comm = CommHelper.Siemens;
public string id { get; set; } = "";
public DateTime ProductStartTime { get; set; }
public void Init()
{
AlarmInfoGet();
@@ -77,7 +78,7 @@ namespace BPASmartClient.Academy._50L
});

}
Thread.Sleep(2000);
//Thread.Sleep(2000);
}
private void Read()
{
@@ -193,31 +194,30 @@ namespace BPASmartClient.Academy._50L
DeviceStatus.BrineTankWeight = s.Content[9];
DeviceStatus.ReactPressure = s.Content[10];


SamplingData sampling = new SamplingData()
{
Temperature = s.Content[0],
SteamPressure = s.Content[1],
SteamFlowRate = s.Content[2],
CondensateWaterTemperature = s.Content[3],
CondensateWaterHumidity = s.Content[4],
NegativePressureFlowRate = s.Content[5],
WeighingWaterTankWeight = s.Content[6],
ReactEncoderValue = s.Content[7],
ProportionalValveOpening = s.Content[8],
BrineTankWeight = s.Content[9],
ReactPressure = s.Content[10]
};
if (Delay.GetInstance("趋势数据").Start(_isReadSuccess, 2))
{
_isReadSuccess = false;
}
else if (!_isReadSuccess)
{
SqliteOperate.GetInstance.RealtimeChart(sampling);
if (!string.IsNullOrWhiteSpace(id))
{
SamplingData sampling = new SamplingData()
{
Temperature = s.Content[0],
SteamPressure = s.Content[1],
SteamFlowRate = s.Content[2],
CondensateWaterTemperature = s.Content[3],
CondensateWaterHumidity = s.Content[4],
NegativePressureFlowRate = s.Content[5],
WeighingWaterTankWeight = s.Content[6],
ReactEncoderValue = s.Content[7],
ProportionalValveOpening = s.Content[8],
BrineTankWeight = s.Content[9],
ReactPressure = s.Content[10]
};
sampling.ProductNumberId = id;
SqliteOperate.GetInstance.RealtimeChart(sampling, ProductStartTime);
SqliteOperate.GetInstance.Add(sampling);
}
_isReadSuccess = true;


+ 5
- 2
BPASmartClient.Academy/50L/SqliteOperate.cs View File

@@ -48,9 +48,12 @@ namespace BPASmartClient.Academy._50L
catch (Exception ex)
{ }
}
public void RealtimeChart(SamplingData sampling)
public void RealtimeChart(SamplingData sampling,DateTime productStartTime)
{
DateTime time = DateTime.Now;
//DateTime time = DateTime.Now;
var interval= DateTime.Now - productStartTime;
//TimeOnly time = new TimeOnly(interval.Ticks);
DateTime time = new DateTime(interval.Ticks);
DataView(DataFeedBacks.Temperature, new DataValue() { DateTime = time, Value = sampling.Temperature });
DataView(DataFeedBacks.SteamPressure, new DataValue() { DateTime = time, Value = sampling.SteamPressure });
DataView(DataFeedBacks.SteamFlowRate, new DataValue() { DateTime = time, Value = sampling.SteamFlowRate });


+ 462
- 290
BPASmartClient.Academy/View/DeviceChart50LView.xaml View File

@@ -7,324 +7,496 @@
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oxy="http://oxyplot.org/wpf" xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d">
d:DesignHeight="949" d:DesignWidth="1734" mc:Ignorable="d">
<UserControl.DataContext>
<vm:DeviceChart50LViewModel />
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="setCheck" TargetType="{x:Type RadioButton}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border Background="Transparent" BorderThickness="0">
<ContentControl
x:Name="check"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
Foreground="#777777" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="check" Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="check" Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<ScrollViewer x:Name="ooo" Grid.Row="1">
<StackPanel>
<StackPanel Orientation="Vertical">
<StackPanel
Margin="0,0,60,0" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center" FontSize="16" Foreground="DeepSkyBlue" Text="产品编号:" />
<TextBox
Width="200" Height="30" Margin="0,0,10,0" VerticalContentAlignment="Center"
Background="Transparent" BorderBrush="DeepSkyBlue" CaretBrush="DeepSkyBlue" FontSize="16"
Foreground="DeepSkyBlue"
Style="{x:Null}"
Text="{Binding ProductNum}" />

<UniformGrid Columns="2" Rows="4">
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
x:Name="ppp" Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="温度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Red" StrokeThickness="2"
Values="{Binding DataFeedback.Temperature}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Blue" StrokeThickness="2"
Values="{Binding DataFeedback.CondensateWaterTemperature}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="210" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="温度曲线/℃" />
<Button
Width="120" Height="30"
Command="{Binding FindProductCommand}"
Content="查询编号"
Style="{StaticResource ButtonStyle}" />

<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="Red" />
<TextBlock Foreground="White" Text="反应釜温度" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="Blue" />
<TextBlock Foreground="White" Text="冷凝水罐温度" />
<TextBlock
Margin="30,0,0,0" VerticalAlignment="Center" FontSize="16" Foreground="DeepSkyBlue"
Text="查询时间:" />
<DatePicker
Width="150" Margin="0,0,10,0" BorderBrush="DeepSkyBlue" FontSize="16"
SelectedDate="{Binding SelectTime}"
Style="{DynamicResource PickerStyle}" />

<Button
Width="120" Height="30"
Command="{Binding Select}"
Content="查询"
Style="{StaticResource ButtonStyle}" />
<Button
Command="{Binding ShowRefrenceWindowCommand}"
Content="打开参照曲线选择"
Style="{StaticResource ButtonStyle}" />
<Button
Command="{Binding HiddenRefrenceWindowCommand}"
Content="关闭参照曲线选择"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
<!--#region 表格-->
<Grid
Grid.Column="0" Margin="20,20,20,0" d:Visibility="Visible" Background="Transparent"
Visibility="{Binding ReferenceWindownVisiblity}">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<!--#region 标题-->
<Grid Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
<ColumnDefinition Width="400" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="1" BorderBrush="#777777" BorderThickness="0.8" />
<Border
Grid.ColumnSpan="2" BorderBrush="#777777" BorderThickness="0,0.8,0.8,0.8" />
<Border
Grid.ColumnSpan="3" BorderBrush="#777777" BorderThickness="0,0.8,0.8,0.8" />
<Border
Grid.ColumnSpan="4" BorderBrush="#777777" BorderThickness="0,0.8,0.8,0.8" />
<TextBlock
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"
Text="序号" />
<TextBlock
Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="配方名称" />
<TextBlock
Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="创建时间" />
<TextBlock
Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="操作" />
</Grid>
<!--#endregion-->
<!--#region 表格内容-->
<ScrollViewer
Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RecipeCharts}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid
Height="30" Margin="0,1" Background="#163175">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
<ColumnDefinition Width="400" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="1" BorderBrush="#777777" BorderThickness="0.4" />
<Border
Grid.ColumnSpan="2" BorderBrush="#777777" BorderThickness="0,0.4,0.4,0.4" />
<Border
Grid.ColumnSpan="3" BorderBrush="#777777" BorderThickness="0,0.4,0.4,0.4" />
<Border
Grid.ColumnSpan="4" BorderBrush="#777777" BorderThickness="0,0.4,0.4,0.4" />
<TextBlock
x:Name="num" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White"
Text="{Binding Num}" />
<TextBlock
Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"
FontSize="16" Foreground="White"
Text="{Binding Name}" />
<TextBlock
Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White"
Text="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" />
<RadioButton
x:Name="ceshi" Grid.Column="3"
Command="{Binding DataContext.InspectDataCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
CommandParameter="{Binding Id}"
Content="添加参照" FontSize="16" Foreground="White"
Style="{StaticResource setCheck}" />
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!--#endregion-->
</Grid>

<!--#endregion-->
</StackPanel>
<UniformGrid Columns="2" Rows="4">
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
x:Name="ppp" Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="温度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Red" StrokeThickness="2"
Values="{Binding DataFeedback.Temperature}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Blue" StrokeThickness="2"
Values="{Binding DataFeedback.CondensateWaterTemperature}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Tomato" StrokeThickness="2"
Values="{Binding PartReferenceData.Temperature}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="AliceBlue" StrokeThickness="2"
Values="{Binding PartReferenceData.CondensateWaterTemperature}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="210" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="温度曲线/℃" />

<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="Red" />
<TextBlock Foreground="White" Text="反应釜温度" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="Blue" />
<TextBlock Foreground="White" Text="冷凝水罐温度" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="压力曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#07F80C" StrokeThickness="2"
Values="{Binding DataFeedback.SteamPressure}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#FFFFFF" StrokeThickness="2"
Values="{Binding DataFeedback.ReactPressure}" />
<!--<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#423FFD"
StrokeThickness="2"
Values="{Binding DataFeedback.M102_Speed}" />-->
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="0.7" MinValue="-0.2">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="压力曲线/MPa" />
<!--<Rectangle
Width="20"
Height="2"
Margin="10,0,0,2"
Fill="#423FFD" />
<TextBlock Foreground="White" Text="物料罐转速" />-->
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="#F44F15" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="#FFFFFF" />
<TextBlock Foreground="White" Text="反应釜压力" />
</StackPanel>

</StackPanel>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="压力曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#07F80C" StrokeThickness="2"
Values="{Binding DataFeedback.SteamPressure}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#FFFFFF" StrokeThickness="2"
Values="{Binding DataFeedback.ReactPressure}" />
<!--<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#423FFD"
StrokeThickness="2"
Values="{Binding DataFeedback.M102_Speed}" />-->
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="0.7" MinValue="-0.2">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="压力曲线/MPa" />
<!--<Rectangle
Width="20"
Height="2"
Margin="10,0,0,2"
Fill="#423FFD" />
<TextBlock Foreground="White" Text="物料罐转速" />-->
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="#F44F15" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="#FFFFFF" />
<TextBlock Foreground="White" Text="反应釜压力" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="比例阀开度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.ProportionalValveOpening}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="110" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="比例阀开度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="蒸汽比例阀开度" />
</StackPanel>

</StackPanel>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="比例阀开度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.ProportionalValveOpening}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="110" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="比例阀开度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="蒸汽比例阀开度" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="流量曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Red" StrokeThickness="2"
Values="{Binding DataFeedback.SteamFlowRate}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#F1C74B" StrokeThickness="2"
Values="{Binding DataFeedback.NegativePressureFlowRate}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis LabelFormatter="{Binding doubleFormatter}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="流量曲线/Mpa" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Red" />
<TextBlock Foreground="White" Text="反应釜蒸汽流量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="#F1C74B" />
<TextBlock Foreground="White" Text="负压流量" />
</StackPanel>

</StackPanel>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="流量曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Red" StrokeThickness="2"
Values="{Binding DataFeedback.SteamFlowRate}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#F1C74B" StrokeThickness="2"
Values="{Binding DataFeedback.NegativePressureFlowRate}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis LabelFormatter="{Binding doubleFormatter}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="流量曲线/Mpa" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Red" />
<TextBlock Foreground="White" Text="反应釜蒸汽流量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="#F1C74B" />
<TextBlock Foreground="White" Text="负压流量" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="重量曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Blue" StrokeThickness="2"
Values="{Binding DataFeedback.WeighingWaterTankWeight}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Brown" StrokeThickness="2"
Values="{Binding DataFeedback.BrineTankWeight}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="35" MinValue="-5">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="重量曲线/kg" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Blue" />
<TextBlock Foreground="White" Text="冷却水罐重量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Brown" />
<TextBlock Foreground="White" Text="卤水罐重量" />
</StackPanel>

</StackPanel>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="重量曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Blue" StrokeThickness="2"
Values="{Binding DataFeedback.WeighingWaterTankWeight}" />
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Brown" StrokeThickness="2"
Values="{Binding DataFeedback.BrineTankWeight}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="35" MinValue="-5">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="重量曲线/kg" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Blue" />
<TextBlock Foreground="White" Text="冷却水罐重量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="Brown" />
<TextBlock Foreground="White" Text="卤水罐重量" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="湿度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.CondensateWaterHumidity}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="110" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="湿度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="冷凝水罐湿度" />
</StackPanel>

</StackPanel>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="湿度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.CondensateWaterHumidity}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="110" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="湿度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="冷凝水罐湿度" />
</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="反应釜角度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.ReactEncoderValue}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="400" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="反应釜角度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="反应釜编码器角度值" />
</StackPanel>

</StackPanel>
</UniformGrid>
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top" AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="反应釜角度曲线">
<lvc:CartesianChart.Series>
<lvc:LineSeries
Fill="Transparent" LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="White" StrokeThickness="2"
Values="{Binding DataFeedback.ReactEncoderValue}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="400" MinValue="-10">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="反应釜角度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="White" />
<TextBlock Foreground="White" Text="反应釜编码器角度值" />
</StackPanel>

</StackPanel>
</UniformGrid>
</StackPanel>
</ScrollViewer>
<Grid
x:Name="chartGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White"


+ 21
- 2
BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs View File

@@ -26,6 +26,8 @@ namespace BPASmartClient.Academy.View
/// </summary>
public partial class DeviceChart50LView : UserControl
{
//private volatile static DeviceChart50LView _Instance;
//public static DeviceChart50LView GetInstance => _Instance ?? (_Instance = new DeviceChart50LView());
public DeviceChart50LView()
{
InitializeComponent();
@@ -53,11 +55,12 @@ namespace BPASmartClient.Academy.View
OxyPlot.Series.LineSeries templine_1 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "冷凝水罐温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> twValues = new List<DataPoint>();
List<DataPoint> tvValues = new List<DataPoint>();
ConcurrentDictionary<DateTime,float> keyValues = new ConcurrentDictionary<DateTime,float>();
SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.Temperature));
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.CondensateWaterTemperature));
keyValues[t.Createtime] = t.Temperature;
});
templine.Points.AddRange(twValues);
templine_1.Points.AddRange(tvValues);
@@ -230,7 +233,23 @@ namespace BPASmartClient.Academy.View
break;
}
}

private void AddOxyLineSeries(string title,OxyColor markerFill, ConcurrentDictionary<DateTime, float> keyValues)
{
OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries()
{ LineStyle = LineStyle.Solid,
Title = title,
MarkerFill = markerFill,
MarkerSize = 2,
LineLegendPosition = OxyPlot.Series.LineLegendPosition.End
};
List<DataPoint> twValues = new List<DataPoint>();
foreach (var item in keyValues)
{
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(item.Key), item.Value));
}
templine.Points.AddRange(twValues);
plotModel.Series.Add(templine);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
chartGrid.Visibility = Visibility.Collapsed;


+ 5
- 5
BPASmartClient.Academy/View/DeviceControlView.xaml View File

@@ -24,7 +24,7 @@
<vm:DeviceControlViewModel />
</UserControl.DataContext>-->
<Border
Name="br" Background="#FF0B2F5F" BorderBrush="#0CADF5" BorderThickness="0">
Name="br" Background="#FF0B2F5F" BorderBrush="#0CADF5" BorderThickness="1.5" Padding="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
@@ -56,21 +56,21 @@
<!--#endregion-->

<!--#region 指令状态显示-->
<TextBlock
<!--<TextBlock
Grid.Row="2" Grid.Column="0" FontSize="28" Text="当前指令状态:" />
<TextBlock
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"
d:Text="打开" FontSize="28"
Text="{Binding CommandState}" />
Text="{Binding CommandState}" />-->
<!--#endregion-->

<!--#region 设备状态显示-->
<TextBlock
<!--<TextBlock
Grid.Row="3" Grid.Column="0" FontSize="28" Text="当前设备状态:" />
<TextBlock
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"
d:Text="关闭" FontSize="28"
Text="{Binding DeviceState}" />
Text="{Binding DeviceState}" />-->
<!--#endregion-->

<!--#region 按钮-->


+ 7
- 7
BPASmartClient.Academy/View/ReactionKettle50LView.xaml View File

@@ -1111,10 +1111,10 @@
Canvas.Left="205" Canvas.Top="465" Canvas.Right="206.5" HorizontalAlignment="Left"
VerticalAlignment="Top" Foreground="White" Text="卤水泵" />
<cc:ValveWithCommandState MouseLeftButtonDown="Canvas_MouseDown"
Canvas.Left="394" Canvas.Top="369"
Canvas.Left="394" Canvas.Top="377" Tag="反应釜压缩空气进气阀"
CommandColor="{Binding DeviceStatus.IsSetReactPressureAirInValve, Converter={StaticResource BoolToColorConverter}}"
EdgeColor="{Binding DeviceStatus.ReactPressureAirInValve, ConverterParameter=2, Converter={StaticResource deviceConvert}}"
OpenEnable="{Binding DeviceStatus.ReactPressureAirInValve}" />
OpenEnable="{Binding DeviceStatus.ReactPressureAirInValve}" HorizontalAlignment="Center" VerticalAlignment="Top" Width="35" Height="24" />


<Grid
@@ -1260,23 +1260,23 @@
Fill="{Binding DeviceStatus.ReactInSteamValue, ConverterParameter=2, Converter={StaticResource deviceConvert}}"
LineWidth="10" Speed="1.5" />
<bpa:PipeLineV
Canvas.Left="371" Canvas.Top="121" Canvas.Right="404.2" Width="10"
Height="222" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
Canvas.Left="371" Canvas.Top="119" Canvas.Right="404.2" Width="10"
Height="224" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
Direction="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=1, Converter={StaticResource deviceConvert}}"
Fill="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=6, Converter={StaticResource deviceConvert}}"
LineWidth="1" />
<bpa:PipeLineBL
Canvas.Left="361" Canvas.Top="101" Canvas.Right="404.2" Width="20"
Canvas.Left="361" Canvas.Top="99" Canvas.Right="404.2" Width="20"
Height="20" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
Direction="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=1, Converter={StaticResource deviceConvert}}"
Fill="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=6, Converter={StaticResource deviceConvert}}"
LineWidth="10" Speed="1.5" />
LineWidth="6" Speed="1.5" />
<bpa:PipeLineTL
Canvas.Left="361" Canvas.Top="342" Canvas.Right="238.3" Width="20"
Height="20" HorizontalAlignment="Center" VerticalAlignment="Top" d:Direction="1"
Direction="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=1, Converter={StaticResource deviceConvert}}"
Fill="{Binding DeviceStatus.ColdWaterTankInWaterValve, ConverterParameter=6, Converter={StaticResource deviceConvert}}"
LineWidth="10" Speed="1.5" />
LineWidth="6" Speed="1.5" />
<TextBlock
Canvas.Left="798" Canvas.Top="120" Canvas.Right="312.8" HorizontalAlignment="Left"
VerticalAlignment="Center" FontSize="12" Foreground="White" Text="反应釜泄压阀"


+ 2
- 1
BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.Academy._50L;
using BPASmartClient.Academy.CustomControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using System;
using System.Collections.Generic;
@@ -271,7 +272,7 @@ namespace BPASmartClient.Academy.View

private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.Source is HandValve valve)
if (e.Source is ValveWithCommandState valve)
{
if (PlcControl.GetInstance.IsConnect && valve.Tag != null && !string.IsNullOrWhiteSpace(valve.Tag.ToString().Trim()))
{


+ 201
- 1
BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs View File

@@ -3,12 +3,21 @@ using BPASmartClient.Academy.Model;
using LiveCharts;
using LiveCharts.Configurations;
using LiveCharts.Wpf;

using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows;
using OxyLineSeries = OxyPlot.Series.LineSeries;
using OxyPlot.Wpf;

namespace BPASmartClient.Academy.ViewModel
{
@@ -24,18 +33,209 @@ namespace BPASmartClient.Academy.ViewModel
.Y(model => model.Value);
Charting.For<DataValue>(mapper);
DataFeedback = SqliteOperate.GetInstance.DataFeedBacks;


LoadNames(SqliteOperate.GetInstance.FindNames(SelectTime));

Select = new BPARelayCommand(() => { LoadNames(SqliteOperate.GetInstance.FindNames(SelectTime)); });

FindProductCommand = new BPARelayCommand(() => { LoadNames(SqliteOperate.GetInstance.FindNames(ProductNum)); });

InspectDataCommand = new BPARelayCommand<string>(s => { OxyInit(s); });

CheckedCommand = new BPARelayCommand<string>(async s =>
{
if (int.TryParse(s, out int index))
{
if (VisStatus.Length == OxyDataModels.Count && index >= 0 && index < VisStatus.Length)
{
IsEnable = false;

await Task.Run(() =>
{
sw.Start();
if (VisStatus[index]) OxyModel.Series.Add(OxyDataModels[index].Line);
else OxyModel.Series.Remove(OxyDataModels[index].Line);
OxyModel.InvalidatePlot(true); //重新加载曲线
IsEnable = true;
Debug.WriteLine(sw.ElapsedMilliseconds);
sw.Restart();
});

}
}
});

ShowRefrenceWindowCommand = new BPARelayCommand(() => {
ReferenceWindownVisiblity = Visibility.Visible;
});
HiddenRefrenceWindowCommand = new BPARelayCommand(() => {
ReferenceWindownVisiblity = Visibility.Collapsed;
});
Task.Factory.StartNew(async () =>
{
while (true)
{
if (ReferenceData != null && ReferenceData.Temperature.Count > 0)
{
DateTime startTime = DataFeedback.Temperature.Select(x => x.DateTime).Min();
DateTime endTime = DataFeedback.Temperature.Select(x => x.DateTime).Max().AddSeconds(6);

PartReferenceData.Temperature.Clear();
PartReferenceData.SteamPressure.Clear();
PartReferenceData.SteamPressure.Clear();
PartReferenceData.CondensateWaterTemperature.Clear();
PartReferenceData.CondensateWaterHumidity.Clear();
PartReferenceData.NegativePressureFlowRate.Clear();
PartReferenceData.WeighingWaterTankWeight.Clear();
PartReferenceData.ReactEncoderValue.Clear();
PartReferenceData.ProportionalValveOpening.Clear();
PartReferenceData.BrineTankWeight.Clear();
PartReferenceData.ReactPressure.Clear();

PartReferenceData.Temperature.AddRange(ReferenceData.Temperature.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.SteamPressure.AddRange(ReferenceData.SteamPressure.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.SteamPressure.AddRange(ReferenceData.SteamFlowRate.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.CondensateWaterTemperature.AddRange(ReferenceData.CondensateWaterTemperature.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.CondensateWaterHumidity.AddRange(ReferenceData.CondensateWaterHumidity.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.NegativePressureFlowRate.AddRange(ReferenceData.NegativePressureFlowRate.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.WeighingWaterTankWeight.AddRange(ReferenceData.WeighingWaterTankWeight.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.ReactEncoderValue.AddRange(ReferenceData.ReactEncoderValue.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.ProportionalValveOpening.AddRange(ReferenceData.ProportionalValveOpening.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.BrineTankWeight.AddRange(ReferenceData.BrineTankWeight.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.ReactPressure.AddRange(ReferenceData.ReactPressure.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));

}
await Task.Delay(2000);
}
}, TaskCreationOptions.LongRunning);
}


private DataFeedBack_50 dataFeedback;
public DataFeedBack_50 DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }

private DataFeedBack_50 _referenceData;
public DataFeedBack_50 ReferenceData { get { return _referenceData; } set { _referenceData = value; OnPropertyChanged(); } }

private DataFeedBack_50 _partReferenceData;
public DataFeedBack_50 PartReferenceData { get { return _partReferenceData; } set { _partReferenceData = value; OnPropertyChanged(); } }

public Func<double, string> DateTimeFormatter { get; set; } = value => value > 0 ? new DateTime((long)value).ToString("HH:mm:ss") : new DateTime((long)DateTime.Now.Ticks).ToString("HH:mm:ss");

public Func<double, string> doubleFormatter { get; set; } = value => value.ToString("F2");


private Visibility _referenceWindownVisiblity=Visibility.Collapsed;
public Visibility ReferenceWindownVisiblity { get { return _referenceWindownVisiblity; } set { _referenceWindownVisiblity = value; OnPropertyChanged(); } }

public double AxisStep { get; set; } = TimeSpan.FromSeconds(2).Ticks;
public double AxisUnit { get; set; } = TimeSpan.TicksPerSecond;

Stopwatch sw = new Stopwatch();

private void OxyInit(string Id)
{
ReferenceData = new();
PartReferenceData = new();
var data = SqliteOperate.GetInstance.QueryableById(Id);
DateTime productStartTime = data.Select(x => x.Createtime).Min();
data.ForEach(item =>
{
var interval = item.Createtime - productStartTime;
DateTime time = new DateTime(interval.Ticks);
ReferenceData.Temperature.Add(new DataValue() { DateTime = time, Value = item.Temperature });
ReferenceData.SteamPressure.Add(new DataValue() { DateTime = time, Value = item.SteamPressure });
ReferenceData.SteamFlowRate.Add(new DataValue() { DateTime = time, Value = item.SteamFlowRate });
ReferenceData.CondensateWaterTemperature.Add(new DataValue() { DateTime = time, Value = item.CondensateWaterTemperature });
ReferenceData.CondensateWaterHumidity.Add(new DataValue() { DateTime = time, Value = item.CondensateWaterHumidity });
ReferenceData.NegativePressureFlowRate.Add(new DataValue() { DateTime = time, Value = item.NegativePressureFlowRate });
ReferenceData.WeighingWaterTankWeight.Add(new DataValue() { DateTime = time, Value = item.WeighingWaterTankWeight });
ReferenceData.ReactEncoderValue.Add(new DataValue() { DateTime = time, Value = item.ReactEncoderValue });
ReferenceData.ProportionalValveOpening.Add(new DataValue() { DateTime = time, Value = item.ProportionalValveOpening });
ReferenceData.BrineTankWeight.Add(new DataValue() { DateTime = time, Value = item.BrineTankWeight });
ReferenceData.ReactPressure.Add(new DataValue() { DateTime = time, Value = item.ReactPressure });
});

}

private OxyLineSeries CreateLine(string title)
{
var scb = Application.Current.TryFindResource(title) as SolidColorBrush;
var color = scb.ToOxyColor();
return new OxyLineSeries()
{
LineStyle = LineStyle.Solid,
Title = title,
MarkerFill = scb.ToOxyColor(),
MarkerSize = 2,
LineLegendPosition = LineLegendPosition.End,
Color = color,
};
}

private void LoadNames(List<SaveNameData> data)
{
if (data == null) return;
if (data.Count <= 0)
{
MessageNotify.GetInstance.OpenMsg("未查询到有效记录");
return;
}
RecipeCharts.Clear();
data.ForEach(item =>
{
RecipeCharts.Add(new RecipeChart()
{
Num = RecipeCharts.Count + 1,
CreateTime = item.Createtime,
Name = item.ProductNumber,
Id = item.Id,
});
});
}

public List<OxyDataModel> OxyDataModels { get; set; } = new List<OxyDataModel>();

public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = new ObservableCollection<RecipeChart>();

public DateTime SelectTime { get { return _mSelectTime; } set { _mSelectTime = value; OnPropertyChanged(); } }
private DateTime _mSelectTime = DateTime.Now;

public string ProductNum { get { return _mProductNum; } set { _mProductNum = value; OnPropertyChanged(); } }
private string _mProductNum;

public PlotModel OxyModel { get { return _mOxyModel; } set { _mOxyModel = value; OnPropertyChanged(); } }
private PlotModel _mOxyModel = new PlotModel();


public bool[] VisStatus { get { return _mVisStatus; } set { _mVisStatus = value; OnPropertyChanged(); } }
private bool[] _mVisStatus = new bool[11];

public bool IsEnable
{
get { return _mIsEnable; }
set
{
_mIsEnable = value;
LoadingVis = value ? Visibility.Collapsed : Visibility.Visible;
OnPropertyChanged();
}
}
private bool _mIsEnable = true;

public Visibility LoadingVis { get { return _mLoadingVis; } set { _mLoadingVis = value; OnPropertyChanged(); } }
private Visibility _mLoadingVis = Visibility.Collapsed;


public BPARelayCommand Select { get; set; }

public BPARelayCommand FindProductCommand { get; set; }

public BPARelayCommand<string> InspectDataCommand { get; set; }

public BPARelayCommand<string> CheckedCommand { get; set; }

public BPARelayCommand ShowRefrenceWindowCommand { get;private set; }
public BPARelayCommand HiddenRefrenceWindowCommand { get; private set; }
}
}

+ 5
- 1
BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs View File

@@ -110,9 +110,13 @@ namespace BPASmartClient.Academy.ViewModel
private DateTime _dateTime;

public DateTime DateTime { get { return _dateTime; } set { _dateTime = value; OnPropertyChanged(); } }
private double _value;


//public TimeOnly DateTime { get { return _dateTime; } set { _dateTime = value; OnPropertyChanged(); } }
//private TimeOnly _dateTime;

public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } }
private double _value;
}

}

+ 3
- 1
BPASmartClient.Academy/ViewModel/HistoryChart50LViewModel.cs View File

@@ -96,7 +96,9 @@ namespace BPASmartClient.Academy.ViewModel
Position = OxyPlot.Axes.AxisPosition.Bottom,
Title = "时间",
StringFormat = "HH:mm:ss",
AxislineColor = OxyColor.FromRgb(84, 164, 227)
AxislineColor = OxyColor.FromRgb(84, 164, 227),
AbsoluteMinimum = OxyDataModels[0].dataPoints[0].X,
AbsoluteMaximum = OxyDataModels[0].dataPoints[OxyDataModels[0].dataPoints.Count - 1].X,
});
OxyModel.Axes.Add(new LinearAxis()
{


+ 1
- 0
BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs View File

@@ -32,6 +32,7 @@ namespace BPASmartClient.Academy.ViewModel
dataFeedback.ProductNumberId = snd.Id;
SqliteOperate.GetInstance.Add(snd);
PlcControl.GetInstance.id = snd.Id;
PlcControl.GetInstance.ProductStartTime=DateTime.Now;
SqliteOperate.GetInstance.DataFeedBacks = dataFeedback;
Content = "系统停止";
}


Loading…
Cancel
Save