diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs index 70d0d587f..f87de2601 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/Pump.cs @@ -108,8 +108,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 controlBoard = (Elde.ControlBoardDev)TbfComponents.FindComponent("CB", components); /// TODO: replace "CB" if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); - //bitPosition = pumpCfg.BitPosition; - bitPosition = 55; /// TODO: replace 55 + bitPosition = pumpCfg.BitPosition; Mask = (((ulong)1) << bitPosition); log.Debug(this.ToString()); @@ -200,21 +199,35 @@ 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.BusAddress; - msg[1] = (byte)Function.ForceMultipleCoils; - msg[2] = 0; /// Data Hi - msg[3] = 0; /// Data Lo - msg[4] = 0; /// Nr. of coils Hi - msg[5] = 0x20; /// Nr. of coils Lo - msg[6] = 4; /// Byte count - msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo - msg[8] = (byte)(controlWord >> 8); /// Control Word Hi - msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo - msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi - - Telegram.UpdateTelegramCRC(msg); - + byte[] msg; + if (pumpCfg.Protocol == PumpProtocol.Modbus) + { + msg = new byte[13]; + msg[0] = (byte)pumpCfg.BusAddress; + msg[1] = (byte)Function.ForceMultipleCoils; + msg[2] = 0; /// Data Hi + msg[3] = 0; /// Data Lo + msg[4] = 0; /// Nr. of coils Hi + msg[5] = 0x20; /// Nr. of coils Lo + msg[6] = 4; /// Byte count + msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo + msg[8] = (byte)(controlWord >> 8); /// Control Word Hi + msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo + msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi + Telegram.UpdateTelegramCRC(msg); + } + else /// if (pumpCfg.Protocol == PumpProtocol.FC) + { + msg = new byte[8]; + msg[0] = 0x02; /// STX + msg[1] = 6; /// lenght (6 bytes following this one) + msg[2] = (byte)pumpCfg.BusAddress; + msg[3] = (byte)(controlWord >> 8); /// Control Word Hi + msg[4] = (byte)(controlWord & 0xFF); /// Control Word Lo + msg[5] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi + msg[6] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo + Telegram.UpdateTelegramChecksum(msg); + } SendData(msg); } @@ -235,21 +248,35 @@ namespace TBF.BenchControl.Danfoss.VLT2800 UInt16 serialComReference = 0; - byte[] msg = new byte[13]; - msg[0] = (byte)pumpCfg.BusAddress; - msg[1] = (byte)Function.ForceMultipleCoils; - msg[2] = 0; /// Data Hi - msg[3] = 0; /// Data Lo - msg[4] = 0; /// Nr. of coils Hi - msg[5] = 0x20; /// Nr. of coils Lo - msg[6] = 4; /// Byte count - msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo - msg[8] = (byte)(controlWord >> 8); /// Control Word Hi - msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo - msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi - - Telegram.UpdateTelegramCRC(msg); - + byte[] msg; + if (pumpCfg.Protocol == PumpProtocol.Modbus) + { + msg = new byte[13]; + msg[0] = (byte)pumpCfg.BusAddress; + msg[1] = (byte)Function.ForceMultipleCoils; + msg[2] = 0; /// Data Hi + msg[3] = 0; /// Data Lo + msg[4] = 0; /// Nr. of coils Hi + msg[5] = 0x20; /// Nr. of coils Lo + msg[6] = 4; /// Byte count + msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo + msg[8] = (byte)(controlWord >> 8); /// Control Word Hi + msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo + msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi + Telegram.UpdateTelegramCRC(msg); + } + else /// if (pumpCfg.Protocol == PumpProtocol.FC) + { + msg = new byte[8]; + msg[0] = 0x02; /// STX + msg[1] = 6; /// lenght (6 bytes following this one) + msg[2] = (byte)pumpCfg.BusAddress; + msg[3] = (byte)(controlWord >> 8); /// Control Word Hi + msg[4] = (byte)(controlWord & 0xFF); /// Control Word Lo + msg[5] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi + msg[6] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo + Telegram.UpdateTelegramChecksum(msg); + } SendData(msg); } diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs index 8f49ebbdf..aa749e46c 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfg.cs @@ -16,6 +16,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 /// 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 BitPosition; public int BusAddress; // Modbus or FC address in range 1..247 (Modbus) or 1..31 (FC) public int ComPortNr; public int BaudRate; diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs index 7e9eb73a1..95be17263 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.cs @@ -103,6 +103,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; delayTextBox.Text = config.Delay.ToString(); + bitPositionTextBox.Text = config.BitPosition.ToString(); protocolComboBox.Text = config.Protocol.ToString(); busAddressTextBox.Text = config.BusAddress.ToString(); comPortNrTextBox.Text = config.ComPortNr.ToString(); @@ -116,6 +117,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 { nameTextBox.Enabled = true; delayTextBox.Enabled = true; + bitPositionTextBox.Enabled = true; protocolComboBox.Enabled = true; busAddressTextBox.Enabled = true; comPortNrTextBox.Enabled = true; @@ -133,6 +135,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 config.Name = nameTextBox.Text; config.Delay = int.Parse(delayTextBox.Text); + config.BitPosition = int.Parse(bitPositionTextBox.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); @@ -155,6 +158,12 @@ namespace TBF.BenchControl.Danfoss.VLT2800 message += Environment.NewLine + "'Delay' is not valid"; } + if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; + } + if (!protocolComboBox.Items.Contains(protocolComboBox.Text)) { flags |= CfgUpdateFlags.Error; diff --git a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs index 710bbf160..bc16345fd 100644 --- a/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/Danfoss/VLT2800/PumpCfgCtrl.designer.cs @@ -47,12 +47,14 @@ this.delayLabel = new System.Windows.Forms.Label(); this.protocolLabel = new System.Windows.Forms.Label(); this.protocolComboBox = new System.Windows.Forms.ComboBox(); + this.bitPositionTextBox = new System.Windows.Forms.TextBox(); + this.bitPositionLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // comPortNrTextBox // this.comPortNrTextBox.Enabled = false; - this.comPortNrTextBox.Location = new System.Drawing.Point(140, 125); + this.comPortNrTextBox.Location = new System.Drawing.Point(140, 129); this.comPortNrTextBox.Name = "comPortNrTextBox"; this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20); this.comPortNrTextBox.TabIndex = 6; @@ -60,7 +62,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(29, 128); + this.label1.Location = new System.Drawing.Point(29, 132); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(98, 13); this.label1.TabIndex = 5; @@ -69,7 +71,7 @@ // baudRateLabel // this.baudRateLabel.AutoSize = true; - this.baudRateLabel.Location = new System.Drawing.Point(29, 150); + this.baudRateLabel.Location = new System.Drawing.Point(29, 153); this.baudRateLabel.Name = "baudRateLabel"; this.baudRateLabel.Size = new System.Drawing.Size(58, 13); this.baudRateLabel.TabIndex = 7; @@ -78,7 +80,7 @@ // baudRateTextBox // this.baudRateTextBox.Enabled = false; - this.baudRateTextBox.Location = new System.Drawing.Point(140, 147); + this.baudRateTextBox.Location = new System.Drawing.Point(140, 150); this.baudRateTextBox.Name = "baudRateTextBox"; this.baudRateTextBox.Size = new System.Drawing.Size(130, 20); this.baudRateTextBox.TabIndex = 8; @@ -86,7 +88,7 @@ // partityLabel // this.partityLabel.AutoSize = true; - this.partityLabel.Location = new System.Drawing.Point(29, 172); + this.partityLabel.Location = new System.Drawing.Point(29, 174); this.partityLabel.Name = "partityLabel"; this.partityLabel.Size = new System.Drawing.Size(33, 13); this.partityLabel.TabIndex = 9; @@ -95,7 +97,7 @@ // dataBitsLabel // this.dataBitsLabel.AutoSize = true; - this.dataBitsLabel.Location = new System.Drawing.Point(29, 195); + this.dataBitsLabel.Location = new System.Drawing.Point(29, 196); this.dataBitsLabel.Name = "dataBitsLabel"; this.dataBitsLabel.Size = new System.Drawing.Size(50, 13); this.dataBitsLabel.TabIndex = 11; @@ -104,7 +106,7 @@ // dataBitsTextBox // this.dataBitsTextBox.Enabled = false; - this.dataBitsTextBox.Location = new System.Drawing.Point(140, 192); + this.dataBitsTextBox.Location = new System.Drawing.Point(140, 193); this.dataBitsTextBox.Name = "dataBitsTextBox"; this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20); this.dataBitsTextBox.TabIndex = 12; @@ -121,7 +123,7 @@ // busAddressLabel // this.busAddressLabel.AutoSize = true; - this.busAddressLabel.Location = new System.Drawing.Point(29, 95); + this.busAddressLabel.Location = new System.Drawing.Point(29, 110); this.busAddressLabel.Name = "busAddressLabel"; this.busAddressLabel.Size = new System.Drawing.Size(66, 13); this.busAddressLabel.TabIndex = 3; @@ -130,7 +132,7 @@ // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(140, 26); + this.nameTextBox.Location = new System.Drawing.Point(140, 23); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 2; @@ -138,7 +140,7 @@ // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(30, 29); + this.nameLabel.Location = new System.Drawing.Point(30, 26); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.TabIndex = 1; @@ -147,7 +149,7 @@ // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(137, 7); + this.classNameLabel.Location = new System.Drawing.Point(137, 5); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.TabIndex = 0; @@ -157,7 +159,7 @@ // this.parityComboBox.Enabled = false; this.parityComboBox.FormattingEnabled = true; - this.parityComboBox.Location = new System.Drawing.Point(140, 169); + this.parityComboBox.Location = new System.Drawing.Point(140, 171); this.parityComboBox.Name = "parityComboBox"; this.parityComboBox.Size = new System.Drawing.Size(130, 21); this.parityComboBox.TabIndex = 10; @@ -174,7 +176,7 @@ // busAddressTextBox // this.busAddressTextBox.Enabled = false; - this.busAddressTextBox.Location = new System.Drawing.Point(140, 93); + this.busAddressTextBox.Location = new System.Drawing.Point(140, 108); this.busAddressTextBox.Name = "busAddressTextBox"; this.busAddressTextBox.Size = new System.Drawing.Size(34, 20); this.busAddressTextBox.TabIndex = 4; @@ -182,7 +184,7 @@ // delayTextBox // this.delayTextBox.Enabled = false; - this.delayTextBox.Location = new System.Drawing.Point(140, 48); + this.delayTextBox.Location = new System.Drawing.Point(140, 44); this.delayTextBox.Name = "delayTextBox"; this.delayTextBox.Size = new System.Drawing.Size(34, 20); this.delayTextBox.TabIndex = 16; @@ -190,7 +192,7 @@ // delayLabel // this.delayLabel.AutoSize = true; - this.delayLabel.Location = new System.Drawing.Point(29, 50); + this.delayLabel.Location = new System.Drawing.Point(29, 46); this.delayLabel.Name = "delayLabel"; this.delayLabel.Size = new System.Drawing.Size(45, 13); this.delayLabel.TabIndex = 15; @@ -199,7 +201,7 @@ // protocolLabel // this.protocolLabel.AutoSize = true; - this.protocolLabel.Location = new System.Drawing.Point(29, 73); + this.protocolLabel.Location = new System.Drawing.Point(29, 89); this.protocolLabel.Name = "protocolLabel"; this.protocolLabel.Size = new System.Drawing.Size(46, 13); this.protocolLabel.TabIndex = 17; @@ -209,16 +211,35 @@ // this.protocolComboBox.Enabled = false; this.protocolComboBox.FormattingEnabled = true; - this.protocolComboBox.Location = new System.Drawing.Point(140, 70); + this.protocolComboBox.Location = new System.Drawing.Point(140, 86); this.protocolComboBox.Name = "protocolComboBox"; this.protocolComboBox.Size = new System.Drawing.Size(130, 21); this.protocolComboBox.TabIndex = 18; // + // bitPositionTextBox + // + this.bitPositionTextBox.Enabled = false; + this.bitPositionTextBox.Location = new System.Drawing.Point(140, 65); + this.bitPositionTextBox.Name = "bitPositionTextBox"; + this.bitPositionTextBox.Size = new System.Drawing.Size(34, 20); + this.bitPositionTextBox.TabIndex = 20; + // + // bitPositionLabel + // + this.bitPositionLabel.AutoSize = true; + this.bitPositionLabel.Location = new System.Drawing.Point(30, 68); + this.bitPositionLabel.Name = "bitPositionLabel"; + this.bitPositionLabel.Size = new System.Drawing.Size(89, 13); + this.bitPositionLabel.TabIndex = 19; + this.bitPositionLabel.Text = "Valve Bit Position"; + // // 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.bitPositionTextBox); + this.Controls.Add(this.bitPositionLabel); this.Controls.Add(this.protocolComboBox); this.Controls.Add(this.protocolLabel); this.Controls.Add(this.delayTextBox); @@ -267,6 +288,8 @@ private System.Windows.Forms.Label delayLabel; private System.Windows.Forms.Label protocolLabel; private System.Windows.Forms.ComboBox protocolComboBox; + private System.Windows.Forms.TextBox bitPositionTextBox; + private System.Windows.Forms.Label bitPositionLabel; } } diff --git a/TestBenchFramework/BenchControl/Elde/PumpTandem/Pump.cs b/TestBenchFramework/BenchControl/Elde/PumpTandem/Pump.cs index 984523ebc..bf4b29f09 100644 --- a/TestBenchFramework/BenchControl/Elde/PumpTandem/Pump.cs +++ b/TestBenchFramework/BenchControl/Elde/PumpTandem/Pump.cs @@ -45,10 +45,12 @@ namespace TBF.BenchControl.Elde.PumpTandem if (pump1 is Elde.Pump.Pump) { mask1 = (pump1 as Elde.Pump.Pump).Mask; } else if (pump1 is Elde.PumpWithFM.Pump) { mask1 = (pump1 as Elde.PumpWithFM.Pump).Mask; } + else if (pump1 is Danfoss.VLT2800.Pump) { mask1 = (pump1 as Danfoss.VLT2800.Pump).Mask; } else { mask1 = 0; } if (pump2 is Elde.Pump.Pump) { mask2 = (pump2 as Elde.Pump.Pump).Mask; } else if (pump2 is Elde.PumpWithFM.Pump) { mask2 = (pump2 as Elde.PumpWithFM.Pump).Mask; } + else if (pump2 is Danfoss.VLT2800.Pump) { mask2 = (pump2 as Danfoss.VLT2800.Pump).Mask; } else { mask2 = 0; } log.Debug(this.ToString()); diff --git a/TestBenchFramework/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs b/TestBenchFramework/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs index 1b39f2d2d..d87854852 100644 --- a/TestBenchFramework/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs @@ -40,6 +40,7 @@ namespace TBF.BenchControl.Elde.PumpTandem { if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Pump.PumpFactory || TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.PumpWithFM.PumpFactory || + TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Danfoss.VLT2800.PumpFactory || TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.PumpTandem.PumpFactory) { pump1ComboBox.Items.Add(cmpnt.Name); diff --git a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs index 74b453a83..85036dd61 100644 --- a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs +++ b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs @@ -41,6 +41,7 @@ namespace TBF.BenchControl.Elde.Valve if (vlv is Valve && ((vlv as Valve).Mask & changed) == 0) continue; if (vlv is Pump.Pump && ((vlv as Pump.Pump).Mask & changed) == 0) continue; if (vlv is PumpWithFM.Pump && ((vlv as PumpWithFM.Pump).Mask & changed) == 0) continue; + if (vlv is Danfoss.VLT2800.Pump && ((vlv as Danfoss.VLT2800.Pump).Mask & changed) == 0) continue; if ((vlv != null) && (vlv.Delay > max)) max = vlv.Delay; } @@ -50,6 +51,7 @@ namespace TBF.BenchControl.Elde.Valve if (vlv is Valve && ((vlv as Valve).Mask & changed) == 0) continue; if (vlv is Pump.Pump && ((vlv as Pump.Pump).Mask & changed) == 0) continue; if (vlv is PumpWithFM.Pump && ((vlv as PumpWithFM.Pump).Mask & changed) == 0) continue; + if (vlv is Danfoss.VLT2800.Pump && ((vlv as Danfoss.VLT2800.Pump).Mask & changed) == 0) continue; if ((vlv != null) && (vlv.Delay > max)) max = vlv.Delay; } @@ -149,6 +151,7 @@ namespace TBF.BenchControl.Elde.Valve if (valve is Valve) point.MasksOpen |= (valve as Valve).Mask; if (valve is Pump.Pump) point.MasksOpen |= (valve as Pump.Pump).Mask; if (valve is PumpWithFM.Pump) point.MasksOpen |= (valve as PumpWithFM.Pump).Mask; + if (valve is Danfoss.VLT2800.Pump) point.MasksOpen |= (valve as Danfoss.VLT2800.Pump).Mask; if (valve is PumpTandem.Pump) point.MasksOpen |= (valve as PumpTandem.Pump).Mask; } point.MasksClose = 0; @@ -157,6 +160,7 @@ namespace TBF.BenchControl.Elde.Valve if (valve is Valve) point.MasksClose |= (valve as Valve).Mask; if (valve is Pump.Pump) point.MasksClose |= (valve as Pump.Pump).Mask; if (valve is PumpWithFM.Pump) point.MasksClose |= (valve as PumpWithFM.Pump).Mask; + if (valve is Danfoss.VLT2800.Pump) point.MasksClose |= (valve as Danfoss.VLT2800.Pump).Mask; if (valve is PumpTandem.Pump) point.MasksClose |= (valve as PumpTandem.Pump).Mask; } point.TimeSec += timeShift;