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

优化 整理机架修正界面。

parent bc6e1a6e
...@@ -28,7 +28,17 @@ ...@@ -28,7 +28,17 @@
<SolidColorBrush>#3f51b4</SolidColorBrush> <SolidColorBrush>#3f51b4</SolidColorBrush>
<SolidColorBrush>#ccdb39</SolidColorBrush> <SolidColorBrush>#ccdb39</SolidColorBrush>
</x:Array> </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轴 标签颜色--> <!--扫描图,纵向趋势图Y轴 标签颜色-->
<SolidColorBrush x:Key="Brushes.Area0">#f34336</SolidColorBrush> <SolidColorBrush x:Key="Brushes.Area0">#f34336</SolidColorBrush>
<SolidColorBrush x:Key="Brushes.Area1">#fec007</SolidColorBrush> <SolidColorBrush x:Key="Brushes.Area1">#fec007</SolidColorBrush>
......
...@@ -11,19 +11,22 @@ namespace FLY.ControlLibrary.Themes ...@@ -11,19 +11,22 @@ namespace FLY.ControlLibrary.Themes
public static class Styles public static class Styles
{ {
static List<SolidColorBrush> randomColors; static List<SolidColorBrush> randomColors;
static List<SolidColorBrush> randomColorsDark;
public static List<SolidColorBrush> AreaColors; public static List<SolidColorBrush> AreaColors;
static Styles() 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>(); AreaColors = new List<SolidColorBrush>();
for (int i = 0; i < 5; i++) 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 = 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[] { //randomColors = new SolidColorBrush[] {
// new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2195f2")), // new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2195f2")),
// new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f34336")), // new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f34336")),
...@@ -49,17 +52,12 @@ namespace FLY.ControlLibrary.Themes ...@@ -49,17 +52,12 @@ namespace FLY.ControlLibrary.Themes
/// </summary> /// </summary>
/// <param name="index"></param> /// <param name="index"></param>
/// <returns></returns> /// <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; if(isDark)
//string assembleName = typeof(Styles).Assembly.GetName().Name;//本程序集名 return randomColorsDark.ElementAt(index % randomColorsDark.Count());
//Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{assembleName}.Themes.Styles.xaml");//获取嵌入资源生成流,XMLPATH为嵌入资源路径,资源名称访问路径为:assemblename.文件夹名.资源名 else
//XamlReader.Load(stream) as return randomColors.ElementAt(index % randomColors.Count());
//IEnumerable<SolidColorBrush> randomColors = App.Current.FindResource("RandomColors") as IEnumerable<SolidColorBrush>;
return randomColors.ElementAt(index % randomColors.Count());
} }
} }
} }
...@@ -205,6 +205,7 @@ ...@@ -205,6 +205,7 @@
<DependentUpon>PgPwManager.xaml</DependentUpon> <DependentUpon>PgPwManager.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="PgScanCorr\PgScanCorrVm.cs" /> <Compile Include="PgScanCorr\PgScanCorrVm.cs" />
<Compile Include="PgScanCorr\PgScanCorrVmUt.cs" />
<Compile Include="UiModule\DynAreaFilmWidth.xaml.cs"> <Compile Include="UiModule\DynAreaFilmWidth.xaml.cs">
<DependentUpon>DynAreaFilmWidth.xaml</DependentUpon> <DependentUpon>DynAreaFilmWidth.xaml</DependentUpon>
</Compile> </Compile>
......
...@@ -40,11 +40,12 @@ namespace FLY.Thick.Base.UI ...@@ -40,11 +40,12 @@ namespace FLY.Thick.Base.UI
[InjectionMethod] [InjectionMethod]
public void Init(IUnityContainer container, public void Init(IUnityContainer container,
IScanCorrService scanCorrService, IScanCorrService scanCorrService,
IInitParamService initParamService IInitParamService initParamService,
ITDGageService gageService
) )
{ {
viewModel = new PgScanCorrVm(); viewModel = new PgScanCorrVm();
viewModel.Init(scanCorrService, initParamService); viewModel.Init(scanCorrService, initParamService, gageService);
this.DataContext = viewModel; this.DataContext = viewModel;
container.BuildUp(mircoGage); container.BuildUp(mircoGage);
......
...@@ -55,13 +55,18 @@ namespace FLY.Thick.Base.Client ...@@ -55,13 +55,18 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public int ScanCnt { get; set; } public int ScanCnt { get; set; }
/// <summary>
/// 平滑
/// </summary>
public int SmoothFactor { get; set; }
/// <summary> /// <summary>
/// 开始机架修正 /// 开始机架修正
/// </summary> /// </summary>
/// <param name="groupIndex">组序号</param> /// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param> /// <param name="scanCnt">扫描次数</param>
public void Start(int groupIndex, int scanCnt) { /// <param name="smoothFactor">平滑</param>
Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt }); public void Start(int groupIndex, int scanCnt, int smoothFactor) {
Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt, smoothFactor = smoothFactor });
} }
/// <summary> /// <summary>
......
...@@ -42,12 +42,18 @@ namespace FLY.Thick.Base.IService ...@@ -42,12 +42,18 @@ namespace FLY.Thick.Base.IService
/// </summary> /// </summary>
int ScanCnt { get; } int ScanCnt { get; }
/// <summary>
/// 平滑
/// </summary>
int SmoothFactor { get; }
/// <summary> /// <summary>
/// 开始机架修正 /// 开始机架修正
/// </summary> /// </summary>
/// <param name="groupIndex">组序号</param> /// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param> /// <param name="scanCnt">扫描次数</param>
void Start(int groupIndex, int scanCnt); /// <param name="smoothFactor">平滑</param>
void Start(int groupIndex, int scanCnt, int smoothFactor);
/// <summary> /// <summary>
/// 清空组数据 /// 清空组数据
......
...@@ -49,7 +49,7 @@ namespace FLY.Thick.Base.Server ...@@ -49,7 +49,7 @@ namespace FLY.Thick.Base.Server
/// </summary> /// </summary>
public int ScanCnt { get; set; } = 2; public int ScanCnt { get; set; } = 2;
public int SmoothFactor { get; set; } = 30;
#endregion #endregion
...@@ -68,8 +68,28 @@ namespace FLY.Thick.Base.Server ...@@ -68,8 +68,28 @@ namespace FLY.Thick.Base.Server
GMState = Common.CTRL_STATE.CORR; GMState = Common.CTRL_STATE.CORR;
this.file_path = param_path; this.file_path = param_path;
Load(); 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) public void Init(FlyAD7 flyad, InitParam initParam)
{ {
base.Init(flyad); base.Init(flyad);
...@@ -105,7 +125,7 @@ namespace FLY.Thick.Base.Server ...@@ -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()) if (Groups == null || groupIndex < 0 || groupIndex >= Groups.Count())
{ {
...@@ -113,7 +133,7 @@ namespace FLY.Thick.Base.Server ...@@ -113,7 +133,7 @@ namespace FLY.Thick.Base.Server
} }
Enable = false;//关闭校正,让flyad7 输出的是原始数据 Enable = false;//关闭校正,让flyad7 输出的是原始数据
SmoothFactor = smoothFactor;
ScanCnt = scanCnt; ScanCnt = scanCnt;
CurrGroupIndex = groupIndex; CurrGroupIndex = groupIndex;
...@@ -146,8 +166,21 @@ namespace FLY.Thick.Base.Server ...@@ -146,8 +166,21 @@ namespace FLY.Thick.Base.Server
//顺便把CorrDatas也算出来 //顺便把CorrDatas也算出来
//默认以10个数据,平均滤波 //默认以10个数据,平均滤波
group.CorrDatas = new int[2][]; group.CorrDatas = new int[2][];
group.CorrDatas[0] = Smooth(group.OrgDatas[0]); group.CorrDatas[0] = Smooth(group.OrgDatas[0], SmoothFactor);
group.CorrDatas[1] = Smooth(group.OrgDatas[1]); 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; UpdateTimes[CurrGroupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes)); NotifyPropertyChanged(nameof(UpdateTimes));
Progress = 100; Progress = 100;
...@@ -165,7 +198,7 @@ namespace FLY.Thick.Base.Server ...@@ -165,7 +198,7 @@ namespace FLY.Thick.Base.Server
Save(); Save();
} }
int[] Smooth(int[] orgDatas, int smoothFactor = 10) int[] Smooth(int[] orgDatas, int smoothFactor = 20)
{ {
var filters = new int[orgDatas.Count()]; var filters = new int[orgDatas.Count()];
...@@ -175,7 +208,7 @@ namespace FLY.Thick.Base.Server ...@@ -175,7 +208,7 @@ namespace FLY.Thick.Base.Server
int cnt = 0; int cnt = 0;
for (int j = 0; j < smoothFactor; j++) for (int j = 0; j < smoothFactor; j++)
{ {
int index = i - smoothFactor / 2; int index = i - smoothFactor / 2+j;
if (index < 0) if (index < 0)
continue; continue;
else if (index >= orgDatas.Count()) else if (index >= orgDatas.Count())
...@@ -216,13 +249,14 @@ namespace FLY.Thick.Base.Server ...@@ -216,13 +249,14 @@ namespace FLY.Thick.Base.Server
/// <param name="groupIndex"></param> /// <param name="groupIndex"></param>
public void Clear(int groupIndex) { public void Clear(int groupIndex) {
if (groupIndex < 0 || groupIndex >= Groups.Count()) if (groupIndex < 0 || groupIndex >= Groups.Count())
{ return;
Groups[groupIndex].Clear();
Save();
}
}
Groups[groupIndex].Clear();
UpdateTimes[groupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes));
Save();
}
private void GM_GageInfo_EndEvent(object obj, MiniGridEventArgs e) private void GM_GageInfo_EndEvent(object obj, MiniGridEventArgs e)
{ {
DataEnd(e.direction, e.posOfGrid, e.grid_start, e.buf); DataEnd(e.direction, e.posOfGrid, e.grid_start, e.buf);
...@@ -258,7 +292,7 @@ namespace FLY.Thick.Base.Server ...@@ -258,7 +292,7 @@ namespace FLY.Thick.Base.Server
orgDatas[i] = org_ad; orgDatas[i] = org_ad;
} }
} }
UpdateTimes[orgDatas_index] = DateTime.Now; UpdateTimes[CurrGroupIndex] = DateTime.Now;
NotifyPropertyChanged(nameof(UpdateTimes)); NotifyPropertyChanged(nameof(UpdateTimes));
} }
...@@ -288,6 +322,7 @@ namespace FLY.Thick.Base.Server ...@@ -288,6 +322,7 @@ namespace FLY.Thick.Base.Server
var group = Groups[groupIndex]; var group = Groups[groupIndex];
group.CorrDatas = corrDatas; group.CorrDatas = corrDatas;
group.Avg = avg; group.Avg = avg;
Save();
} }
...@@ -534,17 +569,9 @@ namespace FLY.Thick.Base.Server ...@@ -534,17 +569,9 @@ namespace FLY.Thick.Base.Server
} }
public bool Enable; 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 ScanCnt = 2;
public int SmoothFactor = 30;
public ScanCorrGroup[] Groups; 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