83 lines
2.5 KiB
C#
83 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Elde.TempMeter
|
|
{
|
|
public class TempMeter : IComponent, GenericDevices.ITempMeter
|
|
{
|
|
/// <summary>
|
|
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
|
|
/// Warn: Start measurement when busy is true
|
|
/// </summary>
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TempMeter));
|
|
public override string ToString()
|
|
{
|
|
return string.Format("TempMeter({0},{1})", Name, Index);
|
|
}
|
|
|
|
public static void ResetStaticProperties() { }
|
|
|
|
TempMeterCfg tempMeterCfg;
|
|
public Generic.IComponentCfg Cfg { get { return tempMeterCfg; } }
|
|
|
|
public string Name { get { return tempMeterCfg.Name; } }
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
|
|
public readonly int Index; /// 0..7
|
|
public readonly float A1;
|
|
public readonly float A2;
|
|
public readonly float A3;
|
|
public readonly float A4;
|
|
public readonly float A5;
|
|
|
|
public TempMeter(TempMeterCfg cfg, IList<Generic.IComponent> components)
|
|
{
|
|
if (cfg == null) throw new ArgumentNullException("cfg");
|
|
this.tempMeterCfg = cfg;
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
Index = cfg.Position;
|
|
A1 = cfg.A1;
|
|
A2 = cfg.A2;
|
|
A3 = cfg.A3;
|
|
A4 = cfg.A4;
|
|
A5 = cfg.A5;
|
|
|
|
/// Prepare data for SendCalibData() control board component method
|
|
ControlBoard.TempCalibData[Index, 0] = A1;
|
|
ControlBoard.TempCalibData[Index, 1] = A2;
|
|
ControlBoard.TempCalibData[Index, 2] = A3;
|
|
ControlBoard.TempCalibData[Index, 3] = A4;
|
|
ControlBoard.TempCalibData[Index, 4] = A5;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events: TempDone, Error
|
|
/// </summary>
|
|
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
|
|
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
|
|
public IOperation ReadTempOp(ref FloatBox temp)
|
|
{
|
|
return new ReadTempOp(this, ref temp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events: tempDone, Error
|
|
/// </summary>
|
|
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
|
|
/// <param name="tempDone">Event returned when measurement done</param>
|
|
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
|
|
public IOperation ReadTempOp(ref FloatBox temp, Event tempDone)
|
|
{
|
|
return new ReadTempOp(this, ref temp, tempDone);
|
|
}
|
|
}
|
|
}
|