From 5e4eec4d70fac4cc6b6a89fa28cf836084f08301 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 18 Feb 2015 16:19:37 +0100 Subject: [PATCH] Support for FC protocol for Danfoss-VLT2800 added - UI Part --- .../BenchControl/Danfoss/VLT2800/Pump.cs | 4 +- .../BenchControl/Danfoss/VLT2800/PumpCfg.cs | 14 +-- .../Danfoss/VLT2800/PumpCfgCtrl.cs | 22 +++-- .../Danfoss/VLT2800/PumpCfgCtrl.designer.cs | 90 ++++++++++++------- TestBenchFramework/BenchControl/Events.cs | 6 ++ 5 files changed, 90 insertions(+), 46 deletions(-) diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs index f3623959e..b75f868ed 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs @@ -201,7 +201,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 UInt16 serialComReference = (UInt16)(Int16)((float)0x4000 * powerArg / 100.0f + 0.5f); byte[] msg = new byte[13]; - msg[0] = (byte)pumpCfg.ModbusAddress; + msg[0] = (byte)pumpCfg.BusAddress; msg[1] = (byte)Function.ForceMultipleCoils; msg[2] = 0; /// Data Hi msg[3] = 0; /// Data Lo @@ -236,7 +236,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 UInt16 serialComReference = 0; byte[] msg = new byte[13]; - msg[0] = (byte)pumpCfg.ModbusAddress; + msg[0] = (byte)pumpCfg.BusAddress; msg[1] = (byte)Function.ForceMultipleCoils; msg[2] = 0; /// Data Hi msg[3] = 0; /// Data Lo diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs index 8f9efbf81..8f49ebbdf 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs @@ -14,8 +14,9 @@ namespace TBF.BenchControl.Danfoss.VLT2800 /// /// Serialized parameters /// - public int Delay; // Delay of the pump function in [s] (affects the duration of transition sequence steps) - public int ModbusAddress; // Modbus address in range 1..247 + public int Delay; // Delay of the pump function in [s] (affects the duration of transition sequence steps) + public PumpProtocol Protocol; // Modbus or FC + public int BusAddress; // Modbus or FC address in range 1..247 (Modbus) or 1..31 (FC) public int ComPortNr; public int BaudRate; public Parity Parity; @@ -25,9 +26,10 @@ namespace TBF.BenchControl.Danfoss.VLT2800 /// Private parameterless constructor invoked by all other (public) constructors PumpCfg() { - Name = "Ambient"; + Name = "Pump-Danfoss"; Delay = 1; - ModbusAddress = 1; + Protocol = PumpProtocol.Modbus; + BusAddress = 1; ParentName = string.Empty; ComPortNr = 5; BaudRate = 9600; @@ -44,8 +46,8 @@ namespace TBF.BenchControl.Danfoss.VLT2800 public string ToString(int i) { - return string.Format("Name={0}, Delay={1}s, ModbusAddress={2}, Com{3}, {4}Bd, {5}-bits, parity={6}, stopBits={7}", - Name, Delay, ModbusAddress, ComPortNr, BaudRate, DataBits, Parity, StopBits); + return string.Format("Name={0}, Delay={1}s, Protocol={2}, BusAddress={3}, Com{4}, {5}Bd, {6}-bits, parity={7}, stopBits={8}", + Name, Delay, Protocol, BusAddress, ComPortNr, BaudRate, DataBits, Parity, StopBits); } } } diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs index a3cec6c40..7e9eb73a1 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs @@ -27,6 +27,9 @@ namespace TBF.BenchControl.Danfoss.VLT2800 { InitializeComponent(); + protocolComboBox.Items.Add(PumpProtocol.Modbus.ToString()); + protocolComboBox.Items.Add(PumpProtocol.FC.ToString()); + parityComboBox.Items.Add(Parity.None.ToString()); parityComboBox.Items.Add(Parity.Even.ToString()); parityComboBox.Items.Add(Parity.Odd.ToString()); @@ -100,7 +103,8 @@ namespace TBF.BenchControl.Danfoss.VLT2800 classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; delayTextBox.Text = config.Delay.ToString(); - modbusAddressTextBox.Text = config.ModbusAddress.ToString(); + protocolComboBox.Text = config.Protocol.ToString(); + busAddressTextBox.Text = config.BusAddress.ToString(); comPortNrTextBox.Text = config.ComPortNr.ToString(); baudRateTextBox.Text = config.BaudRate.ToString(); parityComboBox.Text = config.Parity.ToString(); @@ -112,7 +116,8 @@ namespace TBF.BenchControl.Danfoss.VLT2800 { nameTextBox.Enabled = true; delayTextBox.Enabled = true; - modbusAddressTextBox.Enabled = true; + protocolComboBox.Enabled = true; + busAddressTextBox.Enabled = true; comPortNrTextBox.Enabled = true; baudRateTextBox.Enabled = true; parityComboBox.Enabled = true; @@ -128,7 +133,8 @@ namespace TBF.BenchControl.Danfoss.VLT2800 config.Name = nameTextBox.Text; config.Delay = int.Parse(delayTextBox.Text); - config.ModbusAddress = int.Parse(modbusAddressTextBox.Text); + config.Protocol = protocolComboBox.Text.Equals(PumpProtocol.Modbus.ToString()) ? PumpProtocol.Modbus : PumpProtocol.FC; + config.BusAddress = int.Parse(busAddressTextBox.Text); config.ComPortNr = int.Parse(comPortNrTextBox.Text); config.BaudRate = int.Parse(baudRateTextBox.Text); config.Parity = GetParity(parityComboBox.SelectedItem.ToString()); @@ -149,10 +155,16 @@ namespace TBF.BenchControl.Danfoss.VLT2800 message += Environment.NewLine + "'Delay' is not valid"; } - if (!int.TryParse(modbusAddressTextBox.Text, out dummy) || dummy < 1 || dummy > 247) + if (!protocolComboBox.Items.Contains(protocolComboBox.Text)) { flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Modbus Address' should be in range 1..247"; + message += Environment.NewLine + "'Protocol' should Modbus or FC"; + } + + if (!int.TryParse(busAddressTextBox.Text, out dummy) || dummy < 1 || dummy > 247) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Bus Address' should be in range 1..247"; } if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999) diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs index c447b55cf..710bbf160 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs @@ -36,21 +36,23 @@ this.dataBitsLabel = new System.Windows.Forms.Label(); this.dataBitsTextBox = new System.Windows.Forms.TextBox(); this.stopBitsLabel = new System.Windows.Forms.Label(); - this.modbusAddressLabel = new System.Windows.Forms.Label(); + this.busAddressLabel = new System.Windows.Forms.Label(); this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label(); this.parityComboBox = new System.Windows.Forms.ComboBox(); this.stopBitsComboBox = new System.Windows.Forms.ComboBox(); - this.modbusAddressTextBox = new System.Windows.Forms.TextBox(); + this.busAddressTextBox = new System.Windows.Forms.TextBox(); this.delayTextBox = new System.Windows.Forms.TextBox(); this.delayLabel = new System.Windows.Forms.Label(); + this.protocolLabel = new System.Windows.Forms.Label(); + this.protocolComboBox = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // comPortNrTextBox // this.comPortNrTextBox.Enabled = false; - this.comPortNrTextBox.Location = new System.Drawing.Point(140, 107); + this.comPortNrTextBox.Location = new System.Drawing.Point(140, 125); this.comPortNrTextBox.Name = "comPortNrTextBox"; this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20); this.comPortNrTextBox.TabIndex = 6; @@ -58,7 +60,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(29, 110); + this.label1.Location = new System.Drawing.Point(29, 128); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(98, 13); this.label1.TabIndex = 5; @@ -67,7 +69,7 @@ // baudRateLabel // this.baudRateLabel.AutoSize = true; - this.baudRateLabel.Location = new System.Drawing.Point(29, 134); + this.baudRateLabel.Location = new System.Drawing.Point(29, 150); this.baudRateLabel.Name = "baudRateLabel"; this.baudRateLabel.Size = new System.Drawing.Size(58, 13); this.baudRateLabel.TabIndex = 7; @@ -76,7 +78,7 @@ // baudRateTextBox // this.baudRateTextBox.Enabled = false; - this.baudRateTextBox.Location = new System.Drawing.Point(140, 131); + this.baudRateTextBox.Location = new System.Drawing.Point(140, 147); this.baudRateTextBox.Name = "baudRateTextBox"; this.baudRateTextBox.Size = new System.Drawing.Size(130, 20); this.baudRateTextBox.TabIndex = 8; @@ -84,7 +86,7 @@ // partityLabel // this.partityLabel.AutoSize = true; - this.partityLabel.Location = new System.Drawing.Point(29, 158); + this.partityLabel.Location = new System.Drawing.Point(29, 172); this.partityLabel.Name = "partityLabel"; this.partityLabel.Size = new System.Drawing.Size(33, 13); this.partityLabel.TabIndex = 9; @@ -93,7 +95,7 @@ // dataBitsLabel // this.dataBitsLabel.AutoSize = true; - this.dataBitsLabel.Location = new System.Drawing.Point(29, 182); + this.dataBitsLabel.Location = new System.Drawing.Point(29, 195); this.dataBitsLabel.Name = "dataBitsLabel"; this.dataBitsLabel.Size = new System.Drawing.Size(50, 13); this.dataBitsLabel.TabIndex = 11; @@ -102,7 +104,7 @@ // dataBitsTextBox // this.dataBitsTextBox.Enabled = false; - this.dataBitsTextBox.Location = new System.Drawing.Point(140, 179); + this.dataBitsTextBox.Location = new System.Drawing.Point(140, 192); this.dataBitsTextBox.Name = "dataBitsTextBox"; this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20); this.dataBitsTextBox.TabIndex = 12; @@ -110,25 +112,25 @@ // stopBitsLabel // this.stopBitsLabel.AutoSize = true; - this.stopBitsLabel.Location = new System.Drawing.Point(29, 206); + this.stopBitsLabel.Location = new System.Drawing.Point(29, 217); this.stopBitsLabel.Name = "stopBitsLabel"; this.stopBitsLabel.Size = new System.Drawing.Size(49, 13); this.stopBitsLabel.TabIndex = 13; this.stopBitsLabel.Text = "Stop Bits"; // - // modbusAddressLabel + // busAddressLabel // - this.modbusAddressLabel.AutoSize = true; - this.modbusAddressLabel.Location = new System.Drawing.Point(29, 79); - this.modbusAddressLabel.Name = "modbusAddressLabel"; - this.modbusAddressLabel.Size = new System.Drawing.Size(86, 13); - this.modbusAddressLabel.TabIndex = 3; - this.modbusAddressLabel.Text = "Modbus Address"; + this.busAddressLabel.AutoSize = true; + this.busAddressLabel.Location = new System.Drawing.Point(29, 95); + this.busAddressLabel.Name = "busAddressLabel"; + this.busAddressLabel.Size = new System.Drawing.Size(66, 13); + this.busAddressLabel.TabIndex = 3; + this.busAddressLabel.Text = "Bus Address"; // // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(140, 28); + this.nameTextBox.Location = new System.Drawing.Point(140, 26); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 2; @@ -136,7 +138,7 @@ // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(30, 31); + this.nameLabel.Location = new System.Drawing.Point(30, 29); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.TabIndex = 1; @@ -155,7 +157,7 @@ // this.parityComboBox.Enabled = false; this.parityComboBox.FormattingEnabled = true; - this.parityComboBox.Location = new System.Drawing.Point(140, 155); + this.parityComboBox.Location = new System.Drawing.Point(140, 169); this.parityComboBox.Name = "parityComboBox"; this.parityComboBox.Size = new System.Drawing.Size(130, 21); this.parityComboBox.TabIndex = 10; @@ -164,23 +166,23 @@ // this.stopBitsComboBox.Enabled = false; this.stopBitsComboBox.FormattingEnabled = true; - this.stopBitsComboBox.Location = new System.Drawing.Point(140, 203); + this.stopBitsComboBox.Location = new System.Drawing.Point(140, 214); this.stopBitsComboBox.Name = "stopBitsComboBox"; this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21); this.stopBitsComboBox.TabIndex = 14; // - // modbusAddressTextBox + // busAddressTextBox // - this.modbusAddressTextBox.Enabled = false; - this.modbusAddressTextBox.Location = new System.Drawing.Point(140, 77); - this.modbusAddressTextBox.Name = "modbusAddressTextBox"; - this.modbusAddressTextBox.Size = new System.Drawing.Size(34, 20); - this.modbusAddressTextBox.TabIndex = 4; + this.busAddressTextBox.Enabled = false; + this.busAddressTextBox.Location = new System.Drawing.Point(140, 93); + this.busAddressTextBox.Name = "busAddressTextBox"; + this.busAddressTextBox.Size = new System.Drawing.Size(34, 20); + this.busAddressTextBox.TabIndex = 4; // // delayTextBox // this.delayTextBox.Enabled = false; - this.delayTextBox.Location = new System.Drawing.Point(140, 53); + this.delayTextBox.Location = new System.Drawing.Point(140, 48); this.delayTextBox.Name = "delayTextBox"; this.delayTextBox.Size = new System.Drawing.Size(34, 20); this.delayTextBox.TabIndex = 16; @@ -188,26 +190,46 @@ // delayLabel // this.delayLabel.AutoSize = true; - this.delayLabel.Location = new System.Drawing.Point(29, 55); + this.delayLabel.Location = new System.Drawing.Point(29, 50); this.delayLabel.Name = "delayLabel"; this.delayLabel.Size = new System.Drawing.Size(45, 13); this.delayLabel.TabIndex = 15; this.delayLabel.Text = "Delay[s]"; // + // protocolLabel + // + this.protocolLabel.AutoSize = true; + this.protocolLabel.Location = new System.Drawing.Point(29, 73); + this.protocolLabel.Name = "protocolLabel"; + this.protocolLabel.Size = new System.Drawing.Size(46, 13); + this.protocolLabel.TabIndex = 17; + this.protocolLabel.Text = "Protocol"; + // + // protocolComboBox + // + this.protocolComboBox.Enabled = false; + this.protocolComboBox.FormattingEnabled = true; + this.protocolComboBox.Location = new System.Drawing.Point(140, 70); + this.protocolComboBox.Name = "protocolComboBox"; + this.protocolComboBox.Size = new System.Drawing.Size(130, 21); + this.protocolComboBox.TabIndex = 18; + // // PumpCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; + this.Controls.Add(this.protocolComboBox); + this.Controls.Add(this.protocolLabel); this.Controls.Add(this.delayTextBox); this.Controls.Add(this.delayLabel); - this.Controls.Add(this.modbusAddressTextBox); + this.Controls.Add(this.busAddressTextBox); this.Controls.Add(this.stopBitsComboBox); this.Controls.Add(this.parityComboBox); this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameLabel); this.Controls.Add(this.classNameLabel); - this.Controls.Add(this.modbusAddressLabel); + this.Controls.Add(this.busAddressLabel); this.Controls.Add(this.stopBitsLabel); this.Controls.Add(this.dataBitsTextBox); this.Controls.Add(this.dataBitsLabel); @@ -234,15 +256,17 @@ private System.Windows.Forms.Label dataBitsLabel; private System.Windows.Forms.TextBox dataBitsTextBox; private System.Windows.Forms.Label stopBitsLabel; - private System.Windows.Forms.Label modbusAddressLabel; + private System.Windows.Forms.Label busAddressLabel; private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.ComboBox parityComboBox; private System.Windows.Forms.ComboBox stopBitsComboBox; - private System.Windows.Forms.TextBox modbusAddressTextBox; + private System.Windows.Forms.TextBox busAddressTextBox; private System.Windows.Forms.TextBox delayTextBox; private System.Windows.Forms.Label delayLabel; + private System.Windows.Forms.Label protocolLabel; + private System.Windows.Forms.ComboBox protocolComboBox; } } diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index b8de567ca..074a7c4df 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -44,6 +44,12 @@ None, /// Valve will not be shown in the paths } + public enum PumpProtocol + { + Modbus, + FC, + } + /// /// StateMachine events (issued by operations, IOperation derived classes) ///