116 lines
2.6 KiB
C#
116 lines
2.6 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.Network.Camera.RoiForFixedStart
|
|
{
|
|
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
|
|
protected override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public float PulsesPerLtr; /// [l^-1]
|
|
|
|
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;
|
|
int idummy;
|
|
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(ProcedureParams prms)
|
|
{
|
|
prms.PulsesPerLtr = this.PulsesPerLtr;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
ProcedureParams pars = new ProcedureParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateProcedureParams(ComponentProcedure dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
ProcedureParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcedureParams;
|
|
|
|
procedureParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
procedure = dbEntity.Procedure;
|
|
|
|
if (tmp != null) tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
public ProcedureParams() { }
|
|
|
|
public ProcedureParams(bool initialize)
|
|
{
|
|
if (initialize) InitializeAll();
|
|
}
|
|
|
|
public ProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procedureParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|