1 ITempControl moved to GenericDevices, 2 Dummy.TempControl component, 3 TempControl.Easytherm changed to fit ITempControl.
This commit is contained in:
parent
451faf1586
commit
2bae912fa0
37
TBF/Rig/Dummy/TempControl/Component.cs
Normal file
37
TBF/Rig/Dummy/TempControl/Component.cs
Normal file
@ -0,0 +1,37 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.Dummy.TempControl
|
||||
{
|
||||
public class Component : ComponentBase, ITempControl
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
public bool MsrmntAvailable { get { return true; } }
|
||||
public double MeasuredVal { get { return ReadTemperature(); } }
|
||||
public double MsrdValLimLo { get { return 5.0; } }
|
||||
public double MsrdValLimHi { get { return 95.0; } }
|
||||
public string MsrdFormat { get { return "{0:F1} C"; } }
|
||||
public Common.Unit MsrdUnit { get { return Common.Unit.C; } }
|
||||
public string AltString { get { return string.Empty; } }
|
||||
|
||||
public Component() { }
|
||||
public Component(Generic.IComponentCfg cfg) : base(cfg) { log.FatalFormat("{0} initialized: {1}", Name, this); }
|
||||
public override void Initialize() { }
|
||||
|
||||
public double ReadTemperature() { return 25.0; }
|
||||
public bool SetTemperatureSetpoint(double reqTempC) { return true; }
|
||||
|
||||
public IOperation ReadTempOp(ref DoubleBox temp) { return null; }
|
||||
public IOperation ReadTempOp(ref DoubleBox temp, Event tempDone) { return null; }
|
||||
public IOperation SetRequiredTemperatureOp() { return null; }
|
||||
}
|
||||
}
|
||||
26
TBF/Rig/Dummy/TempControl/Factory.cs
Normal file
26
TBF/Rig/Dummy/TempControl/Factory.cs
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.Configs.NameOnly;
|
||||
|
||||
namespace TBF.Rig.Dummy.TempControl
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return GetType().Namespace.Substring(8); } }
|
||||
public override string ToString() { return ClassName; }
|
||||
|
||||
public IComponent DummyComponent() { return new Component(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new TestMethodCfg(GetType().Namespace.Substring(14), this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
TBF/Rig/GenericDevices/ITempControl.cs
Normal file
19
TBF/Rig/GenericDevices/ITempControl.cs
Normal file
@ -0,0 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.GenericDevices
|
||||
{
|
||||
public interface ITempControl : ITempMeter
|
||||
{
|
||||
/// <summary>
|
||||
/// Set temperature controller setpoint to specified value in °C
|
||||
/// </summary>
|
||||
/// <param name="reqTempC">Temperature in °C</param>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
bool SetTemperatureSetpoint(double reqTempC);
|
||||
|
||||
IOperation SetRequiredTemperatureOp();
|
||||
}
|
||||
}
|
||||
@ -15,12 +15,12 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
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 RequiredTemp; /// [°C] target temperature for a temperature controller or 0=not communicated to the controller
|
||||
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
RequiredTemp = 0.0f;
|
||||
RequiredTemp = 0;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
@ -50,7 +50,7 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
}
|
||||
else
|
||||
{
|
||||
RequiredTemp = Utils.ParseUFloat(strValue);
|
||||
RequiredTemp = Utils.ParseUDouble(strValue);
|
||||
}
|
||||
return CfgUpdateFlags.None;
|
||||
default:
|
||||
@ -69,12 +69,12 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
float temp;
|
||||
double temp;
|
||||
switch (i)
|
||||
{
|
||||
case 0: /// T_hot_heating
|
||||
if (strValue == "-" || strValue == "--" || strValue == "---" ||
|
||||
(Utils.TryParseUFloat(strValue, out temp) && (temp == 0 || (temp >= 5 && temp <= 95.0f))))
|
||||
(Utils.TryParseUDouble(strValue, out temp) && (temp == 0 || (temp >= 5 && temp <= 95.0f))))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,12 +6,12 @@ using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
{
|
||||
public class TControl : ComponentBase, IDevice, ITempControl
|
||||
public class TControl : ComponentBase, Generic.IDevice, ITempControl
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TControl));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
@ -29,11 +29,11 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
public string MsrdFormat { get { return easythermCfg.MsrdFormat; } }
|
||||
public string AltString { get { return string.Empty; } }
|
||||
|
||||
private float temperatureSetPoint;
|
||||
private double temperatureSetPoint;
|
||||
private bool temperatureSetPointValid;
|
||||
private bool temperatureSetPointRequested;
|
||||
|
||||
public float requiredTemp { get { return easythermCfg.ProcParams.RequiredTemp; } }
|
||||
public double requiredTemp { get { return easythermCfg.ProcParams.RequiredTemp; } }
|
||||
|
||||
|
||||
public TControl() { }
|
||||
@ -66,7 +66,7 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
if (telegram.Length == 7 && telegram[1] == (byte)Function.ReadHoldingRegisters && telegram[2] == 2)
|
||||
{
|
||||
ushort value = (ushort)(256 * telegram[3] + telegram[4]);
|
||||
temperatureSetPoint = (float)value * 0.04f;
|
||||
temperatureSetPoint = Convert.ToDouble(value) * 0.04;
|
||||
temperatureSetPointValid = true;
|
||||
|
||||
log.InfoFormat("{0} - Received current temperature setpoint = {1}", Name, temperatureSetPoint);
|
||||
@ -74,7 +74,7 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
else if (telegram.Length == 7 && telegram[1] == (byte)Function.ReadInputRegister && telegram[2] == 2)
|
||||
{
|
||||
ushort value = (ushort)(256 * telegram[3] + telegram[4]);
|
||||
actualTemperature = (double)value * 0.04;
|
||||
actualTemperature = Convert.ToDouble(value) * 0.04;
|
||||
|
||||
log.InfoFormat("{0} - Received actual temperature = {1}", Name, actualTemperature);
|
||||
}
|
||||
@ -120,9 +120,9 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
|
||||
/// </summary>
|
||||
/// <param name="temperature">Temperature in °C</param>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
public bool SetTemperatureSetpoint(float temperature)
|
||||
public bool SetTemperatureSetpoint(double temperature)
|
||||
{
|
||||
if (temperature != 0 && (temperature < 5 || temperature > 95.0f))
|
||||
if (temperature != 0 && (temperature < 5.0 || temperature > 95.0))
|
||||
{
|
||||
return false; /// required temperature out of range
|
||||
}
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.Modbus.TempControl
|
||||
{
|
||||
public interface ITempControl : GenericDevices.ITempMeter
|
||||
{
|
||||
IOperation SetRequiredTemperatureOp();
|
||||
}
|
||||
}
|
||||
@ -19,8 +19,7 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
/// <summary>
|
||||
/// Events: PressureInDone, PressureOutDone or Error
|
||||
/// </summary>
|
||||
/// <param name="tempControl">Pressure meter reference</param>
|
||||
/// <param name="pressure">Reference to the measured pressure variable, value is in bar</param>
|
||||
/// <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)
|
||||
{
|
||||
|
||||
@ -9,11 +9,11 @@ using Common;
|
||||
using Config.Entities;
|
||||
using SchematicDrawing;
|
||||
using TBF.Boxes;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.GenericDevices;
|
||||
|
||||
namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
{
|
||||
public class TControl : ComponentBase, IDevice, ITempControl, GenericDevices.ISequenceCondition,
|
||||
public class TControl : ComponentBase, Generic.IDevice, ITempControl, ISequenceCondition,
|
||||
IDrawingItCmpntWithSetpoint, IDrawingItCmpntWithMeasuredVal, IDrawingItCmpntWithCustomBmp
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TControl));
|
||||
@ -246,7 +246,8 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set Easytherm controller to required temperature procedure parameter
|
||||
/// Set temperature controller setpoint to required temperature,
|
||||
/// where temperature is a procedure parameter
|
||||
/// </summary>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
public bool SetTemperatureSetpoint()
|
||||
@ -255,7 +256,7 @@ namespace TBF.Rig.Modbus.TempControl.Novus
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set Easytherm controller to specified temperature
|
||||
/// Set temperature controller setpoint to specified value
|
||||
/// </summary>
|
||||
/// <param name="reqTempC">Temperature in °C</param>
|
||||
/// <returns>true = OK, false = any error</returns>
|
||||
|
||||
@ -51,6 +51,7 @@ namespace TBF.Rig
|
||||
Factories.Add(new Dummy.Diverter.Factory());
|
||||
Factories.Add(new Dummy.FlowMeter.Factory());
|
||||
Factories.Add(new Dummy.RegValve.Factory());
|
||||
Factories.Add(new Dummy.TempControl.Factory());
|
||||
Factories.Add(new Dummy.Valve.Factory());
|
||||
Factories.Add(new Uni.FlowMeter.Factory());
|
||||
Factories.Add(new Uni.FlowMetersInParallel.Factory());
|
||||
|
||||
@ -604,6 +604,8 @@
|
||||
<Compile Include="Rig\Dummy\RegValve\Factory.cs" />
|
||||
<Compile Include="Rig\Dummy\RegValve\SetFlowOp.cs" />
|
||||
<Compile Include="Rig\Dummy\RegValve\SetRegValvePositionOp.cs" />
|
||||
<Compile Include="Rig\Dummy\TempControl\Component.cs" />
|
||||
<Compile Include="Rig\Dummy\TempControl\Factory.cs" />
|
||||
<Compile Include="Rig\Dummy\Valve\Component.cs" />
|
||||
<Compile Include="Rig\Dummy\Valve\Factory.cs" />
|
||||
<Compile Include="Rig\GenericDevices\ICalibInfoCfg.cs" />
|
||||
@ -637,6 +639,7 @@
|
||||
<Compile Include="Rig\GenericDevices\IStatisticsMonitoring.cs" />
|
||||
<Compile Include="Rig\GenericDevices\ITankDraining.cs" />
|
||||
<Compile Include="Rig\GenericDevices\ITankDrainingCfg.cs" />
|
||||
<Compile Include="Rig\GenericDevices\ITempControl.cs" />
|
||||
<Compile Include="Rig\GenericDevices\ITestMethodWith2ndPass.cs" />
|
||||
<Compile Include="Rig\GenericDevices\IVolumeMeter.cs" />
|
||||
<Compile Include="Rig\Hart\Common\Enums.cs" />
|
||||
@ -745,7 +748,6 @@
|
||||
<Compile Include="Rig\Modbus\TempControl\Easytherm\ReadTempOp.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\Easytherm\SetRequiredTemperatureOp.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\Easytherm\SetTemperatureOp.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\ITempControl.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\Novus\Factory.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\Novus\TControl.cs" />
|
||||
<Compile Include="Rig\Modbus\TempControl\Novus\TControlCfg.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user