2017-03-09 12:28:06 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
using Config.Entities;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
2017-03-09 15:13:23 +00:00
|
|
|
|
namespace TBF.BenchControl.Modbus.Easytherm
|
2017-03-09 12:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
public float RequiredTemp; /// [°C] target temperature for temperature controlled
|
2017-03-09 12:28:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void InitializeAll()
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
RequiredTemp = 20.0f;
|
2017-03-09 12:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
Strings.Required_temperature_C,
|
2017-03-09 12:28:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
public override string ParamName(int i) { return paramNames[i]; }
|
|
|
|
|
|
public override int ParamsCount() { return paramNames.Length; }
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
case 0: return RequiredTemp.ToString();
|
2017-03-09 12:28:06 +00:00
|
|
|
|
default: return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
case 0: RequiredTemp = Utils.ParseUFloat(strValue); return;
|
2017-03-09 12:28:06 +00:00
|
|
|
|
default: return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-09 15:13:23 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Verifiy the string representation of the parameter
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="i">Parameter ID</param>
|
|
|
|
|
|
/// <param name="strValue">String representation of the parameter</param>
|
|
|
|
|
|
/// <param name="message">In case false is returned this is the error messsage to be displayed</param>
|
|
|
|
|
|
/// <returns>true = parameter OK, false = parameter NOK</returns>
|
2017-03-09 12:28:06 +00:00
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = string.Empty;
|
|
|
|
|
|
|
2017-03-09 15:13:23 +00:00
|
|
|
|
float temp;
|
2017-03-09 12:28:06 +00:00
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0: /// T_hot_heating
|
2017-03-09 15:13:23 +00:00
|
|
|
|
if (Utils.TryParseUFloat(strValue, out temp) && temp > 0 && temp < 100.0f)
|
|
|
|
|
|
return true;
|
2017-03-09 12:28:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
message = "Invalid index";
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CopyContentTo(ProcParams prms)
|
|
|
|
|
|
{
|
2017-03-09 15:13:23 +00:00
|
|
|
|
prms.RequiredTemp = this.RequiredTemp;
|
2017-03-09 12:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|