72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
///
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.TempMeterInternal
|
|
{
|
|
public class TempMeter : ComponentBase, GenericDevices.ITempMeter
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TempMeter));
|
|
public override string ToString() { return string.Format("TempMeter({0})", Cfg.ToString(1)); }
|
|
|
|
readonly TempMeterCfg tempMtrCfg;
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
|
|
public int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..7
|
|
|
|
public TempMeter()
|
|
{
|
|
}
|
|
|
|
public TempMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
tempMtrCfg = cfg as TempMeterCfg;
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
/// Prepare data for SendCalibData() control board component method
|
|
ControlBoard.TempCalibData[tempMtrCfg.CoefsIdx0, 0] = tempMtrCfg.A1;
|
|
ControlBoard.TempCalibData[tempMtrCfg.CoefsIdx0, 1] = tempMtrCfg.A2;
|
|
ControlBoard.TempCalibData[tempMtrCfg.CoefsIdx0, 2] = tempMtrCfg.A3;
|
|
ControlBoard.TempCalibData[tempMtrCfg.CoefsIdx0, 3] = tempMtrCfg.A4;
|
|
ControlBoard.TempCalibData[tempMtrCfg.CoefsIdx0, 4] = tempMtrCfg.A5;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
public float ReadTemperature()
|
|
{
|
|
return ControlBoard.Temperature(Idx0);
|
|
}
|
|
|
|
/// <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);
|
|
}
|
|
}
|
|
}
|