64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
///
|
|
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
|
///
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Xml.Serialization;
|
|
using Common;
|
|
using TBF.Rig.Generic;
|
|
|
|
namespace TBF.Rig.RegisterReaders.SerialStream
|
|
{
|
|
public class SerialStreamCfg : ComponentCfgBase, Generic.IComponentCfg
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SerialStreamCfg) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new SerialStreamCfgCtrl(); }
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public int ComPortNr;
|
|
public int BaudRate;
|
|
public Parity Parity;
|
|
public int DataBits;
|
|
public StopBits StopBits;
|
|
public Handshake Handshake;
|
|
|
|
///
|
|
/// Procedure parameters
|
|
///
|
|
[XmlIgnore]
|
|
public ProcParams ProcParams;
|
|
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
|
|
public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); }
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
SerialStreamCfg()
|
|
{
|
|
ProcParams = CreateProcParamsProvider() as ProcParams;
|
|
}
|
|
|
|
public SerialStreamCfg(string name, IComponentFactory factory)
|
|
: this()
|
|
{
|
|
Name = name;
|
|
Factory = factory;
|
|
ParentName = string.Empty;
|
|
ComPortNr = 21;
|
|
BaudRate = 9600;
|
|
Parity = System.IO.Ports.Parity.None;
|
|
DataBits = 8;
|
|
StopBits = System.IO.Ports.StopBits.One;
|
|
Handshake = System.IO.Ports.Handshake.None;
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("{0} Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
|
|
Name, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
|
}
|
|
}
|
|
}
|