- all components, componentCfg-s and parameter providers use base classes - less boilerplate code, simpler access to test/procedure parameters from code - CreateTestParams(test), CreateProcedureParams(procedure) methods added - TestBenchSim class is made static, it is not inheritted by any device anymore
117 lines
2.6 KiB
C#
117 lines
2.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.WaterMeter
|
|
{
|
|
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
{
|
|
public string Producer; /// Hersteller
|
|
public float Qn;
|
|
public string ApprovalInfo; /// Zulassungszeichen
|
|
public string MetrologicalClass; /// Metr. Klasse
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
Producer = "";
|
|
Qn = 2.5f;
|
|
ApprovalInfo = "";
|
|
MetrologicalClass = "A";
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Producer,
|
|
Strings.Qn,
|
|
Strings.Approval_info,
|
|
Strings.Metrological_class,
|
|
};
|
|
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 Producer;
|
|
case 1: return Qn.ToString();
|
|
case 2: return ApprovalInfo;
|
|
case 3: return MetrologicalClass;
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: Producer = strValue; return;
|
|
case 1: Qn = Utils.ParseUFloat(strValue); return;
|
|
case 2: ApprovalInfo = strValue; return;
|
|
case 3: MetrologicalClass = strValue; return;
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
switch (i)
|
|
{
|
|
case 1:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 0:
|
|
case 2:
|
|
case 3:
|
|
return true;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
public override void UpdateProcedureParams(Entities.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;
|
|
|
|
Producer = tmp.Producer;
|
|
Qn = tmp.Qn;
|
|
ApprovalInfo = tmp.ApprovalInfo;
|
|
MetrologicalClass = tmp.MetrologicalClass;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
public ProcParams()
|
|
{
|
|
}
|
|
|
|
public ProcParams(Entities.ComponentProcedure procParamsEntity, string componentName, Entities.Procedure procedure)
|
|
{
|
|
this.procedureParamsEntity = procParamsEntity;
|
|
this.componentName = componentName;
|
|
this.procedure = procedure;
|
|
}
|
|
}
|
|
}
|