tbf/TBF/Rig/TestMethods/iPerlCommunication/TestMethodCfg.cs

100 lines
3.5 KiB
C#

///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using System.IO.Ports;
using System.Threading;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.TestMethods.iPerlCommunication
{
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new TestMethodCfgCtrl(); }
///
/// Serialized parameters
///
public int CommTimeout; /// Communication timeout in ms (500 .. 5000)
public int DelayBetweenRetries; /// Delay between communication retries in ms (0 .. 5000)
public int MaxCommRetries; /// Max. number of retries (1 .. 10)
public int WaitTimeAfterFailure; /// Wait time after communication failure in ms
public int PassThroughWaitTime; /// Pass Through wait time for radio parameters in ms
public int NrThreads; /// Numbwr of parallel threads (1, 2 or 4)
public int IperlCheckErrorsToStop;
///
/// NFC S4.5 Combihead params
///
public int MciTimeoutMs;
public int BaudRate;
public int DataBits;
public Parity ParityBit;
public StopBits StopBits;
public int DfltQ2c_15_rl;
public int DfltQ2c_15_lr;
public int DfltQ2c_20_rl;
public int DfltQ2c_20_lr;
public int DfltQ2c_25_63_rl;
public int DfltQ2c_25_63_lr;
public int DfltQ2c_25_10_rl;
public int DfltQ2c_25_10_lr;
public int DfltQ2c_32_rl;
public int DfltQ2c_32_lr;
public int DfltQ2c_40_rl;
public int DfltQ2c_40_lr;
public bool UseWebService;
public string BaseUrl;
public string RelativeUrl;
/// <summary> Test parameters </summary>
[XmlIgnore]
public iPerlCommunicationParams TestParams;
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
public override IParamsProvider CreateTestParamsProvider() { return new iPerlCommunicationParams(true); }
public override IParamsProvider GetUITestParamsProvider(Test test)
{
return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null;
}
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
Name = "iPerlCommunication";
ParentName = string.Empty;
CommTimeout = 1800; /// ms
MaxCommRetries = 4;
WaitTimeAfterFailure = 2200;
PassThroughWaitTime = 1500;
NrThreads = 2; /// 1, 2 or 4 threads
IperlCheckErrorsToStop = 10;
MciTimeoutMs = 4000; // ms, NFC interface
BaudRate = 57600; // NFC Interface
DataBits = 8; // NFC Interface
ParityBit = Parity.None; // NFC Interface
StopBits = StopBits.Two; // NFC Interface
TestParams = CreateTestParamsProvider() as iPerlCommunicationParams;
}
public TestMethodCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, CommTimeout={1}, MaxRetries={2}, NrThreads={3}", Name, CommTimeout, MaxCommRetries, NrThreads);
}
}
}