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;
...@@ -239,14 +240,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -239,14 +240,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
//更新平均值,它会引起 YFormatter 刷新 //更新平均值,它会引起 YFormatter 刷新
UpdateAverage(); UpdateAverage();
//更新Target
UpdateY();
//必须先更新Y轴, X轴资料,最后再画线!!!!!!! PropertyChanged_Average();
//不然 YAxisCrossing 会有机会无效
Values.AddRange(datas); Values.AddRange(datas);
} }
protected void BulkDb_TempFrameChanged(object sender, EventArgs e) protected void BulkDb_TempFrameChanged(object sender, EventArgs e)
...@@ -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,9 +305,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -310,9 +305,7 @@ 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))
...@@ -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 PropertyChanged_ParamTarget()
{
//自动目标值模式 且 已经有平均值
if (graphparam.IsAutoTarget && (!double.IsNaN(Average)))
{
return; //现在 Y轴 与 产品中的目标值 无关
}
Target = profileParam.Target;
PropertyChanged_Target_Tolerance_YRangePercent();
} }
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;
void UpdateY_profileParam() YMax = Target + Tolerance * graphparam.YRangePercent;
YMin = Target - Tolerance * graphparam.YRangePercent;
}
void PropertyChanged_YRangePercent()
{ {
bool isAutoTarget = false; YMax = Target + Tolerance * graphparam.YRangePercent;
double target = this.profileParam.Target; YMin = Target - Tolerance * graphparam.YRangePercent;
if (graphparam.IsAutoTarget) }
{ void PropertyChanged_Average()
if (!double.IsNaN(Average)) {
{ if (!graphparam.IsAutoTarget)
target = Average; return;
isAutoTarget = true;
}
else {
if (!double.IsNaN(Target)) {
//没有数据 且之前能显示,不更新界面。
return;
}
} if (double.IsNaN(Average))
} return;
if (isAutoTarget) if (!double.IsNaN(Target))//之前有显示范围
{ {
if (!double.IsNaN(Target)) if (Average < ToleranceYMax && Average > ToleranceYMin)
{ {
if (profileParam.TolerancePercent == TolerancePercent) { //变化很小, 不调整显示
//公差没变 return;
if (target < ToleranceYMax && target > ToleranceYMin) {
//变化很小, 不调整显示
return;
}
}
} }
} }
Target = Average;
double tolerance = this.profileParam.TolerancePercent * target; PropertyChanged_Target_Tolerance_YRangePercent();
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
TolerancePercent = profileParam.TolerancePercent;
Target = target;
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