Bug fix in TempControl.Novus and Easytherm, both ProcParams contains Temp_A/B/C/D/E, related ConditionOp-s, ver. 3.2.1911

This commit is contained in:
Milan Hanajik
2022-05-13 17:49:44 +02:00
parent 4a1eb91c2f
commit 158bba0d27
14 changed files with 500 additions and 287 deletions
+51 -24
View File
@@ -5,8 +5,9 @@ using System.IO;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.Sequences;
namespace TBF.Rig.Modbus.TempControl.Novus
{
@@ -15,17 +16,29 @@ namespace TBF.Rig.Modbus.TempControl.Novus
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 double Temp_A; /// [°C] Target temperature for a tempe. controller or 0=not communicated to the controller
public double Temp_B; /// [°C] Target temperature for a tempe. controller or 0=not communicated to the controller
public double Temp_C; /// [°C] Target temperature for a tempe. controller or 0=not communicated to the controller
public double Temp_D; /// [°C] Target temperature for a tempe. controller or 0=not communicated to the controller
public double Temp_E; /// [°C] Target temperature for a tempe. controller or 0=not communicated to the controller
public override void InitializeAll()
{
RequiredTemp = 0.0f;
}
Temp_A = 10.0;
Temp_B = 20.0;
Temp_C = 30.0;
Temp_D = 40.0;
Temp_E = 50.0;
}
string[] paramNames = new string[]
{
Strings.Required_temperature_C,
string.Format("{0} A [{1}]", Strings.Temperature, ProcessData.TempUnit.ToDescription()),
string.Format("{0} B [{1}]", Strings.Temperature, ProcessData.TempUnit.ToDescription()),
string.Format("{0} C [{1}]", Strings.Temperature, ProcessData.TempUnit.ToDescription()),
string.Format("{0} D [{1}]", Strings.Temperature, ProcessData.TempUnit.ToDescription()),
string.Format("{0} E [{1}]", Strings.Temperature, ProcessData.TempUnit.ToDescription()),
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
@@ -34,26 +47,36 @@ namespace TBF.Rig.Modbus.TempControl.Novus
{
switch (i)
{
case 0: return (RequiredTemp == 0) ? "---" : RequiredTemp.ToString();
default: return string.Empty;
case 0: return (Temp_A == 0) ? "---" : Units.ConvertTo(ProcessData.TempUnit, Temp_A).ToString();
case 1: return (Temp_B == 0) ? "---" : Units.ConvertTo(ProcessData.TempUnit, Temp_B).ToString();
case 2: return (Temp_C == 0) ? "---" : Units.ConvertTo(ProcessData.TempUnit, Temp_C).ToString();
case 3: return (Temp_D == 0) ? "---" : Units.ConvertTo(ProcessData.TempUnit, Temp_D).ToString();
case 4: return (Temp_E == 0) ? "---" : Units.ConvertTo(ProcessData.TempUnit, Temp_E).ToString();
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
public CfgUpdateFlags UpdateParam(int i, string str)
{
bool isDash = (str == "-" || str == "--" || str == "---");
switch (i)
{
case 0:
if (strValue == "-" || strValue == "--" || strValue == "---")
{
RequiredTemp = 0;
}
else
{
RequiredTemp = Utils.ParseUFloat(strValue);
}
Temp_A = isDash ? 0 : Units.ConvertFrom(ProcessData.TempUnit, Utils.ParseUDouble(str));
return CfgUpdateFlags.None;
default:
case 1:
Temp_B = isDash ? 0 : Units.ConvertFrom(ProcessData.TempUnit, Utils.ParseUDouble(str));
return CfgUpdateFlags.None;
case 2:
Temp_C = isDash ? 0 : Units.ConvertFrom(ProcessData.TempUnit, Utils.ParseUDouble(str));
return CfgUpdateFlags.None;
case 3:
Temp_D = isDash ? 0 : Units.ConvertFrom(ProcessData.TempUnit, Utils.ParseUDouble(str));
return CfgUpdateFlags.None;
case 4:
Temp_E = isDash ? 0 : Units.ConvertFrom(ProcessData.TempUnit, Utils.ParseUDouble(str));
return CfgUpdateFlags.None;
default:
return CfgUpdateFlags.None;
}
}
@@ -62,19 +85,19 @@ namespace TBF.Rig.Modbus.TempControl.Novus
/// 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="str">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)
public bool ValidateParam(int i, string str, out string message)
{
message = string.Empty;
float temp;
double ddummy;
switch (i)
{
case 0: /// T_hot_heating
if (strValue == "-" || strValue == "--" || strValue == "---" ||
(Utils.TryParseUFloat(strValue, out temp) && (temp == 0 || (temp >= 5 && temp <= 95.0f))))
if (str == "-" || str == "--" || str == "---" ||
(Utils.TryParseUDouble(str, out ddummy) && (ddummy == 0 || (ddummy >= 5 && ddummy <= 95.0))))
{
return true;
}
@@ -90,8 +113,12 @@ namespace TBF.Rig.Modbus.TempControl.Novus
void CopyContentTo(ProcParams prms)
{
prms.RequiredTemp = this.RequiredTemp;
}
prms.Temp_A = Temp_A;
prms.Temp_B = Temp_B;
prms.Temp_C = Temp_C;
prms.Temp_D = Temp_D;
prms.Temp_E = Temp_E;
}
public IParamsProvider Clone()
{