增加监控界面

This commit is contained in:
2024-07-12 10:39:55 +08:00
parent 1e0cba7b53
commit c9f4e88e04
11 changed files with 892 additions and 141 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();