- Tank emptying on start-up implemented, EmptyTimeSec parameter added to Balances

- added events Event.TimerBusy, Event.ValvesBusy, etc.
- fixed bug in SetValvesOp
- preparing a virtual bench drawing on the Process screen - partly done
This commit is contained in:
Milan Hanajik
2014-12-10 12:37:05 +01:00
parent 6aada39d97
commit 415adba8cf
17 changed files with 226 additions and 58 deletions
@@ -15,15 +15,17 @@ 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;
/// Parameterless constructor
public BalanceCfg()
{
Empty = 20.0f;
EmptyTimeSec = 180;
}
/// Constructor
public BalanceCfg(IComponentFactory factory, string name, int comPortNr, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, float capacity, float empty)
public BalanceCfg(IComponentFactory factory, string name, int comPortNr, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, float capacity, float empty, int emptyTimeSec)
: base(factory, name)
{
this.ComPortNr = comPortNr;
@@ -34,16 +36,18 @@ namespace TBF.BenchControl.MettlerToledo
this.Handshake = handshake;
this.Capacity = capacity;
this.Empty = empty;
this.EmptyTimeSec = emptyTimeSec;
}
public IComponentCfg Clone()
{
return new BalanceCfg(Factory, Name, ComPortNr, BaudRate, Parity, DataBits, StopBits, Handshake, Capacity, Empty);
return new BalanceCfg(Factory, Name, ComPortNr, BaudRate, Parity, DataBits, StopBits, Handshake, Capacity, Empty, EmptyTimeSec);
}
public string ToString(int i)
{
return string.Format("COM{0}, {1}Bd, {2}bits, parity={3}, stopBits={4}, {5}, capacity={6}kg", ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake, Capacity);
return string.Format("COM{0}, {1}Bd, {2}bits, parity={3}, stopBits={4}, {5}, capacity={6}kg, empty={7}kg, emptyTime={8}s",
ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake, Capacity, Empty, EmptyTimeSec);
}
public TBF.Entities.Component CreateDbEntity()
@@ -49,13 +49,16 @@
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, 173);
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;
@@ -64,7 +67,7 @@
//
this.stopBitsComboBox.Enabled = false;
this.stopBitsComboBox.FormattingEnabled = true;
this.stopBitsComboBox.Location = new System.Drawing.Point(136, 149);
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;
@@ -73,7 +76,7 @@
//
this.parityComboBox.Enabled = false;
this.parityComboBox.FormattingEnabled = true;
this.parityComboBox.Location = new System.Drawing.Point(136, 101);
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;
@@ -81,7 +84,7 @@
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(136, 29);
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;
@@ -89,7 +92,7 @@
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(26, 32);
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;
@@ -98,7 +101,7 @@
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(133, 8);
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;
@@ -107,7 +110,7 @@
// handshakeLabel
//
this.handshakeLabel.AutoSize = true;
this.handshakeLabel.Location = new System.Drawing.Point(25, 176);
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;
@@ -116,7 +119,7 @@
// stopBitsLabel
//
this.stopBitsLabel.AutoSize = true;
this.stopBitsLabel.Location = new System.Drawing.Point(25, 152);
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;
@@ -125,7 +128,7 @@
// dataBitsTextBox
//
this.dataBitsTextBox.Enabled = false;
this.dataBitsTextBox.Location = new System.Drawing.Point(136, 125);
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;
@@ -133,7 +136,7 @@
// dataBitsLabel
//
this.dataBitsLabel.AutoSize = true;
this.dataBitsLabel.Location = new System.Drawing.Point(25, 128);
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;
@@ -142,7 +145,7 @@
// partityLabel
//
this.partityLabel.AutoSize = true;
this.partityLabel.Location = new System.Drawing.Point(25, 104);
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;
@@ -151,7 +154,7 @@
// baudRateTextBox
//
this.baudRateTextBox.Enabled = false;
this.baudRateTextBox.Location = new System.Drawing.Point(136, 77);
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;
@@ -159,7 +162,7 @@
// baudRateLabel
//
this.baudRateLabel.AutoSize = true;
this.baudRateLabel.Location = new System.Drawing.Point(25, 80);
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;
@@ -168,7 +171,7 @@
// comPortNrTextBox
//
this.comPortNrTextBox.Enabled = false;
this.comPortNrTextBox.Location = new System.Drawing.Point(136, 53);
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;
@@ -176,7 +179,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 56);
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;
@@ -185,7 +188,7 @@
// capacityLabel
//
this.capacityLabel.AutoSize = true;
this.capacityLabel.Location = new System.Drawing.Point(25, 201);
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;
@@ -194,7 +197,7 @@
// capacityTextBox
//
this.capacityTextBox.Enabled = false;
this.capacityTextBox.Location = new System.Drawing.Point(136, 198);
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;
@@ -202,7 +205,7 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(185, 201);
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;
@@ -211,7 +214,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(185, 225);
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;
@@ -220,7 +223,7 @@
// emptyTextBox
//
this.emptyTextBox.Enabled = false;
this.emptyTextBox.Location = new System.Drawing.Point(136, 222);
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;
@@ -228,16 +231,45 @@
// emptyLabel
//
this.emptyLabel.AutoSize = true;
this.emptyLabel.Location = new System.Drawing.Point(25, 225);
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);
@@ -290,5 +322,8 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox emptyTextBox;
private System.Windows.Forms.Label emptyLabel;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox emptyTimeTextBox;
private System.Windows.Forms.Label label5;
}
}
@@ -104,6 +104,7 @@ namespace TBF.BenchControl.MettlerToledo
handshakeComboBox.Text = config.Handshake.ToString();
capacityTextBox.Text = config.Capacity.ToString();
emptyTextBox.Text = config.Empty.ToString();
emptyTimeTextBox.Text = config.EmptyTimeSec.ToString();
}
public void Unlock()
@@ -117,6 +118,7 @@ namespace TBF.BenchControl.MettlerToledo
handshakeComboBox.Enabled = true;
capacityTextBox.Enabled = true;
emptyTextBox.Enabled = true;
emptyTimeTextBox.Enabled = true;
}
public CfgVerifyFlags VerifyCfg(ref string message)
@@ -150,6 +152,11 @@ namespace TBF.BenchControl.MettlerToledo
flags |= CfgVerifyFlags.Error;
message += Environment.NewLine + "'Tank Empty' is not valid";
}
if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
flags |= CfgVerifyFlags.Error;
message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec";
}
return flags;
}
@@ -167,6 +174,7 @@ namespace TBF.BenchControl.MettlerToledo
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text);
}
}
}
@@ -44,7 +44,8 @@ namespace TBF.BenchControl.MettlerToledo
public string Name { get { return balanceCfg.Name; } }
public int BalanceNr { get { return balanceNr; } }
public float Capacity { get { return balanceCfg.Capacity; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return balanceCfg.Corrections; } }
public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return balanceCfg.Corrections; } }
/// <summary>The state of the mass measurement</summary>
public MsrmntState MsrmntState
@@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo
{
return new BalanceCfg(this, "Balance1", 3, 2400, System.IO.Ports.Parity.Even, 7,
System.IO.Ports.StopBits.One, System.IO.Ports.Handshake.XOnXOff,
200.0f, 20.0f); // kg
200.0f, 20.0f, 180); // kg, kg, s
}
public IComponentCfgCtrl CreateCfgCtrl()
@@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo
{
return new BalanceCfg(this, "Balance1", 3, 2400, System.IO.Ports.Parity.Even, 7,
System.IO.Ports.StopBits.One, System.IO.Ports.Handshake.XOnXOff,
200.0f, 20.0f); // kg
200.0f, 20.0f, 180); // kg, kg, s
}
public IComponentCfgCtrl CreateCfgCtrl()
@@ -47,7 +47,7 @@ namespace TBF.BenchControl.MettlerToledo
{
if (done) return Event.BalanceDone; /// Taring has been done already
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.None;
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
if (balanceDev.MsrmntState == MsrmntState.Overload)
{
@@ -64,7 +64,7 @@ namespace TBF.BenchControl.MettlerToledo
}
balanceDev.Taring(); /// Failed -> repeat taring
return Event.None;
return Event.Busy;
}
/// <summary>Stop this operation</summary>