117 lines
2.5 KiB
C#
117 lines
2.5 KiB
C#
///
|
|
/// Copyright (c) 2013-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.Elde.FixedStartRegisterReader
|
|
{
|
|
public class RRProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
{
|
|
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
PulsesPerLtr = 1.0f;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.PulsesPerLtr,
|
|
};
|
|
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 PulsesPerLtr.ToString();
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
/// Retrieves parameters from UI controls
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
/// Verifies whether strings in UI controls represent valid parameters
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(RRProcedureParams prms)
|
|
{
|
|
prms.PulsesPerLtr = this.PulsesPerLtr;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
RRProcedureParams pars = new RRProcedureParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateProcedureParams(ComponentProcedure dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
RRProcedureParams tmp = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
|
|
.Deserialize(new StringReader(dbEntity.Parameters));
|
|
|
|
procedureParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
procedure = dbEntity.Procedure;
|
|
|
|
tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
public RRProcedureParams()
|
|
{
|
|
}
|
|
|
|
public RRProcedureParams(bool initialize)
|
|
{
|
|
if (initialize) InitializeAll();
|
|
}
|
|
|
|
public RRProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procedureParamsEntity;
|
|
this.componentName = componentName;
|
|
}
|
|
}
|
|
}
|