103 lines
3.5 KiB
C#
103 lines
3.5 KiB
C#
///
|
|
/// Copyright (c) 2013-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.Standard
|
|
{
|
|
public enum ActionA1D
|
|
{
|
|
Zero,
|
|
Tara,
|
|
None,
|
|
Count
|
|
}
|
|
|
|
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 ComPortNr;
|
|
public int BaudRate;
|
|
public Parity Parity;
|
|
public int DataBits;
|
|
public StopBits StopBits;
|
|
public Handshake Handshake;
|
|
|
|
public float Capacity { get; set; } /// Max. water mass in 'kg' or volume in 'l'
|
|
public float Empty { get; set; } /// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l')
|
|
public float EmptyUp { get; set; } /// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l') when the drain valve is not open
|
|
public string Evaporation { get; set; }
|
|
public string DrainValve { get; set; }
|
|
public int DrainTimeSec { get; set; }
|
|
public ActionA1D ActionAfter1stDraining { get; set; }
|
|
public string Format;
|
|
|
|
/// 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; }
|
|
|
|
/// Calibration info serialized parameters displayed in Metrology tab page
|
|
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() { }
|
|
|
|
public BalanceCfg(IComponentFactory factory)
|
|
: this()
|
|
{
|
|
Factory = factory;
|
|
Name = "WT1";
|
|
ParentName = string.Empty;
|
|
InitializeAll();
|
|
}
|
|
|
|
void InitializeAll()
|
|
{
|
|
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;
|
|
EmptyUp = 2.0f;
|
|
Format = "F3";
|
|
DrainValve = "VB1";
|
|
DrainTimeSec = 180;
|
|
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 string ToString(int i)
|
|
{
|
|
return string.Format("Name={0}, {1}kg, empty={2}kg, emptyUp={3}kg, drainVlv={4}, drainTm={5}s, Com{6}, {7}Bd, {8}-bits, parity={9}, stopBits={10}, {11}",
|
|
Name, Capacity, Empty, EmptyUp, DrainValve, DrainTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
|
}
|
|
}
|
|
}
|