346 lines
12 KiB
C#
346 lines
12 KiB
C#
///
|
|
/// Copyright (c) 2013-2017 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.WaterMeter
|
|
{
|
|
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 Qmax; /// [m3/h]
|
|
public float Qn; /// [m3/h]
|
|
public float Qt; /// [m3/h]
|
|
public float Qmin; /// [m3/h]
|
|
|
|
public string MetrologicalClass; /// Metr. Klasse
|
|
public TemperatureClass TemperatureClass;
|
|
public PressureLossClass PressureLossClass;
|
|
public MaxAdmissiblePressure MaxAdmissiblePressure;
|
|
public FlowProfileSensitivityClass FlowProfileSensitivityClass;
|
|
|
|
public string ApprovalInfo; /// Zulassungszeichen, WE (PL)
|
|
public string Certificate;
|
|
|
|
public double PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
|
|
|
public string Text1;
|
|
public string Text2;
|
|
public string Text3;
|
|
public string Text4;
|
|
public string Text5;
|
|
|
|
public Medium WaterTemp; /// Woda: zimna / tepla (PL)
|
|
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
ProductName = string.Empty;
|
|
Producer = string.Empty;
|
|
DN = 0;
|
|
L = 0;
|
|
Mounting = Mounting.NotSpecified;
|
|
NewQnames = false;
|
|
Qmax = 4.0f;
|
|
Qn = 2.5f;
|
|
Qt = 0.005f;
|
|
Qmin = 0.003125f;
|
|
MetrologicalClass = "A";
|
|
TemperatureClass = TemperatureClass.NotSpecified;
|
|
PressureLossClass = PressureLossClass.NotSpecified;
|
|
MaxAdmissiblePressure = MaxAdmissiblePressure.NotSpecified;
|
|
FlowProfileSensitivityClass = FlowProfileSensitivityClass.NotSpecified;
|
|
ApprovalInfo = string.Empty;
|
|
Certificate = string.Empty;
|
|
PulsesPerLtr = 1.0;
|
|
Text1 = string.Empty;
|
|
Text2 = string.Empty;
|
|
Text3 = string.Empty;
|
|
Text4 = string.Empty;
|
|
Text5 = string.Empty;
|
|
|
|
WaterTemp = Medium.ColdWater;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Product_name,
|
|
Strings.Producer,
|
|
"DN",
|
|
Strings.L,
|
|
Strings.Mounting,
|
|
Strings.New_Q_names,
|
|
Strings.Qmax,
|
|
Strings.Qn,
|
|
Strings.Qt,
|
|
Strings.Qmin,
|
|
Strings.Metrological_class,
|
|
Strings.Temperature_class,
|
|
Strings.Pressure_loss_class,
|
|
Strings.Maximum_admissible_pressure,
|
|
Strings.Flow_profile_sensitivity_class,
|
|
Strings.Approval_info,
|
|
Strings.Certificate,
|
|
Strings.PulsesPerLtr,
|
|
"Text1",
|
|
"Text2",
|
|
"Text3",
|
|
"Text4",
|
|
"Text5",
|
|
|
|
Strings.Water, /// "Woda"
|
|
};
|
|
public override string ParamName(int i)
|
|
{
|
|
string name = paramNames[i];
|
|
|
|
if (NewQnames && name.Equals(Strings.Qmax)) name = "Q4";
|
|
if (NewQnames && name.Equals(Strings.Qn)) name = "Q3";
|
|
if (NewQnames && name.Equals(Strings.Qt)) name = "Q2";
|
|
if (NewQnames && name.Equals(Strings.Qmin)) name = "Q1";
|
|
|
|
return name;
|
|
}
|
|
|
|
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 Qmax.ToString();
|
|
case 7: return Qn.ToString();
|
|
case 8: return Qt.ToString();
|
|
case 9: return Qmin.ToString();
|
|
case 10: return MetrologicalClass;
|
|
case 11: return TemperatureClass.ToDescription();
|
|
case 12: return PressureLossClass.ToDescription();
|
|
case 13: return MaxAdmissiblePressure.ToDescription();
|
|
case 14: return FlowProfileSensitivityClass.ToDescription();
|
|
case 15: return ApprovalInfo;
|
|
case 16: return Certificate;
|
|
case 17: return PulsesPerLtr.ToString();
|
|
case 18: return Text1;
|
|
case 19: return Text2;
|
|
case 20: return Text3;
|
|
case 21: return Text4;
|
|
case 22: return Text5;
|
|
|
|
case 23: return (WaterTemp == Medium.HotWater) ? Medium.HotWater.ToDescription() : Medium.ColdWater.ToDescription(); /// "tepla" : "zimna";
|
|
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: NewQnames = strValue.Equals(Strings.yes); return;
|
|
case 6: Qmax = Utils.ParseUFloat(strValue); return;
|
|
case 7: Qn = Utils.ParseUFloat(strValue); return;
|
|
case 8: Qt = Utils.ParseUFloat(strValue); return;
|
|
case 9: Qmin = Utils.ParseUFloat(strValue); return;
|
|
case 10: MetrologicalClass = strValue; return;
|
|
case 11:
|
|
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++)
|
|
{
|
|
if (tc.ToDescription().Equals(strValue)) { TemperatureClass = tc; return; }
|
|
}
|
|
break;
|
|
case 12:
|
|
for (PressureLossClass dp = 0; dp < PressureLossClass.Count; dp++)
|
|
{
|
|
if (dp.ToDescription().Equals(strValue)) { PressureLossClass = dp; return; }
|
|
}
|
|
break;
|
|
case 13:
|
|
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++)
|
|
{
|
|
if (map.ToDescription().Equals(strValue)) { MaxAdmissiblePressure = map; return; }
|
|
}
|
|
break;
|
|
case 14:
|
|
for (FlowProfileSensitivityClass fps = 0; fps < FlowProfileSensitivityClass.Count; fps++)
|
|
{
|
|
if (fps.ToDescription().Equals(strValue)) { FlowProfileSensitivityClass = fps; return; }
|
|
}
|
|
break;
|
|
case 15: ApprovalInfo = strValue; return;
|
|
case 16: Certificate = strValue; return;
|
|
case 17: PulsesPerLtr = Utils.ParseUDouble(strValue); return;
|
|
case 18: Text1 = strValue; return;
|
|
case 19: Text2 = strValue; return;
|
|
case 20: Text3 = strValue; return;
|
|
case 21: Text4 = strValue; return;
|
|
case 22: Text5 = strValue; return;
|
|
|
|
case 23: WaterTemp = strValue.Equals(Medium.HotWater.ToDescription()) ? Medium.HotWater : Medium.ColdWater; return; /// "tepla"
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
double dummy;
|
|
switch (i)
|
|
{
|
|
case 0: /// ProductName
|
|
case 1: /// Producer
|
|
case 10: /// MetrologicalClass
|
|
case 15: /// ApprovalInfo
|
|
case 16: /// Certificate
|
|
case 18: /// Text1
|
|
case 19: /// Text2
|
|
case 20: /// Text3
|
|
case 21: /// Text4
|
|
case 22: /// Text5
|
|
return true;
|
|
case 5:
|
|
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
|
|
break;
|
|
case 2: /// DN
|
|
case 3: /// L
|
|
case 6: /// Qmax
|
|
case 7: /// Qn
|
|
case 8: /// Qt
|
|
case 9: /// Qmin
|
|
case 17: /// PulsesPerLtr
|
|
if (Utils.TryParseUDouble(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 11:
|
|
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 12:
|
|
for (PressureLossClass tc = 0; tc < PressureLossClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 13:
|
|
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++) if (map.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 14:
|
|
for (FlowProfileSensitivityClass tc = 0; tc < FlowProfileSensitivityClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 23:
|
|
if (strValue.Equals(Medium.ColdWater.ToDescription()) || strValue.Equals(Medium.HotWater.ToDescription())) return true; /// "zimna", "tepla"
|
|
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.Qmax = this.Qmax;
|
|
prms.Qn = this.Qn;
|
|
prms.Qt = this.Qt;
|
|
prms.Qmin = this.Qmin;
|
|
prms.MetrologicalClass = this.MetrologicalClass;
|
|
prms.TemperatureClass = this.TemperatureClass;
|
|
prms.PressureLossClass = this.PressureLossClass;
|
|
prms.MaxAdmissiblePressure = this.MaxAdmissiblePressure;
|
|
prms.FlowProfileSensitivityClass = this.FlowProfileSensitivityClass;
|
|
prms.ApprovalInfo = this.ApprovalInfo;
|
|
prms.Certificate = this.Certificate;
|
|
prms.PulsesPerLtr = this.PulsesPerLtr;
|
|
prms.Text1 = this.Text1;
|
|
prms.Text2 = this.Text2;
|
|
prms.Text3 = this.Text3;
|
|
prms.Text4 = this.Text4;
|
|
prms.Text5 = this.Text5;
|
|
|
|
prms.WaterTemp = this.WaterTemp;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|