首次上传
This commit is contained in:
@@ -0,0 +1,408 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.Operations.RealTime.RealtimeView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
|
||||
xmlns:userControls="clr-namespace:MECF.Framework.UI.Client.CenterViews.Core.UserControls"
|
||||
xmlns:userControls1="clr-namespace:Sicentury.Core.UserControls;assembly=Sicentury.Core"
|
||||
xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
xmlns:realTime="clr-namespace:MECF.Framework.UI.Client.CenterViews.Operations.RealTime"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="1800"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=realTime:RealtimeViewModel, IsDesignTimeCreatable=False}"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
|
||||
<UserControl.Resources>
|
||||
<cv:BoolReverseConverter x:Key="boolReverseConverter" />
|
||||
<cv:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid IsEnabled="{Binding IsPermission}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="400" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="200" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.RowSpan="2" Grid.Column="0">
|
||||
<Border
|
||||
Padding="5"
|
||||
Background="{DynamicResource Tab_BG}"
|
||||
BorderBrush="{DynamicResource Tab_BD}"
|
||||
BorderThickness="1"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<userControls1:ParameterNodeTreeViewControl
|
||||
x:Name="tvParameterNodes"
|
||||
IsEnabled="{Binding IsBusy, Converter={StaticResource boolReverseConverter}}"
|
||||
TreeRoot="{Binding ParameterNodes}"
|
||||
PresetGroupsFolderName="RealTimeView"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<GridSplitter
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="Transparent"
|
||||
Style="{DynamicResource VerticalGridSplitterStyle}" />
|
||||
|
||||
<!-- data chart -->
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Orientation="Horizontal" Margin="0,5,0,0">
|
||||
|
||||
<userControls:DataViewDataGrid
|
||||
x:Name="dataGrid"
|
||||
Width="1000"
|
||||
IsShowStatisticColumn="False"
|
||||
IsEnabled="{Binding IsBusy, Converter={StaticResource boolReverseConverter}}"
|
||||
ItemsSource="{Binding Path=SelectedData}">
|
||||
<i:Interaction.Behaviors>
|
||||
<userControls:PhotoShotBehavior Target="{Binding ElementName=sciChart}"/>
|
||||
</i:Interaction.Behaviors>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Deleted">
|
||||
<micro:ActionMessage MethodName="Deleted">
|
||||
<micro:Parameter Value="$source" />
|
||||
<micro:Parameter Value="$eventargs" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="Exporting">
|
||||
<micro:ActionMessage MethodName="Exporting">
|
||||
<micro:Parameter Value="$source" />
|
||||
<micro:Parameter Value="$eventargs" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="Exported">
|
||||
<micro:ActionMessage MethodName="Exported">
|
||||
<micro:Parameter Value="$source" />
|
||||
<micro:Parameter Value="$eventargs" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="ProgressMessageUpdating">
|
||||
<micro:ActionMessage MethodName="ProgressUpdating">
|
||||
<micro:Parameter Value="$source" />
|
||||
<micro:Parameter Value="$eventargs" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</userControls:DataViewDataGrid>
|
||||
|
||||
<Grid Margin="15,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="26" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="49" />
|
||||
<ColumnDefinition Width="61" />
|
||||
<ColumnDefinition Width="120" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="4"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="{lex:Loc ID_TXT_TrendChartSetting}"
|
||||
Style="{DynamicResource Table_TitleStyle}" />
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1,0,1,1">
|
||||
<TextBlock
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="{lex:Loc ID_TXT_Interval}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Padding="5,1"
|
||||
Background="{Binding AlignerStatusBackground}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<controls:TextBoxEx
|
||||
Width="100"
|
||||
Height="25"
|
||||
EditBoxMode="UnSignInteger"
|
||||
MaxValue="60000"
|
||||
MinValue="100"
|
||||
Text="{Binding TrendInterval, Mode=TwoWay}"
|
||||
TextSaved="{Binding IntervalSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Validation.ErrorTemplate="{x:Null}" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<Button
|
||||
Width="70"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
Content="{lex:Loc ID_BTN_Set_Content}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetInterval" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Border>
|
||||
|
||||
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1,0,1,1">
|
||||
<TextBlock
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="{lex:Loc ID_TXT_TimeSpan}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Padding="5,1"
|
||||
Background="{Binding AlignerStatusBackground}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<controls:TextBoxEx
|
||||
Width="100"
|
||||
Height="25"
|
||||
EditBoxMode="UnSignInteger"
|
||||
MaxValue="3600"
|
||||
MinValue="1"
|
||||
Text="{Binding TrendTimeSpan, Mode=TwoWay}"
|
||||
TextSaved="{Binding TimeSpanSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Validation.ErrorTemplate="{x:Null}" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Grid.Column="3"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<Button
|
||||
Width="70"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
Content="{lex:Loc ID_BTN_Set_Content}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetTimeSpan" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,0,0">
|
||||
<s:SciChartSurface
|
||||
Name="sciChart"
|
||||
Padding="2"
|
||||
s:ThemeManager.Theme="ExpressionLight"
|
||||
BorderBrush="Gray"
|
||||
DebugWhyDoesntSciChartRender="False"
|
||||
Focusable="False"
|
||||
IsTabStop="False"
|
||||
RenderableSeries="{Binding SelectedData}">
|
||||
|
||||
<!-- Create an X Axis -->
|
||||
<s:SciChartSurface.XAxis>
|
||||
<s:DateTimeAxis
|
||||
Margin="0,0,0,0"
|
||||
AutoRange="{Binding ChartAutoRange}"
|
||||
DrawMinorGridLines="False"
|
||||
DrawMinorTicks="False"
|
||||
FontSize="14"
|
||||
Id="DefaultAxisId"
|
||||
SubDayTextFormatting="HH:mm:ss"
|
||||
TextFormatting="HH:mm:ss"
|
||||
TitleFontSize="15"
|
||||
TitleFontWeight="Normal" />
|
||||
|
||||
</s:SciChartSurface.XAxis>
|
||||
|
||||
<!-- Create a Y Axis -->
|
||||
<s:SciChartSurface.YAxis>
|
||||
<s:NumericAxis
|
||||
HorizontalAlignment="Center"
|
||||
AutoRange="{Binding ChartAutoRange}"
|
||||
AxisAlignment="Right"
|
||||
BorderThickness="0"
|
||||
CursorTextFormatting="0.######"
|
||||
DrawLabels="True"
|
||||
DrawMajorBands="False"
|
||||
DrawMajorGridLines="True"
|
||||
DrawMajorTicks="False"
|
||||
DrawMinorGridLines="False"
|
||||
DrawMinorTicks="False"
|
||||
Focusable="False"
|
||||
Id="DefaultAxisId"
|
||||
MajorDelta="0.001"
|
||||
MinorDelta="0.001">
|
||||
<s:NumericAxis.GrowBy>
|
||||
<s:DoubleRange Max="0.001" Min="0.001" />
|
||||
</s:NumericAxis.GrowBy>
|
||||
</s:NumericAxis>
|
||||
</s:SciChartSurface.YAxis>
|
||||
|
||||
<s:SciChartSurface.ChartModifier>
|
||||
|
||||
<s:ModifierGroup>
|
||||
|
||||
<s:RubberBandXyZoomModifier
|
||||
x:Name="rubberBandZoomModifier"
|
||||
ExecuteOn="MouseLeftButton"
|
||||
IsAnimated="True"
|
||||
IsEnabled="True"
|
||||
IsXAxisOnly="False"
|
||||
ReceiveHandledEvents="True"
|
||||
ZoomExtentsY="True" />
|
||||
|
||||
<s:CursorModifier
|
||||
IsEnabled="True"
|
||||
ShowAxisLabels="True"
|
||||
ShowTooltip="False"
|
||||
ShowTooltipOn="Never"
|
||||
SourceMode="AllSeries" />
|
||||
|
||||
<s:LegendModifier
|
||||
x:Name="legendModifier"
|
||||
GetLegendDataFor="AllSeries"
|
||||
ShowLegend="False" />
|
||||
|
||||
<s:ZoomExtentsModifier
|
||||
x:Name="zoomExtentsModifier"
|
||||
ExecuteOn="MouseDoubleClick"
|
||||
XyDirection="XYDirection" />
|
||||
|
||||
<s:ZoomPanModifier
|
||||
x:Name="zoomPanModifier"
|
||||
ClipModeX="None"
|
||||
ExecuteOn="MouseRightButton"
|
||||
IsEnabled="True"
|
||||
XyDirection="XYDirection"
|
||||
ZoomExtentsY="False" />
|
||||
|
||||
<s:RolloverModifier
|
||||
x:Name="rolloverModifier"
|
||||
DrawVerticalLine="False"
|
||||
FontFamily="Arial,SimSun"
|
||||
FontSize="9"
|
||||
IsEnabled="True"
|
||||
ShowAxisLabels="False"
|
||||
SnapsToDevicePixels="False"
|
||||
UseInterpolation="False" />
|
||||
|
||||
<s:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" XyDirection="XYDirection" />
|
||||
|
||||
<s:SeriesValueModifier />
|
||||
</s:ModifierGroup>
|
||||
</s:SciChartSurface.ChartModifier>
|
||||
</s:SciChartSurface>
|
||||
|
||||
<CheckBox
|
||||
Margin="0,10,1208,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Content="Auto Zoom"
|
||||
IsChecked="{Binding EnableAutoZoom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<Border
|
||||
x:Name="btnScreenShot"
|
||||
Margin="5,5,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Background="Transparent"
|
||||
Cursor="Hand"
|
||||
Opacity="0.4"
|
||||
ToolTip="Fit to Screen">
|
||||
<Button Width="35" Height="35" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0">
|
||||
<i:Interaction.Behaviors>
|
||||
<userControls:PhotoShotBehavior Target="{Binding ElementName=sciChart}"/>
|
||||
</i:Interaction.Behaviors>
|
||||
<Button.Background>
|
||||
<ImageBrush ImageSource="pack://application:,,,/Resources/Images/screenshot.png" Stretch="Uniform"/>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<Border.Style>
|
||||
<Style>
|
||||
<Setter Property="Border.Opacity" Value="0.8" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Border.IsMouseOver" Value="True">
|
||||
<Setter Property="Border.Opacity" Value="1" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
<userControls1:BusyIndicator
|
||||
Grid.Row="1" Grid.Column="2"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="3"
|
||||
Padding="20 10"
|
||||
Background="{StaticResource Tab_BG}"
|
||||
Visibility="{Binding IsBusy, Converter={StaticResource BoolVisibilityConverter}}"
|
||||
Message="{Binding BusyIndicatorContent}" Margin="350,0,0,0">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Canceled">
|
||||
<micro:ActionMessage MethodName="Cancel" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</userControls1:BusyIndicator>
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Operations.RealTime
|
||||
{
|
||||
/// <summary>
|
||||
/// RealtimeView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RealtimeView : UserControl
|
||||
{
|
||||
public RealtimeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Aitex.Core.RT.Log;
|
||||
using Aitex.Core.Util;
|
||||
using Aitex.Core.Utilities;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.UI.Client.CenterViews.Core;
|
||||
using MECF.Framework.UI.Client.CenterViews.Core.Charting;
|
||||
using MECF.Framework.UI.Client.CenterViews.Core.EventArgs;
|
||||
using SciChart.Charting.Visuals.Axes;
|
||||
using Sicentury.Core.EventArgs;
|
||||
using Sicentury.Core.Tree;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Operations.RealTime
|
||||
{
|
||||
public sealed class RealtimeViewModel : BusyIndicateableUiViewModelBase
|
||||
{
|
||||
#region Variables
|
||||
|
||||
/// <summary>
|
||||
/// 允许监控的最大曲线数量
|
||||
/// </summary>
|
||||
private const int MAX_PARAMETERS_ALLOWED = 200;
|
||||
|
||||
private readonly RealtimeProvider _provider = new RealtimeProvider();
|
||||
|
||||
private bool _enableAutoZoom = true;
|
||||
private int _pointCount;
|
||||
private readonly PeriodicJob _thread;
|
||||
|
||||
/// <summary>
|
||||
/// Monitor中添加数据点时直接向DataSeries对象添加,已实现跨线程操作。
|
||||
/// </summary>
|
||||
private readonly List<SicFastLineDataSeries> _dataSeriesList;
|
||||
|
||||
/// <summary>
|
||||
/// 更新报告导出信息。
|
||||
/// </summary>
|
||||
private readonly IProgress<ProgressUpdatingEventArgs> _exportingProgressReporter;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public RealtimeViewModel()
|
||||
{
|
||||
DisplayName = "Realtime";
|
||||
|
||||
SelectedData = new ChartingLineSeriesCollection(DisplayName);
|
||||
|
||||
ParameterNodes = new TreeNode(DisplayName)
|
||||
{
|
||||
MaxTerminalSelectionAllowed = MAX_PARAMETERS_ALLOWED
|
||||
};
|
||||
|
||||
ParameterNodes.ChildNodes.AddRange(_provider.GetParameters());
|
||||
ParameterNodes.TerminalNodeSelectionChanged += OnNodeSelectionChanged;
|
||||
|
||||
IntervalSaved = true;
|
||||
TrendInterval = 500;
|
||||
TimeSpanSaved = true;
|
||||
TrendTimeSpan = 60 * 5;
|
||||
|
||||
_thread = new PeriodicJob(TrendInterval, MonitorData, "RealTime", true);
|
||||
_pointCount = Math.Max(TrendTimeSpan * 1000 / TrendInterval, 10);
|
||||
|
||||
_dataSeriesList = new List<SicFastLineDataSeries>();
|
||||
|
||||
_exportingProgressReporter = new Progress<ProgressUpdatingEventArgs>(e =>
|
||||
{
|
||||
BusyIndicatorContent = e.Message;
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public TreeNode ParameterNodes { get; }
|
||||
|
||||
public ChartingLineSeriesCollection SelectedData { get; set; }
|
||||
|
||||
|
||||
public AutoRange ChartAutoRange => EnableAutoZoom ? AutoRange.Always : AutoRange.Never;
|
||||
|
||||
public bool EnableAutoZoom
|
||||
{
|
||||
get => _enableAutoZoom;
|
||||
|
||||
set
|
||||
{
|
||||
_enableAutoZoom = value;
|
||||
NotifyOfPropertyChange(nameof(EnableAutoZoom));
|
||||
NotifyOfPropertyChange(nameof(ChartAutoRange));
|
||||
}
|
||||
}
|
||||
|
||||
[IgnorePropertyChange]
|
||||
public int TrendInterval { get; set; }
|
||||
|
||||
public bool IntervalSaved { get; set; }
|
||||
|
||||
[IgnorePropertyChange]
|
||||
public int TrendTimeSpan { get; set; }
|
||||
|
||||
public bool TimeSpanSaved { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected bool MonitorData()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, object> data = null;
|
||||
if (SelectedData.Count > 0)
|
||||
{
|
||||
data = QueryDataClient.Instance.Service.PollData(Array.ConvertAll(SelectedData.ToArray(), x => (x as SicFastLineSeries).DataName));
|
||||
}
|
||||
|
||||
AppendData(data);
|
||||
|
||||
for (var j = 0; j < ParameterNodes.ChildNodes.Count; j++)
|
||||
{
|
||||
var par = ParameterNodes.ChildNodes[j];
|
||||
par.IsVisibilityParentNode = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error(ex.Message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AppendData(Dictionary<string, object> data)
|
||||
{
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
var dt = DateTime.Now;
|
||||
|
||||
foreach (var ds in _dataSeriesList)
|
||||
{
|
||||
if (ds == null || !data.ContainsKey(ds.SeriesName))
|
||||
continue;
|
||||
|
||||
if (data[ds.SeriesName] is bool)
|
||||
{
|
||||
ds.Append(dt, ((bool)data[ds.SeriesName] ? 1 : 0) * ds.Factor + ds.Offset, new ParameterNodePoint(dt, ((bool)data[ds.SeriesName] ? 1 : 0)));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!double.TryParse(data[ds.SeriesName].ToString(), out var value))
|
||||
continue;
|
||||
|
||||
ds.Append(dt, value * ds.Factor + ds.Offset, new ParameterNodePoint(dt, value));
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFifoCapacity(int capacity)
|
||||
{
|
||||
foreach (var renderableSeries in SelectedData)
|
||||
{
|
||||
if (renderableSeries is SicFastLineSeries line)
|
||||
{
|
||||
var ds = line.GetDataSeries();
|
||||
var copyMetaData = ds.Metadata.Where(x => x != null && ((ParameterNodePoint)x).Time > DateTime.Now.AddSeconds(-TrendTimeSpan)).ToList();
|
||||
|
||||
ds.FifoCapacity = capacity;
|
||||
foreach (ParameterNodePoint item in copyMetaData)
|
||||
{
|
||||
ds.Append(item.Time, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInterval()
|
||||
{
|
||||
_thread.ChangeInterval(TrendInterval);
|
||||
_pointCount = Math.Max(10, TrendTimeSpan * 1000 / TrendInterval);
|
||||
IntervalSaved = true;
|
||||
NotifyOfPropertyChange(nameof(IntervalSaved));
|
||||
|
||||
UpdateFifoCapacity(_pointCount);
|
||||
}
|
||||
|
||||
public void SetTimeSpan()
|
||||
{
|
||||
_pointCount = Math.Max(10, TrendTimeSpan * 1000 / TrendInterval);
|
||||
TimeSpanSaved = true;
|
||||
NotifyOfPropertyChange(nameof(TimeSpanSaved));
|
||||
|
||||
UpdateFifoCapacity(_pointCount);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public void OnNodeSelectionChanged(object sender, TreeNodeSelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue == true && SelectedData.Count >= MAX_PARAMETERS_ALLOWED)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var line = SelectedData.Cast<SicFastLineSeries>().FirstOrDefault(x => x.DataName == e.Source.FullName);
|
||||
switch (e.NewValue)
|
||||
{
|
||||
case false:
|
||||
{
|
||||
if (line != null)
|
||||
{
|
||||
_dataSeriesList.Remove(line.GetDataSeries());
|
||||
SelectedData.Remove(line);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case true:
|
||||
{
|
||||
if (line == null)
|
||||
{
|
||||
var series = new SicFastLineSeries(e.Source.FullName)
|
||||
{
|
||||
BackendParameterNode = e.Source
|
||||
};
|
||||
series.GetDataSeries().FifoCapacity = _pointCount;
|
||||
|
||||
SelectedData.Add(series);
|
||||
_dataSeriesList.Add(series.GetDataSeries());
|
||||
SelectedData.ResetColors();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Deleted(object sender, RenderableSeriesDeletingEventArgs e)
|
||||
{
|
||||
var list = e.Source.Cast<SicFastLineSeries>().ToList();
|
||||
|
||||
//var total = SelectedData.Count;
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 清除左侧Tree中的选中状态
|
||||
list[i].BackendParameterNode.IsSelected = false;
|
||||
_dataSeriesList.Remove(list[i].GetDataSeries());
|
||||
}
|
||||
|
||||
((RealtimeView)View).tvParameterNodes.ClearPresetGroupSelectionOnly();
|
||||
}
|
||||
|
||||
public void Exporting(object sender, EventArgs e)
|
||||
{
|
||||
BusyIndicatorContent = "Exporting ...";
|
||||
IsBusy = true;
|
||||
}
|
||||
|
||||
public void Exported(object sender, EventArgs e)
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
|
||||
public void ProgressUpdating(object sender, ProgressUpdatingEventArgs e)
|
||||
{
|
||||
_exportingProgressReporter.Report(e);
|
||||
}
|
||||
|
||||
public override void Cancel()
|
||||
{
|
||||
if (View is RealtimeView view)
|
||||
{
|
||||
view.dataGrid.CancelOperation();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.UI.Client.CenterViews.Core;
|
||||
using OpenSEMI.ClientBase.ServiceProvider;
|
||||
using Sicentury.Core.Tree;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Operations.RealTime
|
||||
{
|
||||
public class RealtimeProvider : IProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用字符串队列创建树结构的分支。
|
||||
/// </summary>
|
||||
/// <param name="branchString"></param>
|
||||
/// <param name="node"></param>
|
||||
private static TreeNode CreateTreeBranch(Queue<string> branchString, TreeNode node)
|
||||
{
|
||||
var rootNode = node;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (branchString.Count <= 0)
|
||||
return rootNode;
|
||||
|
||||
var name = branchString.Dequeue();
|
||||
|
||||
if (node == null)
|
||||
{
|
||||
// 根节点
|
||||
node = new TreeNode(name);
|
||||
rootNode = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(node.Name == name)
|
||||
continue;
|
||||
|
||||
// 向ChildNode插入
|
||||
var subNode = node.ChildNodes.FirstOrDefault(x => x.Name == name);
|
||||
if (subNode == null)
|
||||
{
|
||||
subNode = new TreeNode(name);
|
||||
node.ChildNodes.Add(subNode);
|
||||
}
|
||||
|
||||
node = subNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<string> GetUserDefineParameters()
|
||||
{
|
||||
var typedContents = ((string)QueryDataClient.Instance.Service.GetTypedConfigContent("UserDefine", ""));
|
||||
var dataList = new List<string>();
|
||||
if (typedContents != null)
|
||||
{
|
||||
var contentList = typedContents.Split(',').ToList();
|
||||
contentList.ForEach(x => { if (!string.IsNullOrEmpty(x)) dataList.Add($"{x}"); });
|
||||
}
|
||||
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public List<TreeNode> GetParameters()
|
||||
{
|
||||
var root = new List<TreeNode>();
|
||||
|
||||
try
|
||||
{
|
||||
var dataList = (List<string>)QueryDataClient.Instance.Service.GetConfig("System.NumericDataList");
|
||||
//var typedContents = QueryDataClient.Instance.Service.GetTypedConfigContent("UserDefine", "");
|
||||
//if (string.IsNullOrEmpty(typedContents))
|
||||
//{
|
||||
// dataList.Add($"UserDefine");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var contentList = typedContents.Split(',').ToList();
|
||||
// contentList.ForEach(x =>
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(x)) dataList.Add($"UserDefine.{x}");
|
||||
// });
|
||||
//}
|
||||
|
||||
dataList.Sort();
|
||||
|
||||
foreach (var dataName in dataList)
|
||||
{
|
||||
var nodeName = new Queue<string>(dataName.Split('.'));
|
||||
if (nodeName.Count <= 0)
|
||||
continue;
|
||||
|
||||
// 开始创建Tree分支
|
||||
var rootNode = root.FirstOrDefault(x => x.Name == nodeName.Peek());
|
||||
var node = CreateTreeBranch(nodeName, rootNode);
|
||||
if(rootNode == null)
|
||||
root.Add(node);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user