TempMeter has 'Default temperature' parameter which specifies a value for simulated mode.

This commit is contained in:
Milan Hanajik
2016-12-05 23:22:33 +01:00
parent 1028866721
commit 72a5385c57
4 changed files with 267 additions and 222 deletions
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -19,11 +19,11 @@ namespace TBF.BenchControl.Elde.TempMeter
public readonly ControlBoardDev ControlBoard;
public int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..7
public float A1 { get { return tempMtrCfg.A1; } }
public float A2 { get { return tempMtrCfg.A2; } }
public float A3 { get { return tempMtrCfg.A3; } }
public float A4 { get { return tempMtrCfg.A4; } }
public float A5 { get { return tempMtrCfg.A5; } }
public double A1 { get { return tempMtrCfg.A1; } }
public double A2 { get { return tempMtrCfg.A2; } }
public double A3 { get { return tempMtrCfg.A3; } }
public double A4 { get { return tempMtrCfg.A4; } }
public double A5 { get { return tempMtrCfg.A5; } }
public TempMeter()
{
@@ -38,18 +38,29 @@ namespace TBF.BenchControl.Elde.TempMeter
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
/// Prepare data for SendCalibData() control board component method
ControlBoard.TempCalibData[Idx0, 0] = A1;
ControlBoard.TempCalibData[Idx0, 1] = A2;
ControlBoard.TempCalibData[Idx0, 2] = A3;
ControlBoard.TempCalibData[Idx0, 3] = A4;
ControlBoard.TempCalibData[Idx0, 4] = A5;
ControlBoard.TempCalibData[Idx0, 0] = (float)A1;
ControlBoard.TempCalibData[Idx0, 1] = (float)A2;
ControlBoard.TempCalibData[Idx0, 2] = (float)A3;
ControlBoard.TempCalibData[Idx0, 3] = (float)A4;
ControlBoard.TempCalibData[Idx0, 4] = (float)A5;
log.Debug(this.ToString());
}
public double ReadTemperature()
{
return (double)ControlBoard.Temperature(Idx0);
if (Cfg.DebugLevel == Config.Entities.DebugMode.Normal)
{
return (double)ControlBoard.Temperature(Idx0);
}
else if (Cfg.DebugLevel == Config.Entities.DebugMode.Simulate)
{
return tempMtrCfg.DefaultTemperature;
}
else
{
return 0;
}
}
/// <summary>
@@ -17,11 +17,12 @@ namespace TBF.BenchControl.Elde.TempMeter
/// Serialized parameters
///
public int Idx0; /// 0..7
public float A1;
public float A2;
public float A3;
public float A4;
public float A5;
public double A1;
public double A2;
public double A3;
public double A4;
public double A5;
public double DefaultTemperature;
/// Private parameterless constructor invoked by all other (public) constructors
TempMeterCfg()
@@ -34,6 +35,7 @@ namespace TBF.BenchControl.Elde.TempMeter
A3 = 0;
A4 = 0;
A5 = 0;
DefaultTemperature = 20.0;
}
public TempMeterCfg(IComponentFactory factory)
@@ -44,11 +46,11 @@ namespace TBF.BenchControl.Elde.TempMeter
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Idx0={2}, A1={3}, A2={4}, A3={5}, A4={6}, A5={7}",
return string.Format("Name={0}, Parent={1}, Idx0={2}, A1={3}, A2={4}, A3={5}, A4={6}, A5={7}, Default={8}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx0,
A1, A2, A3, A4, A5);
A1, A2, A3, A4, A5, DefaultTemperature);
}
}
}
@@ -31,197 +31,218 @@ namespace TBF.BenchControl.Elde.TempMeter
/// </summary>
private void InitializeComponent()
{
this.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = 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.a1TextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.a2TextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.a3TextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.a5TextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.a4TextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(130, 82);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(20, 85);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(20, 61);
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(130, 34);
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(20, 37);
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(127, 10);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// a1TextBox
//
this.a1TextBox.Enabled = false;
this.a1TextBox.Location = new System.Drawing.Point(130, 107);
this.a1TextBox.Name = "a1TextBox";
this.a1TextBox.Size = new System.Drawing.Size(130, 20);
this.a1TextBox.TabIndex = 8;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 110);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(20, 13);
this.label1.TabIndex = 7;
this.label1.Text = "A1";
//
// a2TextBox
//
this.a2TextBox.Enabled = false;
this.a2TextBox.Location = new System.Drawing.Point(130, 128);
this.a2TextBox.Name = "a2TextBox";
this.a2TextBox.Size = new System.Drawing.Size(130, 20);
this.a2TextBox.TabIndex = 10;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 131);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 9;
this.label2.Text = "A2";
//
// a3TextBox
//
this.a3TextBox.Enabled = false;
this.a3TextBox.Location = new System.Drawing.Point(130, 149);
this.a3TextBox.Name = "a3TextBox";
this.a3TextBox.Size = new System.Drawing.Size(130, 20);
this.a3TextBox.TabIndex = 12;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(20, 13);
this.label3.TabIndex = 11;
this.label3.Text = "A3";
//
// a5TextBox
//
this.a5TextBox.Enabled = false;
this.a5TextBox.Location = new System.Drawing.Point(130, 191);
this.a5TextBox.Name = "a5TextBox";
this.a5TextBox.Size = new System.Drawing.Size(130, 20);
this.a5TextBox.TabIndex = 16;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 194);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(20, 13);
this.label5.TabIndex = 15;
this.label5.Text = "A5";
//
// a4TextBox
//
this.a4TextBox.Enabled = false;
this.a4TextBox.Location = new System.Drawing.Point(130, 170);
this.a4TextBox.Name = "a4TextBox";
this.a4TextBox.Size = new System.Drawing.Size(130, 20);
this.a4TextBox.TabIndex = 14;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 173);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 13;
this.label4.Text = "A4";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(130, 58);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// TempMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.a5TextBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.a4TextBox);
this.Controls.Add(this.label4);
this.Controls.Add(this.a3TextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.a2TextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.a1TextBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TempMeterCfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.Load += new System.EventHandler(this.TempMeterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = 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.a1TextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.a2TextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.a3TextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.a5TextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.a4TextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.defaultTempTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(130, 83);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(20, 86);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(20, 61);
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(130, 34);
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(20, 37);
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(127, 10);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// a1TextBox
//
this.a1TextBox.Enabled = false;
this.a1TextBox.Location = new System.Drawing.Point(130, 107);
this.a1TextBox.Name = "a1TextBox";
this.a1TextBox.Size = new System.Drawing.Size(130, 20);
this.a1TextBox.TabIndex = 8;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 110);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(20, 13);
this.label1.TabIndex = 7;
this.label1.Text = "A1";
//
// a2TextBox
//
this.a2TextBox.Enabled = false;
this.a2TextBox.Location = new System.Drawing.Point(130, 128);
this.a2TextBox.Name = "a2TextBox";
this.a2TextBox.Size = new System.Drawing.Size(130, 20);
this.a2TextBox.TabIndex = 10;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 131);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 9;
this.label2.Text = "A2";
//
// a3TextBox
//
this.a3TextBox.Enabled = false;
this.a3TextBox.Location = new System.Drawing.Point(130, 149);
this.a3TextBox.Name = "a3TextBox";
this.a3TextBox.Size = new System.Drawing.Size(130, 20);
this.a3TextBox.TabIndex = 12;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(20, 13);
this.label3.TabIndex = 11;
this.label3.Text = "A3";
//
// a5TextBox
//
this.a5TextBox.Enabled = false;
this.a5TextBox.Location = new System.Drawing.Point(130, 191);
this.a5TextBox.Name = "a5TextBox";
this.a5TextBox.Size = new System.Drawing.Size(130, 20);
this.a5TextBox.TabIndex = 16;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 194);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(20, 13);
this.label5.TabIndex = 15;
this.label5.Text = "A5";
//
// a4TextBox
//
this.a4TextBox.Enabled = false;
this.a4TextBox.Location = new System.Drawing.Point(130, 170);
this.a4TextBox.Name = "a4TextBox";
this.a4TextBox.Size = new System.Drawing.Size(130, 20);
this.a4TextBox.TabIndex = 14;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 173);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 13;
this.label4.Text = "A4";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(130, 58);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// defaultTempTextBox
//
this.defaultTempTextBox.Enabled = false;
this.defaultTempTextBox.Location = new System.Drawing.Point(130, 217);
this.defaultTempTextBox.Name = "defaultTempTextBox";
this.defaultTempTextBox.Size = new System.Drawing.Size(46, 20);
this.defaultTempTextBox.TabIndex = 17;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(20, 220);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 13);
this.label6.TabIndex = 18;
this.label6.Text = "Default temperature";
//
// TempMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label6);
this.Controls.Add(this.defaultTempTextBox);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.a5TextBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.a4TextBox);
this.Controls.Add(this.label4);
this.Controls.Add(this.a3TextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.a2TextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.a1TextBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TempMeterCfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.Load += new System.EventHandler(this.TempMeterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -244,5 +265,7 @@ namespace TBF.BenchControl.Elde.TempMeter
private System.Windows.Forms.TextBox a4TextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox defaultTempTextBox;
private System.Windows.Forms.Label label6;
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Globalization;
@@ -69,6 +69,7 @@ namespace TBF.BenchControl.Elde.TempMeter
a3TextBox.Text = config.A3.ToString();
a4TextBox.Text = config.A4.ToString();
a5TextBox.Text = config.A5.ToString();
defaultTempTextBox.Text = config.DefaultTemperature.ToString();
}
public void Unlock()
@@ -81,6 +82,7 @@ namespace TBF.BenchControl.Elde.TempMeter
a3TextBox.Enabled = true;
a4TextBox.Enabled = true;
a5TextBox.Enabled = true;
defaultTempTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -99,37 +101,43 @@ namespace TBF.BenchControl.Elde.TempMeter
message += Environment.NewLine + "'Position' should be between 0 and 7";
}
float fdummy;
if (!Utils.TryParseEFloat(a1TextBox.Text, out fdummy))
double fdummy;
if (!Utils.TryParseEDouble(a1TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A1' is not valid";
}
if (!Utils.TryParseEFloat(a2TextBox.Text, out fdummy))
if (!Utils.TryParseEDouble(a2TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A2' is not valid";
}
if (!Utils.TryParseEFloat(a3TextBox.Text, out fdummy))
if (!Utils.TryParseEDouble(a3TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A3' is not valid";
}
if (!Utils.TryParseEFloat(a4TextBox.Text, out fdummy))
if (!Utils.TryParseEDouble(a4TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A4' is not valid";
}
if (!Utils.TryParseEFloat(a5TextBox.Text, out fdummy))
if (!Utils.TryParseEDouble(a5TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A5' is not valid";
}
if (!Utils.TryParseEDouble(defaultTempTextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Default temperature' is not valid";
}
return flags;
}
@@ -142,11 +150,12 @@ namespace TBF.BenchControl.Elde.TempMeter
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx0 = int.Parse(positionTextBox.Text);
bool updateOk = Utils.TryParseEFloat(a1TextBox.Text, out config.A1) &&
Utils.TryParseEFloat(a2TextBox.Text, out config.A2) &&
Utils.TryParseEFloat(a3TextBox.Text, out config.A3) &&
Utils.TryParseEFloat(a4TextBox.Text, out config.A4) &&
Utils.TryParseEFloat(a5TextBox.Text, out config.A5);
bool updateOk = Utils.TryParseEDouble(a1TextBox.Text, out config.A1) &&
Utils.TryParseEDouble(a2TextBox.Text, out config.A2) &&
Utils.TryParseEDouble(a3TextBox.Text, out config.A3) &&
Utils.TryParseEDouble(a4TextBox.Text, out config.A4) &&
Utils.TryParseEDouble(a5TextBox.Text, out config.A5) &&
Utils.TryParseEDouble(defaultTempTextBox.Text, out config.DefaultTemperature);
return flags;
}