using System; using System.IO; using System.Text; using System.Xml.Serialization; using TBF.BenchControl.Generic; using TBF.Resources; namespace TBF.BenchControl.Elde.PumpWithFM { public class FMPumpTestParams : TestParamsBase, IParamsProvider, ITestParams { public float Power; /// Target=terminal flow durning detection when increasing or decreasing the flow public override void InitializeAll() { Power = 50.0f; } string[] paramNames = new string[] { Strings.PowerPct, }; public override string ParamName(int i) { return paramNames[i]; } public override int ParamsCount() { return paramNames.Length; } public override string ToString(int i) { switch (i) { case 0: return Power.ToString("F1"); default: return string.Empty; } } public void UpdateParam(int i, string strValue) { switch (i) { case 0: Power = Utils.ParseUFloat(strValue); return; default: return; } } public bool ValidateParam(int i, string strValue, out string message) { message = string.Empty; float dummy; switch (i) { case 0: if (Utils.TryParseUFloat(strValue, out dummy)) return true; break; default: message = "Invalid index"; return false; } message = ParamName(i) + " is invalid"; return false; } public override void UpdateTestParams(Entities.ComponentTest dbEntity) { if (dbEntity == null) return; try { FMPumpTestParams tmp = (FMPumpTestParams)(new XmlSerializer(typeof(FMPumpTestParams))) .Deserialize(new StringReader(dbEntity.Parameters)); testParamsEntity = dbEntity; componentName = dbEntity.CmpntName; test = dbEntity.Test; Power = tmp.Power; } catch { } } /// Parameterless constructor public FMPumpTestParams() { } public FMPumpTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test) { this.testParamsEntity = testParamsEntity; this.componentName = componentName; this.test = test; } } }