diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs index 4d17f6f37..0b4339db9 100644 --- a/DeviceTest/DeviceTestDlg.cs +++ b/DeviceTest/DeviceTestDlg.cs @@ -261,7 +261,13 @@ namespace DeviceTest if (className == "Keithley.TempMeter") radioButton1.Text = "ReadPressureOp"; else if (className == "Network.Camera.CLP1611") radioButton1.Text = "Livestream"; else if (className == "Network.Camera.Roi") radioButton1.Text = "RoiDetection"; - else if (className == "TankSelector") + else if (className == "Modbus.Easytherm") + { + radioButton1.Text = "SetTemperature(10)"; + radioButton2.Text = "SetTemperature(20)"; + radioButton3.Text = "SetTemperature(30)"; + } + else if (className == "Modbus.TankSelector") { radioButton1.Text = "SelectTank 1"; radioButton2.Text = "SelectTank 2"; @@ -276,7 +282,13 @@ namespace DeviceTest if (className == "Keithley.TempMeter") radioButton21.Text = "ReadPressureOp"; else if (className == "Network.Camera.CLP1611") radioButton21.Text = "Livestream"; else if (className == "Network.Camera.Roi") radioButton21.Text = "RoiDetection"; - else if (className == "TankSelector") + else if (className == "Modbus.Easytherm") + { + radioButton21.Text = "SetTemperature(10)"; + radioButton22.Text = "SetTemperature(20)"; + radioButton23.Text = "SetTemperature(30)"; + } + else if (className == "Modbus.TankSelector") { radioButton21.Text = "SelectTank 1"; radioButton22.Text = "SelectTank 2"; @@ -291,7 +303,13 @@ namespace DeviceTest if (className == "Keithley.TempMeter") radioButton31.Text = "ReadPressureOp"; else if (className == "Network.Camera.CLP1611") radioButton31.Text = "Livestream"; else if (className == "Network.Camera.Roi") radioButton31.Text = "RoiDetection"; - else if (className == "TankSelector") + else if (className == "Modbus.Easytherm") + { + radioButton31.Text = "SetTemperature(10)"; + radioButton32.Text = "SetTemperature(20)"; + radioButton33.Text = "SetTemperature(30)"; + } + else if (className == "Modbus.TankSelector") { radioButton31.Text = "SelectTank 1"; radioButton32.Text = "SelectTank 2"; @@ -637,12 +655,18 @@ namespace DeviceTest { operation1 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); } - else if (tbfComponent1forOp is TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector) + else if (tbfComponent1forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm) { - operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(1); - operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(2); - operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(3); - operation4 = (tbfComponent1forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(0); + 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).SetTemperatureOp(30); + } + else if (tbfComponent1forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) + { + operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1); + //operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2); + //operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3); + //operation4 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0); } @@ -659,12 +683,18 @@ namespace DeviceTest { operation21 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); } - else if (tbfComponent2forOp is TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector) + else if (tbfComponent2forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm) { - operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(1); - //operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(2); - //operation23 = (tbfComponent2forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(3); - //operation24 = (tbfComponent2forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(0); + 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).SetTemperatureOp(30); + } + else if (tbfComponent2forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) + { + operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1); + //operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2); + //operation23 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3); + //operation24 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0); } @@ -681,12 +711,18 @@ namespace DeviceTest { operation31 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); } - else if (tbfComponent3forOp is TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector) + else if (tbfComponent3forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm) { - operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(1); - operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(2); - operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(3); - operation34 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.TankSelector.TankSelector).SelectTankOp(0); + 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).SetTemperatureOp(30); + } + else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector) + { + operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1); + //operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2); + //operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3); + //operation34 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0); } diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index 1da136f1f..285ae3137 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -58,7 +58,7 @@ namespace TBF.BenchControl.Elde public float RValvePosition(int rvNr1) { return controlCom.RValvePosition(rvNr1); } public float DivSamples(int ms) { return controlCom.DivSamples(ms); } public int ScopeSamples(int i, int j, int k) { return controlCom.ScopeSamples(i, j, k); } - public ulong DigitalInputs { get { return controlCom.DigitalInputs; } } + public uint DigitalInputs { get { return controlCom.DigitalInputs; } } public float AnalogInput(int adcNr0) { return controlCom.AnalogInput(adcNr0); } public uint AnalogInputRaw(int adcNr0, int bank) { return controlCom.AnalogInputRaw(adcNr0, bank); } /// adcNr0: 0=RV1, 1=RV2,... bank: 0=RV, 1=Temp public float ReferenceVolume { get { return controlCom.TotalRefVolume; } } diff --git a/TestBenchFramework/BenchControl/Elde/ControlComSim.cs b/TestBenchFramework/BenchControl/Elde/ControlComSim.cs index c75080726..ca4d66dc0 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlComSim.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlComSim.cs @@ -63,7 +63,7 @@ namespace TBF.BenchControl.Elde public float RValvePosition(int rvNr1) { return 0; } public float DivSamples(int ms) { return 0; } public int ScopeSamples(int i, int j, int k) { return 0; } - public ulong DigitalInputs { get { return 0; } } + public uint DigitalInputs { get { return 0; } } public float AnalogInput(int adcNr0) { return 0; } public uint AnalogInputRaw(int adcNr0, int bank) { return 0; } /// bank0=RV, bank1=Temp public float TotalRefVolume { get { return 0; } } diff --git a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs index d2deadc29..da906d794 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs @@ -64,7 +64,7 @@ namespace TBF.BenchControl.Elde } public float DivSamples(int ms) { return ctrlBrdComponent.DIVSamples[ms, 0]; } public int ScopeSamples(int i, int j, int k) { return ctrlBrdComponent.ScopeSamples[i, j, k]; } - public ulong DigitalInputs { get { return (ulong)ctrlBrdComponent.Vstupy; } } + public uint DigitalInputs { get { return ctrlBrdComponent.Vstupy; } } public float AnalogInput(int adcNr0) { return ctrlBrdComponent.Analogy[adcNr0]; } public uint AnalogInputRaw(int adcNr0, int bank) { return ctrlBrdComponent.AnalogyRaw[adcNr0, bank]; } /// bank0=RV, bank1=Temp diff --git a/TestBenchFramework/BenchControl/Elde/IControlCom.cs b/TestBenchFramework/BenchControl/Elde/IControlCom.cs index 8beb9d78a..48cef7b91 100644 --- a/TestBenchFramework/BenchControl/Elde/IControlCom.cs +++ b/TestBenchFramework/BenchControl/Elde/IControlCom.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.Elde float RValvePosition(int rvNr1); float DivSamples(int ms); int ScopeSamples(int i, int j, int k); - ulong DigitalInputs { get; } + uint DigitalInputs { get; } float AnalogInput(int adcNr0); uint AnalogInputRaw(int adcNr0, int bank); float TotalRefVolume { get; } diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs new file mode 100644 index 000000000..cd66d1dee --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/Easytherm.cs @@ -0,0 +1,103 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using TBF.BenchControl.Generic; +using TBF.Boxes; + +namespace TBF.BenchControl.Modbus.Easytherm +{ + public class Easytherm : ComponentBase, IDevice + { + private static readonly ILog log = LogManager.GetLogger(typeof(Easytherm)); + public override string ToString() { return string.Format("Easytherm({0})", Cfg.ToString(1)); } + + readonly EasythermCfg easythermCfg; + readonly GenericDevices.IModbus modbus; + + private ushort temperatureSetpoint; + + public Easytherm() + { + } + + public Easytherm(Generic.IComponentCfg cfg, IList components) + : base(cfg) + { + easythermCfg = cfg as EasythermCfg; + + modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components); + if (modbus == null) throw new Exception("Cannot find " + Name + " parent"); + + log.Debug(this.ToString()); + } + + /// Initialize this device + public void Initialize() + { + } + + /// Run this device + public void RunDeviceBefore() + { + } + + /// Run this device + public void RunDeviceAfter() + { + } + + /// Stop this device + public void StopDevice() + { + } + + /// + /// Set outputs of QuidoRS board + /// + /// output value + public void SetTemperature(ushort temperature) + { + temperatureSetpoint = temperature; + SendTemperature(temperatureSetpoint); + } + + private void SendTemperature(ushort temperatureSetpoint) + { + byte[] msg = new byte[8]; + + msg[0] = easythermCfg.ModbusAddress; + msg[1] = (byte)Function.PresetSingleRegister; + msg[2] = 0; /// Relative address Hi + msg[3] = 2; /// Relative address Lo + msg[4] = (byte)(temperatureSetpoint >> 8); /// Output data Hi + msg[5] = (byte)(temperatureSetpoint & 0xFF); /// Output data Lo + + modbus.SendMessage(msg); + } + + + /// + /// Events: SetOpututsDone, Error + /// + /// Reference to a variable for the pressure in Bar + /// SetOutputsOp instance reference casted to IOperaton + public IOperation SetTemperatureOp(ushort temperatureSetpoint) + { + return new SetTemperatureOp(this, temperatureSetpoint); + } + + /// + /// Events: pressureDone, Error + /// + /// Reference to a variable for the pressure in Bar + /// Event returned when SetOutput is done + /// SetOutputsOp instance reference casted to IOperaton + public IOperation ReadTemperatureOp(ushort outValue, Event setOutputsDone) + { + return new ReadTemperatureOp(this, outValue, setOutputsDone); + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs new file mode 100644 index 000000000..61b426f7b --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfg.cs @@ -0,0 +1,43 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Modbus.Easytherm +{ + public class EasythermCfg : ComponentCfgBase, Generic.IChildComponentCfg + { + public IComponentCfgCtrl GetControl() { return new EasythermCfgCtrl(); } + + /// + /// Serialized parameters + /// + public byte ModbusAddress; /// 1..255 + + /// Private parameterless constructor invoked by all other (public) constructors + EasythermCfg() + { + Name = "Easytherm"; + ParentName = "Modbus"; + ModbusAddress = 49; + } + + public EasythermCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}, ModbusAddr={1}, Parent={2}", + Name, + ModbusAddress, + (string.IsNullOrEmpty(ParentName) ? "-" : ParentName)); + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.cs new file mode 100644 index 000000000..821565eb2 --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.cs @@ -0,0 +1,106 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Modbus.Easytherm +{ + public partial class EasythermCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(EasythermCfgCtrl)); + + ComponentParametersDlg parent; + + public bool ShowMore { get { return false; } } + + EasythermCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as EasythermCfg; + Redraw(); + } + } + + public EasythermCfgCtrl() + { + InitializeComponent(); + } + + private void QuidoRSCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.TbfComponents != null) + { + foreach (var cmpnt in parent.TbfComponents) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Modbus.Common.Factory) + { + parentNameComboBox.Items.Add(cmpnt.Name); + } + } + } + + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + componentNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; + modbusAddressTextBox.Text = config.ModbusAddress.ToString(); + } + + public void Unlock() + { + nameTextBox.Enabled = true; + parentNameComboBox.Enabled = true; + modbusAddressTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Parent Name'"; + } + if (!int.TryParse(modbusAddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Modbus Address' should be between 0 and 255"; + } + 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; + config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; + config.ModbusAddress = (byte)int.Parse(modbusAddressTextBox.Text); + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.designer.cs new file mode 100644 index 000000000..3cf6c9cac --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.designer.cs @@ -0,0 +1,133 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.BenchControl.Modbus.Easytherm +{ + partial class EasythermCfgCtrl + { + /// + /// 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.parentNameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.componentNameLabel = new System.Windows.Forms.Label(); + this.modbusAddressLabel = new System.Windows.Forms.Label(); + this.modbusAddressTextBox = new System.Windows.Forms.TextBox(); + this.parentNameComboBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // parentNameLabel + // + this.parentNameLabel.AutoSize = true; + this.parentNameLabel.Location = new System.Drawing.Point(28, 81); + this.parentNameLabel.Name = "parentNameLabel"; + this.parentNameLabel.Size = new System.Drawing.Size(69, 13); + this.parentNameLabel.TabIndex = 3; + this.parentNameLabel.Text = "Parent Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(138, 52); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(28, 55); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // componentNameLabel + // + this.componentNameLabel.AutoSize = true; + this.componentNameLabel.Location = new System.Drawing.Point(135, 28); + this.componentNameLabel.Name = "componentNameLabel"; + this.componentNameLabel.Size = new System.Drawing.Size(83, 13); + this.componentNameLabel.TabIndex = 0; + this.componentNameLabel.Text = "ComonentName"; + // + // modbusAddressLabel + // + this.modbusAddressLabel.AutoSize = true; + this.modbusAddressLabel.Location = new System.Drawing.Point(28, 108); + this.modbusAddressLabel.Name = "modbusAddressLabel"; + this.modbusAddressLabel.Size = new System.Drawing.Size(86, 13); + this.modbusAddressLabel.TabIndex = 7; + this.modbusAddressLabel.Text = "Modbus Address"; + // + // modbusAddressTextBox + // + this.modbusAddressTextBox.Enabled = false; + this.modbusAddressTextBox.Location = new System.Drawing.Point(138, 105); + this.modbusAddressTextBox.Name = "modbusAddressTextBox"; + this.modbusAddressTextBox.Size = new System.Drawing.Size(46, 20); + this.modbusAddressTextBox.TabIndex = 8; + // + // parentNameComboBox + // + this.parentNameComboBox.Enabled = false; + this.parentNameComboBox.FormattingEnabled = true; + this.parentNameComboBox.Location = new System.Drawing.Point(138, 78); + this.parentNameComboBox.Name = "parentNameComboBox"; + this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); + this.parentNameComboBox.TabIndex = 4; + // + // EasythermCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.parentNameComboBox); + this.Controls.Add(this.modbusAddressTextBox); + this.Controls.Add(this.modbusAddressLabel); + this.Controls.Add(this.parentNameLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.componentNameLabel); + this.Name = "EasythermCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.QuidoRSCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label parentNameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label componentNameLabel; + private System.Windows.Forms.Label modbusAddressLabel; + private System.Windows.Forms.TextBox modbusAddressTextBox; + private System.Windows.Forms.ComboBox parentNameComboBox; + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.resx b/TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.resx similarity index 100% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.resx rename to TestBenchFramework/BenchControl/Modbus/Easytherm/EasythermCfgCtrl.resx diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/Factory.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/Factory.cs new file mode 100644 index 000000000..47af7614c --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Modbus.Easytherm +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Easytherm.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Easytherm(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Easytherm(cfg, components); } + + public IComponentCfg DefaultConfig() { return new EasythermCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(EasythermCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs new file mode 100644 index 000000000..7a3f6d20d --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/ReadTemperatureOp.cs @@ -0,0 +1,56 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using log4net; +using TBF.Boxes; + +namespace TBF.BenchControl.Modbus.Easytherm +{ + public class ReadTemperatureOp : IOperation + { + private static readonly ILog log = LogManager.GetLogger(typeof(SetTemperatureOp)); + public override string ToString() { return string.Format("SetOutputsOp(.,{0},{1})", outValue, eventDone); } + + /// Set by the constructor + readonly Easytherm easytherm; + readonly Event eventDone; + ushort outValue; + + /// + /// Events: PressureInDone, PressureOutDone or Error + /// + /// 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, ushort outValue, 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, ushort outValue) + : this(easytherm, outValue, Event.SetOutputsDone) + { + } + + /// Start this operation + public void Start() + { + } + + /// Run this operation + public Event Run() + { + return eventDone; + } + + /// Stop this operation + public void Stop() + { + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs new file mode 100644 index 000000000..19d839d4f --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/Easytherm/SetTemperatureOp.cs @@ -0,0 +1,57 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using log4net; +using TBF.Boxes; + +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); } + + /// Set by the constructor + readonly Easytherm easytherm; + readonly Event eventDone; + ushort temperatureSetpoint; + + /// + /// Events: PressureInDone, PressureOutDone or Error + /// + /// Pressure meter reference + /// Reference to the measured pressure variable, value is in bar + /// Event to be returned by Run() when completed OK + public SetTemperatureOp(Easytherm easytherm, ushort temperatureSetpoint, Event eventDone) + { + if (easytherm == null) throw new ArgumentNullException("easytherm"); + this.easytherm = easytherm; + this.temperatureSetpoint = temperatureSetpoint; + this.eventDone = eventDone; + + log.Debug(this.ToString()); + } + public SetTemperatureOp(Easytherm easytherm, ushort outValue) + : this(easytherm, outValue, Event.SetOutputsDone) + { + } + + /// Start this operation + public void Start() + { + easytherm.SetTemperature(temperatureSetpoint); + } + + /// Run this operation + public Event Run() + { + return eventDone; + } + + /// Stop this operation + public void Stop() + { + } + } +} diff --git a/TestBenchFramework/BenchControl/Modbus/Enums.cs b/TestBenchFramework/BenchControl/Modbus/Enums.cs index f4dc749f4..beecbdb1e 100644 --- a/TestBenchFramework/BenchControl/Modbus/Enums.cs +++ b/TestBenchFramework/BenchControl/Modbus/Enums.cs @@ -7,14 +7,14 @@ namespace TBF.BenchControl.Modbus { public enum Function : byte { - ReadCoilStatus = 0x01, - ReadSingleInput = 0x02, - ReadHoldingRegisters = 0x03, - ReadInputRegister = 0x04, - ForceSingleCoil = 0x05, - PresetSingleRegister = 0x06, - ForceMultipleCoils = 0x0F, + ReadCoilStatus = 0x01, + ReadSingleInput = 0x02, + ReadHoldingRegisters = 0x03, + ReadInputRegister = 0x04, + ForceSingleCoil = 0x05, + PresetSingleRegister = 0x06, + ForceMultipleCoils = 0x0F, PresetMultipleRegisters = 0x10, - Identification = 0x11, + Identification = 0x11, } } diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/Factory.cs b/TestBenchFramework/BenchControl/Modbus/QuidoRS/Factory.cs index 387937c0f..076c84603 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/Factory.cs +++ b/TestBenchFramework/BenchControl/Modbus/QuidoRS/Factory.cs @@ -8,7 +8,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS { public class Factory : IComponentFactory { - public string ClassName { get { return "QuidoRS"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } public void ResetStaticProperties() { QuidoRS.ResetStaticProperties(); } diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs b/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs index bd9d97ec4..a67ea6af5 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs +++ b/TestBenchFramework/BenchControl/Modbus/QuidoRS/QuidoRS.cs @@ -51,8 +51,11 @@ namespace TBF.BenchControl.Modbus.QuidoRS /// Run this device public void RunDeviceAfter() { - currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)watchdogBitMask); - SendOutputs(currentOutputs); + if (watchdogBitMask != 0) + { + currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)watchdogBitMask); + SendOutputs(currentOutputs); + } } /// Stop this device diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/Factory.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/Factory.cs similarity index 84% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/Factory.cs rename to TestBenchFramework/BenchControl/Modbus/TankSelector/Factory.cs index b63d7693a..98eb629ca 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/Factory.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/Factory.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector +namespace TBF.BenchControl.Modbus.TankSelector { public class Factory : IComponentFactory { - public string ClassName { get { return "TankSelector"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } public void ResetStaticProperties() { TankSelector.ResetStaticProperties(); } diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelector.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs similarity index 68% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelector.cs rename to TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs index 6f830a54b..4e939ad13 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelector.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelector.cs @@ -7,7 +7,7 @@ using log4net; using TBF.BenchControl.Generic; using TBF.Boxes; -namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector +namespace TBF.BenchControl.Modbus.TankSelector { public class TankSelector : ComponentBase, IOperation { @@ -15,7 +15,9 @@ namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector public override string ToString() { return string.Format("TankSelector({0})", Cfg.ToString(1)); } readonly TankSelectorCfg tankSelectorCfg; - readonly QuidoRS quidoRS; + readonly TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS; + readonly TBF.BenchControl.Modbus.Easytherm.Easytherm easytherm; + readonly Elde.ControlBoardDev controlBoard; public enum CurrentOp @@ -27,6 +29,27 @@ namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector CurrentOp currentOp; + /// + /// Quido digital out board outputs assignment + /// + private enum QuidoInputs + { + None = 0, + SelectColdTank = 0x0001, + SelectWarmTank = 0x0002, + SelectHotTank = 0x0004, + PumpToColdTank = 0x0008, + PumpToWarmTank = 0x0010, + PumpToHotTank = 0x0020, + Mixing = 0x0040, + HeatingHotTank = 0x0080, + HeatingWarmTank = 0x0100, + CoolingHotTank = 0x0200, + CoolingWarmTank = 0x0400, + CoolingColdTank = 0x0800, + } + + public TankSelector() { } @@ -36,8 +59,11 @@ namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector { tankSelectorCfg = cfg as TankSelectorCfg; - quidoRS = (QuidoRS)TbfComponents.FindComponent(cfg.ParentName, components); - if (quidoRS == null) throw new Exception("Cannot find " + Name + " parent"); + 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)); + + controlBoard = (Elde.ControlBoardDev)TbfComponents.FindComponent(tankSelectorCfg.ControlBoard, components); + if (controlBoard == null) throw new Exception(string.Format("Cannot find control board '{0}' for the component {1}", tankSelectorCfg.ControlBoard, Name)); log.Debug(this.ToString()); } diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfg.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs similarity index 94% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfg.cs rename to TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs index 9d6ab96ff..b7ac54acd 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfg.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfg.cs @@ -7,7 +7,7 @@ using System.IO; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector +namespace TBF.BenchControl.Modbus.TankSelector { public class TankSelectorCfg : ComponentCfgBase, Generic.IChildComponentCfg { diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.cs similarity index 98% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.cs rename to TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.cs index aec5d4a45..94eca154e 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using log4net; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector +namespace TBF.BenchControl.Modbus.TankSelector { public partial class TankSelectorCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.designer.cs similarity index 99% rename from TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.designer.cs rename to TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.designer.cs index 8cf56f3af..007fc3c60 100644 --- a/TestBenchFramework/BenchControl/Modbus/QuidoRS/TankSelector/TankSelectorCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2017 Sensus Metering Systems /// -namespace TBF.BenchControl.Modbus.QuidoRS.TankSelector +namespace TBF.BenchControl.Modbus.TankSelector { partial class TankSelectorCfgCtrl { diff --git a/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.resx b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/Modbus/TankSelector/TankSelectorCfgCtrl.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/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index 6ddc121ed..8b3bebeb4 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -70,7 +70,10 @@ namespace TBF.BenchControl Factories.Add(new MettlerToledo.Standard.BalanceNewFactory()); /// MettlerToledoBalanceSN Factories.Add(new MettlerToledo.Multi.BalanceFactory()); /// MettlerToledo-Multi Factories.Add(new Modbus.Common.Factory()); /// Modbus - Factories.Add(new Modbus.PressureMeter.Meret.Factory()); /// Meret pressure meter connected via modbus + Factories.Add(new Modbus.Easytherm.Factory()); /// Modbus.Easytherm + Factories.Add(new Modbus.PressureMeter.Meret.Factory()); /// Modbus.PressureMeter.Meret - Meret pressure meter connected via modbus + Factories.Add(new Modbus.QuidoRS.Factory()); /// Modbus.QuidoRS + Factories.Add(new Modbus.TankSelector.Factory()); /// Modbus.TankSelector Factories.Add(new Network.Adapter.Factory()); Factories.Add(new Network.Camera.CLP1611.Factory()); Factories.Add(new Network.Camera.Roi.Factory()); @@ -86,14 +89,12 @@ namespace TBF.BenchControl Factories.Add(new Danfoss.VLT2800.PumpFactory()); Factories.Add(new Elde.PumpWithFM.PumpFactory()); Factories.Add(new Elde.PumpTandem.PumpFactory()); - Factories.Add(new Modbus.QuidoRS.Factory()); /// QuidoRS Factories.Add(new Elde.RegisterReader.Factory()); Factories.Add(new Elde.RegulValve.RegulValveFactory()); Factories.Add(new Elde.RegulValveTandem.RegulValveTandemFactory()); Factories.Add(new ResultsPrinters.Cevak.PrinterFactory()); Factories.Add(new ResultsPrinters.Munich.PrinterFactory()); Factories.Add(new DB.SensusOracle.DatabaseFactory()); - Factories.Add(new Modbus.QuidoRS.TankSelector.Factory()); /// TankSelector Factories.Add(new Elde.TempMeter.TempMeterFactory()); Factories.Add(new Elde.TempMeterInternal.TempMeterFactory()); Factories.Add(new Elde.Valve.ValveFactory()); diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index ca80fd193..28bcc6c7f 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sensus")] [assembly: AssemblyProduct("TestBenchFramework")] -[assembly: AssemblyCopyright("Copyright © 2013 - 2016 Sensus Slovensko, a.s.")] +[assembly: AssemblyCopyright("Copyright © 2013 - 2017 Sensus Slovensko, a.s.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.12.456.1")] -[assembly: AssemblyFileVersion("2.12.456.1")] +[assembly: AssemblyVersion("2.12.457.1")] +[assembly: AssemblyFileVersion("2.12.457.1")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 4395ae964..51002aea5 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -486,6 +486,17 @@ + + + + + UserControl + + + EasythermCfgCtrl.cs + + + @@ -516,13 +527,13 @@ - - - - + + + + UserControl - + TankSelectorCfgCtrl.cs @@ -1877,13 +1888,16 @@ ModbusCfgCtrl.cs + + EasythermCfgCtrl.cs + PressureMeterCfgCtrl.cs QuidoRSCfgCtrl.cs - + TankSelectorCfgCtrl.cs