Modbus.Easytherm component added, QuidoRS.TankSelector --> TankSelector, ver. 2.12.457
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.Easytherm
|
||||
{
|
||||
public class Easytherm : ComponentBase, IDevice
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Easytherm));
|
||||
public override string ToString() { return string.Format("Easytherm({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly EasythermCfg easythermCfg;
|
||||
readonly GenericDevices.IModbus modbus;
|
||||
|
||||
private ushort temperatureSetpoint;
|
||||
|
||||
public Easytherm()
|
||||
{
|
||||
}
|
||||
|
||||
public Easytherm(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
easythermCfg = cfg as EasythermCfg;
|
||||
|
||||
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Initialize this device</summary>
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Stop this device</summary>
|
||||
public void StopDevice()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set outputs of QuidoRS board
|
||||
/// </summary>
|
||||
/// <param name="temperature">output value</param>
|
||||
public void SetTemperature(ushort temperature)
|
||||
{
|
||||
temperatureSetpoint = temperature;
|
||||
SendTemperature(temperatureSetpoint);
|
||||
}
|
||||
|
||||
private void SendTemperature(ushort temperatureSetpoint)
|
||||
{
|
||||
byte[] msg = new byte[8];
|
||||
|
||||
msg[0] = easythermCfg.ModbusAddress;
|
||||
msg[1] = (byte)Function.PresetSingleRegister;
|
||||
msg[2] = 0; /// Relative address Hi
|
||||
msg[3] = 2; /// Relative address Lo
|
||||
msg[4] = (byte)(temperatureSetpoint >> 8); /// Output data Hi
|
||||
msg[5] = (byte)(temperatureSetpoint & 0xFF); /// Output data Lo
|
||||
|
||||
modbus.SendMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Events: SetOpututsDone, Error
|
||||
/// </summary>
|
||||
/// <param name="temperatureSetpoint">Reference to a variable for the pressure in Bar</param>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation SetTemperatureOp(ushort temperatureSetpoint)
|
||||
{
|
||||
return new SetTemperatureOp(this, temperatureSetpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: pressureDone, Error
|
||||
/// </summary>
|
||||
/// <param name="outValue">Reference to a variable for the pressure in Bar</param>
|
||||
/// <param name="setOutputsDone">Event returned when SetOutput is done</param>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadTemperatureOp(ushort outValue, Event setOutputsDone)
|
||||
{
|
||||
return new ReadTemperatureOp(this, outValue, setOutputsDone);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user