128 lines
2.9 KiB
C#
128 lines
2.9 KiB
C#
///
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|
{
|
|
public class iPerlCommunicationParams : TestParamsBase, IParamsProvider, ITestParams
|
|
{
|
|
public string Activity; /// Communication activity
|
|
public bool SimultWithPrevious;
|
|
public bool SimultWithNext;
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
Activity = "Read Configuration";
|
|
SimultWithPrevious = false;
|
|
SimultWithNext = false;
|
|
}
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Activity,
|
|
Strings.Simultaneous_with_previous_step,
|
|
Strings.Simultaneous_with_next_step,
|
|
};
|
|
public override string ParamName(int i) { return paramNames[i]; }
|
|
public override int ParamsCount() { return paramNames.Length; }
|
|
|
|
public override string ToString(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return Activity;
|
|
case 1: return (SimultWithPrevious ? Strings.yes : Strings.no);
|
|
case 2: return (SimultWithNext ? Strings.yes : Strings.no);
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: Activity = strValue; return;
|
|
case 1: SimultWithPrevious = strValue.Equals(Strings.yes); return;
|
|
case 2: SimultWithNext = strValue.Equals(Strings.yes); return;
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return true;
|
|
case 1:
|
|
case 2:
|
|
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(iPerlCommunicationParams prms)
|
|
{
|
|
prms.Activity = this.Activity;
|
|
prms.SimultWithPrevious = this.SimultWithPrevious;
|
|
prms.SimultWithNext = this.SimultWithNext;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
iPerlCommunicationParams pars = new iPerlCommunicationParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateTestParams(ComponentTest dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
iPerlCommunicationParams tmp = (iPerlCommunicationParams)(new XmlSerializer(typeof(iPerlCommunicationParams)))
|
|
.Deserialize(new StringReader(dbEntity.Parameters));
|
|
|
|
testParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
test = dbEntity.Test;
|
|
|
|
tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public iPerlCommunicationParams()
|
|
{
|
|
}
|
|
|
|
public iPerlCommunicationParams(ComponentTest testParamsEntity, string componentName, Test test)
|
|
{
|
|
this.testParamsEntity = testParamsEntity;
|
|
this.componentName = componentName;
|
|
this.test = test;
|
|
}
|
|
}
|
|
}
|