Commit 5601880d authored by 潘栩锋's avatar 潘栩锋 🚴

修复 即时扫描图 Y轴范围 不能及时修改

parent 6e772c72
...@@ -36,6 +36,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -36,6 +36,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
public double YMin { get; set; } = double.NaN; public double YMin { get; set; } = double.NaN;
public double Target { get; set; } = double.NaN; public double Target { get; set; } = double.NaN;
public double TolerancePercent { get; set; } = 0.05; public double TolerancePercent { get; set; } = 0.05;
public double Tolerance { get; set; } = MIN_TOLERANCE;
public double ToleranceYMax { get; set; } = double.NaN; public double ToleranceYMax { get; set; } = double.NaN;
public double ToleranceYMin { get; set; } = double.NaN; public double ToleranceYMin { get; set; } = double.NaN;
public double Tolerance2YMax { get; set; } = double.NaN; public double Tolerance2YMax { get; set; } = double.NaN;
...@@ -240,12 +241,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -240,12 +241,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
//更新平均值,它会引起 YFormatter 刷新 //更新平均值,它会引起 YFormatter 刷新
UpdateAverage(); UpdateAverage();
//更新Target PropertyChanged_Average();
UpdateY();
//必须先更新Y轴, X轴资料,最后再画线!!!!!!!
//不然 YAxisCrossing 会有机会无效
Values.AddRange(datas); Values.AddRange(datas);
} }
...@@ -282,8 +278,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -282,8 +278,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
//更新平均值,它会引起 YFormatter 刷新 //更新平均值,它会引起 YFormatter 刷新
UpdateAverage(); UpdateAverage();
//更新Target PropertyChanged_Average();
UpdateY();
for (int i = 0; i < reponse.D.Count(); i++) for (int i = 0; i < reponse.D.Count(); i++)
{ {
...@@ -310,10 +305,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -310,10 +305,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
if (e.PropertyName == nameof(Target)) if (e.PropertyName == nameof(Target))
{ {
if (graphparam.IsPercent) if (graphparam.IsPercent)
{
NotifyPropertyChanged(nameof(YFormatter)); NotifyPropertyChanged(nameof(YFormatter));
} }
}
if (propertyname_updateMaxMinText.Contains(e.PropertyName)) if (propertyname_updateMaxMinText.Contains(e.PropertyName))
UpdateMaxMinTextAsync(); UpdateMaxMinTextAsync();
...@@ -324,11 +317,11 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -324,11 +317,11 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
if (e.PropertyName == nameof(profileParam.Target)) if (e.PropertyName == nameof(profileParam.Target))
{ {
UpdateY(); PropertyChanged_ParamTarget();
} }
else if (e.PropertyName == nameof(profileParam.TolerancePercent)) else if (e.PropertyName == nameof(profileParam.TolerancePercent))
{ {
UpdateY(); PropertyChanged_ParamTolerancePercent();
} }
} }
...@@ -347,12 +340,11 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -347,12 +340,11 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
if (e.PropertyName == nameof(graphparam.YRangePercent)) if (e.PropertyName == nameof(graphparam.YRangePercent))
{ {
UpdateY(); PropertyChanged_YRangePercent();
} }
else if (e.PropertyName == nameof(graphparam.IsPercent)) else if (e.PropertyName == nameof(graphparam.IsPercent))
{ {
NotifyPropertyChanged(nameof(YFormatter)); NotifyPropertyChanged(nameof(YFormatter));
UpdateY();
UpdateMaxMinTextAsync(); UpdateMaxMinTextAsync();
} }
} }
...@@ -361,63 +353,69 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -361,63 +353,69 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
protected void UpdateY() protected void UpdateY()
{ {
double target = this.profileParam.Target;
if (graphparam.IsAutoTarget && (!double.IsNaN(Average)))
{
target = Average;
}
Target = target;
TolerancePercent = profileParam.TolerancePercent;
Tolerance = Math.Max(TolerancePercent * Target, MIN_TOLERANCE);
//使用 profileParam 的参数显示 PropertyChanged_Target_Tolerance_YRangePercent();
UpdateY_profileParam();
} }
void UpdateY_profileParam() void PropertyChanged_ParamTarget()
{
bool isAutoTarget = false;
double target = this.profileParam.Target;
if (graphparam.IsAutoTarget)
{ {
if (!double.IsNaN(Average)) //自动目标值模式 且 已经有平均值
if (graphparam.IsAutoTarget && (!double.IsNaN(Average)))
{ {
target = Average; return; //现在 Y轴 与 产品中的目标值 无关
isAutoTarget = true;
} }
else {
if (!double.IsNaN(Target)) { Target = profileParam.Target;
//没有数据 且之前能显示,不更新界面。 PropertyChanged_Target_Tolerance_YRangePercent();
return;
} }
void PropertyChanged_ParamTolerancePercent()
{
TolerancePercent = profileParam.TolerancePercent;
Tolerance = Math.Max(TolerancePercent * Target, MIN_TOLERANCE);
PropertyChanged_Target_Tolerance_YRangePercent();
}
void PropertyChanged_Target_Tolerance_YRangePercent()
{
ToleranceYMax = Target + Tolerance;
ToleranceYMin = Target - Tolerance;
Tolerance2YMax = Target + Tolerance * 2;
Tolerance2YMin = Target - Tolerance * 2;
YMax = Target + Tolerance * graphparam.YRangePercent;
YMin = Target - Tolerance * graphparam.YRangePercent;
} }
void PropertyChanged_YRangePercent()
{
YMax = Target + Tolerance * graphparam.YRangePercent;
YMin = Target - Tolerance * graphparam.YRangePercent;
} }
void PropertyChanged_Average()
{
if (!graphparam.IsAutoTarget)
return;
if (isAutoTarget) if (double.IsNaN(Average))
return;
if (!double.IsNaN(Target))//之前有显示范围
{ {
if (!double.IsNaN(Target)) if (Average < ToleranceYMax && Average > ToleranceYMin)
{ {
if (profileParam.TolerancePercent == TolerancePercent) {
//公差没变
if (target < ToleranceYMax && target > ToleranceYMin) {
//变化很小, 不调整显示 //变化很小, 不调整显示
return; return;
} }
} }
}
}
double tolerance = this.profileParam.TolerancePercent * target;
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
TolerancePercent = profileParam.TolerancePercent; Target = Average;
Target = target; PropertyChanged_Target_Tolerance_YRangePercent();
ToleranceYMax = target + tolerance;
ToleranceYMin = target - tolerance;
Tolerance2YMax = target + tolerance * 2;
Tolerance2YMin = target - tolerance * 2;
YMax = target + tolerance * graphparam.YRangePercent;
YMin = target - tolerance * graphparam.YRangePercent;
} }
protected void UpdateX() protected void UpdateX()
...@@ -493,8 +491,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -493,8 +491,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
} }
protected void NotifyPropertyChanged(string propertyName) protected void NotifyPropertyChanged(string propertyName)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
......
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