Comet Ambient added, TODO: Implement the protocol.
This commit is contained in:
parent
cd18d6498a
commit
754bcd3dc6
@ -10,7 +10,7 @@ using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Greco
|
||||
namespace TBF.BenchControl.Ambient.Comet
|
||||
{
|
||||
/// <summary>
|
||||
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
|
||||
@ -7,7 +7,7 @@ using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Greco
|
||||
namespace TBF.BenchControl.Ambient.Comet
|
||||
{
|
||||
public class AmbientCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.Greco
|
||||
namespace TBF.BenchControl.Ambient.Comet
|
||||
{
|
||||
partial class AmbientCfgCtrl
|
||||
{
|
||||
@ -7,7 +7,7 @@ using System.IO.Ports;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Greco
|
||||
namespace TBF.BenchControl.Ambient.Comet
|
||||
{
|
||||
public partial class AmbientCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
21
TestBenchFramework/BenchControl/Ambient/Comet/Factory.cs
Normal file
21
TestBenchFramework/BenchControl/Ambient/Comet/Factory.cs
Normal file
@ -0,0 +1,21 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Ambient.Comet
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "Comet-Ambient"; } }
|
||||
|
||||
public void ResetStaticProperties() { Ambient.ResetStaticProperties(); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new AmbientCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(AmbientCfg), component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
TestBenchFramework/BenchControl/Ambient/Greco/Ambient.cs
Normal file
188
TestBenchFramework/BenchControl/Ambient/Greco/Ambient.cs
Normal file
@ -0,0 +1,188 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO.Ports;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Ambient.Greco
|
||||
{
|
||||
/// <summary>
|
||||
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
|
||||
/// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware.
|
||||
/// </summary>
|
||||
public class Ambient : ComponentBase, IDevice, IOperation, GenericDevices.IAmbient
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Ambient));
|
||||
public override string ToString() { return string.Format("Ambient({0})", Cfg.ToString(1)); }
|
||||
|
||||
private readonly AmbientCfg ambientCfg;
|
||||
|
||||
/// Private fields
|
||||
SerialPort serialPort;
|
||||
StringBuilder measurementBuilder;
|
||||
|
||||
/// <summary>The state of the measurement</summary>
|
||||
MsrmntState msrmntState;
|
||||
|
||||
/// <summary>Measured temperature when MsrmntState == MsrmntState.Valid</summary>
|
||||
float temperature;
|
||||
|
||||
/// <summary>Measured humidity when MsrmntState == MsrmntState.Valid</summary>
|
||||
float humidity;
|
||||
|
||||
/// <summary>Measured pressure when MsrmntState == MsrmntState.Valid</summary>
|
||||
float pressure;
|
||||
|
||||
/// <summary>Measurement time stamp when MsrmntState == MsrmntState.Valid</summary>
|
||||
int msrmntTimeStamp;
|
||||
|
||||
/// <summary>
|
||||
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
|
||||
/// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware.
|
||||
/// </summary>
|
||||
public Ambient(AmbientCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
ambientCfg = cfg;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate)
|
||||
{
|
||||
temperature = 20.0f;
|
||||
humidity = 40.0f;
|
||||
pressure = 1.0f;
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
return;
|
||||
}
|
||||
|
||||
string comPortName = "COM" + ambientCfg.ComPortNr.ToString();
|
||||
serialPort = new SerialPort(comPortName, ambientCfg.BaudRate, ambientCfg.Parity, ambientCfg.DataBits, ambientCfg.StopBits);
|
||||
serialPort.Handshake = ambientCfg.Handshake;
|
||||
serialPort.Open();
|
||||
measurementBuilder = new StringBuilder(40);
|
||||
msrmntState = MsrmntState.Busy;
|
||||
|
||||
log.FatalFormat("Successfully initialized device {0}", ToString());
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate)
|
||||
{
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
return;
|
||||
}
|
||||
|
||||
measurementBuilder.Append(serialPort.ReadExisting());
|
||||
int len = measurementBuilder.Length;
|
||||
|
||||
///
|
||||
/// Device sends each 20 sec one line of ASCII text with data in the following format:
|
||||
/// (temp) 6 characters, two decimal digits, with leading spaces
|
||||
/// TAB 1 character
|
||||
/// (humi) 6 characters, two decimal digits, with leading spaces
|
||||
/// TAB 1 character
|
||||
/// (pressure) 6 characters, one decimal digits, with leading spaces is LT 1000
|
||||
/// CR + LF 2 characters
|
||||
/// Example:
|
||||
/// 23.42 38.08 1061.1
|
||||
/// 23.39 38.04 1060.8
|
||||
/// 23.39 38.08 1061.4
|
||||
///
|
||||
if (len >= 22)
|
||||
{
|
||||
string measurement = measurementBuilder.ToString();
|
||||
measurementBuilder.Clear();
|
||||
|
||||
float t = 0;
|
||||
float h = 0;
|
||||
float p = 0;
|
||||
if (float.TryParse(measurement.Substring(len - 22, 6), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out t) &&
|
||||
measurement[len - 16] == '\t' &&
|
||||
float.TryParse(measurement.Substring(len - 15, 6), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out h) &&
|
||||
measurement[len - 9] == '\t' &&
|
||||
float.TryParse(measurement.Substring(len - 8, 6), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out p) &&
|
||||
measurement[len - 2] == '\r' &&
|
||||
measurement[len - 1] == '\n')
|
||||
{
|
||||
temperature = t;
|
||||
humidity = h;
|
||||
pressure = p;
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
|
||||
log.InfoFormat("Msrmnt OK: time = {0}, temp={1}, humi={2}, pres={3}", msrmntTimeStamp, t, h, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Warn("Invalid string received: " + measurement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Stop this device</summary>
|
||||
public void StopDevice()
|
||||
{
|
||||
if (serialPort != null) serialPort.Close();
|
||||
}
|
||||
|
||||
///
|
||||
/// Boxes for the operation result
|
||||
///
|
||||
FloatBox tempBox;
|
||||
FloatBox pressureBox;
|
||||
FloatBox humiBox;
|
||||
|
||||
public IOperation ReadAmbientOp(FloatBox temperature, FloatBox pressure, FloatBox humidity)
|
||||
{
|
||||
this.tempBox = temperature;
|
||||
this.pressureBox = pressure;
|
||||
this.humiBox = humidity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
if (tempBox != null) tempBox.Val = temperature;
|
||||
if (pressureBox != null) pressureBox.Val = pressure;
|
||||
if (humiBox != null) humiBox.Val = humidity;
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.FlowInDone or Event.FlowOutDone
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (tempBox != null) tempBox.Val = temperature;
|
||||
if (pressureBox != null) pressureBox.Val = pressure;
|
||||
if (humiBox != null) humiBox.Val = humidity;
|
||||
return Event.AmbientDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
52
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfg.cs
Normal file
52
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfg.cs
Normal file
@ -0,0 +1,52 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Ambient.Greco
|
||||
{
|
||||
public class AmbientCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public IComponent GetComponent(IList<IComponent> components) { return new Ambient(this, components); }
|
||||
public IComponentCfgCtrl GetControl() { return new AmbientCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int ComPortNr;
|
||||
public int BaudRate;
|
||||
public Parity Parity;
|
||||
public int DataBits;
|
||||
public StopBits StopBits;
|
||||
public Handshake Handshake;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
AmbientCfg()
|
||||
{
|
||||
Name = "Ambient";
|
||||
ParentName = string.Empty;
|
||||
ComPortNr = 6;
|
||||
BaudRate = 19200;
|
||||
Parity = System.IO.Ports.Parity.None;
|
||||
DataBits = 8;
|
||||
StopBits = System.IO.Ports.StopBits.One;
|
||||
Handshake = System.IO.Ports.Handshake.None;
|
||||
}
|
||||
|
||||
public AmbientCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
|
||||
Name, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
||||
}
|
||||
}
|
||||
}
|
||||
229
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfgCtrl.Designer.cs
generated
Normal file
229
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfgCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,229 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.Ambient.Greco
|
||||
{
|
||||
partial class AmbientCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.baudRateLabel = new System.Windows.Forms.Label();
|
||||
this.baudRateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.partityLabel = new System.Windows.Forms.Label();
|
||||
this.dataBitsLabel = new System.Windows.Forms.Label();
|
||||
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stopBitsLabel = new System.Windows.Forms.Label();
|
||||
this.handshakeLabel = 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.parityComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comPortNrTextBox
|
||||
//
|
||||
this.comPortNrTextBox.Enabled = false;
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(140, 52);
|
||||
this.comPortNrTextBox.Name = "comPortNrTextBox";
|
||||
this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.comPortNrTextBox.TabIndex = 4;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(29, 55);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(98, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Serial Port Number:";
|
||||
//
|
||||
// baudRateLabel
|
||||
//
|
||||
this.baudRateLabel.AutoSize = true;
|
||||
this.baudRateLabel.Location = new System.Drawing.Point(29, 79);
|
||||
this.baudRateLabel.Name = "baudRateLabel";
|
||||
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
|
||||
this.baudRateLabel.TabIndex = 5;
|
||||
this.baudRateLabel.Text = "Baud Rate";
|
||||
//
|
||||
// baudRateTextBox
|
||||
//
|
||||
this.baudRateTextBox.Enabled = false;
|
||||
this.baudRateTextBox.Location = new System.Drawing.Point(140, 76);
|
||||
this.baudRateTextBox.Name = "baudRateTextBox";
|
||||
this.baudRateTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.baudRateTextBox.TabIndex = 6;
|
||||
//
|
||||
// partityLabel
|
||||
//
|
||||
this.partityLabel.AutoSize = true;
|
||||
this.partityLabel.Location = new System.Drawing.Point(29, 103);
|
||||
this.partityLabel.Name = "partityLabel";
|
||||
this.partityLabel.Size = new System.Drawing.Size(33, 13);
|
||||
this.partityLabel.TabIndex = 7;
|
||||
this.partityLabel.Text = "Parity";
|
||||
//
|
||||
// dataBitsLabel
|
||||
//
|
||||
this.dataBitsLabel.AutoSize = true;
|
||||
this.dataBitsLabel.Location = new System.Drawing.Point(29, 127);
|
||||
this.dataBitsLabel.Name = "dataBitsLabel";
|
||||
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
|
||||
this.dataBitsLabel.TabIndex = 9;
|
||||
this.dataBitsLabel.Text = "Data Bits";
|
||||
//
|
||||
// dataBitsTextBox
|
||||
//
|
||||
this.dataBitsTextBox.Enabled = false;
|
||||
this.dataBitsTextBox.Location = new System.Drawing.Point(140, 124);
|
||||
this.dataBitsTextBox.Name = "dataBitsTextBox";
|
||||
this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.dataBitsTextBox.TabIndex = 10;
|
||||
//
|
||||
// stopBitsLabel
|
||||
//
|
||||
this.stopBitsLabel.AutoSize = true;
|
||||
this.stopBitsLabel.Location = new System.Drawing.Point(29, 151);
|
||||
this.stopBitsLabel.Name = "stopBitsLabel";
|
||||
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
|
||||
this.stopBitsLabel.TabIndex = 11;
|
||||
this.stopBitsLabel.Text = "Stop Bits";
|
||||
//
|
||||
// handshakeLabel
|
||||
//
|
||||
this.handshakeLabel.AutoSize = true;
|
||||
this.handshakeLabel.Location = new System.Drawing.Point(29, 175);
|
||||
this.handshakeLabel.Name = "handshakeLabel";
|
||||
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
|
||||
this.handshakeLabel.TabIndex = 13;
|
||||
this.handshakeLabel.Text = "Handshake";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(140, 28);
|
||||
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(30, 31);
|
||||
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(137, 7);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// parityComboBox
|
||||
//
|
||||
this.parityComboBox.Enabled = false;
|
||||
this.parityComboBox.FormattingEnabled = true;
|
||||
this.parityComboBox.Location = new System.Drawing.Point(140, 100);
|
||||
this.parityComboBox.Name = "parityComboBox";
|
||||
this.parityComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parityComboBox.TabIndex = 8;
|
||||
//
|
||||
// stopBitsComboBox
|
||||
//
|
||||
this.stopBitsComboBox.Enabled = false;
|
||||
this.stopBitsComboBox.FormattingEnabled = true;
|
||||
this.stopBitsComboBox.Location = new System.Drawing.Point(140, 148);
|
||||
this.stopBitsComboBox.Name = "stopBitsComboBox";
|
||||
this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.stopBitsComboBox.TabIndex = 12;
|
||||
//
|
||||
// handshakeComboBox
|
||||
//
|
||||
this.handshakeComboBox.Enabled = false;
|
||||
this.handshakeComboBox.FormattingEnabled = true;
|
||||
this.handshakeComboBox.Location = new System.Drawing.Point(140, 172);
|
||||
this.handshakeComboBox.Name = "handshakeComboBox";
|
||||
this.handshakeComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.handshakeComboBox.TabIndex = 14;
|
||||
//
|
||||
// AmbientCfgCtrl
|
||||
//
|
||||
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.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 = "AmbientCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 240);
|
||||
this.Load += new System.EventHandler(this.AbbientCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox comPortNrTextBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label baudRateLabel;
|
||||
private System.Windows.Forms.TextBox baudRateTextBox;
|
||||
private System.Windows.Forms.Label partityLabel;
|
||||
private System.Windows.Forms.Label dataBitsLabel;
|
||||
private System.Windows.Forms.TextBox dataBitsTextBox;
|
||||
private System.Windows.Forms.Label stopBitsLabel;
|
||||
private System.Windows.Forms.Label handshakeLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.ComboBox parityComboBox;
|
||||
private System.Windows.Forms.ComboBox stopBitsComboBox;
|
||||
private System.Windows.Forms.ComboBox handshakeComboBox;
|
||||
|
||||
}
|
||||
}
|
||||
171
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfgCtrl.cs
Normal file
171
TestBenchFramework/BenchControl/Ambient/Greco/AmbientCfgCtrl.cs
Normal file
@ -0,0 +1,171 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Ports;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Ambient.Greco
|
||||
{
|
||||
public partial class AmbientCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(AmbientCfgCtrl));
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
AmbientCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as AmbientCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public AmbientCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
parityComboBox.Items.Add(Parity.None.ToString());
|
||||
parityComboBox.Items.Add(Parity.Even.ToString());
|
||||
parityComboBox.Items.Add(Parity.Odd.ToString());
|
||||
|
||||
stopBitsComboBox.Items.Add(StopBits.None.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.One.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.OnePointFive.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.Two.ToString());
|
||||
|
||||
handshakeComboBox.Items.Add(Handshake.None.ToString());
|
||||
handshakeComboBox.Items.Add(Handshake.RequestToSend.ToString());
|
||||
handshakeComboBox.Items.Add(Handshake.XOnXOff.ToString());
|
||||
}
|
||||
|
||||
int GetParityIx(Parity par)
|
||||
{
|
||||
if (par == Parity.None) return 0;
|
||||
if (par == Parity.Even) return 0;
|
||||
if (par == Parity.Odd) return 0;
|
||||
return -1;
|
||||
}
|
||||
Parity GetParity(string str)
|
||||
{
|
||||
if (str.Equals(Parity.None.ToString())) return Parity.None;
|
||||
if (str.Equals(Parity.Even.ToString())) return Parity.Even;
|
||||
if (str.Equals(Parity.Odd.ToString())) return Parity.Odd;
|
||||
return (Parity)(-1);
|
||||
}
|
||||
|
||||
int GetStopBitsIx(StopBits sb)
|
||||
{
|
||||
if (sb == StopBits.None) return 0;
|
||||
if (sb == StopBits.One) return 1;
|
||||
if (sb == StopBits.OnePointFive) return 2;
|
||||
if (sb == StopBits.Two) return 3;
|
||||
return -1;
|
||||
}
|
||||
StopBits GetStopBits(string str)
|
||||
{
|
||||
if (str.Equals(StopBits.None.ToString())) return StopBits.None;
|
||||
if (str.Equals(StopBits.One.ToString())) return StopBits.One;
|
||||
if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive;
|
||||
if (str.Equals(StopBits.Two.ToString())) return StopBits.Two;
|
||||
return (StopBits)(-1);
|
||||
}
|
||||
|
||||
int GetHandshakeIx(Handshake par)
|
||||
{
|
||||
if (par == Handshake.None) return 0;
|
||||
if (par == Handshake.RequestToSend) return 0;
|
||||
if (par == Handshake.XOnXOff) return 0;
|
||||
return -1;
|
||||
}
|
||||
Handshake GetHandshake(string str)
|
||||
{
|
||||
if (str.Equals(Handshake.None.ToString())) return Handshake.None;
|
||||
if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend;
|
||||
if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff;
|
||||
return (Handshake)(-1);
|
||||
}
|
||||
|
||||
private void AbbientCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
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();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
comPortNrTextBox.Enabled = true;
|
||||
baudRateTextBox.Enabled = true;
|
||||
parityComboBox.Enabled = true;
|
||||
dataBitsTextBox.Enabled = true;
|
||||
stopBitsComboBox.Enabled = true;
|
||||
handshakeComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.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());
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Serial Port Number' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(baudRateTextBox.Text, out dummy) || dummy < 150 || dummy > 115200)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Baud Rate' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(dataBitsTextBox.Text, out dummy) || dummy < 7 || dummy > 8)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Data Bits' is not valid";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -3,9 +3,9 @@
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Greco
|
||||
namespace TBF.BenchControl.Ambient.Greco
|
||||
{
|
||||
public class AmbientFactory : IComponentFactory
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "Greco Ambient"; } }
|
||||
|
||||
@ -21,7 +21,7 @@ namespace TBF.BenchControl.DataEntry.Combined
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
EntryFormCfg()
|
||||
{
|
||||
Name = "DataEntryForm-Munich";
|
||||
Name = "DataEntry-Combined";
|
||||
ParentName = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,8 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new TestMethods.FlyingStart.TestMethodFactory());
|
||||
Factories.Add(new TestMethods.FlyingStartCollectionMethod.TestMethodFactory());
|
||||
Factories.Add(new DataEntry.WMStates.EntryFormFactory());
|
||||
Factories.Add(new Greco.AmbientFactory());
|
||||
Factories.Add(new Ambient.Comet.Factory());
|
||||
Factories.Add(new Ambient.Greco.Factory());
|
||||
Factories.Add(new Cameras.IdcCamera.IdcCameraFactory());
|
||||
Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
|
||||
Factories.Add(new MettlerToledo.BalanceFactory());
|
||||
|
||||
@ -132,6 +132,24 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BenchControl\Ambient\Comet\Ambient.cs" />
|
||||
<Compile Include="BenchControl\Ambient\Comet\AmbientCfg.cs" />
|
||||
<Compile Include="BenchControl\Ambient\Comet\AmbientCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Ambient\Comet\AmbientCfgCtrl.designer.cs">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Ambient\Comet\Factory.cs" />
|
||||
<Compile Include="BenchControl\Ambient\Greco\Ambient.cs" />
|
||||
<Compile Include="BenchControl\Ambient\Greco\AmbientCfg.cs" />
|
||||
<Compile Include="BenchControl\Ambient\Greco\AmbientCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Ambient\Greco\AmbientCfgCtrl.designer.cs">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Ambient\Greco\Factory.cs" />
|
||||
<Compile Include="BenchControl\DataEntry\Standard\WMStatesForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -441,12 +459,6 @@
|
||||
<Compile Include="BenchControl\Generic\IParamsProvider.cs" />
|
||||
<Compile Include="BenchControl\Generic\IProcedureParams.cs" />
|
||||
<Compile Include="BenchControl\Generic\ITestParams.cs" />
|
||||
<Compile Include="BenchControl\Greco\AmbientCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Greco\AmbientCfgCtrl.Designer.cs">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\Valve\ValveCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
@ -741,8 +753,6 @@
|
||||
<Compile Include="BenchControl\GenericDevices\IRegulValve.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\ITempMeter.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IValve.cs" />
|
||||
<Compile Include="BenchControl\Greco\AmbientCfg.cs" />
|
||||
<Compile Include="BenchControl\Greco\AmbientFactory.cs" />
|
||||
<Compile Include="BenchControl\Generic\IComponent.cs" />
|
||||
<Compile Include="BenchControl\Generic\IComponentFactory.cs" />
|
||||
<Compile Include="BenchControl\Generic\IComponentCfg.cs" />
|
||||
@ -794,7 +804,6 @@
|
||||
<Compile Include="DatabaseSettings.cs" />
|
||||
<Compile Include="BenchControl\Operations\ClearResultsOp.cs" />
|
||||
<Compile Include="BenchControl\Sequences\MainSeq.cs" />
|
||||
<Compile Include="BenchControl\Greco\Ambient.cs" />
|
||||
<Compile Include="BenchControl\Elde\ControlBoardDev.cs" />
|
||||
<Compile Include="BenchControl\Sequences\SequenceBase.cs" />
|
||||
<Compile Include="BenchControl\State.cs" />
|
||||
@ -1095,6 +1104,12 @@
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Utils.cs" />
|
||||
<EmbeddedResource Include="BenchControl\Ambient\Comet\AmbientCfgCtrl.resx">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Ambient\Greco\AmbientCfgCtrl.resx">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\BenchId\ComponentCfgCtrl.resx">
|
||||
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -1191,9 +1206,6 @@
|
||||
<EmbeddedResource Include="BenchControl\Elde\TempMeter\TempMeterCfgCtrl.resx">
|
||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Greco\AmbientCfgCtrl.resx">
|
||||
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Elde\Valve\ValveCfgCtrl.resx">
|
||||
<DependentUpon>ValveCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user