4 Commits

21 changed files with 2137 additions and 2359 deletions
Split View
  1. +3
    -0
      BPASmartClient.Academy/50L/AlarmData.cs
  2. +6
    -0
      BPASmartClient.Academy/50L/DeviceStatus.cs
  3. +26
    -9
      BPASmartClient.Academy/50L/PlcControl.cs
  4. +2
    -0
      BPASmartClient.Academy/50L/SqliteOperate.cs
  5. +5
    -4
      BPASmartClient.Academy/App.config
  6. +1
    -0
      BPASmartClient.Academy/App.xaml
  7. +17
    -5
      BPASmartClient.Academy/App.xaml.cs
  8. +2
    -0
      BPASmartClient.Academy/ColorResource.xaml
  9. +30
    -0
      BPASmartClient.Academy/Converter/BoolToColorConverter.cs
  10. +8
    -0
      BPASmartClient.Academy/Model/DataFeedback.cs
  11. +8
    -0
      BPASmartClient.Academy/Model/DeviceCtrl.cs
  12. +12
    -0
      BPASmartClient.Academy/Model/Simens_PLC.cs
  13. +292
    -282
      BPASmartClient.Academy/View/DeviceChart50LView.xaml
  14. +162
    -101
      BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs
  15. +367
    -1022
      BPASmartClient.Academy/View/DeviceMotion_2View.xaml
  16. +58
    -143
      BPASmartClient.Academy/View/HistoryChart50LView.xaml
  17. +1032
    -778
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  18. +87
    -0
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs
  19. +3
    -1
      BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs
  20. +5
    -1
      BPASmartClient.Academy/ViewModel/HistoryChart50LViewModel.cs
  21. +11
    -13
      BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.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; }
}
}

+ 6
- 0
BPASmartClient.Academy/50L/DeviceStatus.cs View File

@@ -108,6 +108,12 @@ namespace BPASmartClient.Academy._50L
public bool ColdWaterTankVacuumValve { get { return _coldWaterTankVacuumValve; } set { _coldWaterTankVacuumValve = value; OnPropertyChanged(); } }
private bool _coldWaterTankVacuumValve;

/// <summary>
/// 空压机启动反馈 V2002.1
/// </summary>
public bool CompressorRunning { get { return _compressorRunning; } set { _compressorRunning = value; OnPropertyChanged(); } }
private bool _compressorRunning;

/// <summary>
/// 心跳反馈 V2003.7
/// </summary>


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

@@ -18,7 +18,10 @@ 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; }
public string id { get; set; } = "";
private bool _lastConnectState;
private volatile uint _readFailureCount;
public void Init()
{
Task.Factory.StartNew(() =>
@@ -26,6 +29,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,10 +40,10 @@ namespace BPASmartClient.Academy._50L

private void Read()
{

TaskManage.GetInstance.StartLong(() =>
{
comm.Read<bool[]>("DB1.DBX2000.0", 17).OnSuccess(s =>
_readFailureCount = 0;
comm.Read<bool[]>("DB1.DBX2000.0", 31).OnSuccess(s =>
{
//Data[FeedbackData.旋转电机启停反馈] = s.Content[0];
//Data[FeedbackData.负压风机启动反馈] = s.Content[1];
@@ -59,7 +64,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 +79,10 @@ namespace BPASmartClient.Academy._50L
#endregion

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

comm.Read<float[]>("DB1.DBD2006", 10).OnSuccess(s =>
{
@@ -117,9 +123,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 +133,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(() =>


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

@@ -58,7 +58,9 @@ namespace BPASmartClient.Academy._50L
DataView(DataFeedBacks.CondensateWaterHumidity, new DataValue() { DateTime = time, Value = sampling.CondensateWaterHumidity });
DataView(DataFeedBacks.NegativePressureFlowRate, new DataValue() { DateTime = time, Value = sampling.NegativePressureFlowRate });
DataView(DataFeedBacks.WeighingWaterTankWeight, new DataValue() { DateTime = time, Value = sampling.WeighingWaterTankWeight });
DataView(DataFeedBacks.ReactEncoderValue, new DataValue() { DateTime = time, Value = sampling.ReactEncoderValue });
DataView(DataFeedBacks.ProportionalValveOpening, new DataValue() { DateTime = time, Value = sampling.ProportionalValveOpening });
DataView(DataFeedBacks.BrineTankWeight, new DataValue() { DateTime = time, Value = sampling.BrineTankWeight });
}
private void DataView<T>(ChartValues<T> values, T value)
{


+ 5
- 4
BPASmartClient.Academy/App.config View File

@@ -8,10 +8,11 @@
<FlexBatchSystem>
<Alarm>
<add key="DB1.DBX2004.0" value="急停"/>
<add key="DB1.DBX2004.1" value="M101电机异常"/>
<add key="DB1.DBX2004.2" value="M102电机异常"/>
<add key="DB1.DBX2004.3" value="M103电机异常"/>
<add key="DB1.DBX2004.4" value="通讯异常"/>
<add key="DB1.DBX2004.1" value="配料罐搅拌异常"/>
<add key="DB1.DBX2004.2" value="反应釜搅拌异常"/>
<add key="DB1.DBX2004.3" value="真空泵异常"/>
<add key="DB1.DBX2004.4" value="一体机柜急停按下"/>
<add key="DB1.DBX2004.5" value="空压机异常"/>
</Alarm>
</FlexBatchSystem>
</configuration>

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

@@ -40,6 +40,7 @@
</ResourceDictionary>
<ResourceDictionary>
<convert:DeviceCtrlConvert x:Key="deviceConvert" />
<convert:BoolToColorConverter x:Key="BoolToColorConverter" TrueColor="Green" FalseColor="Red"/>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>



+ 17
- 5
BPASmartClient.Academy/App.xaml.cs View File

@@ -100,12 +100,24 @@ namespace BPASmartClient.Academy
Json<LocaMaterial>.Save();
BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave();
TaskManage.GetInstance.Dispose();
if (Simens_PLC.GetInstance.IsConnected)
switch (Json<DevicePar>.Data.ProjectTypeName)
{
Simens_PLC.GetInstance.id = "";
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
case "HKYF20240916":
if (PlcControl.GetInstance.IsConnect)
{
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, false);
}
break;
default:
if (Simens_PLC.GetInstance.IsConnected)
{
Simens_PLC.GetInstance.id = "";
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
}
break;
}
App.Current.Shutdown();
Environment.Exit(0);
//Process.GetCurrentProcess().Kill();
@@ -311,7 +323,7 @@ namespace BPASmartClient.Academy
break;
case ProjectType.HKYF20240916:
//SqliteOperate.GetInstance.Init();
//PlcControl.GetInstance.Init();
PlcControl.GetInstance.Init();
break;
default:
break;


+ 2
- 0
BPASmartClient.Academy/ColorResource.xaml View File

@@ -6,5 +6,7 @@
<SolidColorBrush x:Key="冷凝水罐湿度">#ffa500</SolidColorBrush>
<SolidColorBrush x:Key="负压流量">#9b30ff</SolidColorBrush>
<SolidColorBrush x:Key="称重水罐重量">#00ffff</SolidColorBrush>
<SolidColorBrush x:Key="反应釜编码器值">#7FFF00</SolidColorBrush>
<SolidColorBrush x:Key="比例阀实际开度">#ff00ff</SolidColorBrush>
<SolidColorBrush x:Key="卤水配制罐重量">#0000ff</SolidColorBrush>
</ResourceDictionary>

+ 30
- 0
BPASmartClient.Academy/Converter/BoolToColorConverter.cs View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace BPASmartClient.Academy.Converter
{
public class BoolToColorConverter:IValueConverter
{
public Brush? TrueColor { get; set; }
public Brush? FalseColor { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is bool tempBool)
{
return tempBool ? TrueColor : FalseColor;
}
return FalseColor;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 8
- 0
BPASmartClient.Academy/Model/DataFeedback.cs View File

@@ -121,8 +121,16 @@ namespace BPASmartClient.Academy.Model
/// </summary>
public ChartValues<DataValue> WeighingWaterTankWeight { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 反应釜编码器值
/// </summary>
public ChartValues<DataValue> ReactEncoderValue { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 蒸汽比例阀实际开度
/// </summary>
public ChartValues<DataValue> ProportionalValveOpening { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 卤水配制罐重量
/// </summary>
public ChartValues<DataValue> BrineTankWeight { get; set; } = new ChartValues<DataValue>();
}
}

+ 8
- 0
BPASmartClient.Academy/Model/DeviceCtrl.cs View File

@@ -71,5 +71,13 @@ namespace BPASmartClient.Academy.Model
private float _pressureWeek;
public float OpenValue { get { return _openValue; } set { _openValue = value; OnPropertyChanged(); } }
private float _openValue;

public bool Compressor { get { return _compressor; } set { _compressor = value; OnPropertyChanged(); } }
private bool _compressor = false;

public bool ByPassMaterial { get { return _byPassMaterial; } set { _byPassMaterial = value; OnPropertyChanged(); } }
private bool _byPassMaterial = false;
public bool ByPassReact { get { return _byPassReact; } set { _byPassReact = value; OnPropertyChanged(); } }
private bool _byPassReact = false;
}
}

+ 12
- 0
BPASmartClient.Academy/Model/Simens_PLC.cs View File

@@ -218,6 +218,18 @@ namespace BPASmartClient.Academy.Model
{
deviceCtrl.VX115 = o.Content;
});
siemens.Read<bool>("DB1.DBX2002.3").OnSuccess(o =>
{
deviceCtrl.Compressor = o.Content;
});
siemens.Read<bool>("DB1.DBX2002.4").OnSuccess(o =>
{
deviceCtrl.ByPassMaterial = o.Content;
});
siemens.Read<bool>("DB1.DBX2002.5").OnSuccess(o =>
{
deviceCtrl.ByPassReact = o.Content;
});
siemens.Read<int>("DB1.DBD2022").OnSuccess(o =>
{
deviceCtrl.TempWok = o.Content;


+ 292
- 282
BPASmartClient.Academy/View/DeviceChart50LView.xaml View File

@@ -6,321 +6,331 @@
xmlns:local="clr-namespace:BPASmartClient.Academy.View"
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">
<UserControl.DataContext>
xmlns:oxy="http://oxyplot.org/wpf" xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d">
<!--<UserControl.DataContext>
<vm:DeviceChart50LViewModel />
</UserControl.DataContext>
</UserControl.DataContext>-->
<Grid>
<UniformGrid
x:Name="ooo"
Grid.Row="1"
Columns="2"
Rows="2">
<StackPanel Orientation="Vertical">
<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.CondensateWaterHumidity}" />
<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Blue"
StrokeThickness="2"
Values="{Binding DataFeedback.TempMaterial}" />
<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Green"
StrokeThickness="2"
Values="{Binding DataFeedback.TempVent}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<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="Blue" />
<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="Green" />
<TextBlock Foreground="White" Text="排气温度" />
</StackPanel>
<ScrollViewer x:Name="ooo" Grid.Row="1">

</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:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="200" 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="温度曲线/℃" />

<StackPanel Margin="20,0,0,0" Orientation="Vertical">
<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="#F44F15"
StrokeThickness="2"
Values="{Binding DataFeedback.M101_Speed}" />
<lvc:LineSeries
<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>

<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="#F44F15" StrokeThickness="2"
Values="{Binding DataFeedback.SteamPressure}" />
<!--<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>
<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="转速曲线/rpm" />
<Rectangle
Values="{Binding DataFeedback.M102_Speed}" />-->
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="0.6" MinValue="-0.1">
<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="反应釜转速" />
<TextBlock Foreground="White" Text="物料罐转速" />-->
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="#F44F15" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力" />
</StackPanel>

</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="100" 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 Orientation="Vertical">
<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.OpenValve}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<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="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 Orientation="Vertical">
<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="#F1C74B"
StrokeThickness="2"
Values="{Binding DataFeedback.PressureWok}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="1.0"
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="压力曲线/Mpa" />
<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="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="30" 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="0,20,0,0" Orientation="Vertical">
<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="Purple"
StrokeThickness="2"
Values="{Binding DataFeedback.WeightWok}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<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="Purple" />
<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.CondensateWaterHumidity}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="100" 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.ReactEncoderValue}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MaxValue="400" 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>
</UniformGrid>
</ScrollViewer>
<Grid
x:Name="chartGrid"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="White"
x:Name="chartGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<oxy:PlotView
x:Name="chartView"
Margin="5"
Background="Transparent"
Foreground="Black"
x:Name="chartView" Margin="5" Background="Transparent" Foreground="Black"
PanCursor="Hand" />
<Button
Grid.Column="1"
Width="120"
Height=" 40"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="Button_Click"
Content="退出" />
Grid.Column="1" Width="120" Height=" 40" HorizontalAlignment="Center"
VerticalAlignment="Center" Click="Button_Click" Content="退出" />
</Grid>
</Grid>
</UserControl>

+ 162
- 101
BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs View File

@@ -17,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ThingsGateway.Foundation.Core;
using BPASmartClient.Academy._50L;

namespace BPASmartClient.Academy.View
{
@@ -28,6 +29,7 @@ namespace BPASmartClient.Academy.View
public DeviceChart50LView()
{
InitializeComponent();
this.DataContext = DeviceChart50LViewModel.GetInstance;
}


@@ -43,122 +45,181 @@ namespace BPASmartClient.Academy.View
switch (liveCharts.ToolTip)
{
case "温度曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "温度曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_1 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜排气温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_2 = 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>();
List<DataPoint> tmValues = new List<DataPoint>();
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
{
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempWok));
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempVent));
tmValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempMaterial));
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "温度曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
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>();
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));

});
line.Points.AddRange(twValues);
line_1.Points.AddRange(tvValues);
line_2.Points.AddRange(tmValues);
if (!(plotModel.Axes.Count > 0))
});
templine.Points.AddRange(twValues);
templine_1.Points.AddRange(tvValues);
//line_2.Points.AddRange(tmValues);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(templine);
plotModel.Series.Add(templine_1);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
break;
case "压力曲线":
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "反应釜蒸汽压力曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜蒸汽压力", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> pressure = new List<DataPoint>();
SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.SteamPressure));
});
line.Points.AddRange(pressure);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
}
plotModel.Series.Add(line);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
plotModel.Series.Add(line);
plotModel.Series.Add(line_1);
plotModel.Series.Add(line_2);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
case "转速曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "转速曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries line_3 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_4 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "配料罐转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> m101 = new List<DataPoint>();
List<DataPoint> m102 = new List<DataPoint>();
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
case "比例阀开度曲线":
{
m101.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M101_Speed));
m102.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M102_Speed));
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "比例阀开度曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "蒸汽比例阀开度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> open = new List<DataPoint>();
SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.ProportionalValveOpening));

});
line_3.Points.AddRange(m101);
line_4.Points.AddRange(m102);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
});
line.Points.AddRange(open);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/%", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
}
plotModel.Series.Add(line);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
plotModel.Series.Add(line_3);
plotModel.Series.Add(line_4);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
//case "比例阀开度曲线":
// plotModel.Series.Clear();
// plotModel = new PlotModel() { Title = "比例阀开度曲线" };
// chartGrid.Visibility = Visibility.Visible;
// List<DataPoint> open = new List<DataPoint>();
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
// {
// open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve));

// });
// line.Points.AddRange(open);
// if (!(plotModel.Axes.Count > 0))
// {
// plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange });
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
// }
// plotModel.Series.Add(line);
// plotModel.InvalidatePlot(true);//重新加载曲线
// chartView.Model = plotModel;
// break;
//case "压力曲线":
// plotModel.Series.Clear();
// plotModel = new PlotModel() { Title = "反应釜压力曲线" };
// chartGrid.Visibility = Visibility.Visible;
// List<DataPoint> pressure = new List<DataPoint>();
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
// {
// pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok));
case "流量曲线":
{
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "流量曲线" };
chartGrid.Visibility = Visibility.Visible;
OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜蒸汽流量", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
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>();
SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.SteamFlowRate));
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.NegativePressureFlowRate));

// });
// line.Points.AddRange(pressure);
// if (!(plotModel.Axes.Count > 0))
// {
// plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange });
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
// }
// plotModel.Series.Add(line);
// plotModel.InvalidatePlot(true);//重新加载曲线
// chartView.Model = plotModel;
// break;
});
templine.Points.AddRange(twValues);
templine_1.Points.AddRange(tvValues);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "流量", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(templine);
plotModel.Series.Add(templine_1);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
break;
case "重量曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "冷却水罐重量曲线" };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> ww = new List<DataPoint>();
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "冷却水罐重量", Color = OxyColor.FromRgb(0, 0, 0), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
{
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok));
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "重量曲线" };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> ww = new List<DataPoint>();
List<DataPoint> ww1 = new List<DataPoint>();
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "冷却水罐重量", Color = OxyColor.FromRgb(110, 79, 79), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_6 = new OxyPlot.Series.LineSeries() { Title = "卤水罐重量", Color = OxyColor.FromRgb(110, 79, 79), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };

});
line_5.Points.AddRange(ww);
if (!(plotModel.Axes.Count > 0))
SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.WeighingWaterTankWeight));
ww1.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.BrineTankWeight));
});
line_5.Points.AddRange(ww);
line_6.Points.AddRange(ww1);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_5);
plotModel.Series.Add(line_6);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
break;
case "湿度曲线":
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "湿度曲线" };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> ww = new List<DataPoint>();
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "冷却水罐湿度", Color = OxyColor.FromRgb(110, 79, 79), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };

SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.CondensateWaterHumidity));
});
line_5.Points.AddRange(ww);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "湿度", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
break;
case "反应釜角度曲线":
{
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "反应釜角度曲线" };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> ww = new List<DataPoint>();
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "反应釜角度", Color = OxyColor.FromRgb(110, 79, 79), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };

SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t =>
{
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.ReactEncoderValue));
});
line_5.Points.AddRange(ww);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "角度/°", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
}
plotModel.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
default:
break;


+ 367
- 1022
BPASmartClient.Academy/View/DeviceMotion_2View.xaml
File diff suppressed because it is too large
View File


+ 58
- 143
BPASmartClient.Academy/View/HistoryChart50LView.xaml View File

@@ -5,11 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.Academy.View"
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">
xmlns:oxy="http://oxyplot.org/wpf" xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d">
<UserControl.DataContext>
<vm:HistoryChart50LViewModel />
</UserControl.DataContext>
@@ -50,52 +47,32 @@
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel
Margin="0,0,60,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
Margin="0,0,60,0" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontSize="16"
Foreground="DeepSkyBlue"
Text="产品编号:" />
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"
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}" />

<Button
Width="120"
Height="30"
Width="120" Height="30"
Command="{Binding FindProductCommand}"
Content="查询编号"
Style="{StaticResource ButtonStyle}" />

<TextBlock
Margin="30,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="DeepSkyBlue"
Margin="30,0,0,0" VerticalAlignment="Center" FontSize="16" Foreground="DeepSkyBlue"
Text="查询时间:" />
<DatePicker
Width="150"
Margin="0,0,10,0"
BorderBrush="DeepSkyBlue"
FontSize="16"
Width="150" Margin="0,0,10,0" BorderBrush="DeepSkyBlue" FontSize="16"
SelectedDate="{Binding SelectTime}"
Style="{DynamicResource PickerStyle}" />

<Button
Width="120"
Height="30"
Width="120" Height="30"
Command="{Binding Select}"
Content="查询"
Style="{StaticResource ButtonStyle}" />
@@ -108,9 +85,7 @@
</Grid.ColumnDefinitions>
<!--#region 表格-->
<Grid
Grid.Column="0"
Margin="20,20,20,300"
Background="Transparent">
Grid.Column="0" Margin="20,20,20,300" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
@@ -124,63 +99,36 @@
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="1"
BorderBrush="#777777"
BorderThickness="0.8" />
Grid.ColumnSpan="1" BorderBrush="#777777" BorderThickness="0.8" />
<Border
Grid.ColumnSpan="2"
BorderBrush="#777777"
BorderThickness="0,0.8,0.8,0.8" />
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" />
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" />
Grid.ColumnSpan="4" BorderBrush="#777777" BorderThickness="0,0.8,0.8,0.8" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"
Text="序号" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="White"
Text="配方名称" />
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="创建时间" />
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.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White" Text="操作" />
</Grid>
<!--#endregion-->
<!--#region 表格内容-->
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RecipeCharts}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid
Height="30"
Margin="0,1"
Background="#163175">
Height="30" Margin="0,1" Background="#163175">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
@@ -188,52 +136,30 @@
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="1"
BorderBrush="#777777"
BorderThickness="0.4" />
Grid.ColumnSpan="1" BorderBrush="#777777" BorderThickness="0.4" />
<Border
Grid.ColumnSpan="2"
BorderBrush="#777777"
BorderThickness="0,0.4,0.4,0.4" />
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" />
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" />
Grid.ColumnSpan="4" BorderBrush="#777777" BorderThickness="0,0.4,0.4,0.4" />
<TextBlock
x:Name="num"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
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"
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"
Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"
Foreground="White"
Text="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd}}" />
<RadioButton
x:Name="ceshi"
Grid.Column="3"
x:Name="ceshi" Grid.Column="3"
Command="{Binding DataContext.InspectDataCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="查看"
FontSize="16"
Foreground="White"
GroupName="sss"
Content="查看" FontSize="16" Foreground="White" GroupName="sss"
Style="{StaticResource setCheck}" />
</Grid>
<!--<Popup
@@ -324,88 +250,77 @@
<UniformGrid Columns="8">
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="0"
Content="反应釜温度"
FontSize="14"
CommandParameter="0" Content="反应釜温度" FontSize="14"
Foreground="{StaticResource 反应釜温度}"
IsChecked="{Binding VisStatus[0]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="1"
Content="反应釜蒸汽压力"
FontSize="14"
CommandParameter="1" Content="反应釜蒸汽压力" FontSize="14"
Foreground="{StaticResource 反应釜蒸汽压力}"
IsChecked="{Binding VisStatus[1]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="2"
Content="反应釜蒸汽流量"
FontSize="14"
CommandParameter="2" Content="反应釜蒸汽流量" FontSize="14"
Foreground="{StaticResource 反应釜蒸汽流量}"
IsChecked="{Binding VisStatus[2]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="3"
Content="冷凝水罐温度"
FontSize="14"
CommandParameter="3" Content="冷凝水罐温度" FontSize="14"
Foreground="{StaticResource 冷凝水罐温度}"
IsChecked="{Binding VisStatus[3]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="4"
Content="冷凝水罐湿度"
FontSize="14"
CommandParameter="4" Content="冷凝水罐湿度" FontSize="14"
Foreground="{StaticResource 冷凝水罐湿度}"
IsChecked="{Binding VisStatus[4]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="5"
Content="负压流量"
FontSize="14"
CommandParameter="5" Content="负压流量" FontSize="14"
Foreground="{StaticResource 负压流量}"
IsChecked="{Binding VisStatus[5]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="6"
Content="称重水罐重量"
FontSize="14"
CommandParameter="6" Content="称重水罐重量" FontSize="14"
Foreground="{StaticResource 称重水罐重量}"
IsChecked="{Binding VisStatus[6]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="7"
Content="比例阀开度"
FontSize="14"
Foreground="{StaticResource 比例阀实际开度}"
CommandParameter="7" Content="反应釜编码器值" FontSize="14"
Foreground="{StaticResource 反应釜编码器值}"
IsChecked="{Binding VisStatus[7]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="7" Content="比例阀开度" FontSize="14"
Foreground="{StaticResource 比例阀实际开度}"
IsChecked="{Binding VisStatus[8]}"
IsEnabled="{Binding IsEnable}" />
<CheckBox
Command="{Binding CheckedCommand}"
CommandParameter="7" Content="卤水配制罐重量" FontSize="14"
Foreground="{StaticResource 卤水配制罐重量}"
IsChecked="{Binding VisStatus[9]}"
IsEnabled="{Binding IsEnable}" />
</UniformGrid>

<oxy:PlotView
x:Name="chartView"
Grid.Row="1"
Margin="5"
Background="White"
x:Name="chartView" Grid.Row="1" Margin="5" Background="White"
Foreground="White"
Model="{Binding OxyModel}"
PanCursor="Hand" />

<Border
Grid.Row="1"
Background="#dd727272"
Grid.Row="1" Background="#dd727272"
Visibility="{Binding LoadingVis}">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Text="正在加载数据,请耐心等待..." />
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Text="正在加载数据,请耐心等待..." />
</Border>

</Grid>


+ 1032
- 778
BPASmartClient.Academy/View/ReactionKettle50LView.xaml
File diff suppressed because it is too large
View File


+ 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)
{

}
}
}

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

@@ -14,7 +14,9 @@ namespace BPASmartClient.Academy.ViewModel
{
public class DeviceChart50LViewModel : NotifyBase
{
public DeviceChart50LViewModel()
private volatile static DeviceChart50LViewModel _Instance;
public static DeviceChart50LViewModel GetInstance => _Instance ?? (_Instance = new DeviceChart50LViewModel());
private DeviceChart50LViewModel()
{
DataFeedback = new DataFeedBack_50();
var mapper = Mappers.Xy<DataValue>()


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

@@ -68,7 +68,9 @@ namespace BPASmartClient.Academy.ViewModel
OxyDataModels.Add(new OxyDataModel(CreateLine("冷凝水罐湿度")));
OxyDataModels.Add(new OxyDataModel(CreateLine("负压流量")));
OxyDataModels.Add(new OxyDataModel(CreateLine("称重水罐重量")));
OxyDataModels.Add(new OxyDataModel(CreateLine("反应釜编码器值")));
OxyDataModels.Add(new OxyDataModel(CreateLine("比例阀实际开度")));
OxyDataModels.Add(new OxyDataModel(CreateLine("卤水配制罐重量")));

SqliteOperate.GetInstance.QueryableByNum(num).ForEach(item =>
{
@@ -80,7 +82,9 @@ namespace BPASmartClient.Academy.ViewModel
OxyDataModels[4].dataPoints.Add(new DataPoint(x, item.CondensateWaterHumidity));
OxyDataModels[5].dataPoints.Add(new DataPoint(x, item.NegativePressureFlowRate));
OxyDataModels[6].dataPoints.Add(new DataPoint(x, item.WeighingWaterTankWeight));
OxyDataModels[7].dataPoints.Add(new DataPoint(x, item.ProportionalValveOpening));
OxyDataModels[7].dataPoints.Add(new DataPoint(x, item.ReactEncoderValue));
OxyDataModels[8].dataPoints.Add(new DataPoint(x, item.ProportionalValveOpening));
OxyDataModels[9].dataPoints.Add(new DataPoint(x, item.BrineTankWeight));
});
OxyDataModels.ForEach(item => { item.AddRange(); });
if (!(OxyModel.Axes.Count > 0))


+ 11
- 13
BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs View File

@@ -1,4 +1,6 @@
using BPASmartClient.Academy._50L;
using BPASmartClient.Academy.Model;

using System;
using System.Collections.Generic;
using System.Linq;
@@ -15,29 +17,25 @@ namespace BPASmartClient.Academy.ViewModel
{
Start = new BPARelayCommand(() =>
{
if (Name != "" && PlcControl.GetInstance.IsConnect)
if (!string.IsNullOrEmpty(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_50 dataFeedback = new ();
dataFeedback.Name = Name;
var snd = new SaveNameData(Name);
dataFeedback.ProductNumberId = snd.Id;
SqliteOperate.GetInstance.Add(snd);
PlcControl.GetInstance.id = snd.Id;
SqliteOperate.GetInstance.DataFeedBacks = dataFeedback;
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);
PlcControl.GetInstance.id = "";
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, false);
Content = "系统启动";
break;


Loading…
Cancel
Save