131 lines
3.7 KiB
C#
131 lines
3.7 KiB
C#
///
|
|
/// Copyright (c) 2015-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.Multi
|
|
{
|
|
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ICalibInfoCfg
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(BalanceCfg) })[0];
|
|
protected override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); }
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public int IdNr; /// Identification number 1..3
|
|
public float Capacity; /// Max. water mass in 'kg' or volume in 'l'
|
|
public float Resolution; /// Resolution of the integer value in the serial protocol in 'kg'
|
|
public float Empty; /// 'Empty' water mass in 'kg' or volume in 'l'
|
|
public string Format;
|
|
public int EmptyTimeSec; /// s
|
|
|
|
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";
|
|
EmptyTimeSec = 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, EmptyTimeSec, 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, EmptyTimeSec);
|
|
}
|
|
}
|
|
}
|
|
}
|