|
|
|
@ -742,7 +742,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "TOTAL_DEPTH"; |
|
|
|
|
info.TestItemName = GetName("TOTAL_DEPTH"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TOTAL_DEPTH*100,Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TOTAL_DEPTH*100,Accuracy.ForceOneDecimal); |
|
|
|
|
info.CutLevel = calGrade_TOTAL_DEPTH(result.Measurements.TOTAL_DEPTH); |
|
|
|
|
info.isEnabled = false; |
|
|
|
|
return info; |
|
|
|
@ -754,7 +754,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "TABLE"; |
|
|
|
|
info.TestItemName = GetName("TABLE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TABLE*100, Accuracy.ZD5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TABLE*100, Accuracy.IntegerFloor); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.TABLE_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.TABLE_MAX); |
|
|
|
|
info.CutLevel = calGrade_TABLE(result.Measurements.TABLE_MIN, result.Measurements.TABLE_MAX); |
|
|
|
@ -776,7 +776,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "CROWN_ANGLE"; |
|
|
|
|
info.TestItemName = GetName("CROWN_ANGLE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CROWN_ANGLE, Accuracy.ZD5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CROWN_ANGLE, Accuracy.DecimalTwoStepRounding); |
|
|
|
|
info.Dev = FormatDouble_A(result.Measurements.CROWN_ANGLE_DEV); |
|
|
|
|
info.Min = FormatDouble_A(result.Measurements.CROWN_ANGLE_MIN); |
|
|
|
|
info.Max = FormatDouble_A(result.Measurements.CROWN_ANGLE_MAX); |
|
|
|
@ -804,7 +804,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "CROWN_HEIGHT"; |
|
|
|
|
info.TestItemName = GetName("CROWN_HEIGHT"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CROWN_HEIGHT * 100, Accuracy.ZD5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CROWN_HEIGHT * 100, Accuracy.HalfStepRounding); |
|
|
|
|
info.Dev = FormatDouble_P(result.Measurements.CROWN_H_DEV); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.CROWN_H_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.CROWN_H_MAX); |
|
|
|
@ -832,7 +832,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "GIRDLE_BEZEL"; |
|
|
|
|
info.TestItemName = GetName("GIRDLE_BEZEL"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_BEZEL * 100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_BEZEL * 100, Accuracy.ForceOneDecimal); |
|
|
|
|
info.Dev = FormatDouble_P(result.Measurements.GIRDLE_BEZEL_DEV); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.GIRDLE_BEZEL_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.GIRDLE_BEZEL_MAX); |
|
|
|
@ -859,7 +859,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "GIRDLE_BONE"; |
|
|
|
|
info.TestItemName = GetName("GIRDLE_BONE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_BONE * 100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_BONE * 100, Accuracy.ForceOneDecimal); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.GIRDLE_BONE_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.GIRDLE_BONE_MAX); |
|
|
|
|
info.isEnabled = false; |
|
|
|
@ -886,7 +886,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "GIRDLE"; |
|
|
|
|
info.TestItemName = GetName("GIRDLE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_VALLEY * 100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.GIRDLE_VALLEY * 100, Accuracy.HalfStepRounding); |
|
|
|
|
info.Dev = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_DEV); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MAX); |
|
|
|
@ -936,7 +936,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "PAV_ANGLE"; |
|
|
|
|
info.TestItemName = GetName("PAV_ANGLE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.PAV_ANGLE, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.PAV_ANGLE, Accuracy.DecimalTwoStepRounding); |
|
|
|
|
info.Dev = FormatDouble_A(result.Measurements.PAV_ANGLE_DEV); |
|
|
|
|
info.Min = FormatDouble_A(result.Measurements.PAV_ANGLE_MIN); |
|
|
|
|
info.Max = FormatDouble_A(result.Measurements.PAV_ANGLE_MAX); |
|
|
|
@ -964,7 +964,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "PAV_DEPTH"; |
|
|
|
|
info.TestItemName = GetName("PAV_DEPTH"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.PAV_DEPTH*100, Accuracy.ZD5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.PAV_DEPTH*100, Accuracy.HalfStepRounding); |
|
|
|
|
info.Dev = FormatDouble_P(result.Measurements.PAV_DEPTH_DEV); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.PAV_DEPTH_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.PAV_DEPTH_MAX); |
|
|
|
@ -993,7 +993,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "STAR"; |
|
|
|
|
info.TestItemName = GetName("STAR"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.STAR*100, Accuracy.Z5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.STAR*100, Accuracy.MultipleOfFive); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.STAR_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.STAR_MAX); |
|
|
|
|
info.CutLevel = calGrade_STAR(result.Measurements.STAR_MIN, result.Measurements.STAR_MAX); |
|
|
|
@ -1019,7 +1019,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "LOWER_HALVES_RATIO"; |
|
|
|
|
info.TestItemName = GetName("LOWER_HALVES_RATIO"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.LOWER_HALVES_RATIO*100, Accuracy.Z5); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.LOWER_HALVES_RATIO*100, Accuracy.MultipleOfFive); |
|
|
|
|
info.Min = FormatDouble_P(result.Measurements.LOWER_HALVES_RATIO_MIN); |
|
|
|
|
info.Max = FormatDouble_P(result.Measurements.LOWER_HALVES_RATIO_MAX); |
|
|
|
|
info.CutLevel = calGrade_LOWER_HALVES_RATIO(result.Measurements.LOWER_HALVES_RATIO_MIN, result.Measurements.LOWER_HALVES_RATIO_MAX); |
|
|
|
@ -1045,7 +1045,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "CULET"; |
|
|
|
|
info.TestItemName = GetName("CULET"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CULET * 100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CULET * 100, Accuracy.ForceOneDecimal); |
|
|
|
|
info.CutLevel = calGrade_CULET(result.Measurements.CULET); |
|
|
|
|
info.isEnabled = false; |
|
|
|
|
|
|
|
|
@ -1058,7 +1058,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "TOC"; |
|
|
|
|
info.TestItemName = GetName("TOC"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TOC * 100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TOC * 100, Accuracy.ForceOneDecimal); |
|
|
|
|
var data = result.Measurements; |
|
|
|
|
info.SymLevel = calGradeSym(info.TestItemId, data.TOC * 100); |
|
|
|
|
|
|
|
|
@ -1071,7 +1071,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "COC"; |
|
|
|
|
info.TestItemName = GetName("COC"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.COC*100, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.COC*100, Accuracy.ForceOneDecimal); |
|
|
|
|
var data = result.Measurements; |
|
|
|
|
info.SymLevel = calGradeSym(info.TestItemId, data.COC * 100); |
|
|
|
|
return info; |
|
|
|
@ -1084,7 +1084,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "TWIST"; |
|
|
|
|
info.TestItemName = GetName("TWIST"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TWIST, Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.TWIST, Accuracy.ForceOneDecimal); |
|
|
|
|
info.Dev = FormatDouble_A(result.Measurements.TWIST_DEV); |
|
|
|
|
info.Min = FormatDouble_A(result.Measurements.TWIST_MIN); |
|
|
|
|
info.Max = FormatDouble_A(result.Measurements.TWIST_MAX); |
|
|
|
@ -1111,7 +1111,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
DataInfo info = new DataInfo(); |
|
|
|
|
info.TestItemId = "CULET_TO_TABLE"; |
|
|
|
|
info.TestItemName = GetName("CULET_TO_TABLE"); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CULET_TO_TABLE*100,Accuracy.ZD1); |
|
|
|
|
info.Avg = FormatDouble_Avg(result.Measurements.CULET_TO_TABLE*100,Accuracy.ForceOneDecimal); |
|
|
|
|
var data = result.Measurements; |
|
|
|
|
info.SymLevel = calGradeSym(info.TestItemId, data.CULET_TO_TABLE * 100); |
|
|
|
|
return info; |
|
|
|
@ -1654,21 +1654,52 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
private string FormatDouble_Avg(double value, Accuracy accuracy) |
|
|
|
|
{ |
|
|
|
|
string result = ""; |
|
|
|
|
switch (accuracy) |
|
|
|
|
if (Common.RunMode == 0) |
|
|
|
|
{ |
|
|
|
|
case Accuracy.ZDZ1: |
|
|
|
|
result = (Math.Floor(value * 100) / 100).ToString("f2"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.ZD1: |
|
|
|
|
result = (Math.Floor(value * 10) / 10).ToString(digitsFormat); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.ZD5: |
|
|
|
|
result = (RoundFiveDownSixUp(value * 2) / 2).ToString("f1"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.Z5: |
|
|
|
|
result = (RoundFiveDownSixUp(value / 5) * 5).ToString(); |
|
|
|
|
break; |
|
|
|
|
switch (accuracy) |
|
|
|
|
{ |
|
|
|
|
case Accuracy.ForceTwoDecimals: |
|
|
|
|
result = (Math.Floor(value * 100) / 100).ToString("f2"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.ForceOneDecimal: |
|
|
|
|
result = (Math.Floor(value * 10) / 10).ToString("f1"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.HalfStepRounding: |
|
|
|
|
result = (RoundFiveDownSixUp(value * 2) / 2).ToString("f1"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.MultipleOfFive: |
|
|
|
|
result = (RoundFiveDownSixUp(value / 5) * 5).ToString(); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.DecimalTwoStepRounding: |
|
|
|
|
result = RoundToPointTwo(value).ToString("f1"); // 保留1位小数 |
|
|
|
|
break; |
|
|
|
|
case Accuracy.IntegerFloor: |
|
|
|
|
result = Math.Floor(value).ToString(); // 直接取整 |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//工厂模式不量化 |
|
|
|
|
switch (accuracy) |
|
|
|
|
{ |
|
|
|
|
case Accuracy.ForceTwoDecimals: |
|
|
|
|
result = (Math.Floor(value * 100) / 100).ToString("f2"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.HalfStepRounding: |
|
|
|
|
case Accuracy.ForceOneDecimal: |
|
|
|
|
case Accuracy.DecimalTwoStepRounding: |
|
|
|
|
result = (Math.Floor(value * 10) / 10).ToString("f1"); |
|
|
|
|
break; |
|
|
|
|
case Accuracy.IntegerFloor: |
|
|
|
|
case Accuracy.MultipleOfFive: |
|
|
|
|
result = Math.Floor(value).ToString(); // 直接取整 |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
[Log] |
|
|
|
@ -1680,14 +1711,16 @@ public class GradingResultVM : BaseViewModel |
|
|
|
|
double fractionalPart = value - integerPart; |
|
|
|
|
|
|
|
|
|
// 判断小数部分是否大于 0.5 |
|
|
|
|
if (fractionalPart > 0.5) |
|
|
|
|
{ |
|
|
|
|
return integerPart + 1; // 大于 0.5,进一 |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
return integerPart; // 小于或等于 0.5,舍去 |
|
|
|
|
} |
|
|
|
|
return fractionalPart > 0.5 ? integerPart + 1 : integerPart; |
|
|
|
|
} |
|
|
|
|
private static double RoundToPointTwo(double value) |
|
|
|
|
{ |
|
|
|
|
// 转换到10倍精度空间处理 |
|
|
|
|
double scaled = value * 10; |
|
|
|
|
double remainder = scaled % 2; // 求模得到余数 |
|
|
|
|
|
|
|
|
|
// 核心舍入规则:余数>=1.5时进位 |
|
|
|
|
return remainder >= 1.5 ? (scaled - remainder + 2) / 10 : (scaled - remainder) / 10; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 直接值(角度,直径)用的小数格式化 |
|
|
|
@ -2866,8 +2899,16 @@ public enum SaveStatus |
|
|
|
|
|
|
|
|
|
public enum Accuracy |
|
|
|
|
{ |
|
|
|
|
ZDZ1 = 0, |
|
|
|
|
ZD1 = 1, |
|
|
|
|
ZD5 = 2, |
|
|
|
|
Z5 = 3 |
|
|
|
|
[Description("强制保留两位小数,向下取整(ZDZ1)")] |
|
|
|
|
ForceTwoDecimals, |
|
|
|
|
[Description("强制保留一位小数,向下取整(ZD1)")] |
|
|
|
|
ForceOneDecimal, |
|
|
|
|
[Description("将数值舍入到最近的 0.5 倍数(ZD5)")] |
|
|
|
|
HalfStepRounding, |
|
|
|
|
[Description("将数值舍入到最近的 5 的整数倍(Z5)")] |
|
|
|
|
MultipleOfFive, |
|
|
|
|
[Description("将数值舍入到最近的0.2倍数(ZD2)")] |
|
|
|
|
DecimalTwoStepRounding, |
|
|
|
|
[Description("强制向下取整为整数(Floor)")] |
|
|
|
|
IntegerFloor |
|
|
|
|
} |