113 lines
3.6 KiB
C#
113 lines
3.6 KiB
C#
///
|
|
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Xml.Serialization;
|
|
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
|
|
public float BuoyancyTemp { get; set; }
|
|
public float BuoyancyPress { get; set; }
|
|
public float BuoyancyHumi { get; set; }
|
|
public float WeightStandardDensity { get; set; }
|
|
|
|
public string CalibCertificateNr { get; set; }
|
|
public string CertPath { get; set; }
|
|
public DateTime CalibDate { get; set; }
|
|
public DateTime CalibValidDate { get; set; }
|
|
|
|
|
|
/// 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;
|
|
|
|
CalibCertificateNr = string.Empty;
|
|
CertPath = string.Empty;
|
|
CalibDate = TBF.UI.Constants.MinDate;
|
|
CalibValidDate = TBF.UI.Constants.MaxDate;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|