MettlerToledo.Multi removed from the project.
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ITankDrainingCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(BalanceCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new BalanceCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int IdNr; /// Identification number 1..3
|
||||
public float Resolution; /// Resolution of the integer value in the serial protocol in 'kg'
|
||||
public string Format;
|
||||
|
||||
/// Max. water mass in 'kg' or volume in 'l'
|
||||
private float capacity;
|
||||
public float Capacity { get { return capacity; } set { capacity = value; } }
|
||||
|
||||
/// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l')
|
||||
private float empty;
|
||||
public float Empty { get { return empty; } set { empty = value; } }
|
||||
|
||||
private string drainValve;
|
||||
public string DrainValve { get { return drainValve; } set { drainValve = value; } }
|
||||
|
||||
private int drainTimeSec;
|
||||
public int DrainTimeSec { get { return drainTimeSec; } set { drainTimeSec = value; } }
|
||||
|
||||
private string evaporation;
|
||||
public string Evaporation { get { return evaporation; } set { evaporation = value; } }
|
||||
|
||||
public int ComPortNr;
|
||||
public int BaudRate;
|
||||
public Parity Parity;
|
||||
public int DataBits;
|
||||
public StopBits StopBits;
|
||||
public Handshake Handshake;
|
||||
|
||||
///
|
||||
/// Buoyancy related serialized parameters - Displayed in Metrology tab page
|
||||
///
|
||||
float buoyancyTemp;
|
||||
float buoyancyPress;
|
||||
float buoyancyHumi;
|
||||
float weightStandardDensity;
|
||||
string calibCertificateNr;
|
||||
DateTime calibDate;
|
||||
DateTime calibValidDate;
|
||||
///
|
||||
public float BuoyancyTemp
|
||||
{
|
||||
get { return buoyancyTemp; }
|
||||
set { buoyancyTemp = value; }
|
||||
}
|
||||
public float BuoyancyPress
|
||||
{
|
||||
get { return buoyancyPress; }
|
||||
set { buoyancyPress = value; }
|
||||
}
|
||||
public float BuoyancyHumi
|
||||
{
|
||||
get { return buoyancyHumi; }
|
||||
set { buoyancyHumi = value; }
|
||||
}
|
||||
public float WeightStandardDensity
|
||||
{
|
||||
get { return weightStandardDensity; }
|
||||
set { weightStandardDensity = value; }
|
||||
}
|
||||
public string CalibCertificateNr
|
||||
{
|
||||
get { return calibCertificateNr; }
|
||||
set { calibCertificateNr = value; }
|
||||
}
|
||||
public DateTime CalibDate
|
||||
{
|
||||
get { return calibDate; }
|
||||
set { calibDate = value; }
|
||||
}
|
||||
public DateTime CalibValidDate
|
||||
{
|
||||
get { return calibValidDate; }
|
||||
set { calibValidDate = value; }
|
||||
}
|
||||
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
BalanceCfg()
|
||||
{
|
||||
Name = "Balance";
|
||||
ParentName = string.Empty;
|
||||
|
||||
IdNr = 1;
|
||||
Capacity = 200.0f;
|
||||
Resolution = 0.001f;
|
||||
Empty = 20.0f;
|
||||
Format = "F3";
|
||||
DrainTimeSec = 180;
|
||||
|
||||
ComPortNr = 3;
|
||||
BaudRate = 2400;
|
||||
Parity = System.IO.Ports.Parity.Even;
|
||||
DataBits = 7;
|
||||
StopBits = System.IO.Ports.StopBits.One;
|
||||
Handshake = System.IO.Ports.Handshake.XOnXOff;
|
||||
|
||||
BuoyancyTemp = 20.0f;
|
||||
BuoyancyPress = 1.0f;
|
||||
BuoyancyHumi = 40.0f;
|
||||
}
|
||||
|
||||
public BalanceCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
if (IdNr == 1)
|
||||
{
|
||||
return string.Format("Name={0}, Id#={1}, {2}kg, empty={3}kg, fmt.={4}, emptyTm={5}s, Com{6}, {7}Bd, {8}-bits, parity={9}, stopBits={10}, {11}",
|
||||
Name, IdNr, Capacity, Empty, Format, DrainTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("Name={0}, Id#={1}, {2}kg, empty={3}kg, fmt.={4}, emptyTm={5}s",
|
||||
Name, IdNr, Capacity, Empty, Format, DrainTimeSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-438
@@ -1,438 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
partial class BalanceCfgCtrl
|
||||
{
|
||||
/// <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.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.parityLabel = 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.comPortNrLabel = 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.idNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.idNrLabel = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.resolutionTextBox = new System.Windows.Forms.TextBox();
|
||||
this.resolutionLabel = new System.Windows.Forms.Label();
|
||||
this.drainValveComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.drainingValveLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// handshakeComboBox
|
||||
//
|
||||
this.handshakeComboBox.Enabled = false;
|
||||
this.handshakeComboBox.FormattingEnabled = true;
|
||||
this.handshakeComboBox.Location = new System.Drawing.Point(236, 256);
|
||||
this.handshakeComboBox.Name = "handshakeComboBox";
|
||||
this.handshakeComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.handshakeComboBox.TabIndex = 32;
|
||||
//
|
||||
// stopBitsComboBox
|
||||
//
|
||||
this.stopBitsComboBox.Enabled = false;
|
||||
this.stopBitsComboBox.FormattingEnabled = true;
|
||||
this.stopBitsComboBox.Location = new System.Drawing.Point(236, 235);
|
||||
this.stopBitsComboBox.Name = "stopBitsComboBox";
|
||||
this.stopBitsComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.stopBitsComboBox.TabIndex = 30;
|
||||
//
|
||||
// parityComboBox
|
||||
//
|
||||
this.parityComboBox.Enabled = false;
|
||||
this.parityComboBox.FormattingEnabled = true;
|
||||
this.parityComboBox.Location = new System.Drawing.Point(100, 256);
|
||||
this.parityComboBox.Name = "parityComboBox";
|
||||
this.parityComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.parityComboBox.TabIndex = 26;
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(150, 26);
|
||||
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, 29);
|
||||
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(147, 7);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComponentName";
|
||||
//
|
||||
// handshakeLabel
|
||||
//
|
||||
this.handshakeLabel.AutoSize = true;
|
||||
this.handshakeLabel.Location = new System.Drawing.Point(162, 259);
|
||||
this.handshakeLabel.Name = "handshakeLabel";
|
||||
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
|
||||
this.handshakeLabel.TabIndex = 31;
|
||||
this.handshakeLabel.Text = "Handshake";
|
||||
//
|
||||
// stopBitsLabel
|
||||
//
|
||||
this.stopBitsLabel.AutoSize = true;
|
||||
this.stopBitsLabel.Location = new System.Drawing.Point(162, 238);
|
||||
this.stopBitsLabel.Name = "stopBitsLabel";
|
||||
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
|
||||
this.stopBitsLabel.TabIndex = 29;
|
||||
this.stopBitsLabel.Text = "Stop Bits";
|
||||
//
|
||||
// dataBitsTextBox
|
||||
//
|
||||
this.dataBitsTextBox.Enabled = false;
|
||||
this.dataBitsTextBox.Location = new System.Drawing.Point(236, 213);
|
||||
this.dataBitsTextBox.Name = "dataBitsTextBox";
|
||||
this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.dataBitsTextBox.TabIndex = 28;
|
||||
//
|
||||
// dataBitsLabel
|
||||
//
|
||||
this.dataBitsLabel.AutoSize = true;
|
||||
this.dataBitsLabel.Location = new System.Drawing.Point(162, 216);
|
||||
this.dataBitsLabel.Name = "dataBitsLabel";
|
||||
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
|
||||
this.dataBitsLabel.TabIndex = 27;
|
||||
this.dataBitsLabel.Text = "Data Bits";
|
||||
//
|
||||
// parityLabel
|
||||
//
|
||||
this.parityLabel.AutoSize = true;
|
||||
this.parityLabel.Location = new System.Drawing.Point(26, 261);
|
||||
this.parityLabel.Name = "parityLabel";
|
||||
this.parityLabel.Size = new System.Drawing.Size(33, 13);
|
||||
this.parityLabel.TabIndex = 25;
|
||||
this.parityLabel.Text = "Parity";
|
||||
//
|
||||
// baudRateTextBox
|
||||
//
|
||||
this.baudRateTextBox.Enabled = false;
|
||||
this.baudRateTextBox.Location = new System.Drawing.Point(100, 235);
|
||||
this.baudRateTextBox.Name = "baudRateTextBox";
|
||||
this.baudRateTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.baudRateTextBox.TabIndex = 24;
|
||||
//
|
||||
// baudRateLabel
|
||||
//
|
||||
this.baudRateLabel.AutoSize = true;
|
||||
this.baudRateLabel.Location = new System.Drawing.Point(26, 238);
|
||||
this.baudRateLabel.Name = "baudRateLabel";
|
||||
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
|
||||
this.baudRateLabel.TabIndex = 23;
|
||||
this.baudRateLabel.Text = "Baud Rate";
|
||||
//
|
||||
// comPortNrTextBox
|
||||
//
|
||||
this.comPortNrTextBox.Enabled = false;
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(100, 213);
|
||||
this.comPortNrTextBox.Name = "comPortNrTextBox";
|
||||
this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.comPortNrTextBox.TabIndex = 22;
|
||||
//
|
||||
// comPortNrLabel
|
||||
//
|
||||
this.comPortNrLabel.AutoSize = true;
|
||||
this.comPortNrLabel.Location = new System.Drawing.Point(26, 216);
|
||||
this.comPortNrLabel.Name = "comPortNrLabel";
|
||||
this.comPortNrLabel.Size = new System.Drawing.Size(68, 13);
|
||||
this.comPortNrLabel.TabIndex = 21;
|
||||
this.comPortNrLabel.Text = "Serial Port #:";
|
||||
//
|
||||
// capacityLabel
|
||||
//
|
||||
this.capacityLabel.AutoSize = true;
|
||||
this.capacityLabel.Location = new System.Drawing.Point(25, 71);
|
||||
this.capacityLabel.Name = "capacityLabel";
|
||||
this.capacityLabel.Size = new System.Drawing.Size(76, 13);
|
||||
this.capacityLabel.TabIndex = 5;
|
||||
this.capacityLabel.Text = "Tank Capacity";
|
||||
//
|
||||
// capacityTextBox
|
||||
//
|
||||
this.capacityTextBox.Enabled = false;
|
||||
this.capacityTextBox.Location = new System.Drawing.Point(151, 68);
|
||||
this.capacityTextBox.Name = "capacityTextBox";
|
||||
this.capacityTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.capacityTextBox.TabIndex = 6;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(200, 71);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(19, 13);
|
||||
this.label2.TabIndex = 7;
|
||||
this.label2.Text = "kg";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(200, 113);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(19, 13);
|
||||
this.label3.TabIndex = 13;
|
||||
this.label3.Text = "kg";
|
||||
//
|
||||
// emptyTextBox
|
||||
//
|
||||
this.emptyTextBox.Enabled = false;
|
||||
this.emptyTextBox.Location = new System.Drawing.Point(151, 110);
|
||||
this.emptyTextBox.Name = "emptyTextBox";
|
||||
this.emptyTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.emptyTextBox.TabIndex = 12;
|
||||
//
|
||||
// emptyLabel
|
||||
//
|
||||
this.emptyLabel.AutoSize = true;
|
||||
this.emptyLabel.Location = new System.Drawing.Point(25, 113);
|
||||
this.emptyLabel.Name = "emptyLabel";
|
||||
this.emptyLabel.Size = new System.Drawing.Size(109, 13);
|
||||
this.emptyLabel.TabIndex = 11;
|
||||
this.emptyLabel.Text = "Tank empty threshold";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(200, 155);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(24, 13);
|
||||
this.label4.TabIndex = 18;
|
||||
this.label4.Text = "sec";
|
||||
//
|
||||
// emptyTimeTextBox
|
||||
//
|
||||
this.emptyTimeTextBox.Enabled = false;
|
||||
this.emptyTimeTextBox.Location = new System.Drawing.Point(151, 152);
|
||||
this.emptyTimeTextBox.Name = "emptyTimeTextBox";
|
||||
this.emptyTimeTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.emptyTimeTextBox.TabIndex = 17;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(26, 155);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(58, 13);
|
||||
this.label5.TabIndex = 16;
|
||||
this.label5.Text = "Drain Time";
|
||||
//
|
||||
// formatTextBox
|
||||
//
|
||||
this.formatTextBox.Enabled = false;
|
||||
this.formatTextBox.Location = new System.Drawing.Point(151, 131);
|
||||
this.formatTextBox.Name = "formatTextBox";
|
||||
this.formatTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.formatTextBox.TabIndex = 15;
|
||||
//
|
||||
// formatLabel
|
||||
//
|
||||
this.formatLabel.AutoSize = true;
|
||||
this.formatLabel.Location = new System.Drawing.Point(26, 134);
|
||||
this.formatLabel.Name = "formatLabel";
|
||||
this.formatLabel.Size = new System.Drawing.Size(76, 13);
|
||||
this.formatLabel.TabIndex = 14;
|
||||
this.formatLabel.Text = "Decimal points";
|
||||
//
|
||||
// idNrTextBox
|
||||
//
|
||||
this.idNrTextBox.Enabled = false;
|
||||
this.idNrTextBox.Location = new System.Drawing.Point(151, 47);
|
||||
this.idNrTextBox.Name = "idNrTextBox";
|
||||
this.idNrTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.idNrTextBox.TabIndex = 4;
|
||||
this.idNrTextBox.TextChanged += new System.EventHandler(this.idNrTextBox_TextChanged);
|
||||
//
|
||||
// idNrLabel
|
||||
//
|
||||
this.idNrLabel.AutoSize = true;
|
||||
this.idNrLabel.Location = new System.Drawing.Point(25, 50);
|
||||
this.idNrLabel.Name = "idNrLabel";
|
||||
this.idNrLabel.Size = new System.Drawing.Size(85, 13);
|
||||
this.idNrLabel.TabIndex = 3;
|
||||
this.idNrLabel.Text = "ID Number (1..3)";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(200, 92);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(19, 13);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "kg";
|
||||
//
|
||||
// resolutionTextBox
|
||||
//
|
||||
this.resolutionTextBox.Enabled = false;
|
||||
this.resolutionTextBox.Location = new System.Drawing.Point(151, 89);
|
||||
this.resolutionTextBox.Name = "resolutionTextBox";
|
||||
this.resolutionTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.resolutionTextBox.TabIndex = 9;
|
||||
//
|
||||
// resolutionLabel
|
||||
//
|
||||
this.resolutionLabel.AutoSize = true;
|
||||
this.resolutionLabel.Location = new System.Drawing.Point(25, 92);
|
||||
this.resolutionLabel.Name = "resolutionLabel";
|
||||
this.resolutionLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.resolutionLabel.TabIndex = 8;
|
||||
this.resolutionLabel.Text = "Resolution";
|
||||
//
|
||||
// drainValveComboBox
|
||||
//
|
||||
this.drainValveComboBox.Enabled = false;
|
||||
this.drainValveComboBox.FormattingEnabled = true;
|
||||
this.drainValveComboBox.Location = new System.Drawing.Point(150, 173);
|
||||
this.drainValveComboBox.Name = "drainValveComboBox";
|
||||
this.drainValveComboBox.Size = new System.Drawing.Size(143, 21);
|
||||
this.drainValveComboBox.TabIndex = 20;
|
||||
//
|
||||
// drainingValveLabel
|
||||
//
|
||||
this.drainingValveLabel.AutoSize = true;
|
||||
this.drainingValveLabel.Location = new System.Drawing.Point(25, 176);
|
||||
this.drainingValveLabel.Name = "drainingValveLabel";
|
||||
this.drainingValveLabel.Size = new System.Drawing.Size(61, 13);
|
||||
this.drainingValveLabel.TabIndex = 19;
|
||||
this.drainingValveLabel.Text = "Drain valve";
|
||||
//
|
||||
// BalanceCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.drainValveComboBox);
|
||||
this.Controls.Add(this.drainingValveLabel);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.resolutionTextBox);
|
||||
this.Controls.Add(this.resolutionLabel);
|
||||
this.Controls.Add(this.idNrTextBox);
|
||||
this.Controls.Add(this.idNrLabel);
|
||||
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.parityLabel);
|
||||
this.Controls.Add(this.baudRateTextBox);
|
||||
this.Controls.Add(this.baudRateLabel);
|
||||
this.Controls.Add(this.comPortNrTextBox);
|
||||
this.Controls.Add(this.comPortNrLabel);
|
||||
this.Name = "BalanceCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(450, 300);
|
||||
this.Load += new System.EventHandler(this.BalanceCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox handshakeComboBox;
|
||||
private System.Windows.Forms.ComboBox stopBitsComboBox;
|
||||
private System.Windows.Forms.ComboBox parityComboBox;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.Label handshakeLabel;
|
||||
private System.Windows.Forms.Label stopBitsLabel;
|
||||
private System.Windows.Forms.TextBox dataBitsTextBox;
|
||||
private System.Windows.Forms.Label dataBitsLabel;
|
||||
private System.Windows.Forms.Label parityLabel;
|
||||
private System.Windows.Forms.TextBox baudRateTextBox;
|
||||
private System.Windows.Forms.Label baudRateLabel;
|
||||
private System.Windows.Forms.TextBox comPortNrTextBox;
|
||||
private System.Windows.Forms.Label comPortNrLabel;
|
||||
private System.Windows.Forms.Label capacityLabel;
|
||||
private System.Windows.Forms.TextBox capacityTextBox;
|
||||
private System.Windows.Forms.Label label2;
|
||||
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;
|
||||
private System.Windows.Forms.TextBox formatTextBox;
|
||||
private System.Windows.Forms.Label formatLabel;
|
||||
private System.Windows.Forms.TextBox idNrTextBox;
|
||||
private System.Windows.Forms.Label idNrLabel;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox resolutionTextBox;
|
||||
private System.Windows.Forms.Label resolutionLabel;
|
||||
private System.Windows.Forms.ComboBox drainValveComboBox;
|
||||
private System.Windows.Forms.Label drainingValveLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,285 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajik
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Ports;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.UI.Bench.Components;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public partial class BalanceCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
BalanceCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as BalanceCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public BalanceCfgCtrl()
|
||||
{
|
||||
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 BalanceCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
parent = ParentForm as ComponentParametersDlg;
|
||||
if (parent == null) return;
|
||||
|
||||
if (parent.CmpntEntities != null)
|
||||
{
|
||||
drainValveComboBox.Items.Add("---");
|
||||
foreach (var cmpnt in parent.CmpntEntities)
|
||||
{
|
||||
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory)
|
||||
{
|
||||
drainValveComboBox.Items.Add(cmpnt.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
idNrTextBox.Text = config.IdNr.ToString();
|
||||
capacityTextBox.Text = config.Capacity.ToString();
|
||||
resolutionTextBox.Text = config.Resolution.ToString();
|
||||
emptyTextBox.Text = config.Empty.ToString();
|
||||
formatTextBox.Text = (config.Format.Length > 1) ? config.Format.Substring(1) : config.Format;
|
||||
emptyTimeTextBox.Text = config.DrainTimeSec.ToString();
|
||||
drainValveComboBox.Text = string.IsNullOrEmpty(config.DrainValve) ? "---" : config.DrainValve;
|
||||
|
||||
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;
|
||||
|
||||
idNrTextBox.Enabled = true;
|
||||
capacityTextBox.Enabled = true;
|
||||
resolutionTextBox.Enabled = true;
|
||||
emptyTextBox.Enabled = true;
|
||||
formatTextBox.Enabled = true;
|
||||
emptyTimeTextBox.Enabled = true;
|
||||
drainValveComboBox.Enabled = true;
|
||||
|
||||
comPortNrTextBox.Enabled = true;
|
||||
baudRateTextBox.Enabled = true;
|
||||
parityComboBox.Enabled = true;
|
||||
dataBitsTextBox.Enabled = true;
|
||||
stopBitsComboBox.Enabled = true;
|
||||
handshakeComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int idNr;
|
||||
if (!int.TryParse(idNrTextBox.Text, out idNr) || idNr < 1 || idNr > 3)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Id Number' is not valid";
|
||||
}
|
||||
|
||||
float mass;
|
||||
if (!Utils.TryParseUFloat(capacityTextBox.Text, out mass) || mass <= 0)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Tank Capacity' is not valid";
|
||||
}
|
||||
if (!Utils.TryParseUFloat(resolutionTextBox.Text, out mass) || mass <= 0)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Resolution' is not valid";
|
||||
}
|
||||
if (!Utils.TryParseUFloat(emptyTextBox.Text, out mass) || mass <= 0)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Tank Empty' is not valid";
|
||||
}
|
||||
|
||||
int dummy;
|
||||
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;
|
||||
message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec";
|
||||
}
|
||||
if (!drainValveComboBox.Items.Contains(drainValveComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Drain valve'";
|
||||
}
|
||||
|
||||
if (idNr == 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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.IdNr = int.Parse(idNrTextBox.Text);
|
||||
|
||||
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
|
||||
config.Resolution = Utils.ParseUFloat(resolutionTextBox.Text);
|
||||
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
|
||||
config.Format = "F" + formatTextBox.Text;
|
||||
config.DrainTimeSec = int.Parse(emptyTimeTextBox.Text);
|
||||
config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
|
||||
|
||||
if (config.IdNr == 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
private void idNrTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int idNr;
|
||||
if (int.TryParse(idNrTextBox.Text, out idNr))
|
||||
{
|
||||
bool visible = (idNr == 1);
|
||||
|
||||
comPortNrLabel.Visible = visible;
|
||||
comPortNrTextBox.Visible = visible;
|
||||
|
||||
baudRateLabel.Visible = visible;
|
||||
baudRateTextBox.Visible = visible;
|
||||
|
||||
parityLabel.Visible = visible;
|
||||
parityComboBox.Visible = visible;
|
||||
|
||||
dataBitsLabel.Visible = visible;
|
||||
dataBitsTextBox.Visible = visible;
|
||||
|
||||
stopBitsLabel.Visible = visible;
|
||||
stopBitsComboBox.Visible = visible;
|
||||
|
||||
handshakeLabel.Visible = visible;
|
||||
handshakeComboBox.Visible = visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,350 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.IO.Ports;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
/// <summary>
|
||||
/// Mettler Toledo ICS4_5 Weighting terminal connected via serial interface (RS232)
|
||||
/// </summary>
|
||||
/// <note>
|
||||
/// Implemented and tested on 15.10.2013 by Milan Hanajik
|
||||
/// </note>
|
||||
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale
|
||||
{
|
||||
/// <summary>
|
||||
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
|
||||
/// Warn: Start measurement when busy is true
|
||||
/// </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(BalanceDev));
|
||||
public override string ToString() { return string.Format("MettlerToledo.Multi.Balance({0})", Cfg.ToString(-1)); }
|
||||
|
||||
protected readonly BalanceCfg balanceCfg;
|
||||
protected static BalanceCfg balance1Cfg;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration of balances via static fields and methods
|
||||
/// </summary>
|
||||
static int nextBalanceIdx = 0;
|
||||
public static new void ResetStaticProperties()
|
||||
{
|
||||
nextBalanceIdx = 0;
|
||||
}
|
||||
public static int BalancesCount { get { return nextBalanceIdx; } }
|
||||
public static BalanceDev[] Balances;
|
||||
public static double[] Masses;
|
||||
///
|
||||
protected int balanceNr; /// 0-based balance number
|
||||
|
||||
protected static SerialPort serialPort;
|
||||
protected static StringBuilder stringBuilder;
|
||||
|
||||
public int ScaleNr { get { return balanceNr; } }
|
||||
public int IdNr { get { return balanceCfg.IdNr; } }
|
||||
public double Capacity { get { return balanceCfg.Capacity; } }
|
||||
public double Resolution { get { return balanceCfg.Resolution; } }
|
||||
public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } }
|
||||
public IValve DrainValve2 { get { return null; } }
|
||||
|
||||
/// Buoyancy
|
||||
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
|
||||
public float BuoyancyPress { get { return balanceCfg.BuoyancyPress; } }
|
||||
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
|
||||
public double WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
|
||||
|
||||
|
||||
/// <summary>The state of the mass measurement</summary>
|
||||
public MsrmntState MsrmntState { get { return msrmntState; } }
|
||||
protected static MsrmntState msrmntState;
|
||||
|
||||
/// <summary>The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
|
||||
public double Mass { get { return Masses[balanceNr]; } }
|
||||
|
||||
/// <summary>The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
|
||||
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
|
||||
protected int msrmntTimeStamp;
|
||||
|
||||
public string Format { get { return balanceCfg.Format; } }
|
||||
|
||||
|
||||
public BalanceDev() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="cfg">Balance properties</param>
|
||||
public BalanceDev(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
balanceCfg = cfg as BalanceCfg;
|
||||
if (balanceCfg.IdNr == 1) balance1Cfg = balanceCfg;
|
||||
|
||||
balanceNr = nextBalanceIdx++;
|
||||
Masses = new double[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
|
||||
///
|
||||
if (Balances == null || Balances.Length < nextBalanceIdx)
|
||||
{
|
||||
BalanceDev[] balancesSoFar = Balances;
|
||||
Balances = new BalanceDev[nextBalanceIdx];
|
||||
if (balancesSoFar != null) for (int i = 0; i < balancesSoFar.Length; i++) Balances[i] = balancesSoFar[i];
|
||||
Balances[nextBalanceIdx - 1] = this;
|
||||
}
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
base.Initalize();
|
||||
|
||||
msrmntState = MsrmntState.Failed; /// Data not valid yet
|
||||
|
||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
if (balanceCfg.IdNr == 1)
|
||||
{
|
||||
stringBuilder = new StringBuilder(40);
|
||||
string comPortName = "COM" + balanceCfg.ComPortNr.ToString();
|
||||
serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits);
|
||||
serialPort.Handshake = balanceCfg.Handshake;
|
||||
serialPort.Open();
|
||||
}
|
||||
|
||||
log.FatalFormat("Successfully initialized device {0}", ToString());
|
||||
}
|
||||
|
||||
public override bool IsEmpty()
|
||||
{
|
||||
return (Mass <= balanceCfg.Empty);
|
||||
}
|
||||
|
||||
public override bool ContainsMoreThen(float thld)
|
||||
{
|
||||
return (Mass >= thld);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a stable mass measurement
|
||||
/// </summary>
|
||||
public static bool GetStableMassMeasurement(int scaleId, string name)
|
||||
{
|
||||
if (balance1Cfg.DebugLevel == DebugMode.Simulate) return true;
|
||||
|
||||
if (msrmntState == MsrmntState.Busy ||
|
||||
msrmntState == MsrmntState.Busy1 ||
|
||||
msrmntState == MsrmntState.Busy2 ||
|
||||
msrmntState == MsrmntState.Busy3)
|
||||
{
|
||||
log.WarnFormat("{0} - GetStableMassMeasurement() returns false ... measurementState == {1}", name, msrmntState.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
msrmntState = (MsrmntState)((int)MsrmntState.Busy + scaleId);
|
||||
stringBuilder.Clear();
|
||||
#if BADGER_STREDNA_TRAT
|
||||
string serialData = string.Format("AR WT0{0}01\r\n", 3 - scaleId); /// 2->1 a 1->2
|
||||
#else
|
||||
string serialData = string.Format("AR WT0{0}01\r\n", scaleId);
|
||||
#endif
|
||||
serialPort.Write(serialData);
|
||||
log.InfoFormat("{0} - GetStableMassMeasurement() ... \"{1}\" sent", name, serialData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an immediate mass measurement
|
||||
/// </summary>
|
||||
public static bool GetImmediateMassMeasurement(int scaleId, string name)
|
||||
{
|
||||
if (balance1Cfg.DebugLevel == DebugMode.Simulate) return true;
|
||||
|
||||
if (msrmntState == MsrmntState.Busy ||
|
||||
msrmntState == MsrmntState.Busy1 ||
|
||||
msrmntState == MsrmntState.Busy2 ||
|
||||
msrmntState == MsrmntState.Busy3)
|
||||
{
|
||||
log.WarnFormat("{0} - GetImmediateMassMeasurement() returns false ... measurementState == {1}", name, msrmntState.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
msrmntState = (MsrmntState)((int)MsrmntState.Busy + scaleId);
|
||||
stringBuilder.Clear();
|
||||
#if BADGER_STREDNA_TRAT
|
||||
string serialData = string.Format("AR WT0{0}01\r\n", 3 - scaleId); /// 2->1 a 1->2
|
||||
#else
|
||||
string serialData = string.Format("AR WT0{0}01\r\n", scaleId);
|
||||
#endif
|
||||
serialPort.Write(serialData);
|
||||
log.InfoFormat("{0} - GetImmediateMassMeasurement() ... \"{1}\" sent", name, serialData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse characters received from the serial port
|
||||
/// </summary>
|
||||
public virtual void RunDeviceBefore()
|
||||
{
|
||||
if (balanceCfg.DebugLevel == DebugMode.Simulate)
|
||||
{
|
||||
Masses[balanceNr] = 123.456;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
return;
|
||||
}
|
||||
|
||||
if (balanceCfg.IdNr != 1) return;
|
||||
|
||||
if (serialPort == null)
|
||||
{
|
||||
log.ErrorFormat("{0} - RunDevice() - serial port closed", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.DebugFormat("{0} - RunDevice()", Name);
|
||||
|
||||
///
|
||||
/// Communication runs only when the state is MsrmntState.Busy#
|
||||
///
|
||||
if (msrmntState != MsrmntState.Busy1 &&
|
||||
msrmntState != MsrmntState.Busy2 &&
|
||||
msrmntState != MsrmntState.Busy3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string justReceived = serialPort.ReadExisting();
|
||||
if (justReceived != null && justReceived.Length > 0)
|
||||
{
|
||||
log.DebugFormat("RunDevice() received {0}", justReceived);
|
||||
stringBuilder.Append(justReceived);
|
||||
}
|
||||
|
||||
string currentBuffer = stringBuilder.ToString();
|
||||
int eolPos = currentBuffer.IndexOf("\r\n");
|
||||
if (eolPos >= 0)
|
||||
{
|
||||
log.InfoFormat("eolPos = {0}", eolPos);
|
||||
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
int balanceIdNr = (int)msrmntState - (int)MsrmntState.Busy;
|
||||
|
||||
/// Get part of the string before EOL
|
||||
string received = currentBuffer.Substring(0, eolPos);
|
||||
|
||||
/// Put the rest back to the string builder
|
||||
stringBuilder.Clear();
|
||||
if (currentBuffer.Length > eolPos + 2)
|
||||
{
|
||||
stringBuilder.Append(currentBuffer.Substring(eolPos + 2));
|
||||
}
|
||||
|
||||
if (received.Length == 19 && received.Substring(0, 6).Equals("AR A \""))
|
||||
{
|
||||
string weightStr = received.Substring(6, 12);
|
||||
while ((weightStr[0] == ' ') && (weightStr.Length > 1))
|
||||
{
|
||||
weightStr = weightStr.Substring(1, weightStr.Length - 1);
|
||||
}
|
||||
|
||||
double weight = 0;
|
||||
if (Utils.TryParseSDouble(weightStr, out weight))
|
||||
{
|
||||
Masses[balanceIdNr - 1] = weight * Balances[balanceIdNr - 1].Resolution;
|
||||
log.InfoFormat("Balance({0}) Valid response=\"{1}<cr>\", Mass = {2}kg", balanceIdNr, received, Masses[balanceIdNr - 1]);
|
||||
|
||||
msrmntState = MsrmntState.Valid;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.WarnFormat("Balance({0}) Failed response=\"{1}<cr>\", Error 1 !!!", balanceIdNr, received);
|
||||
msrmntState = MsrmntState.Failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Balances[balanceIdNr - 1].msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance({0}) Failed response=\"{1}<cr>\", Error 2 !!!", balanceIdNr, received);
|
||||
msrmntState = MsrmntState.Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter() { }
|
||||
|
||||
/// <summary>Stop this device</summary>
|
||||
public void StopDevice()
|
||||
{
|
||||
if ((balanceCfg.DebugLevel != DebugMode.Simulate) && (balanceCfg.IdNr == 1) && (serialPort != null))
|
||||
{
|
||||
serialPort.Close();
|
||||
serialPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopDevice2() { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <returns>ZeroOp reference</returns>
|
||||
public IOperation ZeroOp()
|
||||
{
|
||||
return new ZeroOp(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="result">Reference to a variable for 'tara' in kg</param>
|
||||
/// <returns>TaringOp reference</returns>
|
||||
public IOperation TaringOp(ref DoubleBox tara)
|
||||
{
|
||||
return new TaringOp(this, ref tara);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="result">Reference to a variable for the measured mass in kg</param>
|
||||
/// <returns>ReadMassOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadMassOp(ref DoubleBox mass)
|
||||
{
|
||||
return new ReadMassOp(this, ref mass);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="result">Reference to a variable for the measured mass in kg</param>
|
||||
/// <param name="readingsCount">Required mass readings count (>= 3)</param>
|
||||
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
|
||||
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
|
||||
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadStableMassOp(ref DoubleBox mass, int delayBefore, Config.Entities.MassMethod method, int readingsCount, double maxSpread)
|
||||
{
|
||||
return new ReadStableMassOp(this, ref mass, delayBefore, method, readingsCount, maxSpread);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSNOp instance reference casted to IOperaton</returns>
|
||||
public IOperation GetSerNumOp(ref string serialNumber)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public class BalanceFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "MettlerToledo-Multi"; } }
|
||||
public override string ToString() { return ClassName; }
|
||||
|
||||
/// <summary>Max. number of components of this class in the system</summary>
|
||||
public int MaxCount { get { return 5; } }
|
||||
|
||||
public IComponent DummyComponent() { return new BalanceDev(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new BalanceDev(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new BalanceCfg(this); }
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl() { return new BalanceCfgCtrl(); }
|
||||
|
||||
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
|
||||
{
|
||||
return new BalanceDev((BalanceCfg)config);
|
||||
}
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(BalanceCfg.Serializer, component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { BalanceDev.ResetStaticProperties(); }
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public class ReadMassOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassOp));
|
||||
public override string ToString() { return string.Format("ReadMassOp(.,.)"); }
|
||||
|
||||
bool started;
|
||||
bool done;
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev scale;
|
||||
DoubleBox result;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="scale">Balance device instance</param>
|
||||
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
|
||||
/// <param name="result">Reference to the measured mass in kg</param>
|
||||
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
|
||||
{
|
||||
if (scale == null) throw new ArgumentNullException("scale");
|
||||
this.scale = scale;
|
||||
|
||||
this.result = result;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
done = false;
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
if (!done)
|
||||
return Event.Busy;
|
||||
else
|
||||
return Event.ScaleDone;
|
||||
}
|
||||
else if (started && scale.MsrmntState != MsrmntState.Busy)
|
||||
{
|
||||
if (scale.MsrmntState == MsrmntState.Valid) result.Val = scale.Mass;
|
||||
log.InfoFormat("ReadMassOp.Run() ... state={0}, mass={1} ... returning Event.BalanceDone",
|
||||
scale.MsrmntState, scale.Mass);
|
||||
done = true;
|
||||
started = false;
|
||||
return Event.ScaleDone; /// Mass read OK
|
||||
}
|
||||
else
|
||||
{
|
||||
return Event.Busy;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
/// <summary>
|
||||
/// Operation to read more mass values and average them to obtain a more accurate result.
|
||||
/// </summary>
|
||||
public class ReadStableMassOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadStableMassOp));
|
||||
public override string ToString() { return string.Format("ReadStableMassOp(.,{0},.)", totalReadingsCount); }
|
||||
|
||||
/// Operation specific
|
||||
double[] massReadings;
|
||||
int currentReadingsCount;
|
||||
|
||||
/// Set by the constructor
|
||||
readonly BalanceDev scale;
|
||||
readonly DoubleBox result;
|
||||
readonly int delayBefore;
|
||||
readonly MassMethod method; /// false = slow (precise), true = fast (immediate)
|
||||
readonly int totalReadingsCount;
|
||||
readonly double maxSpread; /// Maximum spread of measurements in kg (otherwise the measurement continues)
|
||||
|
||||
bool started;
|
||||
int startTime;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="scale">Balance device instance</param>
|
||||
/// <param name="result">Reference to the measured mass in kg</param>
|
||||
/// <param name="readingsCount">Required mass readings count (>= 3)</param>
|
||||
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
|
||||
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
|
||||
public ReadStableMassOp(BalanceDev scale, ref DoubleBox result, int delayBefore, MassMethod method,
|
||||
int readingsCount, double maxSpread)
|
||||
{
|
||||
this.scale = scale;
|
||||
if (this.scale == null) throw new ArgumentNullException("balanceDev");
|
||||
|
||||
this.result = result;
|
||||
this.delayBefore = delayBefore;
|
||||
this.method = method;
|
||||
this.totalReadingsCount = (readingsCount < 4) ? 5 : readingsCount; /// readingsCount is at least 4
|
||||
this.maxSpread = (maxSpread == 0) ? (scale.Capacity / 20000.0) : maxSpread;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
startTime = StateMachine.Time;
|
||||
currentReadingsCount = 0;
|
||||
massReadings = new double[totalReadingsCount];
|
||||
if (delayBefore == 0)
|
||||
{
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
if (StateMachine.Time >= startTime + delayBefore)
|
||||
{
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
}
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
if (currentReadingsCount >= totalReadingsCount) return Event.ScaleDone; /// Mass has already been calculated
|
||||
|
||||
if (scale.MsrmntState == MsrmntState.Busy) return Event.None;
|
||||
|
||||
if (scale.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
massReadings[currentReadingsCount++] = scale.Mass;
|
||||
|
||||
if (currentReadingsCount == totalReadingsCount)
|
||||
{
|
||||
#if true /// OLD_WAY_OF_MASS_CALCULATION
|
||||
/// Exclude min. and max. value, calculate average
|
||||
Array.Sort(massReadings);
|
||||
double calcMass = 0;
|
||||
for (int i = 1; i < totalReadingsCount - 1; i++)
|
||||
{
|
||||
calcMass += massReadings[i];
|
||||
}
|
||||
calcMass = (calcMass / (totalReadingsCount - 2));
|
||||
log.InfoFormat("ReadStableMassOp.Run() ... valid mass={0} ... returning Event.BalanceDone", calcMass);
|
||||
result.Val = calcMass;
|
||||
return Event.ScaleDone; /// Mass has just been calculated
|
||||
#else
|
||||
double minimum = double.MaxValue;
|
||||
double maximum = double.MinValue;
|
||||
foreach (double val in massReadings)
|
||||
{
|
||||
if (val < minimum) minimum = val;
|
||||
if (val > maximum) maximum = val;
|
||||
}
|
||||
|
||||
if ((maximum - minimum) <= maxSpread)
|
||||
{
|
||||
double calcMass = 0;
|
||||
for (int i = 0; i < totalReadingsCount; i++)
|
||||
{
|
||||
calcMass += massReadings[i];
|
||||
}
|
||||
calcMass = (calcMass / totalReadingsCount);
|
||||
log.InfoFormat("ReadStableMassOp.Run() ... valid mass={0} ... returning Event.BalanceDone", calcMass);
|
||||
result.Val = calcMass;
|
||||
return Event.BalanceDone; /// Mass has just been calculated
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Shift data and decrement 'currentReadingsCount'
|
||||
for (int i = 0; i < totalReadingsCount - 1; i++)
|
||||
{
|
||||
massReadings[i] = massReadings[i + 1];
|
||||
}
|
||||
currentReadingsCount--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public class TaringOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TaringOp));
|
||||
public override string ToString() { return string.Format("TaringOp(.,.)"); }
|
||||
|
||||
bool done;
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev balanceDev;
|
||||
DoubleBox tara;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
||||
public TaringOp(BalanceDev balanceDev, ref DoubleBox tara)
|
||||
{
|
||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
||||
this.balanceDev = balanceDev;
|
||||
|
||||
this.tara = tara;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
tara.Val = 0.0f; // Don't do anything, tara = 0
|
||||
done = true;
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (done) return Event.ScaleDone; /// Taring has been done already
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
||||
{
|
||||
tara.Val = balanceDev.Capacity;
|
||||
done = true;
|
||||
return Event.ScaleOverload;
|
||||
}
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
tara.Val = balanceDev.Mass;
|
||||
done = true;
|
||||
return Event.ScaleDone; /// Taring completed
|
||||
}
|
||||
|
||||
return Event.Busy;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
public class ZeroOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp));
|
||||
public override string ToString() { return string.Format("ZeroOp(.,.)"); }
|
||||
|
||||
bool done;
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev balanceDev;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
public ZeroOp(BalanceDev balanceDev)
|
||||
{
|
||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
||||
this.balanceDev = balanceDev;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (done) return Event.ScaleDone; /// Zero has been done already
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
||||
{
|
||||
done = true;
|
||||
return Event.ScaleOverload;
|
||||
}
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
done = true;
|
||||
return Event.ScaleDone; /// Zero completed
|
||||
}
|
||||
|
||||
return Event.Busy;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,6 @@ namespace TBF.Rig
|
||||
Factories.Add(new MettlerToledo.Standard.BalanceFactory()); /// MettlerToledo Balance
|
||||
Factories.Add(new MettlerToledo.Standard.BalanceOldFactory()); /// MettlerToledoBalanceOld
|
||||
Factories.Add(new MettlerToledo.Standard.BalanceNewFactory()); /// MettlerToledoBalanceSN
|
||||
Factories.Add(new MettlerToledo.Multi.BalanceFactory()); /// MettlerToledo-Multi
|
||||
Factories.Add(new Modbus.Common.Factory()); /// Modbus
|
||||
Factories.Add(new Modbus.Ambient.Comet.Factory()); /// Comet Ambient temp./pressure/humidity measurement via a modbus on a PC
|
||||
Factories.Add(new Modbus.Easytherm.Factory()); /// Modbus.Easytherm
|
||||
|
||||
Reference in New Issue
Block a user