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:
@@ -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()
|
||||
{
|
||||
|
||||
+9
-7
@@ -7,13 +7,14 @@ using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
{
|
||||
public class SetRequiredTemperatureOp : IOperation
|
||||
public class SetTemperatureSetpointOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SetRequiredTemperatureOp));
|
||||
public override string ToString() { return string.Format("SetRequiredTemperatureOp({0})", eventDone); }
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SetTemperatureSetpointOp));
|
||||
public override string ToString() { return string.Format("SetTemperatureSetpointOp({0})", eventDone); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly TControl tempControl;
|
||||
readonly double temperature;
|
||||
readonly Event eventDone;
|
||||
|
||||
/// <summary>
|
||||
@@ -21,23 +22,24 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
/// </summary>
|
||||
/// <param name="tempControl">Temp. controller reference</param>
|
||||
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
||||
public SetRequiredTemperatureOp(TControl tempControl, Event eventDone)
|
||||
public SetTemperatureSetpointOp(TControl tempControl, double temperature, Event eventDone)
|
||||
{
|
||||
if (tempControl == null) throw new ArgumentNullException("tempControl");
|
||||
this.tempControl = tempControl;
|
||||
this.temperature = temperature;
|
||||
this.eventDone = eventDone;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
public SetRequiredTemperatureOp(TControl tempControl)
|
||||
: this(tempControl, Event.ConditionMet)
|
||||
public SetTemperatureSetpointOp(TControl tempControl, double temperature)
|
||||
: this(tempControl, temperature, Event.ConditionMet)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
tempControl.SetTemperatureSetpoint();
|
||||
tempControl.SetTemperatureSetpoint(temperature);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
@@ -83,7 +83,6 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
SetTemperatureSetpoint(Math.Max(newSetpoint, 5.0));
|
||||
}
|
||||
|
||||
|
||||
public DrawingShape GetCustomBitmap()
|
||||
{
|
||||
switch (novusCfg.Sz)
|
||||
@@ -121,22 +120,14 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
bool isFahrenheit { get { return (status2 & (1 << 9)) != 0; } }
|
||||
|
||||
|
||||
public float requiredTemp
|
||||
{
|
||||
get
|
||||
{
|
||||
return novusCfg.ProcParams != null ? novusCfg.ProcParams.RequiredTemp : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TControl() { }
|
||||
|
||||
public TControl(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
novusCfg = cfg as TControlCfg;
|
||||
|
||||
CreateConditions(true);
|
||||
}
|
||||
|
||||
/// <summary>Initialize this device</summary>
|
||||
@@ -245,43 +236,33 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
public void StopDevice2() { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set temperature controller setpoint to required temperature,
|
||||
/// where temperature is a procedure parameter
|
||||
/// </summary>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
public bool SetTemperatureSetpoint()
|
||||
{
|
||||
return SetTemperatureSetpoint(requiredTemp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set temperature controller setpoint to specified value
|
||||
/// </summary>
|
||||
/// <param name="reqTempC">Temperature in °C</param>
|
||||
/// <param name="temperatureC">Temperature in °C</param>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
public bool SetTemperatureSetpoint(double reqTempC)
|
||||
public bool SetTemperatureSetpoint(double temperatureC)
|
||||
{
|
||||
if (reqTempC != 0 && (reqTempC < 5.0 || reqTempC > 95.0))
|
||||
if (temperatureC != 0 && (temperatureC < 5.0 || temperatureC > 95.0))
|
||||
{
|
||||
return false; /// required temperature out of range
|
||||
}
|
||||
|
||||
if (novusDataValid && (reqTempC == temperatureSetPoint))
|
||||
if (novusDataValid && (temperatureC == temperatureSetPoint))
|
||||
{
|
||||
return true; /// already set to the required temperature
|
||||
}
|
||||
|
||||
if (reqTempC != 0) /// temperature==0 disables sending the setpoint
|
||||
if (temperatureC != 0) /// temperature==0 disables sending the setpoint
|
||||
{
|
||||
double reqTemp = isFahrenheit ? Units.ConvertTo(Unit.F, reqTempC) : reqTempC;
|
||||
double reqTemp = isFahrenheit ? Units.ConvertTo(Unit.F, temperatureC) : temperatureC;
|
||||
Int16 tempSetpointInt16 = Convert.ToInt16(Math.Round(10 * reqTemp)); /// setpoint in 0.1 °C or °F
|
||||
ushort destAddress = SetpointAddress;
|
||||
///
|
||||
SendValueToNovus(Function.PresetSingleRegister, destAddress, tempSetpointInt16);
|
||||
}
|
||||
|
||||
temperatureSetPoint = reqTempC;
|
||||
temperatureSetPoint = temperatureC;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -313,19 +294,9 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
/// Events: SetOpututsDone, Error
|
||||
/// </summary>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation SetRequiredTemperatureOp()
|
||||
public IOperation SetTemperatureSetpointOp(double temperature)
|
||||
{
|
||||
return new SetRequiredTemperatureOp(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: SetOpututsDone, Error
|
||||
/// </summary>
|
||||
/// <param name="temperature">Reference to a variable for the pressure in Bar</param>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation SetTemperatureOp(float temperature)
|
||||
{
|
||||
return new SetTemperatureOp(this, temperature);
|
||||
return new SetTemperatureSetpointOp(this, temperature);
|
||||
}
|
||||
|
||||
public IOperation ReadTempOp(ref DoubleBox temp)
|
||||
@@ -339,33 +310,57 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
}
|
||||
|
||||
|
||||
public int ConditionsCount
|
||||
{
|
||||
get { return 3; }
|
||||
}
|
||||
|
||||
///
|
||||
/// ISequenceCondition interface implementation (conditions in transition sequences)
|
||||
///
|
||||
IList<string> sequenceConditionNames;
|
||||
IList<IOperation> sequenceConditions;
|
||||
|
||||
public int ConditionsCount { get { return sequenceConditions != null ? sequenceConditions.Count : 0; } }
|
||||
|
||||
/// Strings are added to the combo-box for transition sequence condition selection
|
||||
public string ConditionName(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return string.Format("{0} open_the_drain_valve", Name);
|
||||
case 1: return string.Format("{0} close_the_drain_valve", Name);
|
||||
case 2: return string.Format("{0} wait_until_the_tank_is_empty", Name);
|
||||
default: return string.Empty;
|
||||
}
|
||||
if (sequenceConditionNames != null && i < sequenceConditionNames.Count && i >= 0)
|
||||
return sequenceConditionNames[i];
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// Operation to be executed as a part of a transition sequence
|
||||
/// Operations are executed as a part of a transition sequence
|
||||
public IOperation ConditionOp(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return null;
|
||||
case 1: return null;
|
||||
case 2: return null;
|
||||
default: return null;
|
||||
}
|
||||
if (sequenceConditions != null && i < sequenceConditions.Count && i >= 0)
|
||||
return sequenceConditions[i];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
void ClearConditions()
|
||||
{
|
||||
sequenceConditionNames = new List<string>();
|
||||
sequenceConditions = new List<IOperation>();
|
||||
}
|
||||
|
||||
void AddCondition(string conditionName, bool createOperation, IOperation conditionOperation)
|
||||
{
|
||||
sequenceConditionNames.Add(conditionName);
|
||||
if (createOperation) sequenceConditions.Add(conditionOperation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a list of conditions
|
||||
/// </summary>
|
||||
/// <param name="createOps">true = create names and condition operations, false = create names only</param>
|
||||
void CreateConditions(bool createOps)
|
||||
{
|
||||
ClearConditions();
|
||||
AddCondition("Set temperature setpoint A", createOps, SetTemperatureSetpointOp(novusCfg.ProcParams.Temp_A));
|
||||
AddCondition("Set temperature setpoint B", createOps, SetTemperatureSetpointOp(novusCfg.ProcParams.Temp_B));
|
||||
AddCondition("Set temperature setpoint C", createOps, SetTemperatureSetpointOp(novusCfg.ProcParams.Temp_C));
|
||||
AddCondition("Set temperature setpoint D", createOps, SetTemperatureSetpointOp(novusCfg.ProcParams.Temp_D));
|
||||
AddCondition("Set temperature setpoint E", createOps, SetTemperatureSetpointOp(novusCfg.ProcParams.Temp_E));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using SchematicDrawing;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
{
|
||||
@@ -70,6 +70,7 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TControlCfg()
|
||||
{
|
||||
ProcParams = new ProcParams(true);
|
||||
GNodes = new List<GNode>();
|
||||
}
|
||||
|
||||
@@ -77,7 +78,6 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
ProcParams = CreateProcParamsProvider() as ProcParams;
|
||||
|
||||
Name = "Novus";
|
||||
ParentName = "Modbus";
|
||||
|
||||
Reference in New Issue
Block a user