using System;
using System.Collections.Generic;
using log4net;
using TBF.BenchControl.Generic;
using TBF.Boxes;
namespace TBF.BenchControl.Elde.TempMeter
{
public class TempMeter : IComponent, GenericDevices.ITempMeter
{
///
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
///
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 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());
}
///
/// Events: TempDone, Error
///
/// Reference to a variable for the temperature in Celsius
/// ReadTempOp instance reference casted to IOperaton
public IOperation ReadTempOp(ref FloatBox temp)
{
return new ReadTempOp(this, ref temp);
}
///
/// Events: tempDone, Error
///
/// Reference to a variable for the temperature in Celsius
/// Event returned when measurement done
/// ReadTempOp instance reference casted to IOperaton
public IOperation ReadTempOp(ref FloatBox temp, Event tempDone)
{
return new ReadTempOp(this, ref temp, tempDone);
}
}
}