166 lines
4.0 KiB
C#
166 lines
4.0 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 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 string ProductName; /// Znak fabryczny (PL)
|
|
public string Producer; /// Producent (PL), Hersteller (D)
|
|
public float Qn; /// [m3/h]
|
|
public float Qt; /// [m3/h]
|
|
public float Qmin; /// [m3/h]
|
|
public string MetrologicalClass;
|
|
public string ApprovalInfo; /// WE (PL)
|
|
public Medium WaterTemp; /// Woda: zimna / tepla (PL)
|
|
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
ProductName = "";
|
|
Producer = "";
|
|
Qn = 2.5f;
|
|
Qt = 1.0f;
|
|
Qmin = 0.01f;
|
|
MetrologicalClass = "A";
|
|
ApprovalInfo = "";
|
|
WaterTemp = Medium.ColdWater;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Product_name, /// "Znak fabryczny"
|
|
Strings.Producer,
|
|
Strings.Qn,
|
|
Strings.Qt,
|
|
Strings.Qmin,
|
|
Strings.Metrological_class,
|
|
Strings.Approval_info,
|
|
Strings.Water, /// "Woda"
|
|
};
|
|
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 Qn.ToString();
|
|
case 3: return Qt.ToString();
|
|
case 4: return Qmin.ToString();
|
|
case 5: return MetrologicalClass;
|
|
case 6: return ApprovalInfo;
|
|
case 7: return (WaterTemp == Medium.HotWater) ? Strings.hot : Strings.cold; /// "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: Qn = Utils.ParseUFloat(strValue); return;
|
|
case 3: Qt = Utils.ParseUFloat(strValue); return;
|
|
case 4: Qmin = Utils.ParseUFloat(strValue); return;
|
|
case 5: MetrologicalClass = strValue; return;
|
|
case 6: ApprovalInfo = strValue; return;
|
|
case 7: WaterTemp = strValue.Equals(Strings.hot) ? Medium.HotWater : Medium.ColdWater; return; /// "tepla"
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
case 1:
|
|
case 5:
|
|
case 6:
|
|
return true;
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 7:
|
|
if (strValue.Equals(Strings.cold) || strValue.Equals(Strings.hot)) 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.Qn = this.Qn;
|
|
prms.Qt = this.Qt;
|
|
prms.Qmin = this.Qmin;
|
|
prms.ApprovalInfo = this.ApprovalInfo;
|
|
prms.MetrologicalClass = this.MetrologicalClass;
|
|
prms.WaterTemp = this.WaterTemp;
|
|
}
|
|
|
|
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
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public ProcParams()
|
|
{
|
|
}
|
|
|
|
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|