2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Elde.RegisterReader
|
|
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public class RRProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
|
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override void InitializeAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
PulsesPerLtr = 1.0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
string[] paramNames = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
Strings.PulsesPerLtr,
|
|
|
|
|
|
};
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override string ParamName(int i) { return paramNames[i]; }
|
|
|
|
|
|
public override int ParamsCount() { return paramNames.Length; }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override string ToString(int i)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override void UpdateProcedureParams(Entities.ComponentProcedure dbEntity)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
if (dbEntity == null) return;
|
|
|
|
|
|
try
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
RRProcedureParams tmp = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
|
|
|
|
|
|
.Deserialize(new StringReader(dbEntity.Parameters));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
procedureParamsEntity = dbEntity;
|
|
|
|
|
|
componentName = dbEntity.CmpntName;
|
|
|
|
|
|
procedure = dbEntity.Procedure;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
PulsesPerLtr = tmp.PulsesPerLtr;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-12-31 12:46:33 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public RRProcedureParams()
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public RRProcedureParams(Entities.ComponentProcedure procedureParamsEntity, string componentName, Entities.Procedure procedure)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
this.procedureParamsEntity = procedureParamsEntity;
|
|
|
|
|
|
this.componentName = componentName;
|
|
|
|
|
|
this.procedure = procedure;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|