174 lines
4.7 KiB
C#
174 lines
4.7 KiB
C#
///
|
|
/// Copyright (c) 2015 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 float PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
|
public string Producer; /// Hersteller
|
|
public float Qn; /// [m3/h]
|
|
public float Q2; /// [m3/h]
|
|
public float Q1; /// [m3/h]
|
|
public string ApprovalInfo; /// Zulassungszeichen
|
|
public string MetrologicalClass; /// Metr. Klasse
|
|
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
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
PulsesPerLtr = 1.0f;
|
|
Producer = "";
|
|
Qn = 2.5f;
|
|
Q2 = 0.005f;
|
|
Q1 = 0.003125f;
|
|
ApprovalInfo = "";
|
|
MetrologicalClass = "A";
|
|
WMType_ID = 2; /// Value for iPerl DN15
|
|
WMType_Rev = 1; /// Value for iPerl DN15
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.PulsesPerLtr,
|
|
Strings.Producer,
|
|
"Q3",
|
|
"Q2",
|
|
"Q1",
|
|
Strings.Approval_info,
|
|
Strings.Metrological_class,
|
|
"WMType ID",
|
|
"WMType Rev.",
|
|
};
|
|
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();
|
|
case 1: return Producer;
|
|
case 2: return Qn.ToString();
|
|
case 3: return Q2.ToString();
|
|
case 4: return Q1.ToString();
|
|
case 5: return ApprovalInfo;
|
|
case 6: return MetrologicalClass;
|
|
case 7: return WMType_ID.ToString();
|
|
case 8: return WMType_Rev.ToString();
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
|
|
case 1: Producer = strValue; return;
|
|
case 2: Qn = Utils.ParseUFloat(strValue); return;
|
|
case 3: Q2 = Utils.ParseUFloat(strValue); return;
|
|
case 4: Q1 = Utils.ParseUFloat(strValue); return;
|
|
case 5: ApprovalInfo = strValue; return;
|
|
case 6: MetrologicalClass = strValue; return;
|
|
case 7: WMType_ID = int.Parse(strValue); return;
|
|
case 8: WMType_Rev = 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:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 1:
|
|
case 5:
|
|
case 6:
|
|
return true;
|
|
case 7:
|
|
case 8:
|
|
if (int.TryParse(strValue, out iDummy)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(ProcParams prms)
|
|
{
|
|
prms.PulsesPerLtr = this.PulsesPerLtr;
|
|
prms.Producer = this.Producer;
|
|
prms.Qn = this.Qn;
|
|
prms.Q2 = this.Q2;
|
|
prms.Q1 = this.Q1;
|
|
prms.ApprovalInfo = this.ApprovalInfo;
|
|
prms.MetrologicalClass = this.MetrologicalClass;
|
|
prms.WMType_ID = this.WMType_ID;
|
|
prms.WMType_Rev = this.WMType_Rev;
|
|
}
|
|
|
|
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(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|