202 lines
5.9 KiB
C#
202 lines
5.9 KiB
C#
///
|
|
/// Copyright (c) 2016 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.Rig.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.Rig.WaterMeters.Munich
|
|
{
|
|
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
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 bool NewQnames; /// true = display Q4,Q3,Q2,Q1, false = display Qmax, Qn, Qt, Qmin
|
|
public float Qn; /// [m3/h]
|
|
public string MetrologicalClass; /// Metr. Klasse
|
|
public string ApprovalInfo; /// Zulassungszeichen, WE (PL)
|
|
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
ProductName = string.Empty;
|
|
Producer = string.Empty;
|
|
DN = 0;
|
|
L = 0;
|
|
Mounting = Mounting.NotSpecified;
|
|
NewQnames = false;
|
|
Qn = 2.5f;
|
|
MetrologicalClass = "A";
|
|
ApprovalInfo = string.Empty;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
#if MUNICH
|
|
"Prüfvorlage;Zählertyp",
|
|
#else
|
|
Strings.Product_name,
|
|
#endif
|
|
Strings.Producer,
|
|
"DN [mm]",
|
|
"L [mm]",
|
|
Strings.Mounting,
|
|
Strings.New_Q_names,
|
|
"Qn or Q3",
|
|
Strings.Metrological_class,
|
|
Strings.Approval_info,
|
|
};
|
|
public override string ParamName(int i)
|
|
{
|
|
if (i == 7 && NewQnames) return NewQnames ? "Q3 [m3/h]" : "Qn [m3/h]";
|
|
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 (NewQnames ? Strings.yes : Strings.no);
|
|
case 6: return Qn.ToString();
|
|
case 7: return MetrologicalClass;
|
|
case 8: return ApprovalInfo;
|
|
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: ProductName = strValue; return CfgUpdateFlags.None;
|
|
case 1: Producer = strValue; return CfgUpdateFlags.None;
|
|
case 2: DN = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
|
|
case 3: L = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
|
|
case 4:
|
|
for (Mounting m = 0; m < Mounting.Count; m++)
|
|
{
|
|
if (m.ToDescription().Equals(strValue)) { Mounting = m; return CfgUpdateFlags.None; }
|
|
}
|
|
break;
|
|
case 5: NewQnames = strValue.Equals(Strings.yes); return CfgUpdateFlags.None;
|
|
case 6: Qn = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
|
|
case 7: MetrologicalClass = strValue; return CfgUpdateFlags.None;
|
|
case 8: ApprovalInfo = strValue; return CfgUpdateFlags.None;
|
|
|
|
default: return CfgUpdateFlags.None;
|
|
}
|
|
|
|
return CfgUpdateFlags.None;
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
switch (i)
|
|
{
|
|
case 0: /// ProductName
|
|
case 1: /// Producer
|
|
case 7: /// MetrologicalClass
|
|
case 8: /// ApprovalInfo
|
|
return true;
|
|
case 2: /// DN
|
|
case 3: /// L
|
|
case 6: /// Qn
|
|
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;
|
|
case 5:
|
|
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(ProcParams prms)
|
|
{
|
|
prms.ProductName = this.ProductName;
|
|
prms.Producer = this.Producer;
|
|
prms.DN = this.DN;
|
|
prms.L = this.L;
|
|
prms.Mounting = this.Mounting;
|
|
prms.NewQnames = this.NewQnames;
|
|
prms.Qn = this.Qn;
|
|
prms.MetrologicalClass = this.MetrologicalClass;
|
|
prms.ApprovalInfo = this.ApprovalInfo;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
ProcParams pars = new ProcParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
|
|
|
|
procedureParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
procedure = dbEntity.Procedure;
|
|
|
|
if (tmp != null) tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public ProcParams()
|
|
{
|
|
}
|
|
|
|
public ProcParams(bool initialize)
|
|
{
|
|
if (initialize) InitializeAll();
|
|
}
|
|
|
|
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|