diff --git a/MP.MONO.Core/DTO/DisplayDataDTO.cs b/MP.MONO.Core/DTO/DisplayDataDTO.cs index e763a47..dfc4bd2 100644 --- a/MP.MONO.Core/DTO/DisplayDataDTO.cs +++ b/MP.MONO.Core/DTO/DisplayDataDTO.cs @@ -16,6 +16,7 @@ namespace MP.MONO.Core.DTO public string Title { get; set; } = ""; public string Value { get; set; } = ""; public double ValueNum { get; set; } = 0; + public string DisplFormat { get; set; } = "N0"; public double MinVal { get; set; } = 0; public double MaxVal { get; set; } = 0; public bool IsNumeric { get; set; } = false; diff --git a/MachineSim/SimParams.json b/MachineSim/SimParams.json index 39c30db..d5d495e 100644 --- a/MachineSim/SimParams.json +++ b/MachineSim/SimParams.json @@ -8,7 +8,8 @@ "MinVal": 1000, "MaxVal": 10000, "SimMean": 100, - "SimStd": 50 + "SimStd": 50, + "DisplFormat": "N0" }, { "Order": 0, @@ -19,18 +20,20 @@ "MinVal": 1000, "MaxVal": 5000, "SimMean": 50, - "SimStd": 5 + "SimStd": 5, + "DisplFormat": "N0" }, { "Order": 0, "Type": "LOAD", "Title": "SPINDLE LOAD", - "Value": "0", - "ValueNum": 0, + "Value": "30", + "ValueNum": 30, "MinVal": 0, "MaxVal": 100, "SimMean": 5, - "SimStd": 1 + "SimStd": 1, + "DisplFormat": "N1" }, { "Order": 0, @@ -41,7 +44,8 @@ "MinVal": 0, "MaxVal": 5000, "SimMean": 100, - "SimStd": 20 + "SimStd": 20, + "DisplFormat": "N2" }, { "Order": 0, @@ -52,7 +56,8 @@ "MinVal": 0, "MaxVal": 10000, "SimMean": 100, - "SimStd": 10 + "SimStd": 10, + "DisplFormat": "N2" }, { "Order": 0, @@ -63,6 +68,7 @@ "MinVal": -3000, "MaxVal": 0, "SimMean": 50, - "SimStd": 5 + "SimStd": 5, + "DisplFormat": "N2" } ] \ No newline at end of file diff --git a/MachineSim/Simulator.cs b/MachineSim/Simulator.cs index fbdeefe..c3bc040 100644 --- a/MachineSim/Simulator.cs +++ b/MachineSim/Simulator.cs @@ -70,13 +70,14 @@ namespace MachineSim Order = i.Order, Title = i.Title, Type = i.Type, - ValueNum = getNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd) + ValueNum = getNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd), + DisplFormat = i.DisplFormat //Value = $"{getNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd):N3}", }).ToList(); foreach (var item in answ) { - item.Value = $"{item.ValueNum:N3}"; + item.Value = $"{item.ValueNum.ToString(item.DisplFormat)}"; } // !!!FIXME TODO... รจ fake...