diff --git a/TODO.txt b/TODO.txt index 292755469..3ca4c3b76 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,7 @@ - dokoncenie process obrazovky - brat desatinnu bodku aj ciarku - dat zapamatanie polohy RV do Parametrov +- moznost prepinania klapky to Transition sekvencii (aby sa dala kontrolovat tesnost ventilov) - Transitions sa nedaju vymazat - kroky v transitions sa nedaju vymazat diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index e551e1144..30ea0ceb2 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -31,8 +31,10 @@ namespace TBF.BenchControl Factories.Add(new DataEntry.WMStates.EntryFormFactory()); Factories.Add(new Greco.AmbientFactory()); Factories.Add(new Cameras.IdcCamera.IdcCameraFactory()); + Factories.Add(new TestMethods.LeakTest.TestMethodFactory()); Factories.Add(new MettlerToledo.BalanceFactory()); Factories.Add(new MettlerToledo.BalanceNewFactory()); + Factories.Add(new TestMethods.PMaxTest.TestMethodFactory()); Factories.Add(new Elde.PressureMeter.PressureMeterFactory()); Factories.Add(new Elde.Pump.PumpFactory()); Factories.Add(new Danfoss.VLT2800.PumpFactory()); diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestParams.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestParams.cs new file mode 100644 index 000000000..5ffb1f186 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestParams.cs @@ -0,0 +1,114 @@ +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public class LeakTestParams : TestParamsBase, IParamsProvider, ITestParams + { + public float PressureLo; /// Presure range low limit in bar + public float PressureHi; /// Presure range high limit in bar + public int Duration; /// Duration of the test in [s] + + public override void InitializeAll() + { + PressureLo = 1.0f; + PressureHi = 2.0f; + Duration = 10; + } + + + string[] paramNames = new string[] + { + Strings.PressureLo_bar, + Strings.PressureHi_bar, + Strings.Duration_s, + }; + 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 PressureLo.ToString(); + case 1: return PressureHi.ToString(); + case 2: return Duration.ToString(); + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: PressureLo = Utils.ParseUFloat(strValue); return; + case 1: PressureHi = Utils.ParseSFloat(strValue); return; + case 2: Duration = int.Parse(strValue); return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + float dummy; + int iDummy; + switch (i) + { + case 0: + case 1: + if (Utils.TryParseUFloat(strValue, out dummy)) return true; + break; + case 2: + if (int.TryParse(strValue, out iDummy)) 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 + { + LeakTestParams tmp = (LeakTestParams)(new XmlSerializer(typeof(LeakTestParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + PressureLo = tmp.PressureLo; + PressureHi = tmp.PressureHi; + Duration = tmp.Duration; + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public LeakTestParams() + { + } + + public LeakTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs new file mode 100644 index 000000000..320b4c91a --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Text; +using log4net; +using TBF.BenchControl; +using TBF.Boxes; +using TBF.Resources; +using TBF.UiBridge; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public class LeakTestSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(LeakTestSeq)); + + /// + /// Flying start mass collection method sequence + /// + /// Test entity + /// + /// Event.Done . . . . . . . OK + /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP + /// Event.OpArgumentError . Target flow is out of range + /// Event.Error . . . . . . Unspecified error + /// + public IList Execute(Entities.Test test, LeakTestParams testParams) + { + Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + + IList e = new List(); /// Events from currently running operations + Event retVal = Event.Done; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + + ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] + + /// Notes: + /// float timeHr = volumeLtr / (1000.0f * targetFlow); + /// float timeSec = 3600.0f * timeHr; + /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); + int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f); + + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); + + int repetitionNr = 1; /// First test: repetitionNr=1 + + //==================================== + // Transition or SetRoute - Start + //==================================== + switch (Transition(transitionStart, TransitionContext.TestStart)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + + /// Start the test, initialize test results + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); + Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Starting_the_pump); + //------------------------------------------------ + int flowSetTime0 = StateMachine.Time; + float estFlowSetTime = 10.0f; + + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + + State.Create("LeakTest : Starting the pump") + .AddOperation(checkUiOp) + .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Setting_the_water_pressure); + //------------------------------------------------ + + const float pumpPowerStep = 3.0f; + float pumpPower = test.PumpPower; + int startTime = StateMachine.Time; + do + { + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(pumpPower); + + State.Create("LeakTest : Setting the water pressure") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .AddOperation(new Operations.TimerOp(5)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Next)) goto pressure_set; + } + while (e.Contains(Event.TimerBusy)); + + UiBridge.Bridge.OnLog(this, string.Format("time = {0}, pump_power = {1}%, pressure_up = {2}, pressure_down = {3}\r\n", + StateMachine.Time - startTime, + pumpPower.ToString("F0"), + pressIn.Val.ToString("F3"), + pressIn.Val.ToString("F3"))); + + if (pumpPower == 100.0f) break; /// Already at the max.pump power + + pumpPower += pumpPowerStep; + if (pumpPower >= 100.0f) pumpPower = 100.0f; /// Max. 100% + } + while (testParams.PressureLo <= pressOut.Val && pressOut.Val <= testParams.PressureHi); + + pressure_set: + + int time = StateMachine.Time; + tstRslt.TimeStart = DateTime.Now; + ResetAveragedData(); + bool firstTime = true; + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + State.Create("LeakTest : Starting the test") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .AddOperation(new Operations.TimerOp(testParams.Duration)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + + if (firstTime) + { + firstTime = false; /// Do the following only once + tstRslt.TempInStart = tempIn.Val; + tstRslt.TempOutStart = tempOut.Val; + tstRslt.TempDivStart = tempDiv.Val; + tstRslt.PressInStart = pressIn.Val; + tstRslt.PressOutStart = pressOut.Val; + } + + tstRslt.TempInEnd = tempIn.Val; + tstRslt.TempOutEnd = tempOut.Val; + tstRslt.TempDivEnd = tempDiv.Val; + tstRslt.PressInEnd = pressIn.Val; + tstRslt.PressOutEnd = pressOut.Val; + tstRslt.MassEndRaw = mass.Val; + + AccumulateAveragedData(); + } + while (e.Contains(Event.TimerBusy)); + + /// Measurement loop - end + + test_completed: + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + + /// + /// Populate TestResult data entity with data + /// + UpdateTestRsltWithAveragedData(tstRslt); + + tstRslt.TimeEnd = DateTime.Now; + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; + tstRslt.MassDiff = 0; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = testParams.Duration; /// [s] measurement time + tstRslt.FlowMass = 0; /// [kg/h] + tstRslt.FlowVolume = 0; /// [l/h] + tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total) + tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter + tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h] + tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ErrorMaster = 0; + tstRslt.TimeDivStart0 = 0; + tstRslt.TimeDivStart1 = 0; + tstRslt.TimeDivStart2 = 0; + tstRslt.TimeDivStart3 = 0; + tstRslt.TimeDivStart4 = 0; + tstRslt.TimeDivStart5 = 0; + tstRslt.TimeDivEnd0 = 0; + tstRslt.TimeDivEnd1 = 0; + tstRslt.TimeDivEnd2 = 0; + tstRslt.TimeDivEnd3 = 0; + tstRslt.TimeDivEnd4 = 0; + tstRslt.TimeDivEnd5 = 0; + + for (int i = 0; i < Program.WMsCount; i++) + { + if (sensPath.RegisterReaders[i] != null) + { + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].VolumeStart = 0; + tstRslt.Meters[i].VolumeEnd = 0; + tstRslt.Meters[i].VolumeMeter = 0; + tstRslt.Meters[i].VolumeRef = 0; + tstRslt.Meters[i].PulsesMeter = 0; + tstRslt.Meters[i].PulsesMaster = 0; + tstRslt.Meters[i].Time = testParams.Duration; + tstRslt.Meters[i].VolumeErrorPct= 0; + tstRslt.Meters[i].Passed = true; + } + } + /// Add data - end + + AddOrOverwriteResult(tstRslt); + + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt)); + + /// Append the results to the CSV-file + allResults.Info(TestResult2CsvLine(tstRslt)); + + + stopTest: + + ///----------------------/// + /// Quit this sequence /// + ///----------------------/// + + State.Create("LeakTest : Stopping diverter, gate, etc.") + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); + + /// Transition sequence at the end of test + /// Prevent overwriting 'retVal' in case it was set to non-default value earlier + switch (Transition(transitionStop, TransitionContext.TestEnd)) + { + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } + } + + /// Create a list with one item 'retVal' (default is Event.Done) and return it + IList retList = new List(1); + retList.Add(retVal); + return retList; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethod.cs new file mode 100644 index 000000000..594bec6bd --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethod.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using log4net; +using TBF.BenchControl; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public class TestMethod : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); + public override string ToString() { return string.Format("TestMethods.LeakTest({0})", Cfg.ToString(1)); } + + readonly TestMethodCfg testMethodCfg; + + public bool Evaluate { get { return true; } } + public bool Publish { get { return true; } } + public bool CanTest(Entities.MetersKind meters) { return true; } + + public TestMethod(TestMethodCfg cfg) + : base(cfg) + { + testMethodCfg = cfg; + log.Debug(this.ToString()); + } + + public IList Execute(Entities.Test test) + { + return (new LeakTestSeq()).Execute(test, testMethodCfg.TestParams); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfg.cs new file mode 100644 index 000000000..3a0f21083 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfg.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponent GetComponent(IList components) { return new TestMethod(this); } + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public LeakTestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Entities.Test test) + { + LeakTestParams testParams = new LeakTestParams(); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + Name = "Leak-Test"; + ParentName = string.Empty; + TestParams = new LeakTestParams(); + } + + public TestMethodCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..772457b74 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.cs @@ -0,0 +1,68 @@ +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); + + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..74286f9ce --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,83 @@ +namespace TBF.BenchControl.TestMethods.LeakTest +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodFactory.cs new file mode 100644 index 000000000..4a4b764bc --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/TestMethodFactory.cs @@ -0,0 +1,18 @@ +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.LeakTest +{ + public class TestMethodFactory : IComponentFactory + { + public string ClassName { get { return "Leak-Test"; } } + + public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestParams.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestParams.cs new file mode 100644 index 000000000..c55b83658 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestParams.cs @@ -0,0 +1,114 @@ +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public class PMaxTestParams : TestParamsBase, IParamsProvider, ITestParams + { + public float PressureLo; /// Presure range low limit in bar + public float PressureHi; /// Presure range high limit in bar + public int Duration; /// Duration of the test in [s] + + public override void InitializeAll() + { + PressureLo = 1.0f; + PressureHi = 2.0f; + Duration = 10; + } + + + string[] paramNames = new string[] + { + Strings.PressureLo_bar, + Strings.PressureHi_bar, + Strings.Duration_s, + }; + 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 PressureLo.ToString(); + case 1: return PressureHi.ToString(); + case 2: return Duration.ToString(); + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: PressureLo = Utils.ParseUFloat(strValue); return; + case 1: PressureHi = Utils.ParseSFloat(strValue); return; + case 2: Duration = int.Parse(strValue); return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + float dummy; + int iDummy; + switch (i) + { + case 0: + case 1: + if (Utils.TryParseUFloat(strValue, out dummy)) return true; + break; + case 2: + if (int.TryParse(strValue, out iDummy)) 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 + { + PMaxTestParams tmp = (PMaxTestParams)(new XmlSerializer(typeof(PMaxTestParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + PressureLo = tmp.PressureLo; + PressureHi = tmp.PressureHi; + Duration = tmp.Duration; + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public PMaxTestParams() + { + } + + public PMaxTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs new file mode 100644 index 000000000..0b2f3dc75 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Text; +using log4net; +using TBF.BenchControl; +using TBF.Boxes; +using TBF.Resources; +using TBF.UiBridge; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public class PMaxTestSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(PMaxTestSeq)); + + /// + /// Pressure test sequence + /// + /// Test entity + /// + /// Event.Done . . . . . . . OK + /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP + /// Event.OpArgumentError . Target flow is out of range + /// Event.Error . . . . . . Unspecified error + /// + public IList Execute(Entities.Test test, PMaxTestParams testParams) + { + Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + + IList e = new List(); /// Events from currently running operations + Event retVal = Event.Done; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + + ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] + + /// Notes: + /// float timeHr = volumeLtr / (1000.0f * targetFlow); + /// float timeSec = 3600.0f * timeHr; + /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); + int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f); + + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); + + int repetitionNr = 1; /// First test: repetitionNr=1 + + //==================================== + // Transition or SetRoute - Start + //==================================== + switch (Transition(transitionStart, TransitionContext.TestStart)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + + /// Start the test, initialize test results + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); + Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Starting_the_pump); + //------------------------------------------------ + int flowSetTime0 = StateMachine.Time; + float estFlowSetTime = 10.0f; + + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + + State.Create("PMaxTest : Starting the pump") + .AddOperation(checkUiOp) + .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Setting_the_water_pressure); + //------------------------------------------------ + + const float pumpPowerStep = 3.0f; + float pumpPower = test.PumpPower; + int startTime = StateMachine.Time; + do + { + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(pumpPower); + + State.Create("PMaxTest : Setting the water pressure") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .AddOperation(new Operations.TimerOp(5)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Next)) goto pressure_set; + } + while (e.Contains(Event.TimerBusy)); + + UiBridge.Bridge.OnLog(this, string.Format("time = {0}, pump_power = {1}%, pressure_up = {2}, pressure_down = {3}\r\n", + StateMachine.Time - startTime, + pumpPower.ToString("F0"), + pressIn.Val.ToString("F3"), + pressIn.Val.ToString("F3"))); + + if (pumpPower == 100.0f) break; /// Already at the max.pump power + + pumpPower += pumpPowerStep; + if (pumpPower >= 100.0f) pumpPower = 100.0f; /// Max. 100% + } + while (testParams.PressureLo <= pressOut.Val && pressOut.Val <= testParams.PressureHi); + + pressure_set: + + int time = StateMachine.Time; + tstRslt.TimeStart = DateTime.Now; + ResetAveragedData(); + bool firstTime = true; + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + State.Create("PMaxTest : Starting the test") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut)) + .AddOperation(new Operations.TimerOp(testParams.Duration)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + + if (firstTime) + { + firstTime = false; /// Do the following only once + tstRslt.TempInStart = tempIn.Val; + tstRslt.TempOutStart = tempOut.Val; + tstRslt.TempDivStart = tempDiv.Val; + tstRslt.PressInStart = pressIn.Val; + tstRslt.PressOutStart = pressOut.Val; + } + + tstRslt.TempInEnd = tempIn.Val; + tstRslt.TempOutEnd = tempOut.Val; + tstRslt.TempDivEnd = tempDiv.Val; + tstRslt.PressInEnd = pressIn.Val; + tstRslt.PressOutEnd = pressOut.Val; + tstRslt.MassEndRaw = mass.Val; + + AccumulateAveragedData(); + } + while (e.Contains(Event.TimerBusy)); + + /// Measurement loop - end + + test_completed: + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + + /// + /// Populate TestResult data entity with data + /// + UpdateTestRsltWithAveragedData(tstRslt); + + tstRslt.TimeEnd = DateTime.Now; + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; + tstRslt.MassDiff = 0; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = testParams.Duration; /// [s] measurement time + tstRslt.FlowMass = 0; /// [kg/h] + tstRslt.FlowVolume = 0; /// [l/h] + tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total) + tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter + tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h] + tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ErrorMaster = 0; + tstRslt.TimeDivStart0 = 0; + tstRslt.TimeDivStart1 = 0; + tstRslt.TimeDivStart2 = 0; + tstRslt.TimeDivStart3 = 0; + tstRslt.TimeDivStart4 = 0; + tstRslt.TimeDivStart5 = 0; + tstRslt.TimeDivEnd0 = 0; + tstRslt.TimeDivEnd1 = 0; + tstRslt.TimeDivEnd2 = 0; + tstRslt.TimeDivEnd3 = 0; + tstRslt.TimeDivEnd4 = 0; + tstRslt.TimeDivEnd5 = 0; + + for (int i = 0; i < Program.WMsCount; i++) + { + if (sensPath.RegisterReaders[i] != null) + { + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].VolumeStart = 0; + tstRslt.Meters[i].VolumeEnd = 0; + tstRslt.Meters[i].VolumeMeter = 0; + tstRslt.Meters[i].VolumeRef = 0; + tstRslt.Meters[i].PulsesMeter = 0; + tstRslt.Meters[i].PulsesMaster = 0; + tstRslt.Meters[i].Time = testParams.Duration; + tstRslt.Meters[i].VolumeErrorPct= 0; + tstRslt.Meters[i].Passed = true; + } + } + /// Add data - end + + AddOrOverwriteResult(tstRslt); + + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt)); + + /// Append the results to the CSV-file + allResults.Info(TestResult2CsvLine(tstRslt)); + + + stopTest: + + ///----------------------/// + /// Quit this sequence /// + ///----------------------/// + + State.Create("PMaxTest : Stopping diverter, gate, etc.") + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); + + /// Transition sequence at the end of test + /// Prevent overwriting 'retVal' in case it was set to non-default value earlier + switch (Transition(transitionStop, TransitionContext.TestEnd)) + { + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } + } + + /// Create a list with one item 'retVal' (default is Event.Done) and return it + IList retList = new List(1); + retList.Add(retVal); + return retList; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethod.cs new file mode 100644 index 000000000..876b14a6c --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethod.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using log4net; +using TBF.BenchControl; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public class TestMethod : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); + public override string ToString() { return string.Format("TestMethods.PMaxTest({0})", Cfg.ToString(1)); } + + readonly TestMethodCfg testMethodCfg; + + public bool Evaluate { get { return true; } } + public bool Publish { get { return true; } } + public bool CanTest(Entities.MetersKind meters) { return true; } + + public TestMethod(TestMethodCfg cfg) + : base(cfg) + { + testMethodCfg = cfg; + log.Debug(this.ToString()); + } + + public IList Execute(Entities.Test test) + { + return (new PMaxTestSeq()).Execute(test, testMethodCfg.TestParams); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfg.cs new file mode 100644 index 000000000..6e93b3f63 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfg.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponent GetComponent(IList components) { return new TestMethod(this); } + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public PMaxTestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Entities.Test test) + { + PMaxTestParams testParams = new PMaxTestParams(); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + Name = "PMax-Test"; + ParentName = string.Empty; + TestParams = new PMaxTestParams(); + } + + public TestMethodCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..654311cd1 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.cs @@ -0,0 +1,68 @@ +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); + + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..aeb53d743 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,83 @@ +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodFactory.cs new file mode 100644 index 000000000..b090ffeb0 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/TestMethodFactory.cs @@ -0,0 +1,18 @@ +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.PMaxTest +{ + public class TestMethodFactory : IComponentFactory + { + public string ClassName { get { return "PMax-Test"; } } + + public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index 325b2682c..5ea56654a 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -1141,28 +1141,34 @@ namespace TBF Test test = new Test(newName, listViewEx.Items.Count, LoadedProcedure); /// Run a create new test wizard - TestWizard.FlowSelection flowDlg = new TestWizard.FlowSelection(test); - TestWizard.MethodSelection methodDlg = new TestWizard.MethodSelection(test, TestMethods, metersPaths); - TestWizard.VolumeAndErrorSelection volumeDlg = new TestWizard.VolumeAndErrorSelection(test); + TestWizard.MethodSelection methodDlg = new TestWizard.MethodSelection(true, false, test, TestMethods); + TestWizard.FlowSelection flowDlg = new TestWizard.FlowSelection(false, false, test, metersPaths); + TestWizard.VolumeAndErrorSelection volumeDlg = new TestWizard.VolumeAndErrorSelection(false, true, test); + TestWizard.PressureSelection pressureDlg = new TestWizard.PressureSelection(false, true, test); //TestWizard.SensorsSelection sensorsDlg = new TestWizard.SensorsSelection(test); - flowLabel: - switch (flowDlg.ShowDialog()) - { - case DialogResult.Cancel: return; - } - methodLabel: switch (methodDlg.ShowDialog()) { case DialogResult.Cancel: return; - case DialogResult.Retry: goto flowLabel; + } + + ITestMethod selectedMethod = TestMethods.FirstOrDefault(x => x.Name.Equals(test.Method)); + + if (selectedMethod is BenchControl.TestMethods.PMaxTest.TestMethod) goto pressure_label; + if (selectedMethod is BenchControl.TestMethods.LeakTest.TestMethod) goto pressure_label; + + flowLabel: + switch (flowDlg.ShowDialog()) + { + case DialogResult.Cancel: return; + case DialogResult.Retry: goto methodLabel; } switch (volumeDlg.ShowDialog()) { case DialogResult.Cancel: return; - case DialogResult.Retry: goto methodLabel; + case DialogResult.Retry: goto flowLabel; } /// Depending on the chosen Q select the paths @@ -1192,6 +1198,18 @@ namespace TBF } } + goto done; + + pressure_label: + + switch (pressureDlg.ShowDialog()) + { + case DialogResult.Cancel: return; + case DialogResult.Retry: goto methodLabel; + } + + done: + LoadedProcedure.Tests.Add(test); AddToMetrology12AndProcessTab(test); foreach (var ctrl in testParamsCtrls) diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index cd1e10043..8ca9e8f16 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1401,6 +1401,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Pressure Hi [bar]. + /// + internal static string Pressure_hi_bar { + get { + return ResourceManager.GetString("Pressure_hi_bar", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pressure Lo [bar]. + /// + internal static string Pressure_lo_bar { + get { + return ResourceManager.GetString("Pressure_lo_bar", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pressure meter. /// @@ -1410,6 +1428,33 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Pressure Selection. + /// + internal static string Pressure_selection { + get { + return ResourceManager.GetString("Pressure_selection", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PreasureHi [bar]. + /// + internal static string PressureHi_bar { + get { + return ResourceManager.GetString("PressureHi_bar", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PressureLo [bar]. + /// + internal static string PressureLo_bar { + get { + return ResourceManager.GetString("PressureLo_bar", resourceCulture); + } + } + /// /// Looks up a localized string similar to Printer. /// @@ -1869,6 +1914,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Setting the water pressure. + /// + internal static string Setting_the_water_pressure { + get { + return ResourceManager.GetString("Setting_the_water_pressure", resourceCulture); + } + } + /// /// Looks up a localized string similar to Single. /// @@ -1914,6 +1968,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Starting the pump. + /// + internal static string Starting_the_pump { + get { + return ResourceManager.GetString("Starting_the_pump", resourceCulture); + } + } + /// /// Looks up a localized string similar to Start valve. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 401814018..25f6aabb9 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -952,4 +952,25 @@ Error [%] + + Starting the pump + + + Setting the water pressure + + + PreasureHi [bar] + + + PressureLo [bar] + + + Pressure Hi [bar] + + + Pressure Lo [bar] + + + Pressure Selection + \ No newline at end of file diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 0f30ad48b..2babdaa3e 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -524,6 +524,28 @@ TestMethodCfgCtrl.cs + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + @@ -870,6 +892,12 @@ MethodSelection.cs + + Form + + + PressureSelection.cs + Form @@ -1114,6 +1142,12 @@ TestMethodCfgCtrl.cs + + TestMethodCfgCtrl.cs + + + TestMethodCfgCtrl.cs + TestMethodCfgCtrl.cs @@ -1283,6 +1317,9 @@ MethodSelection.cs + + PressureSelection.cs + SensorsSelection.cs diff --git a/TestBenchFramework/TestWizard/FlowSelection.Designer.cs b/TestBenchFramework/TestWizard/FlowSelection.Designer.cs index 85d28c68f..e55ec32fc 100644 --- a/TestBenchFramework/TestWizard/FlowSelection.Designer.cs +++ b/TestBenchFramework/TestWizard/FlowSelection.Designer.cs @@ -29,12 +29,12 @@ private void InitializeComponent() { this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.sensorsComboBox = new System.Windows.Forms.ComboBox(); + this.sensorsLabel = new System.Windows.Forms.Label(); this.qToTextBox = new System.Windows.Forms.TextBox(); this.qFromTextBox = new System.Windows.Forms.TextBox(); - this.testNameTextBox = new System.Windows.Forms.TextBox(); this.qToLabel = new System.Windows.Forms.Label(); this.qFromLabel = new System.Windows.Forms.Label(); - this.testNameLabel = new System.Windows.Forms.Label(); this.cancelButton = new System.Windows.Forms.Button(); this.nextButton = new System.Windows.Forms.Button(); this.backButton = new System.Windows.Forms.Button(); @@ -54,12 +54,12 @@ // // horizSplitContainer.Panel1 // + this.horizSplitContainer.Panel1.Controls.Add(this.sensorsComboBox); + this.horizSplitContainer.Panel1.Controls.Add(this.sensorsLabel); this.horizSplitContainer.Panel1.Controls.Add(this.qToTextBox); this.horizSplitContainer.Panel1.Controls.Add(this.qFromTextBox); - this.horizSplitContainer.Panel1.Controls.Add(this.testNameTextBox); this.horizSplitContainer.Panel1.Controls.Add(this.qToLabel); this.horizSplitContainer.Panel1.Controls.Add(this.qFromLabel); - this.horizSplitContainer.Panel1.Controls.Add(this.testNameLabel); // // horizSplitContainer.Panel2 // @@ -70,34 +70,44 @@ this.horizSplitContainer.SplitterDistance = 182; this.horizSplitContainer.TabIndex = 1; // + // sensorsComboBox + // + this.sensorsComboBox.FormattingEnabled = true; + this.sensorsComboBox.Location = new System.Drawing.Point(137, 105); + this.sensorsComboBox.Name = "sensorsComboBox"; + this.sensorsComboBox.Size = new System.Drawing.Size(124, 21); + this.sensorsComboBox.TabIndex = 7; + this.sensorsComboBox.SelectedIndexChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // sensorsLabel + // + this.sensorsLabel.AutoSize = true; + this.sensorsLabel.Location = new System.Drawing.Point(21, 108); + this.sensorsLabel.Name = "sensorsLabel"; + this.sensorsLabel.Size = new System.Drawing.Size(45, 13); + this.sensorsLabel.TabIndex = 6; + this.sensorsLabel.Text = "Sensors"; + // // qToTextBox // - this.qToTextBox.Location = new System.Drawing.Point(126, 86); + this.qToTextBox.Location = new System.Drawing.Point(137, 74); this.qToTextBox.Name = "qToTextBox"; - this.qToTextBox.Size = new System.Drawing.Size(97, 20); + this.qToTextBox.Size = new System.Drawing.Size(124, 20); this.qToTextBox.TabIndex = 5; this.qToTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); // // qFromTextBox // - this.qFromTextBox.Location = new System.Drawing.Point(126, 56); + this.qFromTextBox.Location = new System.Drawing.Point(137, 44); this.qFromTextBox.Name = "qFromTextBox"; - this.qFromTextBox.Size = new System.Drawing.Size(97, 20); + this.qFromTextBox.Size = new System.Drawing.Size(124, 20); this.qFromTextBox.TabIndex = 4; this.qFromTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); // - // testNameTextBox - // - this.testNameTextBox.Location = new System.Drawing.Point(126, 26); - this.testNameTextBox.Name = "testNameTextBox"; - this.testNameTextBox.Size = new System.Drawing.Size(97, 20); - this.testNameTextBox.TabIndex = 3; - this.testNameTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); - // // qToLabel // this.qToLabel.AutoSize = true; - this.qToLabel.Location = new System.Drawing.Point(24, 89); + this.qToLabel.Location = new System.Drawing.Point(21, 77); this.qToLabel.Name = "qToLabel"; this.qToLabel.Size = new System.Drawing.Size(61, 13); this.qToLabel.TabIndex = 2; @@ -106,21 +116,12 @@ // qFromLabel // this.qFromLabel.AutoSize = true; - this.qFromLabel.Location = new System.Drawing.Point(24, 59); + this.qFromLabel.Location = new System.Drawing.Point(21, 47); this.qFromLabel.Name = "qFromLabel"; this.qFromLabel.Size = new System.Drawing.Size(72, 13); this.qFromLabel.TabIndex = 1; this.qFromLabel.Text = "Q from [m3/h]"; // - // testNameLabel - // - this.testNameLabel.AutoSize = true; - this.testNameLabel.Location = new System.Drawing.Point(24, 29); - this.testNameLabel.Name = "testNameLabel"; - this.testNameLabel.Size = new System.Drawing.Size(57, 13); - this.testNameLabel.TabIndex = 0; - this.testNameLabel.Text = "Test name"; - // // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -183,10 +184,10 @@ private System.Windows.Forms.Button backButton; private System.Windows.Forms.TextBox qToTextBox; private System.Windows.Forms.TextBox qFromTextBox; - private System.Windows.Forms.TextBox testNameTextBox; private System.Windows.Forms.Label qToLabel; private System.Windows.Forms.Label qFromLabel; - private System.Windows.Forms.Label testNameLabel; + private System.Windows.Forms.ComboBox sensorsComboBox; + private System.Windows.Forms.Label sensorsLabel; } } \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/FlowSelection.cs b/TestBenchFramework/TestWizard/FlowSelection.cs index f0e238df4..1c8451a08 100644 --- a/TestBenchFramework/TestWizard/FlowSelection.cs +++ b/TestBenchFramework/TestWizard/FlowSelection.cs @@ -13,38 +13,44 @@ namespace TBF.TestWizard public partial class FlowSelection : Form { Entities.Test test; + IList sensorPaths; public FlowSelection() { InitializeComponent(); } - public FlowSelection(Entities.Test test) + public FlowSelection(bool first, bool last, + Entities.Test test, + IList sensorPaths) : this() { this.test = test; + this.sensorPaths = sensorPaths; + + Text = Strings.Flow_selection; + qFromLabel.Text = Strings.Q_from_m3h; + qToLabel.Text = Strings.Q_to_m3h; + sensorsLabel.Text = Strings.Sensors; + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; } private void FlowSelection_Load(object sender, EventArgs e) { if (test == null) return; - backButton.Visible = false; - - Text = Strings.Flow_selection; - testNameLabel.Text = Strings.Test_name; - qFromLabel.Text = Strings.Q_from_m3h; - qToLabel.Text = Strings.Q_to_m3h; - backButton.Text = Strings.BackBtnText; - nextButton.Text = Strings.NextBtnText; - cancelButton.Text = Strings.CancelBtnText; + foreach (var path in sensorPaths) sensorsComboBox.Items.Add(path.Name); RefreshWizardPage(); } void RefreshWizardPage() { - testNameTextBox.Text = test.Name; qFromTextBox.Text = test.Qfrom.ToString(); qToTextBox.Text = test.Qto.ToString(); nextButton.Enabled = IsFormValid(); @@ -52,16 +58,21 @@ namespace TBF.TestWizard void UpdateTest() { - test.Name = testNameTextBox.Text; test.Qfrom = Utils.ParseUFloat(qFromTextBox.Text); test.Qto = Utils.ParseUFloat(qToTextBox.Text); + + if (sensorsComboBox.Items.Contains(sensorsComboBox.Text)) + { + test.MetersPath = sensorsComboBox.Text; + } } bool IsFormValid() { float dummy; return Utils.TryParseUFloat(qFromTextBox.Text, out dummy) && - Utils.TryParseUFloat(qToTextBox.Text, out dummy); + Utils.TryParseUFloat(qToTextBox.Text, out dummy) && + sensorsComboBox.Items.Contains(sensorsComboBox.Text); } private void backButton_Click(object sender, EventArgs e) diff --git a/TestBenchFramework/TestWizard/MethodSelection.Designer.cs b/TestBenchFramework/TestWizard/MethodSelection.Designer.cs index 649afd3c4..1fe91771a 100644 --- a/TestBenchFramework/TestWizard/MethodSelection.Designer.cs +++ b/TestBenchFramework/TestWizard/MethodSelection.Designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); - this.sensorsComboBox = new System.Windows.Forms.ComboBox(); - this.sensorsLabel = new System.Windows.Forms.Label(); + this.testNameTextBox = new System.Windows.Forms.TextBox(); + this.testNameLabel = new System.Windows.Forms.Label(); this.testMethodComboBox = new System.Windows.Forms.ComboBox(); this.testMethodLabel = new System.Windows.Forms.Label(); this.cancelButton = new System.Windows.Forms.Button(); @@ -52,8 +52,8 @@ // // horizSplitContainer.Panel1 // - this.horizSplitContainer.Panel1.Controls.Add(this.sensorsComboBox); - this.horizSplitContainer.Panel1.Controls.Add(this.sensorsLabel); + this.horizSplitContainer.Panel1.Controls.Add(this.testNameTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.testNameLabel); this.horizSplitContainer.Panel1.Controls.Add(this.testMethodComboBox); this.horizSplitContainer.Panel1.Controls.Add(this.testMethodLabel); // @@ -66,28 +66,26 @@ this.horizSplitContainer.SplitterDistance = 182; this.horizSplitContainer.TabIndex = 0; // - // sensorsComboBox + // testNameTextBox // - this.sensorsComboBox.FormattingEnabled = true; - this.sensorsComboBox.Location = new System.Drawing.Point(96, 84); - this.sensorsComboBox.Name = "sensorsComboBox"; - this.sensorsComboBox.Size = new System.Drawing.Size(165, 21); - this.sensorsComboBox.TabIndex = 3; - this.sensorsComboBox.TextChanged += new System.EventHandler(this.sensorsComboBox_TextChanged); + this.testNameTextBox.Location = new System.Drawing.Point(99, 47); + this.testNameTextBox.Name = "testNameTextBox"; + this.testNameTextBox.Size = new System.Drawing.Size(165, 20); + this.testNameTextBox.TabIndex = 5; // - // sensorsLabel + // testNameLabel // - this.sensorsLabel.AutoSize = true; - this.sensorsLabel.Location = new System.Drawing.Point(12, 87); - this.sensorsLabel.Name = "sensorsLabel"; - this.sensorsLabel.Size = new System.Drawing.Size(45, 13); - this.sensorsLabel.TabIndex = 2; - this.sensorsLabel.Text = "Sensors"; + this.testNameLabel.AutoSize = true; + this.testNameLabel.Location = new System.Drawing.Point(15, 50); + this.testNameLabel.Name = "testNameLabel"; + this.testNameLabel.Size = new System.Drawing.Size(57, 13); + this.testNameLabel.TabIndex = 4; + this.testNameLabel.Text = "Test name"; // // testMethodComboBox // this.testMethodComboBox.FormattingEnabled = true; - this.testMethodComboBox.Location = new System.Drawing.Point(96, 48); + this.testMethodComboBox.Location = new System.Drawing.Point(99, 96); this.testMethodComboBox.Name = "testMethodComboBox"; this.testMethodComboBox.Size = new System.Drawing.Size(165, 21); this.testMethodComboBox.TabIndex = 1; @@ -96,7 +94,7 @@ // testMethodLabel // this.testMethodLabel.AutoSize = true; - this.testMethodLabel.Location = new System.Drawing.Point(12, 51); + this.testMethodLabel.Location = new System.Drawing.Point(15, 99); this.testMethodLabel.Name = "testMethodLabel"; this.testMethodLabel.Size = new System.Drawing.Size(66, 13); this.testMethodLabel.TabIndex = 0; @@ -164,7 +162,7 @@ private System.Windows.Forms.Button backButton; private System.Windows.Forms.ComboBox testMethodComboBox; private System.Windows.Forms.Label testMethodLabel; - private System.Windows.Forms.ComboBox sensorsComboBox; - private System.Windows.Forms.Label sensorsLabel; + private System.Windows.Forms.TextBox testNameTextBox; + private System.Windows.Forms.Label testNameLabel; } } \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/MethodSelection.cs b/TestBenchFramework/TestWizard/MethodSelection.cs index 99c3faa4d..20c6a5009 100644 --- a/TestBenchFramework/TestWizard/MethodSelection.cs +++ b/TestBenchFramework/TestWizard/MethodSelection.cs @@ -14,61 +14,59 @@ namespace TBF.TestWizard { Entities.Test test; IList methods; - IList sensorPaths; public MethodSelection() { InitializeComponent(); } - public MethodSelection(Entities.Test test, - IList methods, - IList sensorPaths) + public MethodSelection(bool first, bool last, + Entities.Test test, + IList methods) : this() { this.test = test; this.methods = methods; - this.sensorPaths = sensorPaths; + + Text = Strings.Method_selection; + testNameLabel.Text = Strings.Test_name; + testMethodLabel.Text = Strings.Test_method; + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; } private void MethodSelection_Load(object sender, EventArgs e) { if (test == null) return; - Text = Strings.Method_selection; - testMethodLabel.Text = Strings.Test_method; - sensorsLabel.Text = Strings.Sensors; - backButton.Text = Strings.BackBtnText; - nextButton.Text = Strings.NextBtnText; - cancelButton.Text = Strings.CancelBtnText; - foreach (var method in methods) testMethodComboBox.Items.Add(method.Cfg.Name); - foreach (var path in sensorPaths) sensorsComboBox.Items.Add(path.Name); RefreshWizardPage(); } void RefreshWizardPage() { + testNameTextBox.Text = test.Name; nextButton.Enabled = IsFormValid(); } void UpdateTest() { + test.Name = testNameTextBox.Text; + if (testMethodComboBox.Items.Contains(testMethodComboBox.Text)) { test.Method = testMethodComboBox.Text; } - if (sensorsComboBox.Items.Contains(sensorsComboBox.Text)) - { - test.MetersPath = sensorsComboBox.Text; - } } bool IsFormValid() { - return testMethodComboBox.Items.Contains(testMethodComboBox.Text) && - sensorsComboBox.Items.Contains(sensorsComboBox.Text); + return testMethodComboBox.Items.Contains(testMethodComboBox.Text); } private void backButton_Click(object sender, EventArgs e) diff --git a/TestBenchFramework/TestWizard/PressureSelection.cs b/TestBenchFramework/TestWizard/PressureSelection.cs new file mode 100644 index 000000000..aef02addd --- /dev/null +++ b/TestBenchFramework/TestWizard/PressureSelection.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using TBF.Resources; + +namespace TBF.TestWizard +{ + public partial class PressureSelection : Form + { + Entities.Test test; + + public PressureSelection() + { + InitializeComponent(); + } + + public PressureSelection(bool first, bool last, Entities.Test test) + : this() + { + this.test = test; + + Text = Strings.Pressure_selection; + pressureLoLabel.Text = Strings.Pressure_lo_bar; + pressureHiLabel.Text = Strings.Pressure_hi_bar; + durationLabel.Text = Strings.Duration_s; + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; + } + + private void FlowSelection_Load(object sender, EventArgs e) + { + if (test == null) return; + + RefreshWizardPage(); + } + + void RefreshWizardPage() + { + pressureLoTextBox.Text = 1.0f.ToString(); /// TODO: replace constants + pressureHiTextBox.Text = 2.0f.ToString(); + durationTextBox.Text = 10.ToString(); + nextButton.Enabled = IsFormValid(); + } + + void UpdateTest() + { + /// TODO: complete + //test.Qfrom = Utils.ParseUFloat(pressureLoTextBox.Text); + //test.Qto = Utils.ParseUFloat(pressureHiTextBox.Text); + //test.TstTime = int.Parse(durationTextBox.Text); + } + + bool IsFormValid() + { + float dummy; + int iDummy; + return Utils.TryParseUFloat(pressureLoTextBox.Text, out dummy) && + Utils.TryParseUFloat(pressureHiTextBox.Text, out dummy) && + int.TryParse(durationTextBox.Text, out iDummy); + } + + private void backButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + Close(); + } + + private void nextButton_Click(object sender, EventArgs e) + { + if (test != null && IsFormValid()) + { + UpdateTest(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.None; + } + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void anyTextBox_TextChanged(object sender, EventArgs e) + { + nextButton.Enabled = IsFormValid(); + } + } +} diff --git a/TestBenchFramework/TestWizard/PressureSelection.designer.cs b/TestBenchFramework/TestWizard/PressureSelection.designer.cs new file mode 100644 index 000000000..609520223 --- /dev/null +++ b/TestBenchFramework/TestWizard/PressureSelection.designer.cs @@ -0,0 +1,191 @@ +namespace TBF.TestWizard +{ + partial class PressureSelection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.durationTextBox = new System.Windows.Forms.TextBox(); + this.durationLabel = new System.Windows.Forms.Label(); + this.pressureHiTextBox = new System.Windows.Forms.TextBox(); + this.pressureLoTextBox = new System.Windows.Forms.TextBox(); + this.pressureHiLabel = new System.Windows.Forms.Label(); + this.pressureLoLabel = new System.Windows.Forms.Label(); + this.cancelButton = new System.Windows.Forms.Button(); + this.nextButton = new System.Windows.Forms.Button(); + this.backButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); + this.horizSplitContainer.Panel1.SuspendLayout(); + this.horizSplitContainer.Panel2.SuspendLayout(); + this.horizSplitContainer.SuspendLayout(); + this.SuspendLayout(); + // + // horizSplitContainer + // + this.horizSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.horizSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.horizSplitContainer.Location = new System.Drawing.Point(0, 0); + this.horizSplitContainer.Name = "horizSplitContainer"; + this.horizSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // horizSplitContainer.Panel1 + // + this.horizSplitContainer.Panel1.Controls.Add(this.durationTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.durationLabel); + this.horizSplitContainer.Panel1.Controls.Add(this.pressureHiTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.pressureLoTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.pressureHiLabel); + this.horizSplitContainer.Panel1.Controls.Add(this.pressureLoLabel); + // + // horizSplitContainer.Panel2 + // + this.horizSplitContainer.Panel2.Controls.Add(this.cancelButton); + this.horizSplitContainer.Panel2.Controls.Add(this.nextButton); + this.horizSplitContainer.Panel2.Controls.Add(this.backButton); + this.horizSplitContainer.Size = new System.Drawing.Size(284, 262); + this.horizSplitContainer.SplitterDistance = 182; + this.horizSplitContainer.TabIndex = 1; + // + // durationTextBox + // + this.durationTextBox.Location = new System.Drawing.Point(136, 103); + this.durationTextBox.Name = "durationTextBox"; + this.durationTextBox.Size = new System.Drawing.Size(125, 20); + this.durationTextBox.TabIndex = 7; + // + // durationLabel + // + this.durationLabel.AutoSize = true; + this.durationLabel.Location = new System.Drawing.Point(21, 106); + this.durationLabel.Name = "durationLabel"; + this.durationLabel.Size = new System.Drawing.Size(83, 13); + this.durationLabel.TabIndex = 6; + this.durationLabel.Text = "Test duration [s]"; + // + // pressureHiTextBox + // + this.pressureHiTextBox.Location = new System.Drawing.Point(137, 74); + this.pressureHiTextBox.Name = "pressureHiTextBox"; + this.pressureHiTextBox.Size = new System.Drawing.Size(124, 20); + this.pressureHiTextBox.TabIndex = 5; + this.pressureHiTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // pressureLoTextBox + // + this.pressureLoTextBox.Location = new System.Drawing.Point(137, 44); + this.pressureLoTextBox.Name = "pressureLoTextBox"; + this.pressureLoTextBox.Size = new System.Drawing.Size(124, 20); + this.pressureLoTextBox.TabIndex = 4; + this.pressureLoTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // pressureHiLabel + // + this.pressureHiLabel.AutoSize = true; + this.pressureHiLabel.Location = new System.Drawing.Point(21, 77); + this.pressureHiLabel.Name = "pressureHiLabel"; + this.pressureHiLabel.Size = new System.Drawing.Size(85, 13); + this.pressureHiLabel.TabIndex = 2; + this.pressureHiLabel.Text = "Pressure Hi [bar]"; + // + // pressureLoLabel + // + this.pressureLoLabel.AutoSize = true; + this.pressureLoLabel.Location = new System.Drawing.Point(21, 47); + this.pressureLoLabel.Name = "pressureLoLabel"; + this.pressureLoLabel.Size = new System.Drawing.Size(87, 13); + this.pressureLoLabel.TabIndex = 1; + this.pressureLoLabel.Text = "Pressure Lo [bar]"; + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(186, 17); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 42); + this.cancelButton.TabIndex = 27; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // nextButton + // + this.nextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.nextButton.Location = new System.Drawing.Point(105, 17); + this.nextButton.Name = "nextButton"; + this.nextButton.Size = new System.Drawing.Size(75, 42); + this.nextButton.TabIndex = 26; + this.nextButton.Text = "&Next >"; + this.nextButton.UseVisualStyleBackColor = true; + this.nextButton.Click += new System.EventHandler(this.nextButton_Click); + // + // backButton + // + this.backButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.backButton.DialogResult = System.Windows.Forms.DialogResult.Retry; + this.backButton.Location = new System.Drawing.Point(24, 17); + this.backButton.Name = "backButton"; + this.backButton.Size = new System.Drawing.Size(75, 42); + this.backButton.TabIndex = 25; + this.backButton.Text = "< &Back"; + this.backButton.UseVisualStyleBackColor = true; + this.backButton.Click += new System.EventHandler(this.backButton_Click); + // + // PressureSelection + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.horizSplitContainer); + this.Name = "PressureSelection"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "PressureSelection"; + this.Load += new System.EventHandler(this.FlowSelection_Load); + this.horizSplitContainer.Panel1.ResumeLayout(false); + this.horizSplitContainer.Panel1.PerformLayout(); + this.horizSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).EndInit(); + this.horizSplitContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer horizSplitContainer; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button nextButton; + private System.Windows.Forms.Button backButton; + private System.Windows.Forms.TextBox pressureHiTextBox; + private System.Windows.Forms.TextBox pressureLoTextBox; + private System.Windows.Forms.Label pressureHiLabel; + private System.Windows.Forms.Label pressureLoLabel; + private System.Windows.Forms.TextBox durationTextBox; + private System.Windows.Forms.Label durationLabel; + + } +} \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/PressureSelection.resx b/TestBenchFramework/TestWizard/PressureSelection.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/TestWizard/PressureSelection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/VolumeAndErrorSelection.cs b/TestBenchFramework/TestWizard/VolumeAndErrorSelection.cs index 680937240..ccaaa486b 100644 --- a/TestBenchFramework/TestWizard/VolumeAndErrorSelection.cs +++ b/TestBenchFramework/TestWizard/VolumeAndErrorSelection.cs @@ -19,15 +19,10 @@ namespace TBF.TestWizard InitializeComponent(); } - public VolumeAndErrorSelection(Entities.Test test) + public VolumeAndErrorSelection(bool first, bool last, Entities.Test test) : this() { this.test = test; - } - - private void VolumeAndErrorSelection_Load(object sender, EventArgs e) - { - if (test == null) return; Text = Strings.Volume_and_error_selection; volumeLabel.Text = Strings.Volume_ltr_chdr; @@ -38,6 +33,14 @@ namespace TBF.TestWizard nextButton.Text = Strings.FinishBtnText; cancelButton.Text = Strings.CancelBtnText; + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; + } + + private void VolumeAndErrorSelection_Load(object sender, EventArgs e) + { + if (test == null) return; + RefreshWizardPage(); }