QuidoRS : Watchdog is optional, configurable, ver. 2 12.455
This commit is contained in:
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
|
||||
private ushort currentOutputs;
|
||||
|
||||
const ushort WatchdogBitMask = 0x0010;
|
||||
ushort watchdogBitMask;
|
||||
|
||||
public QuidoRS()
|
||||
{
|
||||
@@ -33,6 +33,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
watchdogBitMask = (ushort)(quidoRSCfg.WatchdogEnabled ? (1 << quidoRSCfg.WatchdogBitNr) : 0);
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
@@ -49,7 +51,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter()
|
||||
{
|
||||
currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)WatchdogBitMask);
|
||||
currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)watchdogBitMask);
|
||||
SendOutputs(currentOutputs);
|
||||
}
|
||||
|
||||
@@ -64,7 +66,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
/// <param name="outputs">output value</param>
|
||||
public void SetOutputs(ushort outputs)
|
||||
{
|
||||
currentOutputs = (UInt16)((Int32)outputs | ((Int32)currentOutputs & (Int32)WatchdogBitMask));
|
||||
currentOutputs = (UInt16)((Int32)outputs | ((Int32)currentOutputs & (Int32)watchdogBitMask));
|
||||
SendOutputs(currentOutputs);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
/// Serialized parameters
|
||||
///
|
||||
public byte ModbusAddress; /// 1..255
|
||||
public bool WatchdogEnabled;
|
||||
public int WatchdogBitNr; /// 0..15
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
QuidoRSCfg()
|
||||
@@ -24,6 +26,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
Name = "QuidoRS";
|
||||
ParentName = "Modbus";
|
||||
ModbusAddress = 49;
|
||||
WatchdogEnabled = true;
|
||||
WatchdogBitNr = 4;
|
||||
}
|
||||
|
||||
public QuidoRSCfg(IComponentFactory factory)
|
||||
|
||||
@@ -63,6 +63,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
nameTextBox.Text = config.Name;
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
modbusAddressTextBox.Text = config.ModbusAddress.ToString();
|
||||
watchdogCheckBox.Checked = config.WatchdogEnabled;
|
||||
watchdogBitNrTextBox.Text = config.WatchdogBitNr.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
@@ -70,6 +72,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
modbusAddressTextBox.Enabled = true;
|
||||
watchdogCheckBox.Enabled = true;
|
||||
watchdogBitNrTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
@@ -87,7 +91,12 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Modbus Address' should be between 0 and 255";
|
||||
}
|
||||
return flags;
|
||||
if (!int.TryParse(watchdogBitNrTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Watchdog Bit Nr.' should be between 0 and 15";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
@@ -99,6 +108,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.ModbusAddress = (byte)int.Parse(modbusAddressTextBox.Text);
|
||||
config.WatchdogEnabled = watchdogCheckBox.Checked;
|
||||
config.WatchdogBitNr = int.Parse(watchdogBitNrTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
+123
-86
@@ -31,92 +31,126 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
/// </summary>
|
||||
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, 133);
|
||||
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, 130);
|
||||
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;
|
||||
//
|
||||
// ComponentCfgCtrl
|
||||
//
|
||||
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 = "ComponentCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.QuidoRSCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
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.watchdogCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.watchdogBitNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.watchdogBitNrLabel = new System.Windows.Forms.Label();
|
||||
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;
|
||||
//
|
||||
// watchdogCheckBox
|
||||
//
|
||||
this.watchdogCheckBox.AutoSize = true;
|
||||
this.watchdogCheckBox.Enabled = false;
|
||||
this.watchdogCheckBox.Location = new System.Drawing.Point(31, 131);
|
||||
this.watchdogCheckBox.Name = "watchdogCheckBox";
|
||||
this.watchdogCheckBox.Size = new System.Drawing.Size(99, 17);
|
||||
this.watchdogCheckBox.TabIndex = 9;
|
||||
this.watchdogCheckBox.Text = "Watchdog \'ON\'";
|
||||
this.watchdogCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// watchdogBitNrTextBox
|
||||
//
|
||||
this.watchdogBitNrTextBox.Enabled = false;
|
||||
this.watchdogBitNrTextBox.Location = new System.Drawing.Point(138, 153);
|
||||
this.watchdogBitNrTextBox.Name = "watchdogBitNrTextBox";
|
||||
this.watchdogBitNrTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.watchdogBitNrTextBox.TabIndex = 11;
|
||||
//
|
||||
// watchdogBitNrLabel
|
||||
//
|
||||
this.watchdogBitNrLabel.AutoSize = true;
|
||||
this.watchdogBitNrLabel.Location = new System.Drawing.Point(28, 156);
|
||||
this.watchdogBitNrLabel.Name = "watchdogBitNrLabel";
|
||||
this.watchdogBitNrLabel.Size = new System.Drawing.Size(81, 13);
|
||||
this.watchdogBitNrLabel.TabIndex = 10;
|
||||
this.watchdogBitNrLabel.Text = "Watchdog bit #";
|
||||
//
|
||||
// QuidoRSCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.watchdogBitNrTextBox);
|
||||
this.Controls.Add(this.watchdogBitNrLabel);
|
||||
this.Controls.Add(this.watchdogCheckBox);
|
||||
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 = "QuidoRSCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.QuidoRSCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -129,5 +163,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
private System.Windows.Forms.Label modbusAddressLabel;
|
||||
private System.Windows.Forms.TextBox modbusAddressTextBox;
|
||||
private System.Windows.Forms.ComboBox parentNameComboBox;
|
||||
private System.Windows.Forms.CheckBox watchdogCheckBox;
|
||||
private System.Windows.Forms.TextBox watchdogBitNrTextBox;
|
||||
private System.Windows.Forms.Label watchdogBitNrLabel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user