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

添加 数据浏览器导出excel 有图表

parent a3480b55
......@@ -108,7 +108,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
return $"{text,6}";
};
MapperPreHeats = Mappers.Xy<int>()
MapperPreHeats = Mappers.Xy<double>()
.X((value, index) =>
{
return index + 1;
......@@ -147,7 +147,7 @@ namespace FLY.FilmCasting.AutoDie.UI.Client.UiModule
});
Mapper = Mappers.Xy<int>()
Mapper = Mappers.Xy<double>()
.X((value, index) =>
{
return index + 1;
......
......@@ -324,7 +324,7 @@ namespace FLY.FilmCasting.AutoDie.Server
{
var thkPercents = thkpercents.ToArray();
if (mHeatBuf.Stability != STABILITY.OK_CORREL || IsLvCtrlLinesValid())
if (mHeatBuf.Stability != STABILITY.OK_CORREL || !IsLvCtrlLinesValid())
{
//数据非稳定, 清空列表
thickPercentsCollection.Clear();
......@@ -332,6 +332,7 @@ namespace FLY.FilmCasting.AutoDie.Server
}
else {
thickPercentsCollection.Add(thkPercents);
int currMix = thickPercentsCollection.Count() + Mix - 1;
int maxMix = LvCtrlLines.Max(lv => lv.Mix);
if (currMix > maxMix)
......
......@@ -55,7 +55,7 @@ namespace FLY.FilmCasting.AutoDie.Server.Model
})
.ForMember(s => s.Heats, opt =>
{
opt.MapFrom(s => Newtonsoft.Json.JsonConvert.DeserializeObject<int[]>(s.Heats));
opt.MapFrom(s => Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(s.Heats));
});
}));
}
......
......@@ -11,12 +11,12 @@ using System.Linq;
namespace FLY.Thick.FilmCasting.UI.DbViewer.Core
{
//整个DbViewer软件的运行核心
public class DbViewerModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string DbDirPath { get; set; } = DbHelper.DefaultDbDirPath;
public List<DbProfilePack> ProfilePacks { get; } = new List<DbProfilePack>();
/// <summary>
......@@ -27,20 +27,35 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer.Core
public DateTime PackBeginDate { get; private set; }
public DateTime PackEndDate { get; private set; }
/// <summary>
/// ProfilePacks.Count()
/// </summary>
public int PackCnt { get; private set; }
/// <summary>
/// 数据库根目录路径
/// </summary>
public string DbDirPath { get; set; } = DbHelper.DefaultDbDirPath;
/// <summary>
/// 直方图统计步距 1um
/// </summary>
public int Step = 1;
/// <summary>
/// 扫描图显示的范围比例 3倍
/// </summary>
public double YRangePercent = 3;
/// <summary>
/// 只统计运行中的数据
/// 混合数
/// </summary>
public bool IsJustRunning { get; set; } = false;
public int Mix { get; set; } = 4;
public double Step { get; set; } = 1;
public DbHelper mDbHelper;
public DbViewerModel()
......@@ -55,14 +70,15 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer.Core
}
public bool GetProfilePacks(List<Db_Profile> profiles)
{
ProfilePacks.Clear();
foreach (var db_profile in profiles)
{
var profilePack = mDbHelper.GetProfilePack(db_profile);
profilePack.Init(IsJustRunning);
if (profilePack.ScanDatas.Count > 0)
{
profilePack.Mix = Mix;
profilePack.YRangePercent = YRangePercent;
profilePack.Step = Step;
if (profilePack.Init())
{
ProfilePacks.Add(profilePack);
}
}
......@@ -132,12 +148,25 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer.Core
}
return false;
}
/// <summary>
/// 数据库根目录路径
/// </summary>
public string DbDirPath { get; set; } = DbHelper.DefaultDbDirPath;
public double Step = 1;
/// <summary>
/// 直方图统计步距 1um
/// </summary>
public int Step = 1;
public double YRangePercent = 2;
/// <summary>
/// 扫描图显示的范围比例 3倍
/// </summary>
public double YRangePercent = 3;
public bool IsJustRunning = false;
/// <summary>
/// 混合数
/// </summary>
public int Mix { get; set; } = 4;
}
}
......@@ -83,6 +83,7 @@
</ApplicationDefinition>
<Compile Include="Core\DbViewerModel.cs" />
<Compile Include="Core\ExcelOuput.cs" />
<Compile Include="Core\GeneratedClass.cs" />
<Compile Include="Db\DbProfilePack.cs" />
<Compile Include="Db\ModelAccessory\AccessoryDbTable.cs" />
<Compile Include="Db\ModelAccessory\AccessoryDbModel.cs" />
......@@ -179,6 +180,9 @@
<PackageReference Include="Costura.Fody">
<Version>4.1.0</Version>
</PackageReference>
<PackageReference Include="DocumentFormat.OpenXml">
<Version>2.16.0</Version>
</PackageReference>
<PackageReference Include="EPPlus">
<Version>4.5.3.2</Version>
</PackageReference>
......@@ -227,7 +231,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Chart\" />
<Folder Include="Converters\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -141,20 +141,11 @@
</Button>
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,-25,0,0">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Styles.Button.Circle.Accent}" Command="{Binding DeleteCmd}">
<iconPacks:MaterialDesign Height="25" Width="25"
<Button Style="{StaticResource Styles.Button.Circle.Accent}" Command="{Binding DeleteCmd}" Margin="0,0,150,0">
<iconPacks:MaterialDesign Height="25" Width="25"
Kind="Delete" />
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<controls:ToggleSwitch
Header="静止数据"
Margin="{StaticResource ControlMargin}"
IsOn="{Binding IsJustRunning}"
OffContent="包含"
OnContent="不含"
Style="{StaticResource MahApps.Styles.ToggleSwitch}" />
</Button>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource Styles.Button.Circle.Accent}" VerticalAlignment="Bottom" Command="{Binding OkCmd}">
<iconPacks:PackIconFontAwesome Width="40" Height="40"
Kind="CheckCircleSolid" />
......
......@@ -63,8 +63,6 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer
public string ProductNameFilter { get; set; }
public string BatchFilter { get; set; }
public bool IsJustRunning { get; set; }
public ObservableCollection<Db_Profile> Profiles { get; } = new ObservableCollection<Db_Profile>();
//public ObservableCollection<Db_Profile> SelectedItems { get; } = new ObservableCollection<Db_Profile>();
......@@ -102,17 +100,6 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer
this.dgridProfiles = dgridProfiles;
IsJustRunning = dbViewerModel.IsJustRunning;
this.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(IsJustRunning))
{
dbViewerModel.IsJustRunning = IsJustRunning;
dbViewerModel.Save();
}
};
Misc.BindingOperations.SetBinding(dbHelper, nameof(dbHelper.MonthPath), () =>
{
if (string.IsNullOrEmpty(this.dbHelper.MonthPath))
......
......@@ -98,7 +98,7 @@
<Grid Style="{StaticResource Styles.Shadow}" >
<TextBlock Padding="10,5" VerticalAlignment="Top"
FontSize="24" Foreground="{StaticResource Brushes.ThemeBackground}" Background="{StaticResource Brushes.Activity}"
Text="扫描图" />
Text="对比图" />
</Grid>
</Button>
<Grid Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2" VerticalAlignment="Top" HorizontalAlignment="Left"
......
......@@ -11,6 +11,12 @@ namespace FLY.Thick.FilmCasting.Common
{
public static new FlyADIODefine Instance => (FlyADIODefine)instance;
/// <summary>
/// 换卷信号
/// </summary>
[Description("换卷信号")]
public int InNo_Finish { get; protected set; } = 9 - 1;
protected override List<string> GetInputPropertyNames()
{
return new List<string> {
......@@ -20,7 +26,8 @@ namespace FLY.Thick.FilmCasting.Common
nameof(InNo_DataValid),
nameof(InNo_Manual_Forw),
nameof(InNo_Manual_Backw),
nameof(InNo_Roll)
nameof(InNo_Roll),
nameof(InNo_Finish)
};
}
protected override List<string> GetOutputPropertyNames()
......
......@@ -186,6 +186,7 @@ namespace FLY.Thick.FilmCasting.IService
{
public Pack_GetFrameRequest Request;
public Lc_ScanData scanData;
public int mix;
}
......@@ -194,6 +195,7 @@ namespace FLY.Thick.FilmCasting.IService
public Pack_GetFrameRequest Request;
public Lc_ScanData scanData;
public Db_Profile profile;
public int mix;
}
public class Pack_GetTrendRequest
......
......@@ -9,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Threading;
using FlyADIODefine = FLY.Thick.FilmCasting.Common.FlyADIODefine;
namespace FLY.Thick.FilmCasting.Server
{
......@@ -74,8 +75,28 @@ namespace FLY.Thick.FilmCasting.Server
autoRollDown = new AutoRollDown();
autoRollDown.Init(profile);
bulkDb.FinishEvent += BulkDb_FinishEvent;
flyAd.IStatusChangedEvent += FlyAd_IStatusChangedEvent;
}
private void FlyAd_IStatusChangedEvent(object sender, IStatusChangedEventArgs e)
{
if (Misc.MyBase.CHECKBIT(e.IChanged, FlyADIODefine.Instance.InNo_Finish))
{
if (Misc.MyBase.CHECKBIT(e.IStatus, FlyADIODefine.Instance.InNo_Finish))
{
FinishProfile();
}
}
}
private void BulkDb_FinishEvent()
{
FinishProfile();
}
void DataEndEvent(object sender, MiniGridEventArgs e)
{
......@@ -237,7 +258,7 @@ namespace FLY.Thick.FilmCasting.Server
if (historyDb.localDb.IsProfileFinished)
{
//已经下辊
FinishProfile();
autoRollDown.Reset();
AddProfile();
}
else
......@@ -255,7 +276,17 @@ namespace FLY.Thick.FilmCasting.Server
#endregion
}
void FinishProfile() {
historyDb.FinishProfile();
if (!historyDb.localDb.IsProfileFinished)
{
historyDb.FinishProfile();
if (int.TryParse(profile.Param.Number, out int number))
{
number++;
profile.Param.Number = number.ToString();
}
}
autoRollDown.Reset();
}
......@@ -418,7 +449,7 @@ namespace FLY.Thick.FilmCasting.Server
ScanBegin = profileParam.ScanRange.Begin,
ScanEnd = profileParam.ScanRange.End,
}, scanMotion.StartDataEndTime);
}, DateTime.Now);// scanMotion.StartDataEndTime);
}
void UpdateProfile()
{
......
......@@ -252,7 +252,7 @@ namespace FLY.Thick.FilmCasting.Server.Model
var lc_scanDatas = Lc_AutoMapperProfile.Mapper.Map<List<Db_ScanData>, List<Lc_ScanData>>(db_scandatas);
var newest_scanData = lc_scanDatas.First();//这个是最新的一幅图
newest_scanData.Thicks = GetMixScanData(lc_scanDatas, 0, newest_scanData.DataBegin, newest_scanData.DataEnd, ref request.Mix);
newest_scanData.Thicks = GetMixScanData(lc_scanDatas, 0, newest_scanData.DataBegin, newest_scanData.DataEnd, request.Mix, out reponse.mix);
reponse.scanData = newest_scanData;
// Last() 就是最早的数据
......@@ -302,7 +302,7 @@ namespace FLY.Thick.FilmCasting.Server.Model
var lc_scanDatas = Lc_AutoMapperProfile.Mapper.Map<List<Db_ScanData>, List<Lc_ScanData>>(db_scandatas);
var newest_scanData = lc_scanDatas.First();//这个是最新的一幅图
newest_scanData.Thicks = GetMixScanData(lc_scanDatas, 0, newest_scanData.DataBegin, newest_scanData.DataEnd, ref request.Mix);
newest_scanData.Thicks = GetMixScanData(lc_scanDatas, 0, newest_scanData.DataBegin, newest_scanData.DataEnd, request.Mix, out reponse.mix);
reponse.scanData = newest_scanData;
// Last() 就是最早的数据
......@@ -517,8 +517,10 @@ namespace FLY.Thick.FilmCasting.Server.Model
return thks;
}
double[] GetMixScanData(List<Lc_ScanData> lc_scanDatas, int offset, int dataBegin, int dataEnd, ref int mix)
double[] GetMixScanData(List<Lc_ScanData> lc_scanDatas, int offset, int dataBegin, int dataEnd, int mix, out int realMix)
{
//lc_scanDatas[0] 是最新的数据!!
List<Lc_ScanData> lc_scanDatas2 = new List<Lc_ScanData>();
for (int i = 0; i < mix; i++)
{
......@@ -528,15 +530,14 @@ namespace FLY.Thick.FilmCasting.Server.Model
lc_scanDatas2.Add(lc_scanDatas[offset + i]);
}
var newest_scanData = lc_scanDatas2[0];
//把时间 与 最新的一幅图 的时间 偏差 大于 MixDataTimeRange 删除
//连续两幅图时间间隔 大于 MixDataTimeRange 删除
if (MixDataTimeRange > TimeSpan.Zero)
{
for (int i = 1; i < lc_scanDatas2.Count(); i++)
{
var scanData = lc_scanDatas2[i];
if (newest_scanData.Time - scanData.Time > MixDataTimeRange)
var scanData0 = lc_scanDatas2[i - 1];
var scanData1 = lc_scanDatas2[i];
if (scanData0.Time - scanData1.Time > MixDataTimeRange)
{
lc_scanDatas2.RemoveRange(i, lc_scanDatas2.Count() - i);
break;
......@@ -544,9 +545,13 @@ namespace FLY.Thick.FilmCasting.Server.Model
}
}
//把 均值与 最新的一幅图 的均值 偏差 大于 MixDataAvgRange 删除
if (MixDataAvgRange > 0)
{
var newest_scanData = lc_scanDatas2[0];
//注意数据是没有剔除的, 计算平均值时,要明确范围
var newest_avg = Misc.MyMath.Avg(newest_scanData.Thicks, dataBegin, dataEnd);
......@@ -557,7 +562,7 @@ namespace FLY.Thick.FilmCasting.Server.Model
var scanData = lc_scanDatas2[i];
var avg = Misc.MyMath.Avg(scanData.Thicks, dataBegin, dataEnd);
if (double.IsNaN(avg))
if (double.IsNaN(avg))//一幅数据异常,全部删除
{
lc_scanDatas2.RemoveRange(i, lc_scanDatas2.Count() - i);
break;
......@@ -577,7 +582,7 @@ namespace FLY.Thick.FilmCasting.Server.Model
}
}
mix = lc_scanDatas2.Count();
realMix = lc_scanDatas2.Count();
if (lc_scanDatas2.Count() > 1)
{
......@@ -621,9 +626,8 @@ namespace FLY.Thick.FilmCasting.Server.Model
var sd = lc_scanDatas[i];
if (sd.ID % interval == 0)
{
int _m = mix;
//它是数据点
double[] thks = GetMixScanData(lc_scanDatas, i, sd.DataBegin, sd.DataEnd, ref _m);
double[] thks = GetMixScanData(lc_scanDatas, i, sd.DataBegin, sd.DataEnd, mix, out int _m);
//求均值
double avg = Misc.MyMath.Avg(thks, sd.DataBegin, sd.DataEnd);
......@@ -637,6 +641,8 @@ namespace FLY.Thick.FilmCasting.Server.Model
Value = avg,
Time = lc_scanDatas[i].Time
});
if (trendValues.Count() >= count)
break;//完成
}
}
......@@ -648,8 +654,9 @@ namespace FLY.Thick.FilmCasting.Server.Model
/// </summary>
public void Finish()
{
shareDb.FinishProfile();
//shareDb.FinishProfile();
FinishEvent?.Invoke();
}
public event Action FinishEvent;
}
}
Subproject commit cabcd8ecbb065fad133c7fb786fb771bfe1c2fe0
Subproject commit 87d5e93d4e0d18745b80f377d4aa213362f23e0b
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