Elde.RegulValveMilwaukee, Modbus.Novus added, Elde component updated (18.12.2020), ver. 2.26.1571
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.Novus
|
||||
{
|
||||
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public float RequiredTemp; /// [°C] target temperature for a temperature controller or 0=not communicated to the controller
|
||||
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
RequiredTemp = 0.0f;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
Strings.Required_temperature_C,
|
||||
};
|
||||
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 (RequiredTemp == 0) ? "---" : RequiredTemp.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (strValue == "-" || strValue == "--" || strValue == "---")
|
||||
{
|
||||
RequiredTemp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RequiredTemp = Utils.ParseUFloat(strValue);
|
||||
}
|
||||
return CfgUpdateFlags.None;
|
||||
default:
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
float temp;
|
||||
switch (i)
|
||||
{
|
||||
case 0: /// T_hot_heating
|
||||
if (strValue == "-" || strValue == "--" || strValue == "---" ||
|
||||
(Utils.TryParseUFloat(strValue, out temp) && (temp == 0 || (temp >= 5 && temp <= 95.0f))))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(ProcParams prms)
|
||||
{
|
||||
prms.RequiredTemp = this.RequiredTemp;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
ProcParams pars = new ProcParams();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
||||
{
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor initializes the parameters
|
||||
/// </summary>
|
||||
public ProcParams()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcParams(bool initialize)
|
||||
{
|
||||
if (initialize) InitializeAll();
|
||||
}
|
||||
|
||||
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
||||
{
|
||||
this.procedureParamsEntity = procParamsEntity;
|
||||
this.componentName = componentName;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user