117 lines
3.6 KiB
C#
117 lines
3.6 KiB
C#
///
|
|
/// Copyright (c) 2013-2016 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.MettlerToledo.Standard
|
|
{
|
|
public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg
|
|
{
|
|
public IComponent GetComponent(IList<IComponent> components)
|
|
{
|
|
if (Factory.ClassName.Equals("MettlerToledoBalanceNew")) return new BalanceNewDev(this);
|
|
else if (Factory.ClassName.Equals("MettlerToledoBalanceOld")) return new BalanceOld(this);
|
|
else return new BalanceDev(this);
|
|
}
|
|
public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); }
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public int ComPortNr;
|
|
public int BaudRate;
|
|
public Parity Parity;
|
|
public int DataBits;
|
|
public StopBits StopBits;
|
|
public Handshake Handshake;
|
|
public float Capacity; /// Max. water mass in 'kg' or volume in 'l'
|
|
public float Empty; /// 'Empty' water mass in 'kg' or volume in 'l'
|
|
public string Format;
|
|
public int EmptyTimeSec; /// s
|
|
|
|
/// Buoyancy related serialized parameters displayed in Metrology tab page
|
|
private float buoyancyTemp;
|
|
private float buoyancyPress;
|
|
private float buoyancyHumi;
|
|
private float weightStandardDensity;
|
|
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; }
|
|
}
|
|
|
|
/// Calibration info serialized parameters displayed in Metrology tab page
|
|
string calibCertificateNr;
|
|
DateTime calibDate;
|
|
DateTime calibValidDate;
|
|
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 = "WT";
|
|
ParentName = string.Empty;
|
|
ComPortNr = 3;
|
|
BaudRate = 2400;
|
|
Parity = System.IO.Ports.Parity.Even;
|
|
DataBits = 7;
|
|
StopBits = System.IO.Ports.StopBits.One;
|
|
Handshake = System.IO.Ports.Handshake.XOnXOff;
|
|
Capacity = 200.0f;
|
|
Empty = 20.0f;
|
|
Format = "F3";
|
|
EmptyTimeSec = 180;
|
|
BuoyancyTemp = 20.0f;
|
|
BuoyancyPress = 1.0f;
|
|
BuoyancyHumi = 40.0f;
|
|
}
|
|
|
|
public BalanceCfg(IComponentFactory factory)
|
|
: this()
|
|
{
|
|
this.Factory = factory;
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("Name={0}, {1}kg, empty={2}kg, fmt.={3}, emptyTm={4}s, Com{5}, {6}Bd, {7}-bits, parity={8}, stopBits={9}, {10}",
|
|
Name, Capacity, Empty, Format, EmptyTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
|
}
|
|
}
|
|
}
|