160 lines
4.2 KiB
C#
160 lines
4.2 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;
|
|
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;
|
|
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,
|
|
Strings.Qn,
|
|
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 ApprovalInfo;
|
|
case 4: return MetrologicalClass;
|
|
case 5: return WMType_ID.ToString();
|
|
case 6: 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: ApprovalInfo = strValue; return;
|
|
case 4: MetrologicalClass = strValue; return;
|
|
case 5: WMType_ID = int.Parse(strValue); return;
|
|
case 6: 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:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 1:
|
|
case 3:
|
|
case 4:
|
|
return true;
|
|
case 5:
|
|
case 6:
|
|
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.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;
|
|
}
|
|
}
|
|
}
|