Commit 8595e70b authored by 潘栩锋's avatar 潘栩锋 🚴

1. 修复 产品界面 【应用】 按钮无动作。

2. 优化 数据浏览器 Style 修改
3. 修复 机架修正,IO功能提示, bug 修复
parent 290c7efc
......@@ -19,9 +19,17 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer.Core
public string DbDirPath { get; set; } = DbHelper.DefaultDbDirPath;
public List<DbProfilePack> ProfilePacks { get; } = new List<DbProfilePack>();
/// <summary>
/// 数据准备好了
/// </summary>
public bool IsPackReady { get; private set; }
public DateTime PackBeginDate { get; private set; }
public DateTime PackEndDate { get; private set; }
/// <summary>
/// ProfilePacks.Count()
/// </summary>
public int PackCnt { get; private set; }
......
......@@ -310,206 +310,6 @@ namespace FLY.Thick.FilmCasting.UI.DbViewer.Db
}
#region 链接表的关系
/// <summary>
/// 包装 DB_Profile, 组织 DB_Profile, DB_ScanData....
/// </summary>
public class DbProfilePack:INotifyPropertyChanged
{
public FLY.Thick.FilmCasting.Server.Model.Db_Profile Profile;
public List<FLY.Thick.FilmCasting.Server.Model.Lc_ScanData> ScanDatas;
public List<Db_Error> Errors;
#region 能重新调整的参数
public double USL
{
get
{
return Target + Target * TolerancePercent;
}
}
public double LSL
{
get
{
return Target - Target * TolerancePercent;
}
}
public double Target { get; set; }
public double YMax
{
get
{
return Target + Target * TolerancePercent * YRangePercent;
}
}
public double YMin
{
get
{
return Target - Target * TolerancePercent * YRangePercent;
}
}
public double TolerancePercent { get; set; }
public double YRangePercent { get; set; } = 2;
#endregion
#region 统计结果,用于输出
public int TotalCount { get; private set; }
public double Average { get; private set; }
public double Sigma2 { get; private set; }
public double CPK { get; private set; }
public double InTolerancePercentRange { get; private set; }
#endregion
/// <summary>
/// 分区数
/// </summary>
public int NBolts { get; private set; }
public void Init(bool isJustRunning) {
if (ScanDatas.Count() > 0) {
NBolts = ScanDatas.Last().Thicks.Count();
}
if (isJustRunning)
{
//把静止下的删除!!!!!
ScanDatas.RemoveAll(sd => sd.FilmVelocity == 0);
}
Target = Profile.Target;
TolerancePercent = Profile.TolerancePercent;
UpdateStatistics();
}
void UpdateStatistics()
{
List<double> values = new List<double>();
for (int i = 0; i < ScanDatas.Count(); i++) {
var scanData = ScanDatas[i];
//不统计NaN
values.AddRange(scanData.Thicks.Where(t => !double.IsNaN(t)));
}
if (values.Count() == 0)
{
//没有数据
Average = double.NaN;
Sigma2 = double.NaN;
CPK = double.NaN;
TotalCount = 0;
InTolerancePercentRange = double.NaN;
return;
}
TotalCount = values.Count();
Average = values.Average();
double sigma = values.Sigma(d => d);
Sigma2 = sigma * 2;
int tolerance_cnt = values.Count(d => d <= USL && d >= LSL);
InTolerancePercentRange = 1.0 * tolerance_cnt / TotalCount;
CPK = values.CPK(USL, LSL);
//NormValues.Clear();
//var normvalues =
// from xy in Values select new XY(xy.X, MathExt.NormDist(xy.X, Average, sigma));
//double sum = normvalues.Sum(xy => xy.Y);
//NormValues.AddRange(normvalues.Select(xy => new XY(xy.X, total * xy.Y / sum)));
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 统计 的 Y是 数量
/// </summary>
/// <param name="step"></param>
/// <returns></returns>
List<XY> GetHistogram(double step)
{
List<XY> list = new List<XY>();
foreach (var scanData in ScanDatas)
{
foreach (var thk in scanData.Thicks) {
if (double.IsNaN(thk))
continue;
double x = ((int)(thk / step)) * step;
XY xy = list.Find(_xy => _xy.X == x);
if (xy != null)
{
xy.Y++;
}
else
{
xy = new XY(x, 1);
list.Add(xy);
}
}
}
list.Sort();
return list;
}
/// <summary>
/// 以 YMin 到 YMax 为范围,统计直方图
/// </summary>
/// <returns></returns>
public List<XY> GetHistogram2(double step)
{
double xmin = YMin;
double xmax = YMax;
int xmin_core = ((int)(xmin / step));
int xmax_core = ((int)(xmax / step));
List<XY> all_values = GetHistogram(step);
List<XY> values = new List<XY>();
for (int x_core = xmin_core; x_core <= xmax_core; x_core++)
{
var list = from v in all_values where (int)(v.X / step) == x_core select v;
if (list.Count() == 0)
values.Add(new XY(x_core * step, 0));
else
values.Add(list.First());
}
return values;
}
public List<TrendValue> GetTrend()
{
List<TrendValue> trendValues = new List<TrendValue>();
for (int i = 0; i < ScanDatas.Count(); i++)
{
var scanData = ScanDatas[i];
double avg = scanData.Thicks.AverageNoNull();
double sigma = scanData.Thicks.Sigma();
trendValues.Add(new TrendValue() { Sigma = sigma, Time = scanData.Time, Value = avg });
}
return trendValues;
}
}
#endregion
public class TrendValue
{
public double Sigma { get; set; }
public double Value { get; set; }
public DateTime Time { get; set; }
}
}
using FLY.OBJComponents.Server.Model;
using Misc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.FilmCasting.UI.DbViewer.Db
{
#region 链接表的关系
/// <summary>
/// 包装 DB_Profile, 组织 DB_Profile, DB_ScanData....
/// </summary>
public class DbProfilePack : INotifyPropertyChanged
{
public FLY.Thick.FilmCasting.Server.Model.Db_Profile Profile;
public List<FLY.Thick.FilmCasting.Server.Model.Lc_ScanData> ScanDatas;
public List<Db_Error> Errors;
#region 能重新调整的参数
public double USL
{
get
{
return Target + Target * TolerancePercent;
}
}
public double LSL
{
get
{
return Target - Target * TolerancePercent;
}
}
public double Target { get; set; }
public double YMax
{
get
{
return Target + Target * TolerancePercent * YRangePercent;
}
}
public double YMin
{
get
{
return Target - Target * TolerancePercent * YRangePercent;
}
}
public double TolerancePercent { get; set; }
public double YRangePercent { get; set; } = 2;
#endregion
#region 统计结果,用于输出
public int TotalCount { get; private set; }
public double Average { get; private set; }
public double Sigma2 { get; private set; }
public double CPK { get; private set; }
public double InTolerancePercentRange { get; private set; }
#endregion
/// <summary>
/// 分区数
/// </summary>
public int NBolts { get; private set; }
public void Init(bool isJustRunning)
{
if (ScanDatas.Count() > 0)
{
NBolts = ScanDatas.Last().Thicks.Count();
}
if (isJustRunning)
{
//把静止下的删除!!!!!
ScanDatas.RemoveAll(sd => sd.FilmVelocity == 0);
}
Target = Profile.Target;
TolerancePercent = Profile.TolerancePercent;
UpdateStatistics();
}
void UpdateStatistics()
{
List<double> values = new List<double>();
for (int i = 0; i < ScanDatas.Count(); i++)
{
var scanData = ScanDatas[i];
//不统计NaN
values.AddRange(scanData.Thicks.Where(t => !double.IsNaN(t)));
}
if (values.Count() == 0)
{
//没有数据
Average = double.NaN;
Sigma2 = double.NaN;
CPK = double.NaN;
TotalCount = 0;
InTolerancePercentRange = double.NaN;
return;
}
TotalCount = values.Count();
Average = values.Average();
double sigma = values.Sigma(d => d);
Sigma2 = sigma * 2;
int tolerance_cnt = values.Count(d => d <= USL && d >= LSL);
InTolerancePercentRange = 1.0 * tolerance_cnt / TotalCount;
CPK = values.CPK(USL, LSL);
//NormValues.Clear();
//var normvalues =
// from xy in Values select new XY(xy.X, MathExt.NormDist(xy.X, Average, sigma));
//double sum = normvalues.Sum(xy => xy.Y);
//NormValues.AddRange(normvalues.Select(xy => new XY(xy.X, total * xy.Y / sum)));
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 统计 的 Y是 数量
/// </summary>
/// <param name="step"></param>
/// <returns></returns>
List<XY> GetHistogram(double step)
{
List<XY> list = new List<XY>();
foreach (var scanData in ScanDatas)
{
foreach (var thk in scanData.Thicks)
{
if (double.IsNaN(thk))
continue;
double x = ((int)(thk / step)) * step;
XY xy = list.Find(_xy => _xy.X == x);
if (xy != null)
{
xy.Y++;
}
else
{
xy = new XY(x, 1);
list.Add(xy);
}
}
}
list.Sort();
return list;
}
/// <summary>
/// 以 YMin 到 YMax 为范围,统计直方图
/// </summary>
/// <returns></returns>
public List<XY> GetHistogram2(double step)
{
double xmin = YMin;
double xmax = YMax;
int xmin_core = ((int)(xmin / step));
int xmax_core = ((int)(xmax / step));
List<XY> all_values = GetHistogram(step);
List<XY> values = new List<XY>();
for (int x_core = xmin_core; x_core <= xmax_core; x_core++)
{
var list = from v in all_values where (int)(v.X / step) == x_core select v;
if (list.Count() == 0)
values.Add(new XY(x_core * step, 0));
else
values.Add(list.First());
}
return values;
}
public List<TrendValue> GetTrend()
{
List<TrendValue> trendValues = new List<TrendValue>();
for (int i = 0; i < ScanDatas.Count(); i++)
{
var scanData = ScanDatas[i];
double avg = scanData.Thicks.AverageNoNull();
double sigma = scanData.Thicks.Sigma();
trendValues.Add(new TrendValue() { Sigma = sigma, Time = scanData.Time, Value = avg });
}
return trendValues;
}
}
#endregion
public class TrendValue
{
public double Sigma { get; set; }
public double Value { get; set; }
public DateTime Time { get; set; }
}
}
......@@ -83,6 +83,7 @@
</ApplicationDefinition>
<Compile Include="Core\DbViewerModel.cs" />
<Compile Include="Core\ExcelOuput.cs" />
<Compile Include="Db\DbProfilePack.cs" />
<Compile Include="Db\ModelAccessory\AccessoryDbTable.cs" />
<Compile Include="Db\ModelAccessory\AccessoryDbModel.cs" />
<Compile Include="DgSelectMonth.xaml.cs">
......
......@@ -22,8 +22,8 @@
</StackPanel.Resources>
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 1" FontSize="20" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="选择数据" VerticalAlignment="Bottom" Margin="4,0"/>
<TextBlock Text="Step 1" FontSize="{StaticResource FontSize.H3}" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="选择数据" VerticalAlignment="Bottom" Margin="{StaticResource Margin.Text}"/>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Circle.Accent2}" Click="ButtonSelect_Click">
<iconPacks:PackIconMaterial Kind="DatabaseImport" />
......@@ -45,32 +45,32 @@
</StackPanel>
<Line X2="96" VerticalAlignment="Center" Stroke="{StaticResource MahApps.Brushes.Gray7}" StrokeThickness="3" Margin="40,0"/>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 2" FontSize="20" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="查看图表(暂不支持)" VerticalAlignment="Bottom" Margin="4,0"/>
<TextBlock Text="Step 2" FontSize="{StaticResource FontSize.H3}" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="查看图表(暂不支持)" VerticalAlignment="Bottom" Margin="{StaticResource Margin.Text}"/>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Circle.Accent2}" Click="ButtonChart_Click" IsEnabled="False">
<iconPacks:PackIconMaterial Kind="ChartAreaspline" />
</Button>
</StackPanel>
<Line X2="96" VerticalAlignment="Center" Stroke="{StaticResource MahApps.Brushes.Gray7}" StrokeThickness="3" Margin="40,0"/>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" >
<StackPanel VerticalAlignment="Center" >
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 3" FontSize="20" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="导出excel" VerticalAlignment="Bottom" Margin="4,0"/>
<TextBlock Text="Step 3" FontSize="{StaticResource FontSize.H3}" Foreground="{StaticResource MahApps.Brushes.Accent}" />
<TextBlock Text="导出excel" VerticalAlignment="Bottom" Margin="{StaticResource Margin.Text}"/>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Circle.Accent2}" Click="ButtonExcel_Click" IsEnabled="{Binding IsPackReady}">
<iconPacks:PackIconMaterial Kind="MicrosoftExcel" />
</Button>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10,30">
<StackPanel Grid.Row="1" Margin="10,30">
<Rectangle Height="1" Fill="{StaticResource MahApps.Brushes.Gray7}" Width="800"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="{StaticResource ControlMargin}">
<StackPanel Orientation="Vertical">
<Button Style="{StaticResource ButtonStyle_empty}" Click="ButtonSetup_Click">
<TextBlock Text="流延数据库浏览器" FontSize="25">
<StackPanel >
<Button Style="{StaticResource Styles.Button.Empty}" Click="ButtonSetup_Click">
<TextBlock Text="流延数据库浏览器" FontSize="{StaticResource FontSize.H2}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Accent}"/>
......@@ -82,7 +82,7 @@
</StackPanel>
<TextBlock Text="by flyautomation" VerticalAlignment="Bottom" Margin="{StaticResource ControlMargin}"/>
<TextBlock FontSize="{StaticResource FontSize.H4}" Text="by flyautomation" VerticalAlignment="Bottom" Margin="{StaticResource ControlMargin}"/>
</StackPanel>
</StackPanel>
......
......@@ -19,9 +19,9 @@
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Text="查找" Margin="{StaticResource ControlMargin}" FontSize="{StaticResource FontSize.H1}" />
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Text="数据库" FontSize="24" Margin="{StaticResource ControlMargin}"/>
<TextBlock FontSize="{StaticResource FontSize.H3}" Text="数据库" />
<TextBlock Text="{Binding ErrorMsg}" Margin="{StaticResource ControlMargin}">
<TextBlock.Style>
<Style TargetType="TextBlock">
......@@ -37,12 +37,11 @@
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Text="查找" FontSize="24"/>
<StackPanel Orientation="Horizontal" >
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Margin="{StaticResource ControlMargin}">
<TextBlock FontSize="{StaticResource FontSize.H4}" Margin="{StaticResource ControlMargin}">
数据源:<Run Text="{Binding MonthPath,Mode=OneWay}"/>
</TextBlock>
<Button Style="{StaticResource MahApps.Styles.Button.Square}" Content="选择数据源" Command="{Binding SelectMonthPathCmd}"/>
<Button Style="{StaticResource MahApps.Styles.Button.Square}" Margin="{StaticResource ControlMargin}" Padding="{StaticResource Padding.Button}" Content="选择数据源" Command="{Binding SelectMonthPathCmd}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="{StaticResource ControlMargin}">
......@@ -56,9 +55,13 @@
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<StackPanel>
<StackPanel Orientation="Horizontal">
<DatePicker Width="200"
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<DatePicker
Width="200"
Margin="{StaticResource ControlMargin}"
HorizontalAlignment="Center"
HorizontalContentAlignment="Stretch"
......@@ -68,8 +71,8 @@
DisplayDateStart="{Binding DbBeginTime,Mode=OneWay}"
DisplayDateEnd="{Binding DbEndTime,Mode=OneWay}"
SelectedDate="{Binding BeginDate}"/>
<DatePicker Width="200"
<DatePicker Grid.Column="1"
Width="200"
Margin="{StaticResource ControlMargin}"
HorizontalAlignment="Center"
HorizontalContentAlignment="Stretch"
......@@ -79,7 +82,7 @@
DisplayDateStart="{Binding DbBeginTime,Mode=OneWay}"
DisplayDateEnd="{Binding DbEndTime,Mode=OneWay}"
SelectedDate="{Binding EndDate}"/>
</StackPanel>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
......
......@@ -18,15 +18,15 @@
</Grid.RowDefinitions>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Text="配置" FontSize="32" Margin="{StaticResource ControlMargin}"/>
<TextBlock Text="配置" FontSize="{StaticResource FontSize.H1}" Margin="{StaticResource ControlMargin}"/>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Text="数据库" FontSize="24" Margin="{StaticResource ControlMargin}"/>
<TextBlock Text="数据库" FontSize="{StaticResource FontSize.H2}" Margin="{StaticResource ControlMargin}"/>
<StackPanel Orientation="Horizontal">
<Button Width="140" Margin="{StaticResource ControlMargin}" Content="选择数据库文件夹"
Command="{Binding DbSelectCmd}"
Style="{StaticResource MahApps.Styles.Button.Square.Accent}" />
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Text="{Binding DbDirPath}" FontSize="15"/>
<TextBlock Text="{Binding DbDirPath}" FontSize="{StaticResource FontSize.H4}"/>
<TextBlock
DataContext="{Binding DbHelper}"
Text="{Binding ErrorMsg,Mode=OneWay}" >
......@@ -45,7 +45,7 @@
</StackPanel>
</StackPanel>
<StackPanel DataContext="{Binding DbHelper}">
<TextBlock Margin="{StaticResource ControlMargin}">
<TextBlock Margin="{StaticResource ControlMargin}" FontSize="{StaticResource FontSize.H4}">
测厚仪数据库[<Run Text="{Binding IsThkExist,Mode=OneWay}"/>]
</TextBlock>
</StackPanel>
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
......@@ -45,4 +46,11 @@
</Style.Resources>
</Style>
<sys:Double x:Key="FontSize.H1">32</sys:Double>
<sys:Double x:Key="FontSize.H2">24</sys:Double>
<sys:Double x:Key="FontSize.H3">20</sys:Double>
<sys:Double x:Key="FontSize.H4">15</sys:Double>
<Thickness x:Key="Margin.Text">3</Thickness>
<Thickness x:Key="Padding.Button">20,5</Thickness>
</ResourceDictionary>
\ No newline at end of file
......@@ -268,7 +268,7 @@
</Grid>
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" Margin="{StaticResource ControlMargin}">
<Button Content="应用" Style="{StaticResource Styles.Button2}" Command="{Binding ApplyCmd}" />
<Button Content="应用" Style="{StaticResource Styles.Button2}" Command="{Binding ApplyParamCmd}" />
<Button Content="读取" Style="{StaticResource Styles.Button2}" Command="{Binding ReadCmd}" />
<Button Content="删除" Style="{StaticResource Styles.Button2}" Command="{Binding DelCmd}"/>
</StackPanel>
......@@ -325,7 +325,7 @@
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="分钟"/>
</StackPanel>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="应用"/>
<Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="应用" Command="{Binding ApplyCmd}"/>
</WrapPanel>
</StackPanel>
</Border>
......
Subproject commit 8db7013a6338e3aa96a9f23f14974ea1898ba606
Subproject commit e4c86d07ea66a8b7e25aef4734f54f932d543ab9
......@@ -70,4 +70,13 @@ files=(\
)
copy_to2 $src_dir $dest_dir $files
src_dir="../Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.DbViewer"
dest_dir="FLY.Thick.FilmCasting.UI.DbViewer"
files=(\
"FLY.Thick.FilmCasting.UI.DbViewer.exe" \
"x64" "x86" \
)
copy_to2 $src_dir $dest_dir $files
echo 完成
\ No newline at end of file
......@@ -13,6 +13,12 @@
"Name":"流延测厚仪客户端",
"IsAutoRun":true
},
{
"PackPath":"佛山市枫莱尔自动化技术有限公司\\windows\\FLY.Thick.FilmCasting.UI.DbViewer",
"Exe":"FLY.Thick.FilmCasting.UI.DbViewer.exe",
"Name":"数据浏览器",
"IsAutoRun":false
},
{
"PackPath":"佛山市枫莱尔自动化技术有限公司\\windows\\LP3",
"Exe":"FLY.LinkProxy.UI.exe",
......
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