370 lines
13 KiB
C#
370 lines
13 KiB
C#
///
|
|
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
|
/// Author: Milan Hanajík
|
|
///
|
|
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.iPerl
|
|
{
|
|
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 Q4; /// [m3/h]
|
|
public float Qn; /// [m3/h]
|
|
public float Q2; /// [m3/h]
|
|
public float Q1; /// [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 float 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 MeterType MeterType;
|
|
#if ORACLE_DB
|
|
public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
|
|
public int WMType_Rev; /// Required for Oracle DB: Rev_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
|
|
#endif
|
|
public int FactorLimitLo; /// Lower limit for the calibration factor
|
|
public int FactorLimitHi; /// Upper limit for the calibration factor
|
|
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
ProductName = string.Empty;
|
|
Producer = string.Empty;
|
|
DN = 0;
|
|
L = 0;
|
|
Mounting = Mounting.NotSpecified;
|
|
Q4 = 4.0f;
|
|
Qn = 2.5f;
|
|
Q2 = 0.005f;
|
|
Q1 = 0.003125f;
|
|
MetrologicalClass = "R800";
|
|
TemperatureClass = TemperatureClass.NotSpecified;
|
|
PressureLossClass = PressureLossClass.NotSpecified;
|
|
MaxAdmissiblePressure = MaxAdmissiblePressure.NotSpecified;
|
|
FlowProfileSensitivityClass = FlowProfileSensitivityClass.NotSpecified;
|
|
ApprovalInfo = string.Empty;
|
|
Certificate = string.Empty;
|
|
PulsesPerLtr = 1.0f;
|
|
Text1 = string.Empty;
|
|
Text2 = string.Empty;
|
|
Text3 = string.Empty;
|
|
Text4 = string.Empty;
|
|
Text5 = string.Empty;
|
|
MeterType = MeterType.AutoDetect;
|
|
#if ORACLE_DB
|
|
WMType_ID = 2; /// Value for iPerl DN15
|
|
WMType_Rev = 1; /// Value for iPerl DN15
|
|
#endif
|
|
FactorLimitLo = 1000;
|
|
FactorLimitHi = 8000;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Product_name,
|
|
Strings.Producer,
|
|
"DN",
|
|
Strings.L,
|
|
Strings.Mounting,
|
|
"Q4",
|
|
"Q3",
|
|
"Q2",
|
|
"Q1",
|
|
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",
|
|
"iPerl type",
|
|
#if ORACLE_DB
|
|
"WMType ID",
|
|
"WMType Rev.",
|
|
#endif
|
|
"Calib. factor Lo",
|
|
"Calib. factor Hi",
|
|
};
|
|
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 Q4.ToString();
|
|
case 6: return Qn.ToString();
|
|
case 7: return Q2.ToString();
|
|
case 8: return Q1.ToString();
|
|
case 9: return MetrologicalClass;
|
|
case 10: return TemperatureClass.ToDescription();
|
|
case 11: return PressureLossClass.ToDescription();
|
|
case 12: return MaxAdmissiblePressure.ToDescription();
|
|
case 13: return FlowProfileSensitivityClass.ToDescription();
|
|
case 14: return ApprovalInfo;
|
|
case 15: return Certificate;
|
|
case 16: return PulsesPerLtr.ToString();
|
|
case 17: return Text1;
|
|
case 18: return Text2;
|
|
case 19: return Text3;
|
|
case 20: return Text4;
|
|
case 21: return Text5;
|
|
case 22: return MeterType.ToString();
|
|
#if ORACLE_DB
|
|
case 23: return WMType_ID.ToString();
|
|
case 24: return WMType_Rev.ToString();
|
|
#endif
|
|
case 25: return FactorLimitLo.ToString();
|
|
case 26: return FactorLimitHi.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: Q4 = Utils.ParseUFloat(strValue); return;
|
|
case 6: Qn = Utils.ParseUFloat(strValue); return;
|
|
case 7: Q2 = Utils.ParseUFloat(strValue); return;
|
|
case 8: Q1 = Utils.ParseUFloat(strValue); return;
|
|
case 9: MetrologicalClass = strValue; return;
|
|
case 10:
|
|
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++)
|
|
{
|
|
if (tc.ToDescription().Equals(strValue)) { TemperatureClass = tc; return; }
|
|
}
|
|
break;
|
|
case 11:
|
|
for (PressureLossClass dp = 0; dp < PressureLossClass.Count; dp++)
|
|
{
|
|
if (dp.ToDescription().Equals(strValue)) { PressureLossClass = dp; return; }
|
|
}
|
|
break;
|
|
case 12:
|
|
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++)
|
|
{
|
|
if (map.ToDescription().Equals(strValue)) { MaxAdmissiblePressure = map; return; }
|
|
}
|
|
break;
|
|
case 13:
|
|
for (FlowProfileSensitivityClass fps = 0; fps < FlowProfileSensitivityClass.Count; fps++)
|
|
{
|
|
if (fps.ToDescription().Equals(strValue)) { FlowProfileSensitivityClass = fps; return; }
|
|
}
|
|
break;
|
|
case 14: ApprovalInfo = strValue; return;
|
|
case 15: Certificate = strValue; return;
|
|
case 16: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
|
|
case 17: Text1 = strValue; return;
|
|
case 18: Text2 = strValue; return;
|
|
case 19: Text3 = strValue; return;
|
|
case 20: Text4 = strValue; return;
|
|
case 21: Text5 = strValue; return;
|
|
case 22:
|
|
for (MeterType mt = 0; mt < MeterType.Count; mt++)
|
|
{
|
|
if (mt.ToString().Equals(strValue)) { MeterType = mt; return; }
|
|
}
|
|
break;
|
|
#if ORACLE_DB
|
|
case 23: WMType_ID = int.Parse(strValue); return;
|
|
case 24: WMType_Rev = int.Parse(strValue); return;
|
|
#endif
|
|
case 25: FactorLimitLo = int.Parse(strValue); return;
|
|
case 26: FactorLimitHi = int.Parse(strValue); return;
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
int iDummy;
|
|
|
|
switch (i)
|
|
{
|
|
case 0: /// ProductName
|
|
case 1: /// Producer
|
|
case 9: /// MetrologicalClass
|
|
case 14: /// ApprovalInfo
|
|
case 15: /// Certificate
|
|
case 17: /// Text1
|
|
case 18: /// Text2
|
|
case 19: /// Text3
|
|
case 20: /// Text4
|
|
case 21: /// Text5
|
|
return true;
|
|
case 2: /// DN
|
|
case 3: /// L
|
|
case 5: /// Q4
|
|
case 6: /// Q3
|
|
case 7: /// Q2
|
|
case 8: /// Q1
|
|
case 16: /// 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;
|
|
case 10:
|
|
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 11:
|
|
for (PressureLossClass tc = 0; tc < PressureLossClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 12:
|
|
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++) if (map.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 13:
|
|
for (FlowProfileSensitivityClass tc = 0; tc < FlowProfileSensitivityClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
|
|
break;
|
|
case 22:
|
|
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
|
|
break;
|
|
#if ORACLE_DB
|
|
case 23: /// WMType_ID
|
|
case 24: /// WMType_Rev
|
|
if (int.TryParse(strValue, out iDummy)) return true;
|
|
break;
|
|
#endif
|
|
case 25:
|
|
case 26:
|
|
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) 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.Q4 = this.Q4;
|
|
prms.Qn = this.Qn;
|
|
prms.Q2 = this.Q2;
|
|
prms.Q1 = this.Q1;
|
|
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.MeterType = this.MeterType;
|
|
#if ORACLE_DB
|
|
prms.WMType_ID = this.WMType_ID;
|
|
prms.WMType_Rev = this.WMType_Rev;
|
|
#endif
|
|
prms.FactorLimitLo = this.FactorLimitLo;
|
|
prms.FactorLimitHi = this.FactorLimitHi;
|
|
}
|
|
|
|
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
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|