Commit 8b24c0ae authored by 潘栩锋's avatar 潘栩锋 🚴

优化 整理机架修正界面。

parent bc6e1a6e
......@@ -28,6 +28,16 @@
<SolidColorBrush>#3f51b4</SolidColorBrush>
<SolidColorBrush>#ccdb39</SolidColorBrush>
</x:Array>
<x:Array x:Key="Brushes.Random.Dark" Type="SolidColorBrush">
<SolidColorBrush>#104673</SolidColorBrush>
<SolidColorBrush>#731f19</SolidColorBrush>
<SolidColorBrush>#806104</SolidColorBrush>
<SolidColorBrush>#2d3a40</SolidColorBrush>
<SolidColorBrush>#801137</SolidColorBrush>
<SolidColorBrush>#1c401d</SolidColorBrush>
<SolidColorBrush>#1b224d</SolidColorBrush>
<SolidColorBrush>#474d14</SolidColorBrush>
</x:Array>
<!--扫描图,纵向趋势图Y轴 标签颜色-->
<SolidColorBrush x:Key="Brushes.Area0">#f34336</SolidColorBrush>
......
......@@ -11,19 +11,22 @@ namespace FLY.ControlLibrary.Themes
public static class Styles
{
static List<SolidColorBrush> randomColors;
static List<SolidColorBrush> randomColorsDark;
public static List<SolidColorBrush> AreaColors;
static Styles()
{
ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri("pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml") };
ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri("pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors2.xaml") };
AreaColors = new List<SolidColorBrush>();
for (int i = 0; i < 5; i++)
AreaColors.Add(resourceDictionary[$"AreaColors{i}"] as SolidColorBrush);
AreaColors.Add(resourceDictionary[$"Brushes.Area{i}"] as SolidColorBrush);
randomColors = new List<SolidColorBrush>();
randomColors.AddRange(resourceDictionary["RandomColors"] as IEnumerable<SolidColorBrush>);
randomColors.AddRange(resourceDictionary["Brushes.Random"] as IEnumerable<SolidColorBrush>);
randomColorsDark = new List<SolidColorBrush>();
randomColorsDark.AddRange(resourceDictionary["Brushes.Random.Dark"] as IEnumerable<SolidColorBrush>);
//randomColors = new SolidColorBrush[] {
// new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2195f2")),
// new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f34336")),
......@@ -49,16 +52,11 @@ namespace FLY.ControlLibrary.Themes
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public static Brush GetForeground(int index)
public static Brush GetForeground(int index, bool isDark = false)
{
//XamlReader.Loadnew FileStream(@"C:\Users\wppcn\source\repos\网易云\网易云\Resourece\SvgImgResource.xaml", FileMode.Open)) as ResourceDictionary;
//string assembleName = typeof(Styles).Assembly.GetName().Name;//本程序集名
//Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{assembleName}.Themes.Styles.xaml");//获取嵌入资源生成流,XMLPATH为嵌入资源路径,资源名称访问路径为:assemblename.文件夹名.资源名
//XamlReader.Load(stream) as
//IEnumerable<SolidColorBrush> randomColors = App.Current.FindResource("RandomColors") as IEnumerable<SolidColorBrush>;
if(isDark)
return randomColorsDark.ElementAt(index % randomColorsDark.Count());
else
return randomColors.ElementAt(index % randomColors.Count());
}
}
......
......@@ -205,6 +205,7 @@
<DependentUpon>PgPwManager.xaml</DependentUpon>
</Compile>
<Compile Include="PgScanCorr\PgScanCorrVm.cs" />
<Compile Include="PgScanCorr\PgScanCorrVmUt.cs" />
<Compile Include="UiModule\DynAreaFilmWidth.xaml.cs">
<DependentUpon>DynAreaFilmWidth.xaml</DependentUpon>
</Compile>
......
......@@ -4,11 +4,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local ="clr-namespace:FLY.Thick.Base.UI" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
d:DesignHeight="1000" d:DesignWidth="1280"
xmlns:local ="clr-namespace:FLY.Thick.Base.UI"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
d:DesignHeight="1500" d:DesignWidth="1280"
Background="WhiteSmoke"
d:DataContext="{d:DesignInstance local:PgScanCorrVm}"
Title="Page_ScanCorr">
<Page.Resources>
<ResourceDictionary>
......@@ -16,9 +16,10 @@
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/Styles.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:PgScanCorrVmUt x:Key="viewModel" Enable="True"/>
</ResourceDictionary>
</Page.Resources>
<Grid Background="{StaticResource Brushes.Card.Background}" >
<Grid Background="{StaticResource Brushes.Card.Background}" d:DataContext="{StaticResource viewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
......@@ -41,7 +42,14 @@
<StackPanel>
<TextBlock Style="{StaticResource Styles.Card.Title}"
Text="状态"/>
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="使能"/>
<ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding Enable}"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock >
......@@ -59,8 +67,6 @@
</TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
......@@ -93,7 +99,7 @@
</Button.Style>
</Button>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" >
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
组<Run Text="{Binding CurrGroupIndex}"/>
</TextBlock>
<Grid Width="100"/>
......@@ -104,11 +110,7 @@
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1"
Orientation="Horizontal">
<Button Style="{StaticResource Styles.Button.Square2}" Content="导出"
Command="{Binding OutXlsxCmd}"/>
</StackPanel>
</Grid>
</StackPanel>
......@@ -117,6 +119,11 @@
<StackPanel>
<TextBlock Style="{StaticResource Styles.Card.Title}"
Text="扫描图"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="组0"
Command="{Binding SelectedGroup0Cmd}">
......@@ -144,9 +151,25 @@
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Content="删除" Style="{StaticResource Styles.Button.Square2}"
Command="{Binding ClearCmd}"/>
</StackPanel>
</Grid>
<ItemsControl ItemsSource="{Binding SeriesInfos}" Margin="5" x:Name="itemSelect">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="平均:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}"
Text="{Binding AvgAd}"/>
</StackPanel>
<ItemsControl Grid.Column="1" ItemsSource="{Binding SeriesInfos}" Margin="{StaticResource ControlMargin}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
......@@ -160,6 +183,9 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
......@@ -222,7 +248,7 @@
Text="修改"/>
<TabControl
Margin="{StaticResource ControlMargin}"
MinHeight="200"
MinHeight="150"
Controls:TabControlHelper.Underlined="TabPanel"
Controls:TabControlHelper.UnderlinePlacement="Bottom"
Controls:HeaderedControlHelper.HeaderFontSize="18">
......@@ -254,10 +280,7 @@
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1"
Orientation="Horizontal">
<Button Content="应用" Style="{StaticResource Styles.Button.Square2}" Command="{Binding SetCorrDataCmd}"/>
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="关键点方式">
......@@ -283,14 +306,27 @@
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</TabItem>
</TabControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="应用" Style="{StaticResource Styles.Button.Square.Accent2}" Command="{Binding SetCorrDataCmd}"/>
</StackPanel>
<StackPanel Grid.Column="1"
Orientation="Horizontal">
<Button Content="应用" Style="{StaticResource Styles.Button.Square2}" Command="{Binding SetCorrDataCmd}"/>
<Button Style="{StaticResource Styles.Button.Square2}" Content="导出"
Command="{Binding SaveXlsxCmd}"/>
<Button Style="{StaticResource Styles.Button.Square2}" Content="导入"
Command="{Binding LoadXlsxCmd}"/>
</StackPanel>
</Grid>
</TabItem>
</TabControl>
</StackPanel>
</Border>
</StackPanel>
......
......@@ -40,11 +40,12 @@ namespace FLY.Thick.Base.UI
[InjectionMethod]
public void Init(IUnityContainer container,
IScanCorrService scanCorrService,
IInitParamService initParamService
IInitParamService initParamService,
ITDGageService gageService
)
{
viewModel = new PgScanCorrVm();
viewModel.Init(scanCorrService, initParamService);
viewModel.Init(scanCorrService, initParamService, gageService);
this.DataContext = viewModel;
container.BuildUp(mircoGage);
......
......@@ -55,13 +55,18 @@ namespace FLY.Thick.Base.Client
/// </summary>
public int ScanCnt { get; set; }
/// <summary>
/// 平滑
/// </summary>
public int SmoothFactor { get; set; }
/// <summary>
/// 开始机架修正
/// </summary>
/// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param>
public void Start(int groupIndex, int scanCnt) {
Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt });
/// <param name="smoothFactor">平滑</param>
public void Start(int groupIndex, int scanCnt, int smoothFactor) {
Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt, smoothFactor = smoothFactor });
}
/// <summary>
......
......@@ -42,12 +42,18 @@ namespace FLY.Thick.Base.IService
/// </summary>
int ScanCnt { get; }
/// <summary>
/// 平滑
/// </summary>
int SmoothFactor { get; }
/// <summary>
/// 开始机架修正
/// </summary>
/// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param>
void Start(int groupIndex, int scanCnt);
/// <param name="smoothFactor">平滑</param>
void Start(int groupIndex, int scanCnt, int smoothFactor);
/// <summary>
/// 清空组数据
......
......@@ -49,7 +49,7 @@ namespace FLY.Thick.Base.Server
/// </summary>
public int ScanCnt { get; set; } = 2;
public int SmoothFactor { get; set; } = 30;
#endregion
......@@ -68,8 +68,28 @@ namespace FLY.Thick.Base.Server
GMState = Common.CTRL_STATE.CORR;
this.file_path = param_path;
Load();
//参数检测
checkParam();
this.PropertyChanged += GM_ScanCorr_PropertyChanged;
}
private void GM_ScanCorr_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Enable))
{
Save();
}
}
void checkParam() {
if (Groups == null || Groups.Count()!=2 || Groups[0]==null || Groups[1] == null)
{
Groups = new ScanCorrGroup[2] { new ScanCorrGroup(), new ScanCorrGroup() };
}
}
public void Init(FlyAD7 flyad, InitParam initParam)
{
base.Init(flyad);
......@@ -105,7 +125,7 @@ namespace FLY.Thick.Base.Server
public void Start(int groupIndex, int scanCnt)
public void Start(int groupIndex, int scanCnt, int smoothFactor)
{
if (Groups == null || groupIndex < 0 || groupIndex >= Groups.Count())
{
......@@ -113,7 +133,7 @@ namespace FLY.Thick.Base.Server
}
Enable = false;//关闭校正,让flyad7 输出的是原始数据
SmoothFactor = smoothFactor;
ScanCnt = scanCnt;
CurrGroupIndex = groupIndex;
......@@ -146,8 +166,21 @@ namespace FLY.Thick.Base.Server
//顺便把CorrDatas也算出来
//默认以10个数据,平均滤波
group.CorrDatas = new int[2][];
group.CorrDatas[0] = Smooth(group.OrgDatas[0]);
group.CorrDatas[1] = Smooth(group.OrgDatas[1]);
group.CorrDatas[0] = Smooth(group.OrgDatas[0], SmoothFactor);
group.CorrDatas[1] = Smooth(group.OrgDatas[1], SmoothFactor);
int avg0 = Misc.MyMath.Avg(group.CorrDatas[0]);
int avg1 = Misc.MyMath.Avg(group.CorrDatas[1]);
if (!Misc.MyBase.ISVALIDATA(avg0) || !Misc.MyBase.ISVALIDATA(avg1))
{
group.CorrDatas = null;
group.Avg = Misc.MyBase.NULL_VALUE;
//失败
}
else {
group.Avg = (avg0 + avg1) / 2;
}
UpdateTimes[CurrGroupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes));
Progress = 100;
......@@ -165,7 +198,7 @@ namespace FLY.Thick.Base.Server
Save();
}
int[] Smooth(int[] orgDatas, int smoothFactor = 10)
int[] Smooth(int[] orgDatas, int smoothFactor = 20)
{
var filters = new int[orgDatas.Count()];
......@@ -175,7 +208,7 @@ namespace FLY.Thick.Base.Server
int cnt = 0;
for (int j = 0; j < smoothFactor; j++)
{
int index = i - smoothFactor / 2;
int index = i - smoothFactor / 2+j;
if (index < 0)
continue;
else if (index >= orgDatas.Count())
......@@ -216,13 +249,14 @@ namespace FLY.Thick.Base.Server
/// <param name="groupIndex"></param>
public void Clear(int groupIndex) {
if (groupIndex < 0 || groupIndex >= Groups.Count())
{
return;
Groups[groupIndex].Clear();
UpdateTimes[groupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes));
Save();
}
}
}
private void GM_GageInfo_EndEvent(object obj, MiniGridEventArgs e)
{
DataEnd(e.direction, e.posOfGrid, e.grid_start, e.buf);
......@@ -258,7 +292,7 @@ namespace FLY.Thick.Base.Server
orgDatas[i] = org_ad;
}
}
UpdateTimes[orgDatas_index] = DateTime.Now;
UpdateTimes[CurrGroupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes));
}
......@@ -288,6 +322,7 @@ namespace FLY.Thick.Base.Server
var group = Groups[groupIndex];
group.CorrDatas = corrDatas;
group.Avg = avg;
Save();
}
......@@ -534,17 +569,9 @@ namespace FLY.Thick.Base.Server
}
public bool Enable;
/// <summary>
/// 机架总长,脉冲
/// </summary>
public int PosLen = 9123;
/// <summary>
/// 1个grid = N个pos
/// </summary>
public int PosOfGrid = 11;
public int ScanCnt = 2;
public int SmoothFactor = 30;
public ScanCorrGroup[] Groups;
}
......
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