From 8d572a650add6d9916ab9b3aaf2da6ad2d58df98 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 9 Mar 2017 16:13:23 +0100 Subject: [PATCH] (1) Easytherm: proc. params, (2) TankSelector: no. proc. params, seq. conditions added., SetQuidoBitOp, SelectTankOp, UnselectTankOp, ver. 2.12.490 --- DeviceTest/DeviceTestDlg.cs | 6 - Results/WMeterRsltItemSpec.cs | 2 + .../BenchControl/Elde/ControlComWrap.cs | 4 +- .../Modbus/Easytherm/Easytherm.cs | 30 +++-- .../Modbus/Easytherm/EasythermCfg.cs | 19 ++- .../{TankSelector => Easytherm}/ProcParams.cs | 56 +++------ ...atureOp.cs => SetRequiredTemperatureOp.cs} | 18 ++- .../Modbus/Easytherm/SetTemperatureOp.cs | 2 +- .../BenchControl/Modbus/QuidoRS/QuidoRS.cs | 22 ++++ .../Modbus/TankSelector/SelectTankOp.cs | 58 +++++---- .../Modbus/TankSelector/SetQuidoBitOp.cs | 57 +++++++++ .../Modbus/TankSelector/TankSelector.cs | 110 ++++++++++++++---- .../Modbus/TankSelector/TankSelectorCfg.cs | 16 --- .../Modbus/TankSelector/UnselectTankOp.cs | 66 +++++++++++ TestBenchFramework/ProcedureDlg.cs | 2 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- .../Resources/Strings.Designer.cs | 66 ++++++++++- TestBenchFramework/Resources/Strings.de.resx | 3 + TestBenchFramework/Resources/Strings.resx | 30 ++++- TestBenchFramework/TBF.csproj | 6 +- 20 files changed, 429 insertions(+), 148 deletions(-) rename TestBenchFramework/BenchControl/Modbus/{TankSelector => Easytherm}/ProcParams.cs (50%) rename TestBenchFramework/BenchControl/Modbus/Easytherm/{ReadTemperatureOp.cs => SetRequiredTemperatureOp.cs} (72%) create mode 100644 TestBenchFramework/BenchControl/Modbus/TankSelector/SetQuidoBitOp.cs create mode 100644 TestBenchFramework/BenchControl/Modbus/TankSelector/UnselectTankOp.cs diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs index 09858ae6a..aaa130d68 100644 --- a/DeviceTest/DeviceTestDlg.cs +++ b/DeviceTest/DeviceTestDlg.cs @@ -265,7 +265,6 @@ namespace DeviceTest { radioButton1.Text = "SetTemperature(10)"; radioButton2.Text = "SetTemperature(20)"; - radioButton3.Text = "GetSomethig(0,1)"; } else if (className == "Modbus.TankSelector") { @@ -286,7 +285,6 @@ namespace DeviceTest { radioButton21.Text = "SetTemperature(10)"; radioButton22.Text = "SetTemperature(20)"; - radioButton23.Text = "GetSomethig(0,1)"; } else if (className == "Modbus.TankSelector") { @@ -307,7 +305,6 @@ namespace DeviceTest { radioButton31.Text = "SetTemperature(10)"; radioButton32.Text = "SetTemperature(20)"; - radioButton33.Text = "GetSomethig(0,1)"; } else if (className == "Modbus.TankSelector") { @@ -659,7 +656,6 @@ namespace DeviceTest { operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10); operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20); - operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).ReadTemperatureOp(); } else if (tbfComponent1forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) { @@ -687,7 +683,6 @@ namespace DeviceTest { operation21 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10); operation22 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20); - operation23 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).ReadTemperatureOp(); } else if (tbfComponent2forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) { @@ -715,7 +710,6 @@ namespace DeviceTest { operation31 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10); operation32 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20); - operation33 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).ReadTemperatureOp(); } else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) { diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index a43b411f1..feaa00419 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -361,6 +361,7 @@ namespace Results if (!added) { WMeterRsltItemSpec item = GetItem(0); + item.Caption = "Prs.Err."; item.Format = string.Format("Parse error: {0}", strArray[i]); result.Add(item); } @@ -369,6 +370,7 @@ namespace Results catch { WMeterRsltItemSpec item = GetItem(0); + item.Caption = "Prs.Err."; item.Format = string.Format("Parse error: {0}", strArray[i]); result.Add(item); } diff --git a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs index a6057d63f..dfb3c8b78 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs @@ -364,7 +364,7 @@ namespace TBF.BenchControl.Elde { string statusPStr = ((ulong)bufferedStatusP).ToString("x16"); log.InfoFormat("RunDeviceBefore() StatusP = {0}", statusPStr); - Program.MainWnd.UpdateStatusP(statusPStr); + //Program.MainWnd.UpdateStatusP(statusPStr); /// TODO 170309 lastStatusP = bufferedStatusP; } } @@ -380,7 +380,7 @@ namespace TBF.BenchControl.Elde { string statusPStr = ((ulong)bufferedStatusP).ToString("x16"); log.InfoFormat("RunDeviceAfter() StatusP = {0}", statusPStr); - Program.MainWnd.UpdateStatusP(statusPStr); + //Program.MainWnd.UpdateStatusP(statusPStr); /// TODO 170309 lastStatusP = bufferedStatusP; } } diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs index 7721c6238..73e7e6ce4 100644 --- a/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs @@ -20,6 +20,9 @@ namespace TBF.BenchControl.Modbus.Easytherm private float temperatureSetPoint; private bool temperatureSetPointValid; + public float requiredTemp { get { return easythermCfg.ProcParams.RequiredTemp; } } + + public Easytherm() { } @@ -58,9 +61,18 @@ namespace TBF.BenchControl.Modbus.Easytherm } /// - /// Set Easytherm controller required temperature + /// Set Easytherm controller to required temperature procedure parameter /// - /// output value + /// true = OK, false = any error + public bool SetRequiredTemperature() + { + return SetTemperature(requiredTemp); + } + + /// + /// Set Easytherm controller to specified temperature + /// + /// Temperature in °C /// true = OK, false = any error public bool SetTemperature(float temperature) { @@ -123,22 +135,20 @@ namespace TBF.BenchControl.Modbus.Easytherm /// /// Events: SetOpututsDone, Error /// - /// Reference to a variable for the pressure in Bar /// SetOutputsOp instance reference casted to IOperaton - public IOperation SetTemperatureOp(ushort temperatureSetpoint) + public IOperation SetRequiredTemperatureOp() { - return new SetTemperatureOp(this, temperatureSetpoint); + return new SetRequiredTemperatureOp(this); } /// - /// Events: pressureDone, Error + /// Events: SetOpututsDone, Error /// - /// Reference to a variable for the pressure in Bar - /// Event returned when SetOutput is done + /// Reference to a variable for the pressure in Bar /// SetOutputsOp instance reference casted to IOperaton - public IOperation ReadTemperatureOp() + public IOperation SetTemperatureOp(float temperature) { - return new ReadTemperatureOp(this); + return new SetTemperatureOp(this, temperature); } } } diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs index 61b426f7b..40869dab7 100644 --- a/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs @@ -2,9 +2,8 @@ /// Copyright (c) 2017 Sensus Metering Systems /// using System; -using System.Collections.Generic; -using System.IO; using System.Xml.Serialization; +using Config.Entities; using TBF.BenchControl.Generic; namespace TBF.BenchControl.Modbus.Easytherm @@ -18,13 +17,27 @@ namespace TBF.BenchControl.Modbus.Easytherm /// public byte ModbusAddress; /// 1..255 + + /// Procedure parameters + [XmlIgnore] + public ProcParams ProcParams; + public override IParamsProvider GetProcedureParams() { return ProcParams; } + public override IParamsProvider CreateProcedureParams(Procedure procedure) + { + ProcParams procParams = new ProcParams(); + procParams.UpdateProcedureParams(Name, procedure); + return procParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors EasythermCfg() { Name = "Easytherm"; ParentName = "Modbus"; ModbusAddress = 49; - } + ProcParams = new ProcParams(); + } public EasythermCfg(IComponentFactory factory) : this() diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/ProcParams.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/ProcParams.cs similarity index 50% rename from TestBenchFramework/BenchControl/Modbus/TankSelector/ProcParams.cs rename to TestBenchFramework/BenchControl/Modbus/Easytherm/ProcParams.cs index 0e1700519..b5dbde379 100644 --- a/TestBenchFramework/BenchControl/Modbus/TankSelector/ProcParams.cs +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/ProcParams.cs @@ -1,41 +1,27 @@ /// /// Copyright (c) 2017 Sensus Metering Systems /// -using System; using System.IO; -using System.Text; using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.Modbus.TankSelector +namespace TBF.BenchControl.Modbus.Easytherm { public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams { - public float TempHotHeating; /// [°C] target temperature for hot water heating - public float TempHotCooling; /// [°C] target temperature for hot water cooling - public float TempWarmHeating; /// [°C] target temperature for warm water heating - public float TempWarmCooling; /// [°C] target temperature for warm water cooling - public float TempColdCooling; /// [°C] target temperature for cold water cooling + public float RequiredTemp; /// [°C] target temperature for temperature controlled public override void InitializeAll() { - TempHotHeating = 20.0f; - TempHotCooling = 20.0f; - TempWarmHeating = 20.0f; - TempWarmCooling = 20.0f; - TempColdCooling = 20.0f; + RequiredTemp = 20.0f; } string[] paramNames = new string[] { - Strings.T_hot_heating, - Strings.T_hot_cooling, - Strings.T_warm_heating, - Strings.T_warm_cooling, - Strings.T_cold_cooling, + Strings.Required_temperature_C, }; public override string ParamName(int i) { return paramNames[i]; } public override int ParamsCount() { return paramNames.Length; } @@ -44,11 +30,7 @@ namespace TBF.BenchControl.Modbus.TankSelector { switch (i) { - case 0: return TempHotHeating.ToString(); - case 1: return TempHotCooling.ToString(); - case 2: return TempWarmHeating.ToString(); - case 3: return TempWarmCooling.ToString(); - case 4: return TempColdCooling.ToString(); + case 0: return RequiredTemp.ToString(); default: return string.Empty; } } @@ -57,28 +39,28 @@ namespace TBF.BenchControl.Modbus.TankSelector { switch (i) { - case 0: TempHotHeating = Utils.ParseUFloat(strValue); return; - case 1: TempHotCooling = Utils.ParseUFloat(strValue); return; - case 2: TempWarmHeating = Utils.ParseUFloat(strValue); return; - case 3: TempWarmCooling = Utils.ParseUFloat(strValue); return; - case 4: TempColdCooling = Utils.ParseUFloat(strValue); return; + case 0: RequiredTemp = Utils.ParseUFloat(strValue); return; default: return; } } + /// + /// Verifiy the string representation of the parameter + /// + /// Parameter ID + /// String representation of the parameter + /// In case false is returned this is the error messsage to be displayed + /// true = parameter OK, false = parameter NOK public bool ValidateParam(int i, string strValue, out string message) { message = string.Empty; - float dummy; + float temp; switch (i) { case 0: /// T_hot_heating - case 1: /// T_hot_cooling - case 2: /// T_warm_heating - case 3: /// T_warm_cooling - case 4: /// T_cold_cooling - if (Utils.TryParseUFloat(strValue, out dummy)) return true; + if (Utils.TryParseUFloat(strValue, out temp) && temp > 0 && temp < 100.0f) + return true; break; default: message = "Invalid index"; @@ -91,11 +73,7 @@ namespace TBF.BenchControl.Modbus.TankSelector void CopyContentTo(ProcParams prms) { - prms.TempHotHeating = this.TempHotHeating; - prms.TempHotCooling = this.TempHotCooling; - prms.TempWarmHeating = this.TempWarmHeating; - prms.TempWarmCooling = this.TempWarmCooling; - prms.TempColdCooling = this.TempColdCooling; + prms.RequiredTemp = this.RequiredTemp; } public IParamsProvider Clone() diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetRequiredTemperatureOp.cs similarity index 72% rename from TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs rename to TestBenchFramework/BenchControl/Modbus/Easytherm/SetRequiredTemperatureOp.cs index 36fad63df..3fd5f2825 100644 --- a/TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetRequiredTemperatureOp.cs @@ -7,15 +7,14 @@ using TBF.Boxes; namespace TBF.BenchControl.Modbus.Easytherm { - public class ReadTemperatureOp : IOperation + public class SetRequiredTemperatureOp : IOperation { - private static readonly ILog log = LogManager.GetLogger(typeof(SetTemperatureOp)); - public override string ToString() { return string.Format("SetOutputsOp(.,{0},{1})", outValue, eventDone); } + private static readonly ILog log = LogManager.GetLogger(typeof(SetRequiredTemperatureOp)); + public override string ToString() { return string.Format("SetRequiredTemperatureOp({0})", eventDone); } /// Set by the constructor readonly Easytherm easytherm; readonly Event eventDone; - ushort outValue; /// /// Events: PressureInDone, PressureOutDone or Error @@ -23,25 +22,24 @@ namespace TBF.BenchControl.Modbus.Easytherm /// Pressure meter reference /// Reference to the measured pressure variable, value is in bar /// Event to be returned by Run() when completed OK - public ReadTemperatureOp(Easytherm easytherm, Event eventDone) + public SetRequiredTemperatureOp(Easytherm easytherm, Event eventDone) { if (easytherm == null) throw new ArgumentNullException("easytherm"); this.easytherm = easytherm; - //this.outValue = outValue; this.eventDone = eventDone; log.Debug(this.ToString()); } - public ReadTemperatureOp(Easytherm easytherm) - : this(easytherm, Event.Done) + public SetRequiredTemperatureOp(Easytherm easytherm) + : this(easytherm, Event.ConditionMet) { } /// Start this operation public void Start() { - easytherm.GetSomething(0, 1); - } + easytherm.SetRequiredTemperature(); + } /// Run this operation public Event Run() diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs index c8c1420ba..765777e7d 100644 --- a/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs @@ -10,7 +10,7 @@ namespace TBF.BenchControl.Modbus.Easytherm public class SetTemperatureOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(SetTemperatureOp)); - public override string ToString() { return string.Format("SetTemperatureOp(.,{0},{1})", temperatureSetpoint, eventDone); } + public override string ToString() { return string.Format("SetTemperatureOp({0},{1})", temperatureSetpoint, eventDone); } /// Set by the constructor readonly Easytherm easytherm; diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs b/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs index a67ea6af5..41b55f6b8 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs +++ b/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs @@ -73,6 +73,28 @@ namespace TBF.BenchControl.Modbus.QuidoRS SendOutputs(currentOutputs); } + /// + /// Set bit(s) specified by a bitMask. Leave other bits unaffeced. + /// + /// Specifies bit(s) to set + /// output value + public void SetBit(ushort bitMask) + { + currentOutputs = (UInt16)((Int32)currentOutputs | (Int32)bitMask); + SendOutputs(currentOutputs); + } + + /// + /// Reset bit(s) specified by a bitMask. Leave other bits unaffeced. + /// + /// Specifies bit(s) to reset + /// output value + public void ResetBit(ushort bitMask) + { + currentOutputs = (UInt16)((Int32)currentOutputs & (~(Int32)bitMask)); + SendOutputs(currentOutputs); + } + private void SendOutputs(ushort outputs) { byte[] msg = new byte[11]; diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/SelectTankOp.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/SelectTankOp.cs index 6ca611f12..fd342df9f 100644 --- a/TestBenchFramework/BenchControl/Modbus/TankSelector/SelectTankOp.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/SelectTankOp.cs @@ -3,45 +3,59 @@ namespace TBF.BenchControl.Modbus.TankSelector { public class SelectTankOp : IOperation { - public enum OpSpecifier - { - None, - SelectTank, - UnselectTank, /// tankNo is ignored, the selected tank is unselected - } - TankSelector tankSelector; - OpSpecifier currentOp; int tankNo; + ushort bitMask; + bool alreadySet; + int time; - public SelectTankOp(TankSelector tankSelector, OpSpecifier op, int tankNo) + public SelectTankOp(TankSelector tankSelector, int tankNo) { this.tankSelector = tankSelector; - this.currentOp = op; - if (currentOp == OpSpecifier.SelectTank) this.tankNo = tankNo; + this.tankNo = tankNo; + this.bitMask = (ushort)((tankNo == 1) ? 1 : ((tankNo == 2) ? 2 : ((tankNo == 3) ? 4 : 0))); } /// Start this operation public void Start() { - switch (currentOp) + if (tankSelector.CurrentlySelectedTankValid && (tankNo == tankSelector.CurrentlySelectedTank)) { - case OpSpecifier.SelectTank: - tankSelector.SetOutputs((tankNo == 1) ? 1u : ((tankNo == 2) ? 2u : ((tankNo == 3) ? 4u : 0))); - break; - case OpSpecifier.UnselectTank: - tankSelector.SetOutputs((tankNo == 1) ? 8u : ((tankNo == 2) ? 16u : ((tankNo == 3) ? 32u : 0))); - break; - default: - break; + alreadySet = true; + } + else + { + tankSelector.CurrentlySelectedTank = tankNo; + tankSelector.CurrentlySelectedTankValid = true; + alreadySet = false; + time = 0; + + tankSelector.QuidoRS.SetBit(bitMask); } } /// Run this operation public Event Run() { - tankSelector.SetOutputs(0); - return Event.ConditionMet; + if (alreadySet) + { + return Event.ConditionMet; + } + else if (time == 0) + { + tankSelector.QuidoRS.ResetBit(bitMask); + time++; + return Event.ConditionNotMet; + } + else if (time <= 60) + { + time++; + return Event.ConditionNotMet; + } + else + { + return Event.ConditionMet; + } } /// Stop this operation diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/SetQuidoBitOp.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/SetQuidoBitOp.cs new file mode 100644 index 000000000..9959179e6 --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/SetQuidoBitOp.cs @@ -0,0 +1,57 @@ + +namespace TBF.BenchControl.Modbus.TankSelector +{ + public class SetQuidoBitOp : IOperation + { + public enum OpSpecifier + { + None, + SelectTank, + UnselectTank, /// tankNo is ignored, the selected tank is unselected + } + + readonly TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS; + readonly ushort bitMask; + readonly bool set; /// true = set, false = reset + readonly Event eventDone; + + + public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, TankSelector.QuidoOutputs bitMask, bool set) + : this(quidoRS, (ushort)bitMask, set, Event.ConditionMet) + { + } + + public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, ushort bitMask, bool set) + : this(quidoRS, bitMask, set, Event.ConditionMet) + { + } + + public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, ushort bitMask, bool set, Event eventDone) + { + this.quidoRS = quidoRS; + this.bitMask = bitMask; + this.set = set; + this.eventDone = eventDone; + } + + /// Start this operation + public void Start() + { + if (set) + quidoRS.SetBit(bitMask); + else + quidoRS.ResetBit(bitMask); + } + + /// Run this operation + public Event Run() + { + return eventDone; + } + + /// Stop this operation + public void Stop() + { + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs index 0a0936315..a048c5973 100644 --- a/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs @@ -18,7 +18,7 @@ namespace TBF.BenchControl.Modbus.TankSelector readonly TankSelectorCfg tankSelectorCfg; - readonly TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS; + public readonly TBF.BenchControl.Modbus.QuidoRS.QuidoRS QuidoRS; readonly TBF.BenchControl.Modbus.Easytherm.Easytherm hotHeating; readonly TBF.BenchControl.Modbus.Easytherm.Easytherm hotCooling; @@ -31,10 +31,13 @@ namespace TBF.BenchControl.Modbus.TankSelector IList sequenceConditions; + public int CurrentlySelectedTank; + public bool CurrentlySelectedTankValid; + /// /// Quido digital out board outputs assignment /// - private enum QuidoOutputs + public enum QuidoOutputs : ushort { None = 0, SelectColdTank = 0x0001, @@ -62,14 +65,15 @@ namespace TBF.BenchControl.Modbus.TankSelector { tankSelectorCfg = cfg as TankSelectorCfg; - quidoRS = (TBF.BenchControl.Modbus.QuidoRS.QuidoRS)TbfComponents.FindComponent(cfg.ParentName, components); - if (quidoRS == null) throw new Exception(string.Format("Cannot find parent '{0}' of the component {1}", cfg.ParentName, Name)); + QuidoRS = (TBF.BenchControl.Modbus.QuidoRS.QuidoRS)TbfComponents.FindComponent(cfg.ParentName, components); + if (QuidoRS == null) throw new Exception(string.Format("Cannot find parent '{0}' of the component {1}", cfg.ParentName, Name)); hotHeating = (TBF.BenchControl.Modbus.Easytherm.Easytherm)TbfComponents.FindComponent(tankSelectorCfg.HotWaterHeating, components); hotCooling = (TBF.BenchControl.Modbus.Easytherm.Easytherm)TbfComponents.FindComponent(tankSelectorCfg.HotWaterCooling, components); warmHeating = (TBF.BenchControl.Modbus.Easytherm.Easytherm)TbfComponents.FindComponent(tankSelectorCfg.WarmWaterHeating, components); warmCooling = (TBF.BenchControl.Modbus.Easytherm.Easytherm)TbfComponents.FindComponent(tankSelectorCfg.WarmWaterCooling, components); coldCooling = (TBF.BenchControl.Modbus.Easytherm.Easytherm)TbfComponents.FindComponent(tankSelectorCfg.ColdWaterCooling, components); + if (hotHeating == null) throw new Exception(string.Format("Component '{0}' cannot find temperature controller '{1}'", Name, tankSelectorCfg.HotWaterHeating)); if (hotCooling == null) throw new Exception(string.Format("Component '{0}' cannot find temperature controller '{1}'", Name, tankSelectorCfg.HotWaterCooling)); if (warmHeating == null) throw new Exception(string.Format("Component '{0}' cannot find temperature controller '{1}'", Name, tankSelectorCfg.WarmWaterHeating)); @@ -78,34 +82,96 @@ namespace TBF.BenchControl.Modbus.TankSelector CreateConditions(true); + CurrentlySelectedTankValid = false; + log.Debug(this.ToString()); } - public void Initialize() { SetOutputs(0); } + + public void Initialize() + { + SetOutputs(0); + } public void RunDeviceBefore() {} public void RunDeviceAfter() {} public void StopDevice() {} + + + void CreateConditions(bool createAll) { sequenceConditionNames = new List(); - sequenceConditionNames.Add(Strings.Select_COLD_tank); - sequenceConditionNames.Add(Strings.Select_WARM_tank); - sequenceConditionNames.Add(Strings.Select_HOT_tank); - sequenceConditionNames.Add(Strings.Unselect_COLD_tank); - sequenceConditionNames.Add(Strings.Unselect_WARM_tank); - sequenceConditionNames.Add(Strings.Unselect_HOT_tank); + sequenceConditions = new List(); - if (createAll) - { - sequenceConditions = new List(); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.SelectTank, 1)); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.SelectTank, 2)); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.SelectTank, 3)); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.UnselectTank, 1)); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.UnselectTank, 2)); - sequenceConditions.Add(new SelectTankOp(this, SelectTankOp.OpSpecifier.UnselectTank, 3)); - } + sequenceConditionNames.Add(Strings.Select_COLD_tank); + if (createAll) sequenceConditions.Add(new SelectTankOp(this, 1)); + + sequenceConditionNames.Add(Strings.Select_WARM_tank); + if (createAll) sequenceConditions.Add(new SelectTankOp(this, 2)); + + sequenceConditionNames.Add(Strings.Select_HOT_tank); + if (createAll) sequenceConditions.Add(new SelectTankOp(this, 3)); + + sequenceConditionNames.Add(Strings.Unselect_COLD_tank); + if (createAll) sequenceConditions.Add(new UnselectTankOp(this, 1)); + + sequenceConditionNames.Add(Strings.Unselect_WARM_tank); + if (createAll) sequenceConditions.Add(new UnselectTankOp(this, 2)); + + sequenceConditionNames.Add(Strings.Unselect_HOT_tank); + if (createAll) sequenceConditions.Add(new UnselectTankOp(this, 3)); + + sequenceConditionNames.Add(Strings.Set_hot_water_heating_temperature); + if (createAll) sequenceConditions.Add(hotHeating.SetRequiredTemperatureOp()); + + sequenceConditionNames.Add(Strings.Set_hot_water_cooling_temperature); + if (createAll) sequenceConditions.Add(hotCooling.SetRequiredTemperatureOp()); + + sequenceConditionNames.Add(Strings.Set_warm_water_heating_temperature); + if (createAll) sequenceConditions.Add(warmHeating.SetRequiredTemperatureOp()); + + sequenceConditionNames.Add(Strings.Set_warm_water_cooling_temperature); + if (createAll) sequenceConditions.Add(warmCooling.SetRequiredTemperatureOp()); + + sequenceConditionNames.Add(Strings.Set_cold_water_cooling_temperature); + if (createAll) sequenceConditions.Add(coldCooling.SetRequiredTemperatureOp()); + + sequenceConditionNames.Add("Start heating hot water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.HeatingHotTank, true)); + + sequenceConditionNames.Add("Stop heating hot water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.HeatingHotTank, false)); + + sequenceConditionNames.Add("Start cooling hot water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingHotTank, true)); + + sequenceConditionNames.Add("Stop cooling hot water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingHotTank, false)); + + sequenceConditionNames.Add("Start heating warm water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.HeatingWarmTank, true)); + + sequenceConditionNames.Add("Stop heating warm water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.HeatingWarmTank, false)); + + sequenceConditionNames.Add("Start cooling warm water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingWarmTank, true)); + + sequenceConditionNames.Add("Stop cooling warm water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingWarmTank, false)); + + sequenceConditionNames.Add("Start cooling cold water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingColdTank, true)); + + sequenceConditionNames.Add("Stop cooling cold water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.CoolingColdTank, false)); + + sequenceConditionNames.Add("Start mixing water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.Mixing, true)); + + sequenceConditionNames.Add("Stop mixing water"); + if (createAll) sequenceConditions.Add(new SetQuidoBitOp(QuidoRS, QuidoOutputs.Mixing, false)); } @@ -115,7 +181,7 @@ namespace TBF.BenchControl.Modbus.TankSelector /// output value public void SetOutputs(uint outputs) { - quidoRS.SetOutputs((ushort)outputs); + QuidoRS.SetOutputs((ushort)outputs); } diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs index b45cd4b78..707996435 100644 --- a/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs @@ -1,9 +1,6 @@ /// /// Copyright (c) 2017 Sensus Metering Systems /// -using System; -using System.Xml.Serialization; -using Config.Entities; using TBF.BenchControl.Generic; namespace TBF.BenchControl.Modbus.TankSelector @@ -22,24 +19,11 @@ namespace TBF.BenchControl.Modbus.TankSelector public string ColdWaterCooling; /// Name of the component communicating with the temperature controller - /// Procedure parameters - [XmlIgnore] - public ProcParams ProcParams; - public override IParamsProvider GetProcedureParams() { return ProcParams; } - public override IParamsProvider CreateProcedureParams(Procedure procedure) - { - ProcParams procParams = new ProcParams(); - procParams.UpdateProcedureParams(Name, procedure); - return procParams; - } - - /// Private parameterless constructor invoked by all other (public) constructors TankSelectorCfg() { Name = "TankSelector"; ParentName = "QuidoRS"; - ProcParams = new ProcParams(); } public TankSelectorCfg(IComponentFactory factory) diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/UnselectTankOp.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/UnselectTankOp.cs new file mode 100644 index 000000000..42cf074ef --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/UnselectTankOp.cs @@ -0,0 +1,66 @@ + +namespace TBF.BenchControl.Modbus.TankSelector +{ + public class UnselectTankOp : IOperation + { + TankSelector tankSelector; + int tankNo; + ushort bitMask; + bool alreadyUnselected; + int time; + + public UnselectTankOp(TankSelector tankSelector, int tankNo) + { + this.tankSelector = tankSelector; + this.tankNo = tankNo; + this.bitMask = (ushort)((tankNo == 1) ? 8 : ((tankNo == 2) ? 0x10 : ((tankNo == 3) ? 0x20 : 0))); + } + + /// Start this operation + public void Start() + { + if (tankSelector.CurrentlySelectedTankValid && (tankNo == 0)) + { + alreadyUnselected = true; + } + else + { + tankSelector.CurrentlySelectedTank = tankNo; + tankSelector.CurrentlySelectedTankValid = true; + alreadyUnselected = false; + time = 0; + + tankSelector.QuidoRS.SetBit(bitMask); + } + } + + /// Run this operation + public Event Run() + { + if (alreadyUnselected) + { + return Event.ConditionMet; + } + else if (time == 0) + { + tankSelector.QuidoRS.ResetBit(bitMask); + time++; + return Event.ConditionNotMet; + } + else if (time <= 60) + { + time++; + return Event.ConditionNotMet; + } + else + { + return Event.ConditionMet; + } + } + + /// Stop this operation + public void Stop() + { + } + } +} diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index 6988773cc..d8c4182cc 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -264,7 +264,7 @@ namespace TBF IList other = new List(); foreach (var cmpnt in TbfComponents) { - if (cmpnt is TBF.BenchControl.Modbus.TankSelector.TankSelector) other.Add(cmpnt); + if (cmpnt is TBF.BenchControl.Modbus.Easytherm.Easytherm) other.Add(cmpnt); } if (other.Count > 0) diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 703b60c45..68125d1bd 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.12.489.1")] -[assembly: AssemblyFileVersion("2.12.489.1")] +[assembly: AssemblyVersion("2.12.490.1")] +[assembly: AssemblyFileVersion("2.12.490.1")] diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index d0947e156..6611c0973 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -3255,6 +3255,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Required temperature [°C]. + /// + internal static string Required_temperature_C { + get { + return ResourceManager.GetString("Required_temperature_C", resourceCulture); + } + } + /// /// Looks up a localized string similar to Resistance. /// @@ -3364,7 +3373,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Select COLD tank. + /// Looks up a localized string similar to Select COLD water. /// internal static string Select_COLD_tank { get { @@ -3382,7 +3391,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Select HOT tank. + /// Looks up a localized string similar to Select HOT water. /// internal static string Select_HOT_tank { get { @@ -3391,7 +3400,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Select WORM tank. + /// Looks up a localized string similar to Select WARM water. /// internal static string Select_WARM_tank { get { @@ -3471,6 +3480,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Set cold water cooling temperature. + /// + internal static string Set_cold_water_cooling_temperature { + get { + return ResourceManager.GetString("Set_cold_water_cooling_temperature", resourceCulture); + } + } + /// /// Looks up a localized string similar to Set flow. /// @@ -3480,6 +3498,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Set hot water cooling temperature. + /// + internal static string Set_hot_water_cooling_temperature { + get { + return ResourceManager.GetString("Set_hot_water_cooling_temperature", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set hot water heating temperature. + /// + internal static string Set_hot_water_heating_temperature { + get { + return ResourceManager.GetString("Set_hot_water_heating_temperature", resourceCulture); + } + } + /// /// Looks up a localized string similar to Set route. /// @@ -3489,6 +3525,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Set warm water cooling temperature. + /// + internal static string Set_warm_water_cooling_temperature { + get { + return ResourceManager.GetString("Set_warm_water_cooling_temperature", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set warm water heating temperature. + /// + internal static string Set_warm_water_heating_temperature { + get { + return ResourceManager.GetString("Set_warm_water_heating_temperature", resourceCulture); + } + } + /// /// Looks up a localized string similar to Setting temperature. /// @@ -4393,7 +4447,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Unselect COLD tank. + /// Looks up a localized string similar to Unselect COLD water. /// internal static string Unselect_COLD_tank { get { @@ -4402,7 +4456,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Unselect HOT tank. + /// Looks up a localized string similar to Unselect HOT water. /// internal static string Unselect_HOT_tank { get { @@ -4411,7 +4465,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Unselect WARM tank. + /// Looks up a localized string similar to Unselect WARM water. /// internal static string Unselect_WARM_tank { get { diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 9216b9d5d..2b56973e4 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -1401,4 +1401,7 @@ <other> + + Solltemperatur [°C] + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 08a80a04f..1b0275212 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1634,22 +1634,22 @@ Do you want to retry RoI detection? - Select COLD tank + Select COLD water - Select HOT tank + Select HOT water - Select WORM tank + Select WARM water - Unselect COLD tank + Unselect COLD water - Unselect HOT tank + Unselect HOT water - Unselect WARM tank + Unselect WARM water T cold cooling @@ -1669,4 +1669,22 @@ Other + + Required temperature [°C] + + + Set cold water cooling temperature + + + Set hot water cooling temperature + + + Set hot water heating temperature + + + Set warm water cooling temperature + + + Set warm water heating temperature + \ No newline at end of file diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 9f5c3eeb4..d223ec9b7 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -508,7 +508,8 @@ EasythermCfgCtrl.cs - + + @@ -541,8 +542,8 @@ - + @@ -551,6 +552,7 @@ TankSelectorCfgCtrl.cs +