Commit 4d073f74 authored by 潘栩锋's avatar 潘栩锋 🚴

完成趋势图2

parent 8fd7b294
......@@ -150,14 +150,18 @@
<Compile Include="UiModule\ScanGraph2\ScanGraph2Vm.cs" />
<Compile Include="UiModule\ScanGraph2\ScanGraph2VmUt.cs" />
<Compile Include="UiModule\ScanGraph2\UIModule_ScanGraph2.cs" />
<Compile Include="UiModule\ScanGraphCircular\PolarChart.xaml.cs">
<DependentUpon>PolarChart.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircular.xaml.cs">
<DependentUpon>ScanGraphCircular.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircularConfig.xaml.cs">
<DependentUpon>ScanGraphCircularConfig.xaml</DependentUpon>
<Compile Include="UiModule\ScanGraphCircular\WdScanGraphCircularConfig.xaml.cs">
<DependentUpon>WdScanGraphCircularConfig.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircularParam.cs" />
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircularParams.cs" />
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircularVmUt.cs" />
<Compile Include="UiModule\ScanGraphCircular\ScanGraphCircularVm.cs" />
<Compile Include="UiModule\ScanGraphCircular\UiModule2_ScanGraphCircular.cs" />
<Compile Include="UiModule\ScanGraph\ScanGraph.xaml.cs">
......@@ -171,6 +175,17 @@
<Compile Include="UiModule\ScanGraph\WdScanGraphConfig.xaml.cs">
<DependentUpon>WdScanGraphConfig.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\TrendGraph2\TrendGraph2.xaml.cs">
<DependentUpon>TrendGraph2.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\TrendGraph2\TrendGraphConfig2.xaml.cs">
<DependentUpon>TrendGraphConfig2.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\TrendGraph2\TrendGraphItemParam2.cs" />
<Compile Include="UiModule\TrendGraph2\TrendGraphParam2s.cs" />
<Compile Include="UiModule\TrendGraph2\TrendGraphVm2.cs" />
<Compile Include="UiModule\TrendGraph2\TrendGraphVm2Ut.cs" />
<Compile Include="UiModule\TrendGraph2\UiModule2_TrendGraph2.cs" />
<Compile Include="UiModule\TrendGraph\TrendGraph.xaml.cs">
<DependentUpon>TrendGraph.xaml</DependentUpon>
</Compile>
......@@ -251,11 +266,15 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UiModule\ScanGraphCircular\PolarChart.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\ScanGraphCircular\ScanGraphCircular.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UiModule\ScanGraphCircular\ScanGraphCircularConfig.xaml">
<Page Include="UiModule\ScanGraphCircular\WdScanGraphCircularConfig.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
......@@ -267,6 +286,14 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\TrendGraph2\TrendGraph2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UiModule\TrendGraph2\TrendGraphConfig2.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\TrendGraph\TrendGraph.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -89,7 +89,7 @@
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" >
<lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Transparent" FontFamily="Courier New">
<lvc:Axis.Resources>
<Style TargetType="lvc:AxisSection" x:Key="AxisSectionStyle">
<Setter Property="StrokeThickness" Value="1"/>
......@@ -102,9 +102,12 @@
</lvc:Axis.Resources>
<lvc:Axis.Sections>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding Target}"
Stroke="{StaticResource AreaColors2}"
Value="{Binding YMax}"
Stroke="LightGray"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding YMin}"
Stroke="LightGray"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding ToleranceYMax}"
......@@ -122,35 +125,31 @@
Value="{Binding Tolerance2YMin}"
Stroke="{StaticResource AreaColors0}"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding Target}"
Stroke="{StaticResource AreaColors2}"
/>
</lvc:Axis.Sections>
<lvc:Axis.Separator>
<lvc:Separator Stroke="LightGray"/>
<lvc:Separator Stroke="Transparent" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
<Button Style="{StaticResource ButtonStyle_icon}"
Click="Button_info_click" Margin="5,5,5,-20" Opacity="0" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Fill="White" Stretch="Fill" Margin="2"/>
<iconPacks:PackIconMaterial Kind="Information" />
<Button Style="{StaticResource ButtonStyle_icon}" Margin="48,0,0,-20"
Click="Button_info_click" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}" >
<TextBlock Padding="10,5" VerticalAlignment="Top"
FontSize="24" Foreground="White" Background="{StaticResource Color_theme_activity}"
Text="扫描图" />
</Grid>
</Button>
<Grid Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2"
VerticalAlignment="Top" HorizontalAlignment="Left" >
<Viewbox MaxWidth="300" MaxHeight="62">
<Viewbox MaxHeight="50">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle_icon}" VerticalAlignment="Top" Margin="0"
Click="Button_info_click" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}" >
<TextBlock Padding="10,5" VerticalAlignment="Top"
FontSize="24" Foreground="White" Background="{StaticResource Color_theme_activity}"
Text="扫描图" />
</Grid>
</Button>
<StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="5">
......@@ -189,10 +188,6 @@
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Style="{StaticResource TitleStyle}" Text="混合:" />
<TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Mix}"/>
</StackPanel>
</StackPanel>
</StackPanel>
......@@ -203,7 +198,7 @@
<Grid Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1"
Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right"
Background="{StaticResource SemiTransparentGreyBrush}" >
<Viewbox MaxWidth="210" MaxHeight="70">
<Viewbox MaxHeight="50">
<StackPanel Margin="5">
<StackPanel.Resources>
<Style TargetType="Viewbox">
......
......@@ -112,6 +112,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
YFormatter = (y) =>
{
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = "";
if (graphparam.IsPercent)
{
double target = Target;//Average
......@@ -119,30 +120,31 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
if (y == target)
{
return y.ToString("F1");
text= y.ToString("F1");
}
else
{
double percent = 100.0 * (y - target) / target;
if (percent > 0)
{
return $"+{Math.Abs(percent):F1}%";
text= $"+{Math.Abs(percent):F1}%";
}
else
{
return $"-{Math.Abs(percent):F1}%";
text= $"-{Math.Abs(percent):F1}%";
}
}
}
else
{
return y.ToString("F1");
text = y.ToString("F1");
}
}
else
{
return y.ToString("F1");
text = y.ToString("F1");
}
return $"{text,6}";
};
Mapper = Mappers.Xy<double>()
......
......@@ -94,10 +94,8 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
#region 与数据无关界面参数
AreaColors = new List<Brush>();
for (int i = 0; i < 5; i++)
AreaColors.Add(FLY.ControlLibrary.Themes.Styles.AreaColors[i]);
AreaColors.AddRange(FLY.ControlLibrary.Themes.Styles.AreaColors);
YFormatter = (y) =>
{
if (IsPercent)
......
......@@ -88,7 +88,7 @@
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" >
<lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Transparent" FontFamily="Courier New">
<lvc:Axis.Resources>
<Style TargetType="lvc:AxisSection" x:Key="AxisSectionStyle">
<Setter Property="StrokeThickness" Value="1"/>
......@@ -101,10 +101,14 @@
</lvc:Axis.Resources>
<lvc:Axis.Sections>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding Target}"
Stroke="{StaticResource AreaColors2}"
Value="{Binding YMax}"
Stroke="LightGray"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding YMin}"
Stroke="LightGray"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding ToleranceYMax}"
Stroke="{StaticResource AreaColors1}"
......@@ -121,34 +125,31 @@
Value="{Binding Tolerance2YMin}"
Stroke="{StaticResource AreaColors0}"
/>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding Target}"
Stroke="{StaticResource AreaColors2}"
/>
</lvc:Axis.Sections>
<lvc:Axis.Separator>
<lvc:Separator Stroke="LightGray"/>
<lvc:Separator Stroke="Transparent"/>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
<Button Style="{StaticResource ButtonStyle_icon}"
Click="Button_info_click" Margin="5,5,5,-20" Opacity="0" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Fill="White" Stretch="Fill" Margin="2"/>
<iconPacks:PackIconMaterial Kind="Information" />
<Button Style="{StaticResource ButtonStyle_icon}" Margin="48,0,0,-20"
Click="Button_info_click" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}" >
<TextBlock Padding="10,5" VerticalAlignment="Top"
FontSize="24" Foreground="White" Background="{StaticResource Color_theme_activity}"
Text="对比图" />
</Grid>
</Button>
<Grid Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2"
VerticalAlignment="Top" HorizontalAlignment="Left" >
<Viewbox MaxWidth="300" MaxHeight="62">
<Viewbox MaxHeight="50">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle_icon}" VerticalAlignment="Top" Margin="0"
Click="Button_info_click" >
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<TextBlock Padding="10,5" VerticalAlignment="Top"
FontSize="24" Foreground="White" Background="{StaticResource Color_theme_activity}"
Text="对比图" />
</Grid>
</Button>
<StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="5">
......@@ -187,10 +188,6 @@
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Style="{StaticResource TitleStyle}" Text="混合:" />
<TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Mix}"/>
</StackPanel>
</StackPanel>
</StackPanel>
......@@ -201,7 +198,7 @@
<Grid Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1"
Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right"
Background="{StaticResource SemiTransparentGreyBrush}" >
<Viewbox MaxWidth="210" MaxHeight="70">
<Viewbox MaxHeight="50">
<StackPanel Margin="5">
<StackPanel.Resources>
<Style TargetType="Viewbox">
......
......@@ -33,7 +33,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
/// </summary>
public double TolerancePercent { get; private set; } = 0.05;
/// <summary>
/// 原始平均值
/// 原始目标值,从产品获取
/// </summary>
public double OrgTarget { get; private set; } = 100;
......@@ -124,36 +124,40 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
YFormatter = (y) =>
{
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = "";
if (graphparam.IsPercent)
{
if (Target > 0)
double target = Target;//Average
if (target > 0)
{
if (y == Target)
if (y == target)
{
return y.ToString("F1");
text = y.ToString("F1");
}
else
{
double percent = 100.0 * (y - Target) / Target;
double percent = 100.0 * (y - target) / target;
if (percent > 0)
{
return $"+{Math.Abs(percent):F1}%";
text = $"+{Math.Abs(percent):F1}%";
}
else
{
return $"-{Math.Abs(percent):F1}%";
text = $"-{Math.Abs(percent):F1}%";
}
}
}
else
{
return y.ToString("F1");
text = y.ToString("F1");
}
}
else
{
return y.ToString("F1");
text = y.ToString("F1");
}
return $"{text,6}";
};
var Mapper = Mappers.Xy<double>()
......@@ -424,7 +428,19 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
//tempdata 不在显示范围内, 调整 target 为 Average2
if (Math.Abs(Average2 - target) > tolerance * graphparam.YRangePercent)
{
target = Average2;
target = Target;
if (!double.IsNaN(target))
{
//tempdata 也不在 当前视图 内
if (Math.Abs(Average2 - target) > tolerance * graphparam.YRangePercent)
{
target = Average2;
}
}
else {
//视图还没初始化。。。
target = Average2;
}
}
}
......
<UserControl x:Class="FLY.Thick.Blowing.UI.Fix.Client.UiModule.PolarChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="315" d:DesignWidth="430" Loaded="UserControl_Loaded">
<Viewbox>
<Canvas x:Name="LayoutRoot" Width="600" Height="600" />
</Viewbox>
</UserControl>

using FLY.Thick.Base.UI;
using FLY.Thick.Blowing.IService;
using System.Windows.Controls;
using Unity;
......@@ -38,6 +39,17 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
this.DataContext = viewModel;
}
private void Button_info_click(object sender, System.Windows.RoutedEventArgs e)
{
if (!WdPassword.Authorize("GraphConfig"))
return;
WdScanGraphCircularConfig window = new WdScanGraphCircularConfig();
window.Init(graphparam);
window.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
window.ShowDialog();
}
}
......
......@@ -20,18 +20,10 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
/// </summary>
public int Number { get; set; } = 0;
/// <summary>
/// 模头手动调节的螺丝对应的分区号
/// </summary>
public int BoltNoWithManual1st { get; set; } = 1;
/// <summary>
/// 模头手动调节的螺丝个数
/// Y轴显示范围是公差的N倍
/// </summary>
public int ManualCnt { get; set; } = 8;
public double YRangePercent { get; set; } = 3;
/// <summary>
/// 探头在右边
......
......@@ -2,6 +2,8 @@
using FLY.Thick.Blowing.Common;
using FLY.Thick.Blowing.IService;
using FLY.Thick.Blowing.Server.Model;
using FObjBase;
using Misc;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
......@@ -16,23 +18,60 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
public class ScanGraphCircularVm : INotifyPropertyChanged
{
const int MARKNO_TEXTUP = 1;
public event PropertyChangedEventHandler PropertyChanged;
public int Target { get; set; } = 10000;
public int Alarm { get; set; } = 300;
#region 界面统计值
/// <summary>
/// 平均值
/// </summary>
public double Average { get; private set; } = double.NaN;
public double Sigma2 { get; private set; } = double.NaN;
/// <summary>
/// 最大值
/// </summary>
public double Max { get; private set; } = double.NaN;
/// <summary>
/// 最小值
/// </summary>
public double Min { get; private set; } = double.NaN;
public string Sigma2Text { get; private set; }
public string MaxText { get; private set; }
public string MinText { get; private set; }
/// <summary>
/// 混合数
/// </summary>
public int Mix { get; private set; } = 2;
public string Info => $"{Time:MM-dd HH:mm:ss} ID:{Id} 混合数:{Mix}";
/// <summary>
/// 测量时间
/// </summary>
public DateTime Time { get; private set; }
/// <summary>
/// 旋转方向 是反向
/// </summary>
public bool IsBackw { get; private set; }
/// <summary>
/// 旋转1周的时间
/// </summary>
public TimeSpan RPeriod { get; private set; }
/// <summary>
/// 数据库中的序号
/// </summary>
public long Id { get; private set; } = -1;
public int OrgBoltNo { get; private set; } = 1;
public int Mix { get; private set; } = 1;
public long Id { get; private set; } = 1231221;
public int OrgBoltNo { get; private set; } = -100;
#endregion
ScanGraphCircularParam graphparam;
IBulkDbService bulkDb;
......@@ -41,7 +80,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
IBlowingService blowingService;
BlowingFixProfileParam profileParam;
ObservableCollection<int> Values = new ObservableCollection<int>();
ObservableCollection<double> Values { get; } = new ObservableCollection<double>();
public ScanGraphCircularVm()
{
......@@ -54,7 +93,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
IBulkDbService bulkDb,
IBlowingService blowingService,
BlowingFixProfileParam profileParam,
GraphScanCircular graph
PolarChart graph
)
{
this.graphparam = graphparam;
......@@ -62,42 +101,15 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
this.blowingService = blowingService;
this.profileParam = profileParam;
Misc.BindingOperations.SetBinding(profileParam,
new string[] {
nameof(profileParam.Target),
nameof(profileParam.TolerancePercent) },
() => {
this.Target = (int)(profileParam.Target * 100);
this.Alarm = (int)(profileParam.TolerancePercent * this.Target);
});
graph.Title = "环型图";
graph.SetBinding(PolarChart.TolerancePercentProperty, new Binding(nameof(profileParam.TolerancePercent)) { Source = profileParam });
graph.SetBinding(GraphScanCircular.BoltNoWithManual1stProperty, new Binding(nameof(ScanGraphCircularParam.BoltNoWithManual1st)) { Source = graphparam });
graph.SetBinding(GraphScanCircular.ManualCntProperty, new Binding(nameof(ScanGraphCircularParam.ManualCnt)) { Source = graphparam });
graph.SetBinding(GraphScanCircular.MPIsRightProperty, new Binding(nameof(ScanGraphCircularParam.MPIsRight)) { Source = graphparam });
graph.SetBinding(PolarChart.MPIsRightProperty, new Binding(nameof(graphparam.MPIsRight)) { Source = graphparam });
graph.SetBinding(PolarChart.YRangePercentProperty, new Binding(nameof(graphparam.YRangePercent)) { Source = graphparam });
//TODO
graph.SetBinding(GraphScanCircular.BoltCntProperty, new Binding(nameof(blowingService.NBolts)) { Source = blowingService });
graph.SetBinding(GraphScanCircular.OrgBoltNoProperty, new Binding(nameof(blowingService.OrgBoltNo)) { Source = blowingService });
graph.SetBinding(GraphScanCircular.Title2Property, new Binding(nameof(Info)) { Source = this });
graph.SetBinding(GraphScanCircular.TargetProperty, new Binding(nameof(Target)) { Source = this });
graph.SetBinding(GraphScanCircular.AlarmProperty, new Binding(nameof(Alarm)) { Source = this });
graph.DataSource = Values;
graph.ShowSettingDialogEvent += new EventHandler(delegate (object sender, EventArgs e)
{
ScanGraphCircularConfig window = new ScanGraphCircularConfig();
window.Init(this.graphparam);
window.Owner = FLY.ControlLibrary.COMMON.GetWindow(graph);
window.ShowDialog();
});
graph.Values = Values;
Misc.BindingOperations.SetBinding(graphparam, nameof(graphparam.Mix), this, nameof(Mix));
......@@ -106,6 +118,16 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
bulkDb.PropertyChanged += BulkDb_PropertyChanged;
graphparam.PropertyChanged += Graphparam_PropertyChanged;
this.PropertyChanged += ScanGraphCircularVm_PropertyChanged;
}
static string[] propertyname_updateMaxMinText = new string[] {
nameof(Average),nameof(Max),nameof(Min),nameof(Sigma2)};
private void ScanGraphCircularVm_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (propertyname_updateMaxMinText.Contains(e.PropertyName))
UpdateMaxMinText();
}
private void Graphparam_PropertyChanged(object sender, PropertyChangedEventArgs e)
......@@ -133,10 +155,68 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
}
}
}
void UpdateId()
{
Update4IdChanged();
}
void UpdateMaxMinText()
{
PollModule.Current.Poll_JustOnce(() =>
{
if (Average > 0)
{
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
Sigma2Text = $"{(Sigma2 / Average) * 100.0:F1}%";
}
else
{
MaxText = $"{Max:F1}";
MinText = $"{Min:F1}";
Sigma2Text = $"{Sigma2:F1}";
}
}, this, MARKNO_TEXTUP);
}
void UpdateAverage()
{
if (this.scanData == null)
{
Time = DateTime.MinValue;
Id = -1;
OrgBoltNo = -100;
return;
}
else
{
Time = this.scanData.Time;
Id = this.scanData.ID;
OrgBoltNo = this.scanData.OrgBoltNo;
IsBackw = this.scanData.IsBackw;
RPeriod = this.scanData.RPeriod;
}
double[] values = this.scanData.Thicks;
var list = from v in values where !double.IsNaN(v) select v;
if (list.Count() > 0)
{
Average = list.Average();
Max = list.Max();
Min = list.Min();
Sigma2 = list.Sigma() * 2;
}
else
{
Average = double.NaN;
Max = double.NaN;
Min = double.NaN;
Sigma2 = double.NaN;
}
}
void Update4IdChanged()
{
if (graphparam.Number > 0
......@@ -165,24 +245,17 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
}
void Update4IdChanged2()
{
//清除全部数据
Values.Clear();
if (this.scanData == null)
{
Time = DateTime.MinValue;
Id = -1;
return;
}
else
//更新平均值
UpdateAverage();
if (scanData != null && scanData.Thicks != null)
{
Time = this.scanData.Time;
Id = this.scanData.ID;
OrgBoltNo = this.scanData.OrgBoltNo;
foreach(var value in scanData.Thicks)
Values.Add(value);
}
double[] values = this.scanData.Thicks;
Values.Clear();
for (int i=0;i< values.Count();i++)
Values.Add((int)(values[i]*100));
}
......
using FLY.ControlLibrary;
using FLY.Thick.Blowing.Common;
using FLY.Thick.Blowing.IService;
using FLY.Thick.Blowing.Server.Model;
using Misc;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
public class ScanGraphCircularVmUt : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 界面统计值
/// <summary>
/// 平均值
/// </summary>
public double Average { get; private set; } = double.NaN;
public double Sigma2 { get; private set; } = double.NaN;
/// <summary>
/// 最大值
/// </summary>
public double Max { get; private set; } = double.NaN;
/// <summary>
/// 最小值
/// </summary>
public double Min { get; private set; } = double.NaN;
public string Sigma2Text { get; private set; }
public string MaxText { get; private set; }
public string MinText { get; private set; }
/// <summary>
/// 混合数
/// </summary>
public int Mix { get; private set; } = 2;
/// <summary>
/// 测量时间
/// </summary>
public DateTime Time { get; private set; }
/// <summary>
/// 旋转方向 是反向
/// </summary>
public bool IsBackw { get; private set; }
/// <summary>
/// 旋转1周的时间
/// </summary>
public TimeSpan RPeriod { get; private set; }
/// <summary>
/// 数据库中的序号
/// </summary>
public long Id { get; private set; } = 1231221;
public int OrgBoltNo { get; private set; } = -100;
#endregion
ObservableCollection<double> Values { get; }= new ObservableCollection<double>();
public ScanGraphCircularVmUt()
{
#region 数据
double target = 100;
double tolerancePercent = 0.02;
double yrangepercent = 3;
int nbolts = 80;
double[] datas = new double[nbolts];
Random random = new Random();
for (int i = 0; i < nbolts; i++)
{
datas[i] = (Math.Sin(i * Math.PI / nbolts) * 3) * (target*tolerancePercent) + target + (random.NextDouble() - 0.5) * 1 - 6;
}
#endregion
#region 界面数据
Mix = 2;
Time = DateTime.Now;
Id = 312312;
OrgBoltNo = 31;
Values.Clear();
foreach(var data in datas)
Values.Add(data);
Average = datas.AverageNoNull();
IsBackw = false;
RPeriod = TimeSpan.FromSeconds(60 * 6.5);
double Max = datas.Max();
double Min = datas.Min();
double Sigma2 = datas.Sigma() * 2;
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
Sigma2Text = $"{(Sigma2 / Average) * 100.0:F1}%";
#endregion
}
}
}
<flyctrllib:WindowBigClose x:Class="FLY.Thick.Blowing.UI.Fix.Client.UiModule.ScanGraphCircularConfig"
<flyctrllib:WindowBigClose x:Class="FLY.Thick.Blowing.UI.Fix.Client.UiModule.WdScanGraphCircularConfig"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
......@@ -7,7 +7,7 @@
xmlns:uiModule="clr-namespace:FLY.Thick.Blowing.UI.Fix.Client.UiModule" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
Title="Window_graphscan" SizeToContent="WidthAndHeight" d:DataContext="{d:DesignInstance uiModule:ScanGraphCircularParam}" >
SizeToContent="WidthAndHeight" d:DataContext="{d:DesignInstance uiModule:ScanGraphCircularParam}" >
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......@@ -18,21 +18,21 @@
</Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" Background="WhiteSmoke" >
<StackPanel Orientation="Vertical" Margin="5,20">
<StackPanel Margin="5,20">
<StackPanel Orientation="Vertical">
<StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="混合数" />
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="混合数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Mix}" />
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Mix}" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="记录点" />
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="记录点" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Number}" />
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Number}" />
</StackPanel>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_largeIcon}" Click="btnPreClick">
......@@ -51,20 +51,15 @@
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="螺栓数" />
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="Y轴倍数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding ManualCnt}" />
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding YRangePercent}" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="第1螺栓对应分区号" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BoltNoWithManual1st}" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="探头位于右边" />
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="探头位于右边" />
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" HorizontalAlignment="Left" IsChecked="{Binding MPIsRight}" />
</StackPanel>
</StackPanel>
......
......@@ -5,10 +5,10 @@ namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
/// <summary>
/// Window_GraphScanCircular.xaml 的交互逻辑
/// </summary>
public partial class ScanGraphCircularConfig : FLY.ControlLibrary.WindowBigClose
public partial class WdScanGraphCircularConfig : FLY.ControlLibrary.WindowBigClose
{
ScanGraphCircularParam graphparam_scan;
public ScanGraphCircularConfig()
public WdScanGraphCircularConfig()
{
InitializeComponent();
}
......
using FLY.Thick.Base.UI;
using FLY.Thick.Blowing.IService;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using Unity;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
/// <summary>
/// TrendGraph2.xaml 的交互逻辑
/// </summary>
public partial class TrendGraph2 : System.Windows.Controls.UserControl
{
TrendGraphVm2 viewModel;
TrendGraphItemParam2 graphparam;
public TrendGraph2()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(int id,
IBulkDbService bulkDb,
IBlowingFixProfileService profileService)
{
graphparam = TrendGraphParam2s.Current.Items.Find(p => p.ID == id);
if (graphparam == null)
{
graphparam = new TrendGraphItemParam2() { ID = id };
TrendGraphParam2s.Current.Items.Add(graphparam);
TrendGraphParam2s.Current.Save();
}
viewModel = new TrendGraphVm2();
viewModel.Init(graphparam, bulkDb, profileService.Param);
this.DataContext = viewModel;
}
private void Button_info_click(object sender, RoutedEventArgs e)
{
if (!WdPassword.Authorize("GraphConfig"))
return;
TrendGraphConfig2 window = new TrendGraphConfig2();
window.Init(graphparam,viewModel);
window.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
window.ShowDialog();
}
}
}
<flyctrllib:WindowBigClose x:Class="FLY.Thick.Blowing.UI.Fix.Client.UiModule.TrendGraphConfig2"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
Background="WhiteSmoke"
SizeToContent="WidthAndHeight"
>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Width="400">
<Grid x:Name="grid_trend"/>
<StackPanel Margin="5,20">
<StackPanel Orientation="Horizontal" DataContext="{Binding DataContext,ElementName=grid_trend}">
<Button Style="{StaticResource ButtonStyle_RectangleIcon}" Click="btnPreClick">
<Grid>
<iconPacks:PackIconMaterial Kind="ArrowLeft" />
</Grid>
</Button>
<Button Click="btnNextClick">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_RectangleIcon}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsNewest}" Value="True">
<Setter Property="Foreground" Value="Gray"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Grid>
<iconPacks:PackIconMaterial Kind="ArrowRight" />
</Grid>
</Button>
<Button Click="btnNewestClick">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_RectangleIcon}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsNewest}" Value="True">
<Setter Property="Foreground" Value="Gray"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Grid>
<iconPacks:PackIconMaterial Kind="ArrowCollapseRight" />
<!--当不是最新, 弹出 自动按[最新] 倒计时-->
<Grid Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,-5,-5" >
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding IsNewest}" Value="True">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Ellipse Fill="#FFFF3535" />
<TextBlock Text="{Binding AutoKeepNewestTimeRemaining}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</Grid>
</Grid>
</Button>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="更新中" Visibility="{Binding IsLoading,Converter={StaticResource visbilityconv}}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="混合数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Mix}" />
</StackPanel>
</StackPanel>
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="Y轴倍数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding YRangePercent}" />
</StackPanel>
</StackPanel>
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="间隔" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Interval}" />
</StackPanel>
</StackPanel>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_apply}" Click="btnOkClick"/>
</StackPanel>
</Grid>
</flyctrllib:WindowBigClose >
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Shapes;
using System.ComponentModel;
using FLY.Thick.Base.UI.Converter;
using FLY.ControlLibrary;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
/// <summary>
/// Window_graphtrend.xaml 的交互逻辑
/// </summary>
public partial class TrendGraphConfig2 : FLY.ControlLibrary.WindowBigClose
{
TrendGraphItemParam2 graphparam;
TrendGraphVm2 trendGraphVm2;
public TrendGraphConfig2()
{
InitializeComponent();
}
public void Init(TrendGraphItemParam2 graphparam, TrendGraphVm2 trendGraphVm2)
{
this.graphparam = graphparam;
this.trendGraphVm2 = trendGraphVm2;
this.DataContext = graphparam;
this.grid_trend.DataContext = trendGraphVm2;
}
private void btnPreClick(object sender, RoutedEventArgs e)
{
trendGraphVm2.PreView();
}
private void btnNextClick(object sender, RoutedEventArgs e)
{
trendGraphVm2.NextView();
}
private void btnOkClick(object sender, RoutedEventArgs e)
{
TrendGraphParam2s.Current.Save();
}
private void btnNewestClick(object sender, RoutedEventArgs e)
{
trendGraphVm2.ToNewest();
}
}
}
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
/// <summary>
/// 纵向图的参数
/// </summary>
public class TrendGraphItemParam2 : UIModuleParam
{
/// <summary>
/// 间隔, 只显示 ID % Interval == 0 的数
/// </summary>
public int Interval { get; set; } = 1;
/// <summary>
/// Y轴比例
/// </summary>
public double YRangePercent { get; set; } = 3;
/// <summary>
/// 混合图
/// </summary>
public int Mix { get; set; } = 1;
}
}
using MultiLayout;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
/// <summary>
/// 全部扫描图的参数
/// </summary>
public class TrendGraphParam2s : UIModuleParams<TrendGraphItemParam2>
{
public TrendGraphParam2s()
{
string path = System.IO.Path.Combine(FlyLayout.BasePath, "trendgraph2.json");
FilePath = path;
}
static TrendGraphParam2s current = null;
public static TrendGraphParam2s Current
{
get
{
if (current == null)
{
current = new TrendGraphParam2s();
current.Load();
}
return current;
}
}
}
}
using FLY.Thick.Blowing.IService;
using LiveCharts;
using LiveCharts.Configurations;
using Misc;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
public class TrendGraphVm2Ut : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 图表控制
public double YMax { get; set; } = double.NaN;
public double YMin { get; set; } = double.NaN;
public double ToleranceYMax { get; set; } = double.NaN;
public double ToleranceYMin { get; set; } = double.NaN;
public double Tolerance2YMax { get; set; } = double.NaN;
public double Tolerance2YMin { get; set; } = double.NaN;
public double XMax { get; set; } = double.NaN;
public Func<double, string> YFormatter { get; set; }
public Func<double, string> XFormatter { get; set; }
#endregion
#region 界面统计值
/// <summary>
/// 平均值
/// </summary>
public double Average { get; private set; } = double.NaN;
/// <summary>
/// 最大值
/// </summary>
public double Max { get; private set; } = double.NaN;
/// <summary>
/// 最小值
/// </summary>
public double Min { get; private set; } = double.NaN;
/// <summary>
/// 混合数
/// </summary>
public int Mix { get; private set; } = 2;
/// <summary>
/// Values.First().Time
/// </summary>
public DateTime BeginTime { get; private set; }
/// <summary>
/// Values.Last().Time
/// </summary>
public DateTime EndTime { get; private set; }
/// <summary>
/// Values.Last().Id
/// </summary>
public long Id { get; private set; } = 1231221;
#endregion
#region 查询模式
/// <summary>
/// 只要 Number被改变,且不为0, AutoKeepNewestTimeRemaining就会被设为10s.
/// 当 AutoKeepNewestTimeRemaining = 0, Number就会被设置为0
/// </summary>
public int AutoKeepNewestTimeRemaining { get; private set; }
/// <summary>
/// 当前就是最新的视图
/// </summary>
public bool IsNewest { get; private set; }
/// <summary>
/// 视图加载中
/// </summary>
public bool IsLoading { get; private set; }
#endregion
List<Brush> AreaColors;
public ChartValues<TrendValue> Values { get; } = new ChartValues<TrendValue>();
public object MapperPositive { get; private set; }
public object MapperNegative { get; private set; }
public object MapperValue { get; private set; }
public TrendGraphVm2Ut()
{
#region 与数据无关界面参数
AreaColors = new List<Brush>();
AreaColors.AddRange(FLY.ControlLibrary.Themes.Styles.AreaColors);
YFormatter = (y) =>
{
double percent = y * 100;
string text = "";
if (percent == 0d)
{
text = "0.0%";
}
else if (percent > 0)
{
text =$"+{Math.Abs(percent):F1}%";
}
else
{
text =$"-{Math.Abs(percent):F1}%";
}
return $"{text,6}";
};
XFormatter = (x) => {
int index = (int)x;
if (index < Values.Count() && index >= 0)
return Values[index].Time.ToString("HH:mm");
else
return "";
};
MapperPositive = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => value.Sigma / value.Value)
.Fill((value) =>
{
double percent = value.Sigma / value.Value;
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
{
return AreaColors[0];
}
else if ((percent > ToleranceYMax) || (percent < -ToleranceYMax))
{
return AreaColors[1];
}
else
{
return AreaColors[2];
}
});
MapperNegative = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => -value.Sigma / value.Value)
.Fill((value) =>
{
double percent = value.Sigma / value.Value;
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
{
return AreaColors[0];
}
else if ((percent > ToleranceYMax) || (percent < -ToleranceYMax))
{
return AreaColors[1];
}
else
{
return AreaColors[2];
}
});
MapperValue = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => value.Value);
#endregion
Values.Clear();
#region 数据
double target = 150;
double tolerancePercent = 0.05;
double yRangePercent = 3;
int len = 200;
DateTime startTime = DateTime.Now;
TimeSpan tsInterval = TimeSpan.FromSeconds(30);
DateTime time = startTime;
int id = 312456;
Random random = new Random();
for (int i = 0; i < len; i++, time+=tsInterval)
{
TrendValue tv = new TrendValue();
tv.Time = time;
tv.Value = target + (random.NextDouble() - 0.5) * target * tolerancePercent * 0.5;
tv.Sigma = (Math.Sin(i * Math.PI / len) * 3) * target * tolerancePercent * random.NextDouble();
Values.Add(tv);
}
#endregion
#region 界面数据
XMax = len;
Mix = 2;
BeginTime = Values.First().Time;
EndTime = Values.Last().Time;
Id = id;
var sigma2Percent = Values.Select(v => 2 * v.Sigma / v.Value);
Average = sigma2Percent.AverageNoNull();
Max = sigma2Percent.Max();
Min = sigma2Percent.Min();
ToleranceYMax = tolerancePercent;
ToleranceYMin = -ToleranceYMax;
Tolerance2YMax = ToleranceYMax * 2;
Tolerance2YMin = -Tolerance2YMax;
YMax = ToleranceYMax * yRangePercent;
YMin = -YMax;
#endregion
}
}
}
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Blowing.UI.Fix.Client.UiModule
{
/// <summary>
/// 扫描图控件模块
/// </summary>
public class UiModule2_TrendGraph2 : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "测厚.纵向图2";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => false;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
return container.Resolve<TrendGraph2>(new Unity.Resolution.ParameterOverride("id", id));
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
TrendGraphParams.Current.MatchParam(IDs);
}
}
}
......@@ -141,7 +141,7 @@ namespace FLY.Thick.Blowing.IService
/// <summary>
/// 最后1幅数据ID, 当-1, 从数据库最后获取
/// </summary>
public int Id;
public long Id;
/// <summary>
/// 长度
......@@ -149,15 +149,29 @@ namespace FLY.Thick.Blowing.IService
public int Count;
/// <summary>
/// 混合数
/// 间隔, 只获取 Id % Interval == 0 的数据
/// </summary>
public int Interval;
/// <summary>
/// 混合数,经过间隔后的数据再混合
/// </summary>
public int Mix;
/// <summary>
/// 按时间查找数据
/// </summary>
public bool IsSearchByTime;
/// <summary>
/// 按时间查找数据, 获取的数据对应的时间都比Time小
/// </summary>
public DateTime Time;
}
public class Pack_GetTrendReponse
{
public Pack_GetTrendRequest Request;
public List<TrendValue> Values;
public Db_Profile profile;
public long ScanDataId;
}
......
......@@ -273,9 +273,9 @@ namespace FLY.Thick.Blowing.Server.Model
/// 获取纵向趋势图
/// </summary>
/// <param name="request"></param>
/// <param name="AsyncDelegate"></param>
/// <param name="AsyncContext"></param>
public async void GetTrend(Pack_GetTrendRequest request, AsyncCBHandler AsyncDelegate, object AsyncContext)
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
public async void GetTrend(Pack_GetTrendRequest request, AsyncCBHandler asyncDelegate, object asyncContext)
{
//TODO 需要异步
Pack_GetTrendReponse reponse = new Pack_GetTrendReponse();
......@@ -291,43 +291,52 @@ namespace FLY.Thick.Blowing.Server.Model
else if (request.Mix < 1)
request.Mix = 1;
if (request.Interval < 1)//避免 /0
request.Interval = 1;
await Task.Factory.StartNew(() =>
{
List<Db_ScanData> db_scandatas;
if (request.Id <= 0)
db_scandatas = dbModel.TbScanData.Find(
$"ORDER BY {nameof(Db_ScanData.ID)} DESC" +
$" LIMIT {request.Mix + request.Count - 1} OFFSET {-request.Id}");
else
db_scandatas = dbModel.TbScanData.Find(
$"WHERE {nameof(Db_ScanData.ID)} <= {request.Id}" +
$" ORDER BY {nameof(Db_ScanData.ID)} DESC" +
$" LIMIT {request.Mix + request.Count - 1}");
await Task.Factory.StartNew(() =>
{
List<Db_ScanData> db_scandatas=null;
if (!request.IsSearchByTime)
{
if (request.Id <= 0)
db_scandatas = dbModel.TbScanData.Find(
$"WHERE {nameof(Db_ScanData.ID)} % {request.Interval} = 0" +
$" ORDER BY {nameof(Db_ScanData.ID)} DESC" +
$" LIMIT {request.Mix + request.Count - 1} OFFSET {-request.Id}");
else
db_scandatas = dbModel.TbScanData.Find(
$"WHERE ({nameof(Db_ScanData.ID)} <= {request.Id})" +
$" AND ({nameof(Db_ScanData.ID)} % {request.Interval} = 0)" +
$" ORDER BY {nameof(Db_ScanData.ID)} DESC" +
$" LIMIT {request.Mix + request.Count - 1}");
}
else
{
db_scandatas = dbModel.TbScanData.Find(
$"WHERE ({nameof(Db_ScanData.Time)} <= {request.Time.ToStringOfSQLiteFieldType()})" +
$" AND ({nameof(Db_ScanData.ID)} % {request.Interval} = 0)" +
$" ORDER BY {nameof(Db_ScanData.ID)} DESC" +
$" LIMIT {request.Mix + request.Count - 1}");
}
if (db_scandatas.Count() == 0)
return;
if (db_scandatas.Count() == 0)
return;
//从尾向前排的!!!!
var lc_scanDatas = Lc_AutoMapperProfile.Mapper.Map<List<Db_ScanData>, List<Lc_ScanData>>(db_scandatas);
reponse.Values = ToTrend(lc_scanDatas, request.Count, request.Mix);
reponse.Values = ToTrend(lc_scanDatas, request.Count, request.Mix);
var lc_scanData = lc_scanDatas.First();
reponse.ScanDataId = lc_scanData.ID;
var lc_scanData = lc_scanDatas.First();
reponse.ScanDataId = lc_scanData.ID;
//找profile
var db_profiles = dbModel.TbProfile.Find(
$"WHERE {nameof(Db_Profile.StartTime)}<={lc_scanData.EndTime.ToStringOfSQLiteFieldType()}" +
$" AND {nameof(Db_Profile.EndTime)}>={lc_scanData.EndTime.ToStringOfSQLiteFieldType()}" +
$" ORDER BY {nameof(Db_Profile.ID)} DESC");
if (db_profiles.Count() > 0)
{
reponse.profile = db_profiles.First();
}
});
AsyncDelegate(AsyncContext, reponse);
});
asyncDelegate(asyncContext, reponse);
}
double[] GetMixScanData(List<Lc_ScanData> lc_scanDatas, int offset, int mix)
......
......@@ -19,6 +19,7 @@
<register type="IUiModule2" mapTo="UiModule2_ScanGraph2" name="blowing_sg2" />
<register type="IUiModule2" mapTo="UiModule2_ScanGraphCircular" name="blowing_sgc" />
<register type="IUiModule2" mapTo="UiModule2_TrendGraph" name="blowing_tg" />
<register type="IUiModule2" mapTo="UiModule2_TrendGraph2" name="blowing_tg2" />
</container>
</unity>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment