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

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

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