Mass values are printed out using format specified by Balance component parameters

This commit is contained in:
Milan Hanajik
2015-03-25 10:01:37 +01:00
parent 4342e7a8b2
commit a26c90f217
8 changed files with 338 additions and 286 deletions
@@ -26,7 +26,8 @@ namespace TBF.BenchControl.MettlerToledo
public Handshake Handshake;
public float Capacity; /// Max. water mass in 'kg' or volume in 'l'
public float Empty; /// 'Empty' water mass in 'kg' or volume in 'l'
public int EmptyTimeSec; /// s
public string Format;
public int EmptyTimeSec; /// s
/// Private parameterless constructor invoked by all other (public) constructors
BalanceCfg()
@@ -41,7 +42,8 @@ namespace TBF.BenchControl.MettlerToledo
Handshake = System.IO.Ports.Handshake.XOnXOff;
Capacity = 200.0f;
Empty = 20.0f;
EmptyTimeSec = 180;
Format = "F3";
EmptyTimeSec = 180;
}
public BalanceCfg(IComponentFactory factory)
@@ -52,8 +54,8 @@ namespace TBF.BenchControl.MettlerToledo
public string ToString(int i)
{
return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}, capacity={7}kg, empty={8}kg, emptyTime={9}s",
Name, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake, Capacity, Empty, EmptyTimeSec);
return string.Format("Name={0}, {1}kg, empty={2}kg, fmt.={3}, emptyTm={4}s, Com{5}, {6}Bd, {7}-bits, parity={8}, stopBits={9}, {10}",
Name, Capacity, Empty, Format, EmptyTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
}
}
}
@@ -28,274 +28,295 @@
/// </summary>
private void InitializeComponent()
{
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
this.parityComboBox = new System.Windows.Forms.ComboBox();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.handshakeLabel = new System.Windows.Forms.Label();
this.stopBitsLabel = new System.Windows.Forms.Label();
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
this.dataBitsLabel = new System.Windows.Forms.Label();
this.partityLabel = new System.Windows.Forms.Label();
this.baudRateTextBox = new System.Windows.Forms.TextBox();
this.baudRateLabel = new System.Windows.Forms.Label();
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.capacityLabel = new System.Windows.Forms.Label();
this.capacityTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.emptyTextBox = new System.Windows.Forms.TextBox();
this.emptyLabel = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.emptyTimeTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// handshakeComboBox
//
this.handshakeComboBox.Enabled = false;
this.handshakeComboBox.FormattingEnabled = true;
this.handshakeComboBox.Location = new System.Drawing.Point(136, 159);
this.handshakeComboBox.Name = "handshakeComboBox";
this.handshakeComboBox.Size = new System.Drawing.Size(130, 21);
this.handshakeComboBox.TabIndex = 14;
//
// stopBitsComboBox
//
this.stopBitsComboBox.Enabled = false;
this.stopBitsComboBox.FormattingEnabled = true;
this.stopBitsComboBox.Location = new System.Drawing.Point(136, 137);
this.stopBitsComboBox.Name = "stopBitsComboBox";
this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21);
this.stopBitsComboBox.TabIndex = 12;
//
// parityComboBox
//
this.parityComboBox.Enabled = false;
this.parityComboBox.FormattingEnabled = true;
this.parityComboBox.Location = new System.Drawing.Point(136, 93);
this.parityComboBox.Name = "parityComboBox";
this.parityComboBox.Size = new System.Drawing.Size(130, 21);
this.parityComboBox.TabIndex = 8;
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(136, 27);
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(26, 30);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(133, 7);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// handshakeLabel
//
this.handshakeLabel.AutoSize = true;
this.handshakeLabel.Location = new System.Drawing.Point(25, 162);
this.handshakeLabel.Name = "handshakeLabel";
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
this.handshakeLabel.TabIndex = 13;
this.handshakeLabel.Text = "Handshake";
//
// stopBitsLabel
//
this.stopBitsLabel.AutoSize = true;
this.stopBitsLabel.Location = new System.Drawing.Point(25, 140);
this.stopBitsLabel.Name = "stopBitsLabel";
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
this.stopBitsLabel.TabIndex = 11;
this.stopBitsLabel.Text = "Stop Bits";
//
// dataBitsTextBox
//
this.dataBitsTextBox.Enabled = false;
this.dataBitsTextBox.Location = new System.Drawing.Point(136, 115);
this.dataBitsTextBox.Name = "dataBitsTextBox";
this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20);
this.dataBitsTextBox.TabIndex = 10;
//
// dataBitsLabel
//
this.dataBitsLabel.AutoSize = true;
this.dataBitsLabel.Location = new System.Drawing.Point(25, 118);
this.dataBitsLabel.Name = "dataBitsLabel";
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
this.dataBitsLabel.TabIndex = 9;
this.dataBitsLabel.Text = "Data Bits";
//
// partityLabel
//
this.partityLabel.AutoSize = true;
this.partityLabel.Location = new System.Drawing.Point(25, 98);
this.partityLabel.Name = "partityLabel";
this.partityLabel.Size = new System.Drawing.Size(33, 13);
this.partityLabel.TabIndex = 7;
this.partityLabel.Text = "Parity";
//
// baudRateTextBox
//
this.baudRateTextBox.Enabled = false;
this.baudRateTextBox.Location = new System.Drawing.Point(136, 71);
this.baudRateTextBox.Name = "baudRateTextBox";
this.baudRateTextBox.Size = new System.Drawing.Size(130, 20);
this.baudRateTextBox.TabIndex = 6;
//
// baudRateLabel
//
this.baudRateLabel.AutoSize = true;
this.baudRateLabel.Location = new System.Drawing.Point(25, 74);
this.baudRateLabel.Name = "baudRateLabel";
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
this.baudRateLabel.TabIndex = 5;
this.baudRateLabel.Text = "Baud Rate";
//
// comPortNrTextBox
//
this.comPortNrTextBox.Enabled = false;
this.comPortNrTextBox.Location = new System.Drawing.Point(136, 49);
this.comPortNrTextBox.Name = "comPortNrTextBox";
this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20);
this.comPortNrTextBox.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 52);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Serial Port Number:";
//
// capacityLabel
//
this.capacityLabel.AutoSize = true;
this.capacityLabel.Location = new System.Drawing.Point(25, 185);
this.capacityLabel.Name = "capacityLabel";
this.capacityLabel.Size = new System.Drawing.Size(76, 13);
this.capacityLabel.TabIndex = 15;
this.capacityLabel.Text = "Tank Capacity";
//
// capacityTextBox
//
this.capacityTextBox.Enabled = false;
this.capacityTextBox.Location = new System.Drawing.Point(136, 182);
this.capacityTextBox.Name = "capacityTextBox";
this.capacityTextBox.Size = new System.Drawing.Size(43, 20);
this.capacityTextBox.TabIndex = 16;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(185, 185);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(19, 13);
this.label2.TabIndex = 17;
this.label2.Text = "kg";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(185, 207);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(19, 13);
this.label3.TabIndex = 20;
this.label3.Text = "kg";
//
// emptyTextBox
//
this.emptyTextBox.Enabled = false;
this.emptyTextBox.Location = new System.Drawing.Point(136, 204);
this.emptyTextBox.Name = "emptyTextBox";
this.emptyTextBox.Size = new System.Drawing.Size(43, 20);
this.emptyTextBox.TabIndex = 19;
//
// emptyLabel
//
this.emptyLabel.AutoSize = true;
this.emptyLabel.Location = new System.Drawing.Point(25, 207);
this.emptyLabel.Name = "emptyLabel";
this.emptyLabel.Size = new System.Drawing.Size(64, 13);
this.emptyLabel.TabIndex = 18;
this.emptyLabel.Text = "Tank Empty";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(185, 229);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(24, 13);
this.label4.TabIndex = 23;
this.label4.Text = "sec";
//
// emptyTimeTextBox
//
this.emptyTimeTextBox.Enabled = false;
this.emptyTimeTextBox.Location = new System.Drawing.Point(136, 226);
this.emptyTimeTextBox.Name = "emptyTimeTextBox";
this.emptyTimeTextBox.Size = new System.Drawing.Size(43, 20);
this.emptyTimeTextBox.TabIndex = 22;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(25, 229);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(90, 13);
this.label5.TabIndex = 21;
this.label5.Text = "Tank Empty Time";
//
// BalanceCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label4);
this.Controls.Add(this.emptyTimeTextBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.emptyTextBox);
this.Controls.Add(this.emptyLabel);
this.Controls.Add(this.label2);
this.Controls.Add(this.capacityTextBox);
this.Controls.Add(this.capacityLabel);
this.Controls.Add(this.handshakeComboBox);
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.handshakeLabel);
this.Controls.Add(this.stopBitsLabel);
this.Controls.Add(this.dataBitsTextBox);
this.Controls.Add(this.dataBitsLabel);
this.Controls.Add(this.partityLabel);
this.Controls.Add(this.baudRateTextBox);
this.Controls.Add(this.baudRateLabel);
this.Controls.Add(this.comPortNrTextBox);
this.Controls.Add(this.label1);
this.Name = "BalanceCfgCtrl";
this.Size = new System.Drawing.Size(300, 250);
this.Load += new System.EventHandler(this.BalanceCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
this.parityComboBox = new System.Windows.Forms.ComboBox();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.handshakeLabel = new System.Windows.Forms.Label();
this.stopBitsLabel = new System.Windows.Forms.Label();
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
this.dataBitsLabel = new System.Windows.Forms.Label();
this.partityLabel = new System.Windows.Forms.Label();
this.baudRateTextBox = new System.Windows.Forms.TextBox();
this.baudRateLabel = new System.Windows.Forms.Label();
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.capacityLabel = new System.Windows.Forms.Label();
this.capacityTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.emptyTextBox = new System.Windows.Forms.TextBox();
this.emptyLabel = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.emptyTimeTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.formatTextBox = new System.Windows.Forms.TextBox();
this.formatLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// handshakeComboBox
//
this.handshakeComboBox.Enabled = false;
this.handshakeComboBox.FormattingEnabled = true;
this.handshakeComboBox.Location = new System.Drawing.Point(236, 216);
this.handshakeComboBox.Name = "handshakeComboBox";
this.handshakeComboBox.Size = new System.Drawing.Size(43, 21);
this.handshakeComboBox.TabIndex = 25;
//
// stopBitsComboBox
//
this.stopBitsComboBox.Enabled = false;
this.stopBitsComboBox.FormattingEnabled = true;
this.stopBitsComboBox.Location = new System.Drawing.Point(236, 193);
this.stopBitsComboBox.Name = "stopBitsComboBox";
this.stopBitsComboBox.Size = new System.Drawing.Size(43, 21);
this.stopBitsComboBox.TabIndex = 23;
//
// parityComboBox
//
this.parityComboBox.Enabled = false;
this.parityComboBox.FormattingEnabled = true;
this.parityComboBox.Location = new System.Drawing.Point(100, 216);
this.parityComboBox.Name = "parityComboBox";
this.parityComboBox.Size = new System.Drawing.Size(43, 21);
this.parityComboBox.TabIndex = 19;
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(136, 27);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(143, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(26, 30);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(133, 7);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// handshakeLabel
//
this.handshakeLabel.AutoSize = true;
this.handshakeLabel.Location = new System.Drawing.Point(162, 219);
this.handshakeLabel.Name = "handshakeLabel";
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
this.handshakeLabel.TabIndex = 24;
this.handshakeLabel.Text = "Handshake";
//
// stopBitsLabel
//
this.stopBitsLabel.AutoSize = true;
this.stopBitsLabel.Location = new System.Drawing.Point(162, 196);
this.stopBitsLabel.Name = "stopBitsLabel";
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
this.stopBitsLabel.TabIndex = 22;
this.stopBitsLabel.Text = "Stop Bits";
//
// dataBitsTextBox
//
this.dataBitsTextBox.Enabled = false;
this.dataBitsTextBox.Location = new System.Drawing.Point(236, 170);
this.dataBitsTextBox.Name = "dataBitsTextBox";
this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20);
this.dataBitsTextBox.TabIndex = 21;
//
// dataBitsLabel
//
this.dataBitsLabel.AutoSize = true;
this.dataBitsLabel.Location = new System.Drawing.Point(162, 173);
this.dataBitsLabel.Name = "dataBitsLabel";
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
this.dataBitsLabel.TabIndex = 20;
this.dataBitsLabel.Text = "Data Bits";
//
// partityLabel
//
this.partityLabel.AutoSize = true;
this.partityLabel.Location = new System.Drawing.Point(26, 221);
this.partityLabel.Name = "partityLabel";
this.partityLabel.Size = new System.Drawing.Size(33, 13);
this.partityLabel.TabIndex = 18;
this.partityLabel.Text = "Parity";
//
// baudRateTextBox
//
this.baudRateTextBox.Enabled = false;
this.baudRateTextBox.Location = new System.Drawing.Point(100, 193);
this.baudRateTextBox.Name = "baudRateTextBox";
this.baudRateTextBox.Size = new System.Drawing.Size(43, 20);
this.baudRateTextBox.TabIndex = 17;
//
// baudRateLabel
//
this.baudRateLabel.AutoSize = true;
this.baudRateLabel.Location = new System.Drawing.Point(26, 196);
this.baudRateLabel.Name = "baudRateLabel";
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
this.baudRateLabel.TabIndex = 16;
this.baudRateLabel.Text = "Baud Rate";
//
// comPortNrTextBox
//
this.comPortNrTextBox.Enabled = false;
this.comPortNrTextBox.Location = new System.Drawing.Point(100, 170);
this.comPortNrTextBox.Name = "comPortNrTextBox";
this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20);
this.comPortNrTextBox.TabIndex = 15;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 173);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 13);
this.label1.TabIndex = 14;
this.label1.Text = "Serial Port #:";
//
// capacityLabel
//
this.capacityLabel.AutoSize = true;
this.capacityLabel.Location = new System.Drawing.Point(26, 54);
this.capacityLabel.Name = "capacityLabel";
this.capacityLabel.Size = new System.Drawing.Size(76, 13);
this.capacityLabel.TabIndex = 3;
this.capacityLabel.Text = "Tank Capacity";
//
// capacityTextBox
//
this.capacityTextBox.Enabled = false;
this.capacityTextBox.Location = new System.Drawing.Point(137, 51);
this.capacityTextBox.Name = "capacityTextBox";
this.capacityTextBox.Size = new System.Drawing.Size(43, 20);
this.capacityTextBox.TabIndex = 4;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(186, 54);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(19, 13);
this.label2.TabIndex = 5;
this.label2.Text = "kg";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(186, 77);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(19, 13);
this.label3.TabIndex = 8;
this.label3.Text = "kg";
//
// emptyTextBox
//
this.emptyTextBox.Enabled = false;
this.emptyTextBox.Location = new System.Drawing.Point(137, 74);
this.emptyTextBox.Name = "emptyTextBox";
this.emptyTextBox.Size = new System.Drawing.Size(43, 20);
this.emptyTextBox.TabIndex = 7;
//
// emptyLabel
//
this.emptyLabel.AutoSize = true;
this.emptyLabel.Location = new System.Drawing.Point(26, 77);
this.emptyLabel.Name = "emptyLabel";
this.emptyLabel.Size = new System.Drawing.Size(64, 13);
this.emptyLabel.TabIndex = 6;
this.emptyLabel.Text = "Tank Empty";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(186, 123);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(24, 13);
this.label4.TabIndex = 13;
this.label4.Text = "sec";
//
// emptyTimeTextBox
//
this.emptyTimeTextBox.Enabled = false;
this.emptyTimeTextBox.Location = new System.Drawing.Point(137, 120);
this.emptyTimeTextBox.Name = "emptyTimeTextBox";
this.emptyTimeTextBox.Size = new System.Drawing.Size(43, 20);
this.emptyTimeTextBox.TabIndex = 12;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(26, 123);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(90, 13);
this.label5.TabIndex = 11;
this.label5.Text = "Tank Empty Time";
//
// formatTextBox
//
this.formatTextBox.Enabled = false;
this.formatTextBox.Location = new System.Drawing.Point(137, 97);
this.formatTextBox.Name = "formatTextBox";
this.formatTextBox.Size = new System.Drawing.Size(43, 20);
this.formatTextBox.TabIndex = 10;
//
// formatLabel
//
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(26, 100);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(76, 13);
this.formatLabel.TabIndex = 9;
this.formatLabel.Text = "Decimal points";
//
// BalanceCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.formatTextBox);
this.Controls.Add(this.formatLabel);
this.Controls.Add(this.label4);
this.Controls.Add(this.emptyTimeTextBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.emptyTextBox);
this.Controls.Add(this.emptyLabel);
this.Controls.Add(this.label2);
this.Controls.Add(this.capacityTextBox);
this.Controls.Add(this.capacityLabel);
this.Controls.Add(this.handshakeComboBox);
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.handshakeLabel);
this.Controls.Add(this.stopBitsLabel);
this.Controls.Add(this.dataBitsTextBox);
this.Controls.Add(this.dataBitsLabel);
this.Controls.Add(this.partityLabel);
this.Controls.Add(this.baudRateTextBox);
this.Controls.Add(this.baudRateLabel);
this.Controls.Add(this.comPortNrTextBox);
this.Controls.Add(this.label1);
this.Name = "BalanceCfgCtrl";
this.Size = new System.Drawing.Size(300, 250);
this.Load += new System.EventHandler(this.BalanceCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -325,5 +346,7 @@
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox emptyTimeTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox formatTextBox;
private System.Windows.Forms.Label formatLabel;
}
}
@@ -104,29 +104,33 @@ namespace TBF.BenchControl.MettlerToledo
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
capacityTextBox.Text = config.Capacity.ToString();
emptyTextBox.Text = config.Empty.ToString();
formatTextBox.Text = (config.Format.Length > 1) ? config.Format.Substring(1) : config.Format;
emptyTimeTextBox.Text = config.EmptyTimeSec.ToString();
comPortNrTextBox.Text = config.ComPortNr.ToString();
baudRateTextBox.Text = config.BaudRate.ToString();
parityComboBox.Text = config.Parity.ToString();
dataBitsTextBox.Text = config.DataBits.ToString();
stopBitsComboBox.Text = config.StopBits.ToString();
handshakeComboBox.Text = config.Handshake.ToString();
capacityTextBox.Text = config.Capacity.ToString();
emptyTextBox.Text = config.Empty.ToString();
emptyTimeTextBox.Text = config.EmptyTimeSec.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
capacityTextBox.Enabled = true;
emptyTextBox.Enabled = true;
formatTextBox.Enabled = true;
emptyTimeTextBox.Enabled = true;
comPortNrTextBox.Enabled = true;
baudRateTextBox.Enabled = true;
parityComboBox.Enabled = true;
dataBitsTextBox.Enabled = true;
stopBitsComboBox.Enabled = true;
handshakeComboBox.Enabled = true;
capacityTextBox.Enabled = true;
emptyTextBox.Enabled = true;
emptyTimeTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -160,6 +164,11 @@ namespace TBF.BenchControl.MettlerToledo
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Empty' is not valid";
}
if (!int.TryParse(formatTextBox.Text, out dummy) || dummy < 0 || dummy > 9)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Decimal points' should be between 0 and 9";
}
if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
flags |= CfgUpdateFlags.Error;
@@ -176,15 +185,17 @@ namespace TBF.BenchControl.MettlerToledo
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.Format = "F" + formatTextBox.Text;
config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text);
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text);
return flags;
}
@@ -59,6 +59,8 @@ namespace TBF.BenchControl.MettlerToledo
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
protected int msrmntTimeStamp;
public string Format { get { return balanceCfg.Format; } }
/// <summary>
/// Constructor
/// </summary>