修改PMCharting界面,优化Charting功能

1.搜索与图形整合到一个界面中
2.删除不常用功能,界面整理
3.选中曲线后点击图形,可修改曲线坐标
4.曲线列表新增时间、配方名称标签,增加界面可读性
This commit is contained in:
SIC1016\caipeilun 2023-09-14 09:56:35 +08:00
parent f8d6332347
commit 9aa4b488a8
7 changed files with 1502 additions and 3 deletions

View File

@ -27,7 +27,8 @@
<menuItem id="DataHistory" resKey="Data History" viewmodel="MECF.Framework.UI.Client.CenterViews.DataLogs.DataHistory.DataViewModel,MECF.Framework.UI.Client" />
<menuItem id="JobList" resKey="JobList" viewmodel="MECF.Framework.UI.Client.CenterViews.JobList.PMJobListViewModel,MECF.Framework.UI.Client" />
<!--<menuItem id="Statistics" resKey="Statistics" viewmodel="MECF.Framework.UI.Client.CenterViews.DataLogs.Statistics.StatisticsViewModel,MECF.Framework.UI.Client" />-->
<menuItem id="Charting" resKey="Charting" viewmodel="SicUI.Models.PMs.Charting.PMChartingViewModel,SicUI" />
<!--<menuItem id="Charting" resKey="Charting" viewmodel="SicUI.Models.PMs.Charting.PMChartingViewModel,SicUI" />-->
<menuItem id="Charting" resKey="Charting" viewmodel="SicUI.Models.PMs.Charting.PMChartingV2ViewModel,SicUI" />
</menuItem>
<menuItem id="Configuration" resKey="Configuration">

View File

@ -40,6 +40,10 @@ namespace SicUI.Models.PMs.Charting
}
#endregion
public string Time { get; set; }
public string RecipeName { get; set; }
public string UniqueId { get; set; }
public string ProcessGuid { get; set; }
@ -112,7 +116,7 @@ namespace SicUI.Models.PMs.Charting
if (Math.Abs(_dataOffset - value) > 0.001)
{
_dataOffset = value;
InvokePropertyChanged(nameof(DataFactor));
InvokePropertyChanged(nameof(DataOffset));
UpdateChartSeriesValue();
}
}
@ -124,7 +128,7 @@ namespace SicUI.Models.PMs.Charting
set
{
_dataxOffset = value;
InvokePropertyChanged(nameof(DataFactor));
InvokePropertyChanged(nameof(DataXOffset));
RePaintChartSeriesValue();
}
}

View File

@ -0,0 +1,651 @@
<UserControl x:Class="SicUI.Models.PMs.Charting.PMChartingV2View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
xmlns:local="clr-namespace:SicUI.Models.PMs.Charting"
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:micro="http://www.caliburn.org"
xmlns:control="clr-namespace:Aitex.Core.UI.Control;assembly=MECF.Framework.UI.Core"
xmlns:controls="http://OpenSEMI.Ctrlib.com/presentation"
xmlns:converters="clr-namespace:Aitex.Core.UI.Converters;assembly=MECF.Framework.UI.Core"
xmlns:converter="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter;assembly=MECF.Framework.UI.Client"
mc:Ignorable="d"
d:DesignHeight="780" d:DesignWidth="1900" Background="#91b0cd">
<UserControl.Resources>
<converters:LineColorConverter x:Key="colorConverter"/>
<Style TargetType="Button" x:Key="ChartingButtonStyle">
<Setter Property="Margin" Value="3" />
<Setter Property="Background" Value="#FF323539" />
<Setter Property="Foreground" Value="#FFF" />
<Setter Property="Padding" Value="3" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="#FF5B5B5B" />
<Setter Property="Width" Value="35" />
<Setter Property="Height" Value="35" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="Border" Margin="{TemplateBinding Margin}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Opacity="0.6" Padding="{TemplateBinding Padding}">
<ContentPresenter Name="ContentHost" HorizontalAlignment="Center" VerticalAlignment="Center" ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Opacity" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Line" x:Key="AnomationStyle">
<Setter Property="Stroke" Value="Black"/>
<Setter Property="StrokeThickness" Value="2"/>
<Setter Property="StrokeDashArray" Value="2 2"/>
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="UseLayoutRounding" Value="True"/>
</Style>
</UserControl.Resources>
<Grid x:Name="gridMain">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="520"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="220"/>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
Grid.Row="0"
Grid.Column="0"
Padding="5,1"
Width="50"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="18"
Foreground="{DynamicResource FG_Black}"
Text="Start" />
</Border>
<Border
Grid.Row="0"
Grid.Column="1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<wfi:WindowsFormsHost
Width="140"
Height="25"
Margin="5,0,0,0"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="12">
<wf:DateTimePicker
x:Name="wfTimeFrom"
CustomFormat="yyyy/MM/dd HH:mm:ss"
Format="Custom"
Value="2023-8-1" />
</wfi:WindowsFormsHost>
</Border>
<Border
Grid.Row="1"
Grid.Column="0"
Width="50"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="1">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="18"
Foreground="{DynamicResource FG_Black}"
Text="End" />
</Border>
<Border
Grid.Row="1"
Grid.Column="1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<wfi:WindowsFormsHost
Width="140"
Height="25"
Margin="5,0,0,0"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="12">
<wf:DateTimePicker
x:Name="wfTimeTo"
CustomFormat="yyyy/MM/dd HH:mm:ss"
Format="Custom"
Value="2011-8-1" />
</wfi:WindowsFormsHost>
</Border>
<Border
Grid.Row="0"
Grid.Column="2"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="Chamber" />
</Border>
<Border
Grid.Row="0"
Grid.Column="3"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<toolkit:CheckComboBox
x:Name="tbLoadPort"
Width="120"
Height="30"
Margin="0,0,7,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
ItemsSource="{Binding SourcePM}"
SelectedValue="{Binding SelectedValuePM}" />
</Border>
<Border
Grid.Row="1"
Grid.Column="2"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="18"
Foreground="{DynamicResource FG_Black}"
Text="Recipe" />
</Border>
<Border
Grid.Row="1"
Grid.Column="3"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBox Width="Auto" Height="30" Text="{Binding RecipeName}" />
</Border>
<Button
Grid.Row="0"
Grid.Column="4"
Width="80"
Height="40"
Margin="0,0,0,0"
FontSize="15"
Content="Search">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SearchRecipe" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
<DataGrid
Grid.Row="1"
Margin="2"
HorizontalAlignment="Left"
AlternationCount="2"
AutoGenerateColumns="False"
BorderThickness="1"
CanUserAddRows="False"
CanUserResizeColumns="True"
CanUserResizeRows="False"
ColumnHeaderHeight="30"
FontFamily="Arial"
FontSize="12"
ItemsSource="{Binding Recipes}">
<DataGrid.Columns>
<DataGridTemplateColumn Width="50">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="Add" Margin="0,0,5,0"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="CheckRecipe">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MinWidth="100" Header="Mark">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding ProcessGuid}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MinWidth="100" Header="Recipe Name">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding Recipe}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="Module">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding Chamber}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MinWidth="100" Header="Start Time">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding StartTime}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MinWidth="100" Header="End Time">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding EndTime}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MinWidth="60" Header="Result">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding Status}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="Filter:" VerticalAlignment="Bottom" FontSize="25" Width="80" Height="30" Margin="5,0,5,0" HorizontalAlignment="Right"/>
<TextBox x:Name="tbxkeyword" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="200" Height="30" Margin="5,0,5,0" Foreground="Black"/>
<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,5,0" Height="25">
<Button.Background>
<ImageBrush ImageSource="pack://application:,,,/Resources/Images/find.png" Stretch="Uniform"/>
</Button.Background>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Find">
<micro:Parameter Value="{Binding ElementName=tbxkeyword,Path=Text}"/>
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,0">
<Button Content="X" VerticalAlignment="Center" HorizontalAlignment="Left">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="RemoveAllLine">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
<Border Grid.Row="3" BorderBrush="{DynamicResource MainFrame_BD_Highlight}" BorderThickness="1" SnapsToDevicePixels="True" Background="{DynamicResource Tab_BG}" Padding="2">
<TreeView x:Name="ParameterTreeView" ItemsSource="{Binding ConfigNodes}" >
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding PMNodeInfo}" >
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="ParameterCheck">
<micro:Parameter Value="{Binding }"/>
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
<TextBlock Text="{Binding NodeStr}" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}">
<Setter Property="Visibility" Value="{Binding Path=IsMatch, Mode=OneWay, Converter={StaticResource ResourceKey=BoolVisibilityConverter}}"></Setter>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Border>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<StackPanel Background="#eee">
<Button Command="{Binding DefaultZoomCommand}"
Padding="0"
FontSize="11"
Content="Zoom"
Style="{StaticResource ChartingButtonStyle}"/>
<Button Command="{Binding ShowLegendCommand}"
Padding="0"
FontSize="11"
Content="Line"
Style="{StaticResource ChartingButtonStyle}"/>
</StackPanel>
<StackPanel Background="#eee" Grid.Row="1">
<Button Command="{Binding DataDetailVisbleCommand}"
Padding="0"
FontSize="11"
Content="Data"
Style="{StaticResource ChartingButtonStyle}"/>
</StackPanel>
</Grid>
<Grid Grid.Column="1" >
<s:SciChartSurface Name="sciChart" RenderableSeries="{Binding SelectedData}"
s:ThemeManager.Theme="ExpressionLight"
Padding="0,0,0,0"
DebugWhyDoesntSciChartRender="false" BorderBrush="Black" Focusable="False" IsTabStop="False" ViewportManager="{Binding ViewportManager}">
<!-- 变更曲线起始点行为 -->
<i:Interaction.Behaviors>
<local:SciChartMouseDownChangingLocationBehavior
Target="{Binding SelectedData}"
XAxisInfo="{Binding ElementName=cm,Path= XAxisInfo}"
YAxisInfo="{Binding ElementName=cm,Path= YAxisInfo}"/>
</i:Interaction.Behaviors>
<!-- Create an X Axis -->
<s:SciChartSurface.XAxis>
<s:NumericAxis DrawMinorTicks="False"
DrawMinorGridLines="True" Focusable="False"
TitleFontSize="15"
FontSize="15"
AutoRange="{Binding ChartAutoRange}"
VisibleRangeLimit="{Binding VisibleRangeXLimit}"
VisibleRange="{Binding VisibleRangeX}"
Id="DefaultAxisId" TitleFontWeight="Normal" />
</s:SciChartSurface.XAxis>
<!-- Create a Y Axis -->
<s:SciChartSurface.YAxis>
<s:NumericAxis DrawMinorTicks="False" MinWidth="50"
DrawMinorGridLines="True"
AxisAlignment="Right"
HorizontalAlignment="Center"
CursorTextFormatting="0.#####"
VisibleRange="{Binding VisibleRangeY}"
VisibleRangeLimit="{Binding VisibleRangeYLimit}"
Id="DefaultAxisId" MajorDelta="0.1"
MinorDelta="0.1" DrawMajorBands="False" Focusable="False"
BorderThickness="0" AutoRange="{Binding ChartAutoRange}"
DrawLabels="True" DrawMajorGridLines="True" DrawMajorTicks="False">
<s:NumericAxis.GrowBy>
<s:DoubleRange Min="0.1" Max="0.1"/>
</s:NumericAxis.GrowBy>
</s:NumericAxis>
</s:SciChartSurface.YAxis>
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True"
IsXAxisOnly="False"
ZoomExtentsY="True"
IsAnimated="True" ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True" />
<s:CursorModifier Name="cm" IsEnabled="True" ShowTooltipOn="MouseOver" ShowAxisLabels="True"
SourceMode="AllSeries" ShowTooltip="False" />
<s:LegendModifier ShowLegend="False" GetLegendDataFor="AllSeries" x:Name="legendModifier"/>
<s:ZoomExtentsModifier x:Name="zoomExtentsModifier" XyDirection="XYDirection" ExecuteOn="MouseDoubleClick"/>
<s:ZoomPanModifier x:Name="zoomPanModifier" IsEnabled="True" ClipModeX="None" XyDirection="XYDirection" ExecuteOn="MouseRightButton" ZoomExtentsY="False" />
<s:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" IsEnabled="True" XyDirection="XYDirection"/>
<s:RolloverModifier IsEnabled="True" DrawVerticalLine="True" ShowAxisLabels="False" x:Name="RolloverModifier"
ShowTooltipOn="Always" SourceMode="AllSeries" ExecuteOn="MouseMove" >
<s:RolloverModifier.LineOverlayStyle>
<!-- The style for the rollover line -->
<Style TargetType="Line">
<Setter Property="Stroke" Value="Pink"/>
<Setter Property="StrokeThickness" Value="2"/>
<Setter Property="StrokeDashArray" Value="2 2"/>
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="UseLayoutRounding" Value="True"/>
</Style>
</s:RolloverModifier.LineOverlayStyle>
</s:RolloverModifier>
<s:YAxisDragModifier DragMode="Scale"/>
<s:XAxisDragModifier DragMode="Pan"/>
<s:LegendModifier ShowLegend="{Binding ShowLegendInfo}"/>
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
</s:SciChartSurface>
</Grid>
</Grid>
<Grid Grid.Row="1" Visibility="{Binding DataDetailVisbility}">
<TabControl Grid.Row="1" Margin="5" MinHeight="300">
<TabItem Header="Data Line" Height="24" VerticalAlignment="Top">
<Grid>
<DataGrid Margin="5" HorizontalAlignment="Left" BorderThickness="1"
AlternationCount="2" ColumnHeaderHeight="30"
ItemsSource="{Binding SelectedData}" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserResizeRows="False" CanUserResizeColumns="True" FontFamily="Arial" FontSize="12" Width="1380">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60">
<DataGridTemplateColumn.HeaderTemplate >
<DataTemplate>
<TextBlock Text="Visible" FontFamily="Arial" FontSize="12" VerticalAlignment="Bottom" Margin="3,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Mark" MinWidth="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProcessGuid}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Recipe Name" MinWidth="150">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RecipeName}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Time" MinWidth="150">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Time}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Color" MinWidth="60">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Style="{DynamicResource Color_Button}" Height="25" HorizontalAlignment="Stretch" Background="{Binding Stroke, Converter={StaticResource colorConverter}}" Width="50">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SelectColor">
<micro:Parameter Value="{Binding}" ></micro:Parameter>
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Factor" MinWidth="60">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding DataFactor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="50" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="YOffset" MinWidth="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding DataOffset, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="80" Margin="5,0" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="XOffset" MinWidth="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding DataXOffset, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="80" Margin="5,0" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Width" MinWidth="60">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding LineThickness, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="50" Margin="5,0" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60">
<DataGridTemplateColumn.HeaderTemplate >
<DataTemplate>
<TextBlock Text="Select" FontFamily="Arial" FontSize="12" VerticalAlignment="Bottom" Margin="3,0,0,0"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Grid>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,103 @@
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Charting.Visuals;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Interactivity;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SicUI.Models.PMs.Charting
{
/// <summary>
/// PMChartingV2View.xaml 的交互逻辑
/// </summary>
public partial class PMChartingV2View : UserControl
{
public PMChartingV2View()
{
InitializeComponent();
}
}
public class SciChartMouseDownChangingLocationBehavior : Behavior<SciChartSurface>
{
public AxisInfo YAxisInfo
{
get { return (AxisInfo)GetValue(YAxisInfoProperty); }
set { SetValue(YAxisInfoProperty, value); }
}
public static readonly DependencyProperty YAxisInfoProperty =
DependencyProperty.Register("YAxisInfo", typeof(AxisInfo), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
public AxisInfo XAxisInfo
{
get { return (AxisInfo)GetValue(XAxisInfoProperty); }
set { SetValue(XAxisInfoProperty, value); }
}
// Using a DependencyProperty as the backing store for XAxisInfo. This enables animation, styling, binding, etc...
public static readonly DependencyProperty XAxisInfoProperty =
DependencyProperty.Register("XAxisInfo", typeof(AxisInfo), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
public ObservableCollection<IRenderableSeries> Target
{
get { return (ObservableCollection<IRenderableSeries>)GetValue(TargetProperty); }
set { SetValue(TargetProperty, value); }
}
public static readonly DependencyProperty TargetProperty =
DependencyProperty.Register("Target", typeof(ObservableCollection<IRenderableSeries>), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
protected override void OnAttached()
{
AssociatedObject.PreviewMouseDown += mousedown;
}
private void mousedown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
foreach (IRenderableSeries series in Target)
{
if (series.IsSelected)
{
double xvalue = 0, yvalue = 0;
if (double.TryParse(XAxisInfo.CursorFormattedDataValue, out xvalue) && double.TryParse(YAxisInfo.CursorFormattedDataValue, out yvalue))
{
ChartDataLineX s = series as ChartDataLineX;
s.DataXOffset = xvalue;
s.DataOffset = yvalue;
s.IsSelected = false;
}
}
}
}
e.Handled = true; //不写会失去焦点
}
}
}

View File

@ -0,0 +1,729 @@
using MECF.Framework.Common.DataCenter;
using MECF.Framework.UI.Client.ClientBase;
using SciChart.Charting.Common.Helpers;
using SciChart.Charting.ViewportManagers;
using SciChart.Charting.Visuals.Annotations;
using SciChart.Charting.Visuals.Axes;
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Data.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;
using Cali = Caliburn.Micro;
using MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory;
using System.Reflection;
using SciChart.Charting.Model.ChartSeries;
using System.IO;
using Aitex.Core.Util;
using Aitex.Core.RT.Log;
namespace SicUI.Models.PMs.Charting
{
public class PMChartingV2ViewModel : SicModuleUIViewModelBase, ISupportMultipleSystem
{
private class QueryIndexer
{
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Module { get; set; }
public string ColumneName { get; set; }
public string ProcessGuid { get; set; }
public List<string> DateList { get; set; }
public long currentTimeTicks { get; set; }
}
/// <summary>
/// ViewModel绑定的View对象
/// </summary>
private PMChartingV2View view;
/// <summary>
/// 初始化界面
/// </summary>
public PMChartingV2ViewModel()
{
DisplayName = "Process History";
var now = DateTime.Now;
this.StartDateTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0);
this.EndDateTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
SourcePM = new ObservableCollection<string>(new[] { "PM1", "PM2" });
//sci按钮操作
DataDetailVisbleCommand = new ActionCommand(SetDataDetailVisble);
DefaultZoomCommand = new ActionCommand(Zoom);
ShowLegendCommand = new ActionCommand(SetLegendAvalible);
//获取所有Device
GetPMNode();
SelectedData = new ObservableCollection<IRenderableSeries>();
SelectedRecipes = new ObservableCollection<RecipeItemSic>();
Recipes = new ObservableCollection<RecipeItemSic>();
//x y always指zoom功能失效总是自动调整大小
//ChartAutoRange = AutoRange.Always;
VisibleRangeX = new DoubleRange(-1000, 10000);
VisibleRangeY = new DoubleRange(-10, 500);
VisibleRangeXLimit = new DoubleRange(-1000, 10000);
VisibleRangeYLimit = new DoubleRange(-10, 500);
_thread = new PeriodicJob(300, MonitorHistoryData, "History", true);
//_threadReal = new PeriodicJob(TrendInterval, MonitorRealTimeData, "RealTime", true);
}
protected override void OnViewLoaded(object _view)
{
//获取绑定的Viewwpf没有默认的日期时间控件Winform日期控件无法通过绑定属性获取
base.OnViewLoaded(_view);
this.view = (PMChartingV2View)_view;
this.view.wfTimeFrom.Value = this.StartDateTime;
this.view.wfTimeTo.Value = this.EndDateTime;
}
private PeriodicJob _thread;
//private PeriodicJob _threadReal;
//DeviceTimer dt = new DeviceTimer();
//设置允许同时显示的最多曲线数
private const int MAX_PARAMETERS = 20;
/// <summary>
/// sci图表的视图管理类
/// </summary>
private readonly IViewportManager _viewportManager = new DefaultViewportManager();
public IViewportManager ViewportManager
{
get { return _viewportManager; }
}
#region Properties
/// <summary>
/// 搜索条件:Recipe开始时间
/// </summary>
public DateTime StartDateTime { get; set; }
/// <summary>
/// 搜索条件:Recipe结束时间
/// </summary>
public DateTime EndDateTime { get; set; }
/// <summary>
/// 搜索条件:PM腔
/// </summary>
public string SelectedValuePM { get; set; }
/// <summary>
/// 搜索条件:PM腔
/// </summary>
public ObservableCollection<string> SourcePM { get; set; }
/// <summary>
/// 搜索条件:Recipe
/// </summary>
public string RecipeName { get; set; }
/// <summary>
/// 查询曲线用点位组,每次有曲线变动时入队,生成曲线后出队
/// </summary>
ConcurrentBag<QueryIndexer> _lstTokenTimeData = new ConcurrentBag<QueryIndexer>();
public ObservableCollection<DataDetail> QueryDataDetail { get; set; }
/// <summary>
/// 用户选中的曲线组前台treeview和chart调用
/// </summary>
public ObservableCollection<IRenderableSeries> SelectedData { get; set; }
/// <summary>
/// 根据条件搜索的recipe
/// </summary>
public ObservableCollection<RecipeItemSic> Recipes { get; set; }
/// <summary>
/// 用户选中查阅的recipe
/// </summary>
public ObservableCollection<RecipeItemSic> SelectedRecipes { get; set; }
private List<PMNodeInfo> Nodes = new List<PMNodeInfo>();
/// <summary>
/// 获取设备需要监控的Device点
/// </summary>
private ObservableCollection<PMNodeInfo> _configNodes = new ObservableCollection<PMNodeInfo>();
public ObservableCollection<PMNodeInfo> ConfigNodes
{
get { return _configNodes; }
set { _configNodes = value; NotifyOfPropertyChange("ConfigNodes"); }
}
private double _maxYValue = 0, _minYValue = 0;
private IRange _visibleRangeXLimit;
public IRange VisibleRangeXLimit
{
get { return _visibleRangeXLimit;}
set { _visibleRangeXLimit = value; NotifyOfPropertyChange(nameof(VisibleRangeXLimit)); }
}
private IRange _visibleRangeYLimit;
public IRange VisibleRangeYLimit
{
get { return _visibleRangeYLimit; }
set { _visibleRangeYLimit = value; NotifyOfPropertyChange(nameof(VisibleRangeYLimit)); }
}
private IRange _visibleRangeX;
public IRange VisibleRangeX
{
get { return _visibleRangeX; }
set { _visibleRangeX = value; NotifyOfPropertyChange(nameof(VisibleRangeX)); }
}
private IRange _visibleRangeY;
public IRange VisibleRangeY
{
get { return _visibleRangeY; }
set { _visibleRangeY = value; NotifyOfPropertyChange(nameof(VisibleRangeY)); }
}
private AutoRange _chartAutoRange = AutoRange.Never;
public AutoRange ChartAutoRange
{
get { return _chartAutoRange; }
set
{
_chartAutoRange = value;
NotifyOfPropertyChange(nameof(ChartAutoRange));
}
}
private Visibility _dataDetailVisbility = Visibility.Collapsed;
public Visibility DataDetailVisbility
{
get { return _dataDetailVisbility; }
set
{
_dataDetailVisbility = value;
NotifyOfPropertyChange(nameof(DataDetailVisbility));
}
}
private bool _showLegendInfo;
public bool ShowLegendInfo
{
get { return _showLegendInfo; }
set
{
_showLegendInfo = value;
NotifyOfPropertyChange(nameof(ShowLegendInfo));
}
}
private Queue<Color> colorQueue = new Queue<Color>(new Color[]{Color.Red,Color.Orange,Color.Green,Color.Blue,Color.Purple,Color.Aqua,Color.Bisque,Color.Brown,Color.BurlyWood,Color.CadetBlue,
Color.CornflowerBlue,Color.DarkBlue,Color.DarkCyan,Color.DarkGray,Color.DarkGreen,Color.DarkKhaki,Color.DarkMagenta,Color.DarkOliveGreen, Color.DarkOrange,
Color.DarkSeaGreen,Color.DarkSlateBlue,Color.DarkSlateGray,Color.DarkViolet,Color.DeepPink,Color.DeepSkyBlue,Color.DimGray, Color.DodgerBlue,Color.ForestGreen, Color.Gold,
Color.Gray,Color.GreenYellow,Color.HotPink,Color.Indigo,Color.Khaki,
Color.LimeGreen,Color.MediumOrchid,Color.MediumPurple,Color.MediumSeaGreen,Color.MediumSlateBlue,Color.MediumSpringGreen,
Color.MediumTurquoise,Color.Moccasin,Color.NavajoWhite,Color.Olive,Color.OliveDrab,Color.OrangeRed,Color.Orchid,Color.PaleGoldenrod,Color.PaleGreen,
Color.PeachPuff,Color.Peru,Color.Plum,Color.PowderBlue,Color.RosyBrown,Color.RoyalBlue,Color.SaddleBrown,Color.Salmon,Color.SeaGreen, Color.Sienna,
Color.SkyBlue,Color.SlateBlue,Color.SlateGray,Color.SpringGreen,Color.Teal,Color.Aquamarine,Color.Tomato,Color.Turquoise,Color.Violet,Color.Wheat, Color.YellowGreen});
#endregion Properties
#region
/// <summary>
/// 重新搜索Recipe
/// </summary>
public void SearchRecipe()
{
this.StartDateTime = this.view.wfTimeFrom.Value;
this.EndDateTime = this.view.wfTimeTo.Value;
if (StartDateTime > EndDateTime)
{
MessageBox.Show("Time range invalid, start time should be early than end time");
return;
}
Recipes.Clear();
RemoveAllLine();
try
{
string sql = $"SELECT * FROM \"process_data\" where \"process_data\".\"process_begin_time\" >='{StartDateTime:yyyyMMdd HHmmss}' and \"process_data\".\"process_end_time\" <='{EndDateTime:yyyyMMdd HHmmss}'";
if (!string.IsNullOrEmpty(SelectedValuePM))
{
string[] pms = SelectedValuePM.Split(',');
if (pms.Length > 0)
{
sql += " and (FALSE ";
foreach (var pm in pms)
{
sql += $" OR \"process_data\".\"process_in\"='{pm}' ";
}
sql += " ) ";
}
}
if (!string.IsNullOrEmpty(RecipeName))
{
sql += string.Format(" and lower( \"process_data\".\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
}
sql += " order by \"process_data\".\"process_begin_time\" ASC;";
DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
if (dbData == null || dbData.Rows.Count == 0)
return;
double maxXValue = 0;
for (int i = 0; i < dbData.Rows.Count; i++)
{
RecipeItemSic item = new RecipeItemSic();
item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
item.Chamber = dbData.Rows[i]["process_in"].ToString();
item.Status = dbData.Rows[i]["process_status"].ToString();
//item.ProcessGuid = dbData.Rows[i]["guid"].ToString();
item.ProcessGuid = "Recipe"+i.ToString().PadLeft(3,'0');
if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
long curTickCount = (DateTime.Parse(item.EndTime).Ticks - DateTime.Parse(item.StartTime).Ticks) / 10000000;
if (maxXValue < curTickCount)
{
maxXValue = curTickCount;
}
//正确设置范围,否则曲线不显示
VisibleRangeX = new DoubleRange(-0.2*maxXValue, maxXValue * 1.2);
VisibleRangeXLimit = new DoubleRange(-0.2 * maxXValue, maxXValue * 1.2);//X轴拉伸1.2倍
Recipes.Add(item);
}
}));
}
catch (Exception e)
{
LOG.Write(e);
}
}
/// <summary>
/// 选择Recipe
/// </summary>
public void CheckRecipe(RecipeItemSic recipe)
{
if (recipe.Selected) //选中配方
{
SelectedRecipes.Add(recipe);
//刷新曲线
//GetXRange();
foreach (PMNodeInfo node in ConfigNodes)
{
if (node.Selected)
{
ParameterCheck(node);
}
}
}
else //取消配方
{
RecipeItemSic item = SelectedRecipes.FirstOrDefault(t => t.Recipe == recipe.Recipe);
if (item != null)
SelectedRecipes.Remove(item);
RemoveRecipeRelated(recipe); //移除配方相关曲线
}
}
/// <summary>
/// 移除配方相关曲线
/// </summary>
/// <param name="recipe"></param>
private void RemoveRecipeRelated(RecipeItemSic recipe)
{
lock (_lockSelection) //递减法移除列表内项,不会删错
{
for (int i = SelectedData.Count - 1; i >= 0; i--)
{
if ((SelectedData[i] as ChartDataLineX).ProcessGuid.Contains(recipe.ProcessGuid))
{
SelectedData.RemoveAt(i);
}
}
}
}
/// <summary>
/// 清除所有选择的节点
/// </summary>
public void RemoveAllLine()
{
this.SelectedData.Clear();
foreach (PMNodeInfo node in ConfigNodes)
{
node.Selected = false;
}
}
#endregion
private void SelectedDataChanged()
{
foreach (var item in SelectedData)
{
if (item.Stroke.Equals(System.Windows.Media.Color.FromArgb(255, 0, 0, 255)))
{
Color drawingColor = colorQueue.Peek();
item.Stroke = System.Windows.Media.Color.FromRgb(drawingColor.R, drawingColor.G, drawingColor.B);
colorQueue.Enqueue(colorQueue.Dequeue());
}
}
}
/// <summary>
/// 加载PM的Device名称
/// </summary>
private void GetPMNode()
{
Nodes.Clear();
ConfigNodes.Clear();
List<string> dataList = (List<string>)QueryDataClient.Instance.Service.GetConfig("System.NumericDataList");
dataList.Sort();
List<string> lstNode = new List<string>();
foreach (string dataName in dataList)
{
string[] nodeName = dataName.Split('.');
if (nodeName.Length > 1 && nodeName[0].IndexOf("PM") == 0)
{
string nodeStr = dataName.Substring(dataName.IndexOf('.') + 1);
if (!lstNode.Contains(nodeStr)) //不显示重复项
{
lstNode.Add(nodeStr);
Nodes.Add(new PMNodeInfo() { NodeStr = nodeStr });
ConfigNodes.Add(new PMNodeInfo() { NodeStr = nodeStr });
}
}
}
}
public void Find(string keyword)
{
ConfigNodes.Clear();
//遍历所有node,隐藏不符合条件项
foreach (var node in Nodes)
{
node.ApplyCriteria(keyword);
if (node.IsMatch)
{
ConfigNodes.Add(node);
}
}
}
private void SetDataDetailVisble()
{
if (DataDetailVisbility == Visibility.Collapsed)
{
DataDetailVisbility = Visibility.Visible;
}
else
{
DataDetailVisbility = Visibility.Collapsed;
}
}
#region HistoryData
private object _lockSelection = new object();
protected bool MonitorHistoryData()
{
try
{
if (_lstTokenTimeData.Count > 0)
{
lock (_lockSelection)
{
foreach (var item in _lstTokenTimeData)
{
DateTime timeFrom = item.StartTime;
DateTime timeTo = item.EndTime;
GetHistoryData(item.DateList, timeFrom, timeTo, item.Module, item.ColumneName, item.ProcessGuid);
_lstTokenTimeData.TryTake(out _);
}
}
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
return true;
}
private void GetHistoryData(List<string> lstDayStr, DateTime from, DateTime to, string module, string colName, string processGuid)
{
Dictionary<string, List<DataDetail>> historyData = new Dictionary<string, List<DataDetail>>();
List<DataDetail> lstDataDetail = new List<DataDetail>();
//db获取对应字段数据
foreach (string cDate in lstDayStr)
{
string sql = String.Format("select time AS InternalTimeStamp,\"{0}\"", colName);
sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc",
cDate + "." + module, from.Ticks, to.Ticks);
DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql);
if (dataTable == null || dataTable.Rows.Count == 0 || dataTable.Columns.Count < 2)
{
return;
}
for (int i = 0; i < dataTable.Rows.Count; i++)
{
DataDetail data = new DataDetail();
long ticks = (long)dataTable.Rows[i][0] - from.Ticks;
data.xValue = ticks / 10000000;
if (dataTable.Rows[i][1] is DBNull || dataTable.Rows[i][1] is null)
{
data.yValue = 0;
}
else if (dataTable.Rows[i][1] is bool)
{
data.yValue = (bool)dataTable.Rows[i][1] ? 1 : 0;
}
else
{
data.yValue = float.Parse(dataTable.Rows[i][1].ToString());
}
if (data.yValue > _maxYValue)
{
_maxYValue = data.yValue;
}
if (data.yValue < _minYValue)
{
_minYValue = data.yValue;
}
lstDataDetail.Add(data);
}
}
//正确设置范围,否则曲线不显示
VisibleRangeY = new DoubleRange(_minYValue - _maxYValue * 0.5, _maxYValue * 2.1);
VisibleRangeYLimit = new DoubleRange(_minYValue - _maxYValue * 0.5, _maxYValue * 2.1);//Y轴拉伸1.2倍
//所有数据内存
historyData.Add(processGuid, lstDataDetail);
//数据绑定到曲线中
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
try
{
foreach (var item in SelectedData)
{
var seriesItem = item as ChartDataLineX;
if (seriesItem == null)
continue;
foreach (var data in historyData)
{
if (data.Key != seriesItem.ProcessGuid)
continue;
seriesItem.Capacity += data.Value.Count;
foreach (var detailDataItem in data.Value)
{
seriesItem.Append(detailDataItem.xValue, detailDataItem.yValue);
}
}
}
}
catch (Exception ex)
{
LOG.Write(ex);
}
}));
}
#endregion
/// <summary>
/// 更新Data变化
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public bool ParameterCheck(PMNodeInfo node)
{
if (SelectedRecipes.Count == 0)
{
return false;
}
if (node.Selected)
{
foreach (RecipeItemSic itemSic in SelectedRecipes)
{
string nodeStr = itemSic.Chamber + "." + node.NodeStr; //字段名称
string nodeStr_1 = itemSic.LotID; //显示名称
string nodeWithGuid = node.NodeStr + "_" + itemSic.ProcessGuid; //字段名+ Guid (唯一ID)
DateTime dtStartTime = DateTime.Parse(itemSic.StartTime);
DateTime dtEndTime = DateTime.Parse(itemSic.EndTime);
lock (_lockSelection)
{
bool isExist = SelectedData.FirstOrDefault(x => (x as ChartDataLineX).ProcessGuid == nodeWithGuid) != null;
if (!isExist)
{
if (SelectedData.Count < MAX_PARAMETERS)
{
var line = new ChartDataLineX(nodeWithGuid);
line.Time=itemSic.StartTime+"-"+itemSic.EndTime;
line.RecipeName = new DirectoryInfo(itemSic.Recipe).Name;
if (itemSic.Chamber.StartsWith("PM1"))
line.Module = "PM1";
else if (itemSic.Chamber.StartsWith("PM2"))
line.Module = "PM2";
else
line.Module = "System";
line.ProcessGuid = nodeWithGuid;
line.RecName = nodeStr_1;
line.Tag = node;
SelectedData.Add(line);
SelectedDataChanged();
QueryIndexer indexer = _lstTokenTimeData.FirstOrDefault(x => x.ProcessGuid == line.ProcessGuid);
if (indexer == null)
{
indexer = new QueryIndexer()
{
Module = line.Module,
StartTime = dtStartTime,
EndTime = dtEndTime,
ProcessGuid = line.ProcessGuid,
ColumneName = nodeStr,
DateList = GetDateList(dtStartTime, dtEndTime)
};
_lstTokenTimeData.Add(indexer);
}
}
else
{
return false;
}
}
}
}
}
else
{
lock (_lockSelection)
{
for (int i = SelectedData.Count - 1; i >= 0; i--)
{
if ((SelectedData[i] as ChartDataLineX).DataName.Contains(node.NodeStr))
{
SelectedData.RemoveAt(i);
}
}
}
}
return true;
}
public void SelectColor(ChartDataLineX cp)
{
if (cp == null)
return;
var dlg = new System.Windows.Forms.ColorDialog();
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
cp.Stroke = new System.Windows.Media.Color() { A = dlg.Color.A, B = dlg.Color.B, G = dlg.Color.G, R = dlg.Color.R };
}
}
/// <summary>
/// 获取开始时间和结束时间之间的所有日期
/// </summary>
/// <param name="timeStart"></param>
/// <param name="timeEnd"></param>
/// <returns></returns>
private List<string> GetDateList(DateTime timeStart, DateTime timeEnd)
{
List<string> lstTime = new List<string>();
string dtEndStr = timeEnd.ToString("yyyyMMdd");
int timeSpan = (int)(timeEnd - timeStart).TotalDays + 1;
for (int i = 0; i <= timeSpan; i++)
{
string dt = timeStart.AddDays(i).ToString("yyyyMMdd");
lstTime.Add(dt);
if (dt == dtEndStr)
{
break;
}
}
return lstTime;
}
/// <summary>
/// 获取所有的列名
/// </summary>
private List<string> GetColumnList(string modleName)
{
List<string> _seletedItemName = new List<string>();
foreach (PMNodeInfo node in ConfigNodes)
{
if (node.Selected)
{
_seletedItemName.Add("\"" + modleName + "." + node.NodeStr + "\"");
}
}
return _seletedItemName;
}
public ActionCommand DefaultZoomCommand { get; private set; }
public ActionCommand ShowLegendCommand { get; private set; }
public ActionCommand DataDetailVisbleCommand { get; private set; }
public ActionCommand ShowAlarmCommand { get; private set; }
private void SetLegendAvalible()
{
ShowLegendInfo = !ShowLegendInfo;
}
private void Zoom()
{
ViewportManager.AnimateZoomExtents(TimeSpan.FromMilliseconds(500));
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -257,6 +257,10 @@
</Compile>
<Compile Include="Models\PMs\Charting\ChartingTemplateViewModel.cs" />
<Compile Include="Models\PMs\Charting\ChartDataLineX.cs" />
<Compile Include="Models\PMs\Charting\PMChartingV2View.xaml.cs">
<DependentUpon>PMChartingV2View.xaml</DependentUpon>
</Compile>
<Compile Include="Models\PMs\Charting\PMChartingV2ViewModel.cs" />
<Compile Include="Models\PMs\ContinueSelectDialogView.xaml.cs">
<DependentUpon>ContinueSelectDialogView.xaml</DependentUpon>
</Compile>
@ -478,6 +482,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Models\PMs\Charting\PMChartingV2View.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Models\PMs\ContinueSelectDialogView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -856,6 +864,9 @@
<ItemGroup>
<Resource Include="Resources\Images\interlock_bypass_watermark.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Images\find.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>