190 lines
5.3 KiB
C#
190 lines
5.3 KiB
C#
///
|
|
/// Copyright (c) 2016 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.WaterMeters.Munich
|
|
{
|
|
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
{
|
|
public string ProductName; /// Znak fabryczny (PL)
|
|
public string Producer; /// Producent (PL), Hersteller (D)
|
|
public float DN;
|
|
|
|
public float L; /// stavebná dĺžka [mm]
|
|
public Mounting Mounting;
|
|
public float Qn; /// [m3/h]
|
|
|
|
public string MetrologicalClass; /// Metr. Klasse
|
|
public string ApprovalInfo; /// Zulassungszeichen, WE (PL)
|
|
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
|
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
ProductName = string.Empty;
|
|
Producer = string.Empty;
|
|
DN = 0;
|
|
|
|
L = 0;
|
|
Mounting = Mounting.NotSpecified;
|
|
Qn = 2.5f;
|
|
|
|
MetrologicalClass = "A";
|
|
ApprovalInfo = string.Empty;
|
|
PulsesPerLtr = 1.0f;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Product_name,
|
|
Strings.Producer,
|
|
"DN",
|
|
|
|
Strings.L,
|
|
Strings.Mounting,
|
|
Strings.Qn,
|
|
|
|
Strings.Metrological_class,
|
|
Strings.Approval_info,
|
|
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 ProductName;
|
|
case 1: return Producer;
|
|
case 2: return DN.ToString();
|
|
|
|
case 3: return L.ToString();
|
|
case 4: return Mounting.ToDescription();
|
|
case 5: return Qn.ToString();
|
|
|
|
case 6: return MetrologicalClass;
|
|
case 7: return ApprovalInfo;
|
|
case 8: return PulsesPerLtr.ToString();
|
|
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: ProductName = strValue; return;
|
|
case 1: Producer = strValue; return;
|
|
case 2: DN = Utils.ParseUFloat(strValue); return;
|
|
|
|
case 3: L = Utils.ParseUFloat(strValue); return;
|
|
case 4:
|
|
for (Mounting m = 0; m < Mounting.Count; m++)
|
|
{
|
|
if (m.ToDescription().Equals(strValue)) { Mounting = m; return; }
|
|
}
|
|
break;
|
|
case 5: Qn = Utils.ParseUFloat(strValue); return;
|
|
|
|
case 6: MetrologicalClass = strValue; return;
|
|
case 7: ApprovalInfo = strValue; return;
|
|
case 8: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
|
|
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
switch (i)
|
|
{
|
|
case 0: /// ProductName
|
|
case 1: /// Producer
|
|
case 6: /// MetrologicalClass
|
|
case 7: /// ApprovalInfo
|
|
return true;
|
|
case 2: /// DN
|
|
case 3: /// L
|
|
case 5: /// Qn
|
|
case 8: /// PulsesPerLtr
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 4:
|
|
for (Mounting tc = 0; tc < Mounting.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(ProcParams prms)
|
|
{
|
|
prms.ProductName = this.ProductName;
|
|
prms.Producer = this.Producer;
|
|
prms.DN = this.DN;
|
|
prms.L = this.L;
|
|
prms.Mounting = this.Mounting;
|
|
prms.Qn = this.Qn;
|
|
prms.MetrologicalClass = this.MetrologicalClass;
|
|
prms.ApprovalInfo = this.ApprovalInfo;
|
|
prms.PulsesPerLtr = this.PulsesPerLtr;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
ProcParams pars = new ProcParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateProcedureParams(ComponentProcedure dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
ProcParams tmp = (ProcParams)(new XmlSerializer(typeof(ProcParams)))
|
|
.Deserialize(new StringReader(dbEntity.Parameters));
|
|
|
|
procedureParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
procedure = dbEntity.Procedure;
|
|
|
|
tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public ProcParams()
|
|
{
|
|
}
|
|
|
|
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|