增加监控界面
This commit is contained in:
102
CapMachine.Shared/Controls/Meter.xaml
Normal file
102
CapMachine.Shared/Controls/Meter.xaml
Normal file
@@ -0,0 +1,102 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Shared.Controls.Meter"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CapMachine.Shared.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Name="MeterInstance"
|
||||
d:DesignHeight="160"
|
||||
d:DesignWidth="160"
|
||||
BorderBrush="Gray"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="5*" />
|
||||
<RowDefinition Height="3*" />
|
||||
<RowDefinition Height="2*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border
|
||||
Margin="3,3,3,0"
|
||||
Background="#404040"
|
||||
CornerRadius="3" />
|
||||
<StackPanel Margin="3,3,3,0">
|
||||
<DockPanel Margin="5">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
FontSize="24"
|
||||
Foreground="White"
|
||||
Text="PV" />
|
||||
<TextBlock
|
||||
Margin="10,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="24"
|
||||
Foreground="White"
|
||||
Text="25.45" />
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="14"
|
||||
Foreground="White"
|
||||
Text="Kg" />
|
||||
</DockPanel>
|
||||
<DockPanel Margin="5,-3,5,0">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
FontSize="22"
|
||||
FontStyle="Italic"
|
||||
Foreground="Gold"
|
||||
Text="SV" />
|
||||
<TextBlock
|
||||
Margin="10,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Foreground="Gold"
|
||||
Text="25.45" />
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="12"
|
||||
Foreground="Gold"
|
||||
Text="Kg" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Margin="0,5,0,0">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="手自动" />
|
||||
<TextBlock
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Bold"
|
||||
Foreground="CadetBlue"
|
||||
Text="自动" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Margin="3,3,3,3"
|
||||
Background="Gray"
|
||||
CornerRadius="3">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Foreground="White"
|
||||
Text="吸气温度" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
48
CapMachine.Shared/Controls/Meter.xaml.cs
Normal file
48
CapMachine.Shared/Controls/Meter.xaml.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CapMachine.Shared.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Meter.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Meter : UserControl
|
||||
{
|
||||
public Meter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仪表名称
|
||||
/// </summary>
|
||||
public string MeterName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)base.GetValue(MeterConfig.MeterNameProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
base.SetValue(MeterConfig.MeterNameProperty, value);
|
||||
}
|
||||
}
|
||||
public static readonly DependencyProperty MeterNameProperty = DependencyProperty.Register("MeterName", typeof(string), typeof(MeterConfig), new PropertyMetadata("速度"));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
BIN
CapMachine.Wpf/Assets/Images/参考工艺图.png
Normal file
BIN
CapMachine.Wpf/Assets/Images/参考工艺图.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 KiB |
@@ -7,6 +7,16 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Images\参考工艺图.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\Images\参考工艺图.png">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="FreeSql" Version="3.2.808" />
|
||||
@@ -25,7 +35,6 @@
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Assets\" />
|
||||
<Folder Include="Dtos\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Arction.Wpf.Charting;
|
||||
using Arction.Wpf.Charting.Annotations;
|
||||
using Arction.Wpf.Charting.Axes;
|
||||
using Arction.Wpf.Charting.Maps;
|
||||
using Arction.Wpf.Charting.Series3D;
|
||||
using Arction.Wpf.Charting.SeriesXY;
|
||||
using Arction.Wpf.Charting.Views.ViewXY;
|
||||
using CapMachine.Model;
|
||||
using ImTools;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
@@ -18,60 +20,64 @@ namespace CapMachine.Wpf.Models
|
||||
/// <summary>
|
||||
/// 曲线实时系列模型
|
||||
/// </summary>
|
||||
public class ChartRtSeries:BindableBase
|
||||
public class ChartRtSeries : BindableBase
|
||||
{
|
||||
public ChartRtSeries(AxisY axisY, LightningChart lightningChart, string SeriesName)
|
||||
{
|
||||
//var CreateAxisY = new AxisY();
|
||||
//CreateAxisY.Title.Text = Name;
|
||||
//CreateAxisY.Title.AllowDragging = false;
|
||||
//CreateAxisY.SetRange(0, 100);
|
||||
//CreateAxisY.MajorGrid.Visible = false;
|
||||
////取消滚轮缩放
|
||||
//CreateAxisY.ZoomingEnabled = false;
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="axisY"></param>
|
||||
/// <param name="lightningChart"></param>
|
||||
/// <param name="SeriesName"></param>
|
||||
//public ChartRtSeries(AxisY axisY, LightningChart lightningChart, string SeriesName)
|
||||
//{
|
||||
// //var CreateAxisY = new AxisY();
|
||||
// //CreateAxisY.Title.Text = Name;
|
||||
// //CreateAxisY.Title.AllowDragging = false;
|
||||
// //CreateAxisY.SetRange(0, 100);
|
||||
// //CreateAxisY.MajorGrid.Visible = false;
|
||||
// ////取消滚轮缩放
|
||||
// //CreateAxisY.ZoomingEnabled = false;
|
||||
|
||||
// //模型赋值
|
||||
// LightningChartInstance = lightningChart;
|
||||
// //ChartAxisY = axisY;
|
||||
// ChartAxisX = lightningChart.ViewXY.XAxes[0];
|
||||
// Name = SeriesName;
|
||||
|
||||
// //Unit = "℃";
|
||||
|
||||
// //判断别重复,因为可能共用Y轴的信息
|
||||
// //绑定lightningChart
|
||||
// lightningChart.ViewXY.YAxes.Add(axisY);
|
||||
|
||||
// ChartPointLineSeries = new PointLineSeries(lightningChart.ViewXY, lightningChart.ViewXY.XAxes[0], axisY);
|
||||
// ChartPointLineSeries.Title.Text = SeriesName;
|
||||
// //绑定lightningChart
|
||||
// lightningChart.ViewXY.PointLineSeries.Add(ChartPointLineSeries);
|
||||
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public ChartRtSeries(LightningChart lightningChart, ChartConfig chartConfig, List<ChartRtSeries> listchartRtSeries, ConfigChartSelect configChartSelect)
|
||||
{
|
||||
//模型赋值
|
||||
LightningChartInstance = lightningChart;
|
||||
ChartAxisY = axisY;
|
||||
ChartAxisX = lightningChart.ViewXY.XAxes[0];
|
||||
Name = SeriesName;
|
||||
ChartConfigInfo = chartConfig;
|
||||
ChartAxisY = configChartSelect.ConfigChartYAxis;
|
||||
ChartAxisX = LightningChartInstance.ViewXY.XAxes[0];
|
||||
Name = configChartSelect.Name;
|
||||
ListChartRtSeries= listchartRtSeries;
|
||||
|
||||
Unit = "℃";
|
||||
AddSeries(configChartSelect.Name!, configChartSelect.ConfigChartYAxis!);
|
||||
|
||||
//判断别重复,因为可能共用Y轴的信息
|
||||
//绑定lightningChart
|
||||
lightningChart.ViewXY.YAxes.Add(axisY);
|
||||
|
||||
ChartPointLineSeries = new PointLineSeries(lightningChart.ViewXY, lightningChart.ViewXY.XAxes[0], axisY);
|
||||
ChartPointLineSeries.Title.Text = SeriesName;
|
||||
//绑定lightningChart
|
||||
lightningChart.ViewXY.PointLineSeries.Add(ChartPointLineSeries);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 名称
|
||||
///// </summary>
|
||||
//public string? Name { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 值
|
||||
///// </summary>
|
||||
//public double Value { get; set; }
|
||||
#region 基本信息
|
||||
|
||||
///// <summary>
|
||||
///// Max
|
||||
///// </summary>
|
||||
//public double Max { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// Min
|
||||
///// </summary>
|
||||
//public double Min { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 单位
|
||||
///// </summary>
|
||||
//public string? Unit { get; set; }
|
||||
|
||||
private string? _Name;
|
||||
/// <summary>
|
||||
@@ -93,37 +99,159 @@ namespace CapMachine.Wpf.Models
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _Max;
|
||||
|
||||
//private string? _Unit;
|
||||
///// <summary>
|
||||
///// 单位
|
||||
///// </summary>
|
||||
//public string? Unit
|
||||
//{
|
||||
// get { return _Unit; }
|
||||
// set { _Unit = value; RaisePropertyChanged(); }
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Max
|
||||
/// 删除Y轴信息
|
||||
/// </summary>
|
||||
public double Max
|
||||
public void DeleteAxisY()
|
||||
{
|
||||
get { return _Max; }
|
||||
set { _Max = value; RaisePropertyChanged(); }
|
||||
//删除Y轴信息
|
||||
LightningChartInstance.ViewXY.YAxes.Remove(LightningChartInstance.ViewXY.YAxes.FindFirst(a => a.Title.Text == ChartAxisY.Name));
|
||||
}
|
||||
|
||||
private double _Min;
|
||||
/// <summary>
|
||||
/// Min
|
||||
/// 删除系列
|
||||
/// </summary>
|
||||
public double Min
|
||||
public void DeleteSeries()
|
||||
{
|
||||
get { return _Min; }
|
||||
set { _Min = value; RaisePropertyChanged(); }
|
||||
LightningChartInstance.BeginUpdate();
|
||||
|
||||
LightningChartInstance.ViewXY.PointLineSeries.Remove(ChartPointLineSeries);
|
||||
|
||||
LightningChartInstance.EndUpdate();
|
||||
|
||||
ListChartRtSeries.Remove(ListChartRtSeries.FindFirst(a=>a.Name== Name));
|
||||
}
|
||||
|
||||
|
||||
private string? _Unit;
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// 增加系列
|
||||
/// </summary>
|
||||
public string? Unit
|
||||
/// <param name="Name"></param>
|
||||
private void AddSeries(string SeriesName, ConfigChartYAxis configChartYAxis)
|
||||
{
|
||||
get { return _Unit; }
|
||||
set { _Unit = value; RaisePropertyChanged(); }
|
||||
LightningChartInstance.BeginUpdate();
|
||||
|
||||
//判断之前的系列是否已经存在(依据名称),存在使用之前的系列,否则新增
|
||||
var AxisYInfo = GetAxisY(configChartYAxis.Name);
|
||||
if (AxisYInfo == null)
|
||||
{
|
||||
//新增
|
||||
AxisYInfo = new AxisY();
|
||||
AxisYInfo.Title.Text = configChartYAxis.Name;
|
||||
AxisYInfo.Title.AllowDragging = false;
|
||||
AxisYInfo.SetRange(configChartYAxis.Min, configChartYAxis.Max);
|
||||
AxisYInfo.MajorGrid.Visible = false;
|
||||
//取消滚轮缩放
|
||||
AxisYInfo.ZoomingEnabled = false;
|
||||
LightningChartInstance.ViewXY.YAxes.Add(AxisYInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
//使用之前
|
||||
AxisYInfo.SetRange(configChartYAxis.Min, configChartYAxis.Max);
|
||||
}
|
||||
|
||||
var SeriesInfo = GetPointLineSeries(SeriesName);
|
||||
if (SeriesInfo == null)
|
||||
{
|
||||
//新增
|
||||
SeriesInfo = new PointLineSeries(LightningChartInstance.ViewXY, LightningChartInstance.ViewXY.XAxes[0], AxisYInfo);
|
||||
SeriesInfo.Title.Text = SeriesName;
|
||||
SeriesInfo.LineStyle.Color = ChartConfigInfo.ListColor[LightningChartInstance.ViewXY.YAxes.Count + 1];
|
||||
SeriesInfo.AllowUserInteraction = false;
|
||||
LightningChartInstance.ViewXY.PointLineSeries.Add(SeriesInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
//使用之前
|
||||
SeriesInfo.AssignYAxisIndex = AxisYInfo.SegmentIndex;
|
||||
}
|
||||
|
||||
//赋值给当前的模型
|
||||
ChartPointLineSeries = SeriesInfo;
|
||||
|
||||
//Configure and add series to the chart
|
||||
|
||||
|
||||
LightningChartInstance.EndUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取AxisY信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
private AxisY GetAxisY(string AxisName)
|
||||
{
|
||||
var AxisYs = LightningChartInstance.ViewXY.YAxes;
|
||||
|
||||
if (AxisYs != null)
|
||||
{
|
||||
var findAxis = AxisYs.FindFirst(a => a.Title.Text == AxisName);
|
||||
if (findAxis != null)
|
||||
{
|
||||
return findAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取PointLineSeries信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
private PointLineSeries GetPointLineSeries(string SeriesName)
|
||||
{
|
||||
var PointLineSeries = LightningChartInstance.ViewXY.PointLineSeries;
|
||||
|
||||
if (PointLineSeries != null)
|
||||
{
|
||||
var findSeries = PointLineSeries.FindFirst(a => a.Title.Text == SeriesName);
|
||||
if (findSeries != null)
|
||||
{
|
||||
return findSeries;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上层管理集合
|
||||
/// </summary>
|
||||
public List<ChartRtSeries> ListChartRtSeries { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 曲线
|
||||
/// </summary>
|
||||
@@ -132,7 +260,7 @@ namespace CapMachine.Wpf.Models
|
||||
/// <summary>
|
||||
/// Y轴
|
||||
/// </summary>
|
||||
public AxisY? ChartAxisY { get; set; }
|
||||
public ConfigChartYAxis? ChartAxisY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// X轴
|
||||
@@ -144,6 +272,12 @@ namespace CapMachine.Wpf.Models
|
||||
/// </summary>
|
||||
public LightningChart LightningChartInstance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置信息
|
||||
/// </summary>
|
||||
public ChartConfig ChartConfigInfo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// X轴滚动
|
||||
/// </summary>
|
||||
@@ -160,7 +294,7 @@ namespace CapMachine.Wpf.Models
|
||||
/// </summary>
|
||||
public void AddValue(double Data)
|
||||
{
|
||||
//foreach (var item in lightningChart1.ViewXY.PointLineSeries)
|
||||
//foreach (var item in LightningChartInstance.ViewXY.PointLineSeries)
|
||||
//{
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
LightningChartInstance.BeginUpdate();
|
||||
@@ -183,10 +317,11 @@ namespace CapMachine.Wpf.Models
|
||||
LightningChartInstance.ViewXY.XAxes[0].ScrollPosition = _previousX;
|
||||
}
|
||||
|
||||
|
||||
//Allow updates again, and update
|
||||
LightningChartInstance.EndUpdate();
|
||||
|
||||
Value = Data;
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Arction.Wpf.Charting.Axes;
|
||||
using Arction.Wpf.Charting.SeriesXY;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,7 +12,7 @@ namespace CapMachine.Wpf.Models
|
||||
/// <summary>
|
||||
/// 曲线实时数据模型
|
||||
/// </summary>
|
||||
public class ChartRtValue
|
||||
public class ChartRtValue:BindableBase
|
||||
{
|
||||
public ChartRtValue()
|
||||
{
|
||||
@@ -23,10 +24,15 @@ namespace CapMachine.Wpf.Models
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
private double _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value { get; set; }
|
||||
public double Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Max
|
||||
|
||||
@@ -54,28 +54,28 @@ namespace CapMachine.Wpf.Services
|
||||
|
||||
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
//第一次计时
|
||||
stopwatch.Start(); //启动Stopwatch
|
||||
//Stopwatch stopwatch = new Stopwatch();
|
||||
////第一次计时
|
||||
//stopwatch.Start(); //启动Stopwatch
|
||||
|
||||
for (var i = 0; i < 10000000; i++)
|
||||
{
|
||||
keyValuePairs.TryAdd(DateTime.UtcNow, new RecordInfo()
|
||||
{
|
||||
CreateTime = DateTime.UtcNow,
|
||||
WorkCondition = "dadf",
|
||||
Temp = 23.3
|
||||
});
|
||||
//keyValuePairs.Add(new RecordInfo()
|
||||
//{
|
||||
// CreateTime = DateTime.UtcNow,
|
||||
// WorkCondition = "dadf",
|
||||
// Temp = 23.3
|
||||
//});
|
||||
}
|
||||
//for (var i = 0; i < 10000000; i++)
|
||||
//{
|
||||
// keyValuePairs.TryAdd(DateTime.UtcNow, new RecordInfo()
|
||||
// {
|
||||
// CreateTime = DateTime.UtcNow,
|
||||
// WorkCondition = "dadf",
|
||||
// Temp = 23.3
|
||||
// });
|
||||
// //keyValuePairs.Add(new RecordInfo()
|
||||
// //{
|
||||
// // CreateTime = DateTime.UtcNow,
|
||||
// // WorkCondition = "dadf",
|
||||
// // Temp = 23.3
|
||||
// //});
|
||||
//}
|
||||
|
||||
stopwatch.Stop(); //停止Stopwatch
|
||||
Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.ToString());
|
||||
//stopwatch.Stop(); //停止Stopwatch
|
||||
//Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.ToString());
|
||||
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
@@ -216,12 +216,13 @@ namespace CapMachine.Wpf.Services
|
||||
await Task.Delay(1000);
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Publish(new List<Models.ChartRtValue>()
|
||||
{
|
||||
new Models.ChartRtValue(){Name="室温0",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温1",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温2",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温3",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温4",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温5",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="EVA风量",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="中间轴转速",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="加热电力",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="加湿电力",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="EMPCV电流",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="INJ压力",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="冷媒流量",Value=random.NextDouble()*100,Unit="℃"},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,39 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Prism.Events;
|
||||
|
||||
namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class MonitorViewModel : NavigationViewModel
|
||||
{
|
||||
public MonitorViewModel()
|
||||
public MonitorViewModel(IEventAggregator eventAggregator)
|
||||
{
|
||||
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Subscribe(GetChartRtEvent);
|
||||
}
|
||||
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
|
||||
public List<ChartRtValue> ListChartRtValue { get; set; } = new List<ChartRtValue>()
|
||||
{
|
||||
new ChartRtValue(){ Name="温度",Value=12.3,Unit="℃"},
|
||||
new ChartRtValue(){ Name="压力",Value=12.3,Unit="bar"},
|
||||
new ChartRtValue(){ Name="湿度",Value=12.3,Unit="%"},
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 获取曲线的实时值
|
||||
/// 数据是发布过来
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void GetChartRtEvent(List<ChartRtValue> RtData)
|
||||
{
|
||||
//ListChartRtValue = RtData;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="32" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<md:ColorZone md:ElevationAssist.Elevation="Dp2" Mode="PrimaryDark">
|
||||
@@ -160,5 +161,74 @@
|
||||
x:Name="MainViewContentControl"
|
||||
prism:RegionManager.RegionName="MainViewContentRegion"
|
||||
Visibility="Collapsed" />
|
||||
|
||||
<Grid Grid.Row="2" Margin="4">
|
||||
<Grid.Resources>
|
||||
<Style x:Key="BoardStyle" TargetType="Border">
|
||||
<Setter Property="Background" Value="AliceBlue" />
|
||||
<Setter Property="Margin" Value="3,0" />
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="PLC通信:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="1" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="仪表通信:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="2" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="服务器通信:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="3" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="用户登录:" />
|
||||
<TextBlock FontSize="20" Text="Admin" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="4" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="记录仪通信:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="5" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="高速记录:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="6" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="数据记录:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Column="7" Style="{StaticResource BoardStyle}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock FontSize="20" Text="系统状态:" />
|
||||
<TextBlock FontSize="20" Text="正常" />
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -2,42 +2,317 @@
|
||||
x:Class="CapMachine.Wpf.Views.MonitorView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:CapMachine.Shared.Controls;assembly=CapMachine.Shared"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="1000"
|
||||
d:DesignWidth="1920"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="140" />
|
||||
<RowDefinition Height="120" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
<TextBlock
|
||||
FontSize="30"
|
||||
Text="调节器操作栏Hey TyroneChong! A third-party OAuth application (BotSharp) with user:email scopes was recently authorized to access your account. Visit https://github.com/settings/connections/applications/a1009924bfc48dbb7360 for more information. To see this and other security events for your account, visit https://github.com/settings/security-log If you run into problems, please contact support by visiting https://github.com/contact Thanks, The GitHub Team"
|
||||
TextWrapping="Wrap" />
|
||||
<materialDesign:DrawerHost
|
||||
x:Name="DrawerHost"
|
||||
BorderBrush="{DynamicResource MaterialDesignDivider}"
|
||||
BorderThickness="2"
|
||||
BottomDrawerBackground="{DynamicResource SecondaryHueLightBrush}"
|
||||
BottomDrawerCornerRadius="20 20 0 0">
|
||||
<materialDesign:DrawerHost.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type materialDesign:DrawerHost}}" TargetType="materialDesign:DrawerHost">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsChecked, ElementName=BackgroundToggle}" Value="True">
|
||||
<Setter Property="OverlayBackground" Value="{DynamicResource PrimaryHueMidBrush}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</materialDesign:DrawerHost.Style>
|
||||
<materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<StackPanel Width="200" Margin="10">
|
||||
<TextBlock
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Text="操作信息" />
|
||||
<Button
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
CommandParameter="{x:Static Dock.Left}"
|
||||
Content="操作1"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
<Button
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
Content="操作2"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
<Button
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
Content="操作3"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
</StackPanel>
|
||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<materialDesign:DrawerHost.TopDrawerContent>
|
||||
<StackPanel
|
||||
Margin="16"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Text="TOP BANANA" />
|
||||
<Button
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
Content="CLOSE ALL"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
<Button
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
CommandParameter="{x:Static Dock.Top}"
|
||||
Content="CLOSE THIS"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
</StackPanel>
|
||||
</materialDesign:DrawerHost.TopDrawerContent>
|
||||
<materialDesign:DrawerHost.RightDrawerContent>
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Text="THE RIGHT STUFF" />
|
||||
<Button
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
CommandParameter="{x:Static Dock.Right}"
|
||||
Content="CLOSE THIS"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
<Button
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
Content="CLOSE ALL"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
</StackPanel>
|
||||
</materialDesign:DrawerHost.RightDrawerContent>
|
||||
<materialDesign:DrawerHost.BottomDrawerContent>
|
||||
<StackPanel
|
||||
Margin="16"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource SecondaryHueMidForegroundBrush}"
|
||||
Text="BOTTOM BRACKET" />
|
||||
<Button
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
Content="CLOSE ALL"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
<Button
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
|
||||
CommandParameter="{x:Static Dock.Bottom}"
|
||||
Content="CLOSE THIS"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
</StackPanel>
|
||||
</materialDesign:DrawerHost.BottomDrawerContent>
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBlock FontSize="30" Text="控制启动区域" />
|
||||
|
||||
</StackPanel>
|
||||
<Canvas Grid.Row="2">
|
||||
<TextBlock FontSize="30" Text="系统流程图" />
|
||||
</Canvas>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="1">
|
||||
<TextBlock FontSize="30" Text="数据监视" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="280" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="160" />
|
||||
<RowDefinition Height="200" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Controls:Meter Margin="5" />
|
||||
<Controls:Meter Grid.Column="1" Margin="5" />
|
||||
<Controls:Meter Grid.Column="2" Margin="3" />
|
||||
<Controls:Meter Grid.Column="3" Margin="3" />
|
||||
<Controls:Meter Grid.Column="4" Margin="3" />
|
||||
<Controls:Meter Grid.Column="5" Margin="3" />
|
||||
<Controls:Meter Grid.Column="6" Margin="3" />
|
||||
<Controls:Meter Grid.Column="7" Margin="3" />
|
||||
<Controls:Meter Grid.Column="8" Margin="3" />
|
||||
<Controls:Meter Grid.Column="9" Margin="3" />
|
||||
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.Resources>
|
||||
<Style x:Key="TitelStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="32" />
|
||||
<Setter Property="Margin" Value="10,0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style x:Key="btnStyle" TargetType="Button">
|
||||
<Setter Property="Width" Value="80" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
Grid.RowSpan="3"
|
||||
Grid.ColumnSpan="6"
|
||||
Margin="5"
|
||||
Background="LightGray"
|
||||
CornerRadius="3" />
|
||||
<StackPanel Grid.ColumnSpan="3" Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="工况名称:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="34"
|
||||
FontWeight="Bold"
|
||||
Text="耐久试验台测试工况-测试名称" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Column="3"
|
||||
Grid.ColumnSpan="3"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="当前进度:" />
|
||||
|
||||
<ProgressBar
|
||||
Width="600"
|
||||
Height="20"
|
||||
Value="25" />
|
||||
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="总时间:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Text="20天5时40分钟30秒" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="剩余时间:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Text="20天5时40分钟30秒" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="当前步骤:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Text="124" />
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Content="开始"
|
||||
FontSize="30" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Content="结束"
|
||||
FontSize="30" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
|
||||
CommandParameter="{x:Static Dock.Left}"
|
||||
Content="{materialDesign:PackIcon Kind=ArrowUp}"
|
||||
FontSize="30" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="3"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Content="复位"
|
||||
FontSize="30" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="4"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Content="消音"
|
||||
FontSize="30" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="5"
|
||||
Width="200"
|
||||
Height="45"
|
||||
Content="开始"
|
||||
FontSize="30" />
|
||||
</Grid>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Margin="5"
|
||||
CornerRadius="3">
|
||||
<Image Source="E:\MyTest\VS2022\CapMachine\CapMachine\CapMachine.Wpf\bin\Debug\net6.0-windows\Assets\Images/参考工艺图.png" Stretch="Fill" />
|
||||
</Border>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="1">
|
||||
<ListView ItemsSource="{Binding ListChartRtValue}">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Value}" Header="值" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Unit}" Header="单位" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</materialDesign:DrawerHost>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -3,10 +3,12 @@ using Arction.Wpf.Charting.Annotations;
|
||||
using Arction.Wpf.Charting.Axes;
|
||||
using Arction.Wpf.Charting.SeriesXY;
|
||||
using Arction.Wpf.Charting.Views.ViewXY;
|
||||
using CapMachine.Model;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using CapMachine.Wpf.Services;
|
||||
using CapMachine.Wpf.ViewModels;
|
||||
using ImTools;
|
||||
using NLog;
|
||||
using Prism.Events;
|
||||
using System.Text;
|
||||
@@ -28,18 +30,19 @@ namespace CapMachine.Wpf.Views
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
public IFreeSql FreeSql { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置
|
||||
/// </summary>
|
||||
public ChartConfig ChartConfigInfo { get; set; }
|
||||
public ChartConfig ChartConfigInfo { get; set; } = new ChartConfig();
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="eventAggregator"></param>
|
||||
/// <param name="machineRtDataService"></param>
|
||||
public RealTimeChartView(IEventAggregator eventAggregator, MachineRtDataService machineRtDataService)
|
||||
public RealTimeChartView(IEventAggregator eventAggregator, MachineRtDataService machineRtDataService, IFreeSql freeSql)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
@@ -51,18 +54,10 @@ namespace CapMachine.Wpf.Views
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
MachineRtDataService = machineRtDataService;
|
||||
|
||||
FreeSql = freeSql;
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Subscribe(GetChartRtEvent);
|
||||
_EventAggregator.GetEvent<ChartRtActionEvent>().Subscribe(ReLoadData);
|
||||
|
||||
var CreateAxisY = new AxisY();
|
||||
CreateAxisY.Title.Text = Name;
|
||||
CreateAxisY.Title.AllowDragging = false;
|
||||
CreateAxisY.SetRange(0, 100);
|
||||
CreateAxisY.MajorGrid.Visible = false;
|
||||
//取消滚轮缩放
|
||||
CreateAxisY.ZoomingEnabled = false;
|
||||
ListChartRtSeries.Add(new ChartRtSeries(CreateAxisY, lightningChart1, "室温0"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,7 +68,17 @@ namespace CapMachine.Wpf.Views
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ReLoadData(ChartActionType type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//
|
||||
switch (type)
|
||||
{
|
||||
case ChartActionType.ReLoadChart:
|
||||
var ChartSelectedData = FreeSql.Select<ConfigChartSelect>().Include(a => a.ConfigChartYAxis).ToList();
|
||||
LoadChartConfigSelect(ChartSelectedData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -106,23 +111,97 @@ namespace CapMachine.Wpf.Views
|
||||
|
||||
}
|
||||
|
||||
private void CurTimer2_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间序列
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CurTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region ListView配置
|
||||
|
||||
#region 开始测试
|
||||
|
||||
#endregion
|
||||
|
||||
#region 曲线配置
|
||||
|
||||
/// <summary>
|
||||
/// 当前曲线配置信息
|
||||
/// </summary>
|
||||
public List<ConfigChartSelect> CurListConfigChartSelect { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载曲线配置信息
|
||||
/// </summary>
|
||||
private void LoadChartConfigSelect(List<ConfigChartSelect> configChartSelects)
|
||||
{
|
||||
//从配置入手对比目前的状态,针对配置新增
|
||||
foreach (var itemConfig in configChartSelects)
|
||||
{
|
||||
//曲线增加时
|
||||
var data = ListChartRtSeries.FindFirst(a => a.Name == itemConfig.Name);
|
||||
if (data == null)
|
||||
{
|
||||
ListChartRtSeries.Add(new ChartRtSeries(lightningChart1, ChartConfigInfo, ListChartRtSeries, itemConfig));
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改
|
||||
}
|
||||
}
|
||||
|
||||
////从目前的状态对比配置,针对删除项目
|
||||
//foreach (var itemSeries in ListChartRtSeries)
|
||||
//{
|
||||
// var data = configChartSelects.FindFirst(a => a.Name == itemSeries.Name);
|
||||
// if (data == null)
|
||||
// {
|
||||
// //查找删除的系列的Y轴是否还有其他的配置使用
|
||||
// var configChartYAxis = configChartSelects.Find(a => a.ConfigChartYAxis.Name == itemSeries.ChartAxisY.Name);
|
||||
// if (configChartYAxis == null)
|
||||
// {
|
||||
// //Y轴没有使用,则删除
|
||||
// itemSeries.DeleteAxisY();
|
||||
// }
|
||||
|
||||
// //未找到,则删除
|
||||
// ListChartRtSeries.Remove(itemSeries);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //存在就不需要操作
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//从目前的状态对比配置,针对删除项目
|
||||
for (int i = 0; i < ListChartRtSeries.Count; i++)
|
||||
{
|
||||
var data = configChartSelects.FindFirst(a => a.Name == ListChartRtSeries[i].Name);
|
||||
if (data == null)
|
||||
{
|
||||
//查找删除的系列的Y轴是否还有其他的配置使用-先删除Y轴
|
||||
var configChartYAxis = configChartSelects.Find(a => a.ConfigChartYAxis.Name == ListChartRtSeries[i].ChartAxisY.Name);
|
||||
if (configChartYAxis == null)
|
||||
{
|
||||
//Y轴没有使用,则删除
|
||||
ListChartRtSeries[i].DeleteAxisY();
|
||||
}
|
||||
|
||||
//未找到,则删除 曲线实例删除
|
||||
ListChartRtSeries[i].DeleteSeries();
|
||||
}
|
||||
else
|
||||
{
|
||||
//存在就不需要操作
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实时曲线数据集合
|
||||
/// </summary>
|
||||
@@ -502,6 +581,7 @@ namespace CapMachine.Wpf.Views
|
||||
MainRealTimeChartSeriesCount++;
|
||||
}
|
||||
|
||||
|
||||
private void DeleteYAxis(string Name)
|
||||
{
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
Reference in New Issue
Block a user