using System; using System.Collections.Generic; namespace TProduct.Model { /// /// 测试设定 /// public class WorkBenchSetting4Valve { public WorkBenchSetting4Valve() { } public WorkBenchSetting4Valve(string jsonString) { FromJsonString(jsonString); } public WorkBenchSetting4Valve(WorkBenchSetting4Valve rhs) { this.IsTemperatureTrn = rhs.IsTemperatureTrn; this.Elevation = rhs.Elevation; this.AtmosphericPressure = rhs.AtmosphericPressure; this.IsAutoTestAble = rhs.IsAutoTestAble; this.IsOperateValveDegree = rhs.IsOperateValveDegree; } public void FromJsonString(string jsonString) { if (string.IsNullOrEmpty(jsonString)) return; Dictionary dict = (new System.Web.Script.Serialization.JavaScriptSerializer()).Deserialize(jsonString, typeof(Dictionary)) as Dictionary; if (dict.ContainsKey("TempTrn")) this.IsTemperatureTrn = Convert.ToBoolean(dict["TempTrn"]); if (dict.ContainsKey("Ele")) this.Elevation = Convert.ToDouble(dict["Ele"]); if (dict.ContainsKey("AP")) this.AtmosphericPressure = Convert.ToDouble(dict["AP"]); if (dict.ContainsKey("IAT")) this.IsAutoTestAble = Convert.ToBoolean(dict["IAT"]); if (dict.ContainsKey("OVD")) this.IsOperateValveDegree = Convert.ToBoolean(dict["OVD"]); } #region Model /// /// 是否温度换算 /// public bool IsTemperatureTrn { get; set; } /// /// 海拔(m) /// public double Elevation { set; get; } = 100; /// /// 大气压(KPa) /// public double AtmosphericPressure { set; get; } = 0; /// /// 是否支持自动测试 /// public bool IsAutoTestAble { get; set; } = false; /// /// 是否支持操控阀门开度 /// public bool IsOperateValveDegree { get; set; } = false; #endregion Model /// /// ToJson /// public string ToJsonString() { Dictionary dict = new Dictionary(); dict["TempTrn"] = this.IsTemperatureTrn.ToString(); dict["Ele"] = this.Elevation.ToString(); dict["AP"] = this.AtmosphericPressure.ToString(); dict["IAT"] = this.IsAutoTestAble.ToString(); dict["OVD"] = this.IsOperateValveDegree.ToString(); string json = (new System.Web.Script.Serialization.JavaScriptSerializer()).Serialize(dict); return json; } } }