Commit 3ece0d23 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 扫描图,即时图,纵向图,当均值<5时,不能以%显示。

parent 60b9f44a
...@@ -21,6 +21,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -21,6 +21,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
const int MARKNO_TEXTUP = 1; const int MARKNO_TEXTUP = 1;
const int MARKNO_TARGET_DELAY = 2; const int MARKNO_TARGET_DELAY = 2;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
#region 图表控制 #region 图表控制
public double YMax { get; set; } = double.NaN; public double YMax { get; set; } = double.NaN;
public double YMin { get; set; } = double.NaN; public double YMin { get; set; } = double.NaN;
...@@ -115,10 +124,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -115,10 +124,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin //只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = ""; string text = "";
if (graphparam.IsPercent)
{
double target = Target; double target = Target;
if (target > 0) if (graphparam.IsPercent && target > MIN_PERCENT_TARGET)
{ {
if (y == target) if (y == target)
{ {
...@@ -141,11 +148,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -141,11 +148,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
text = y.ToString("F1"); text = y.ToString("F1");
} }
}
else
{
text = y.ToString("F1");
}
return $"{text,6}"; return $"{text,6}";
}; };
...@@ -315,6 +317,10 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -315,6 +317,10 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
double tolerance = this.profileParam.TolerancePercent * target; double tolerance = this.profileParam.TolerancePercent * target;
//确保没有负数,Y轴显示范围正确
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
Target = target; Target = target;
ToleranceYMax = target + tolerance; ToleranceYMax = target + tolerance;
ToleranceYMin = target - tolerance; ToleranceYMin = target - tolerance;
...@@ -342,7 +348,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -342,7 +348,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
PollModule.Current.Poll_JustOnce(() => PollModule.Current.Poll_JustOnce(() =>
{ {
if (graphparam.IsPercent && (Average > 0)) if (graphparam.IsPercent && (Average > MIN_PERCENT_TARGET))
{ {
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%"; MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%"; MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
......
...@@ -22,6 +22,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -22,6 +22,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
const int MARKNO_TEXTUP = 1; const int MARKNO_TEXTUP = 1;
const int MARKNO_TARGET_DELAY = 2; const int MARKNO_TARGET_DELAY = 2;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
#region 图表控制 #region 图表控制
public double YMax { get; set; } = double.NaN; public double YMax { get; set; } = double.NaN;
public double YMin { get; set; } = double.NaN; public double YMin { get; set; } = double.NaN;
...@@ -103,10 +112,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -103,10 +112,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin //只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = ""; string text = "";
if (graphparam.IsPercent)
{
double target = Target; double target = Target;
if (target > 0) if (graphparam.IsPercent && target > MIN_PERCENT_TARGET)
{ {
if (y == target) if (y == target)
{ {
...@@ -129,13 +136,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -129,13 +136,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
text = y.ToString("F1"); text = y.ToString("F1");
} }
}
else
{
text = y.ToString("F1");
}
return $"{text,6}"; return $"{text,6}";
}; };
XFormatter = (x) => XFormatter = (x) =>
{ {
//全部+1 //全部+1
...@@ -403,7 +406,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -403,7 +406,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
double tolerance = this.profileParam.TolerancePercent * target; double tolerance = this.profileParam.TolerancePercent * target;
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
TolerancePercent = profileParam.TolerancePercent; TolerancePercent = profileParam.TolerancePercent;
Target = target; Target = target;
...@@ -433,7 +437,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -433,7 +437,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
} }
protected void UpdateMaxMinText() protected void UpdateMaxMinText()
{ {
if (graphparam.IsPercent && (Average > 0)) if (graphparam.IsPercent && (Average > MIN_PERCENT_TARGET))
{ {
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%"; MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%"; MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
......
...@@ -20,6 +20,14 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -20,6 +20,14 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
/// </summary> /// </summary>
const int AutoKeepTotalSec = 60; const int AutoKeepTotalSec = 60;
const int Len = 100; const int Len = 100;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
...@@ -127,37 +135,40 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -127,37 +135,40 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
return ""; return "";
}; };
MapperPositive = Mappers.Xy<TrendValue>() MapperPositive = Mappers.Xy<TrendValue>()
.X((value, index) => .X((value, index) => index)
{ .Y(value => ToSigma2Percent(value))
return index; .Fill((value) => ToBrush(value));
})
.Y(value => 2 * value.Sigma / value.Value) MapperNegative = Mappers.Xy<TrendValue>()
.Fill((value) => .X((value, index) => index)
{ .Y(value => -ToSigma2Percent(value))
double percent = 2 * value.Sigma / value.Value; .Fill((value) => ToBrush(value));
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
MapperValue = Mappers.Xy<TrendValue>()
.X((value, index) => index)
.Y(value => value.Value)
.Stroke((value) =>
{ {
return AreaColors[2]; if (value.ProfileID % 2 == 0)
}
else if ((percent > ToleranceYMax) || (percent < -ToleranceYMax))
{ {
return AreaColors[1]; return null;
} }
else else
{ {
return AreaColors[0]; return System.Windows.Media.Brushes.DarkBlue;
} }
}); });
MapperNegative = Mappers.Xy<TrendValue>() #endregion
.X((value, index) => }
Brush ToBrush(TrendValue value)
{ {
return index; double percent = ToSigma2Percent(value);
}) if (double.IsNaN(percent))
.Y(value => -2 * value.Sigma / value.Value)
.Fill((value) =>
{ {
double percent = 2 * value.Sigma / value.Value; return AreaColors[0];
}
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax)) if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
{ {
return AreaColors[2]; return AreaColors[2];
...@@ -170,27 +181,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -170,27 +181,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{ {
return AreaColors[0]; return AreaColors[0];
} }
});
MapperValue = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => value.Value)
.Stroke((value) =>
{
if (value.ProfileID % 2 == 0)
{
return null;
}
else
{
return System.Windows.Media.Brushes.DarkBlue;
}
});
#endregion
} }
public void Init( public void Init(
TrendGraphItemParam graphparam, TrendGraphItemParam graphparam,
...@@ -275,7 +265,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -275,7 +265,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
void UpdateY() void UpdateY()
{ {
double tolerance = this.profileParam.TolerancePercent; double tolerance = this.profileParam.TolerancePercent;
if (tolerance < MIN_TOLERANCE) {
tolerance = MIN_TOLERANCE;
}
ToleranceYMax = tolerance; ToleranceYMax = tolerance;
ToleranceYMin = -tolerance; ToleranceYMin = -tolerance;
Tolerance2YMax = tolerance * 2; Tolerance2YMax = tolerance * 2;
...@@ -307,9 +299,25 @@ namespace FLY.Thick.FilmCasting.UI.UiModule ...@@ -307,9 +299,25 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
} }
} }
} }
double ToSigma2Percent(TrendValue v)
{
if (double.IsNaN(v.Value))
{
return double.NaN;
}
else if (v.Value < MIN_PERCENT_TARGET)
{
return double.NaN;
}
else
{
return 2 * v.Sigma / v.Value;
}
}
void UpdateAverage() void UpdateAverage()
{ {
var sigma2s = this.Values.Select(v => 2 * v.Sigma / v.Value); var sigma2s = this.Values.Select(v => ToSigma2Percent(v));
var list = from v in sigma2s where !double.IsNaN(v) select v; var list = from v in sigma2s where !double.IsNaN(v) select v;
......
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