tbf/TestBenchFramework/BenchControl/Elde/TempMeter/TempMeter.cs
Milan Hanajik fcfdfeca41 - COmponent properties 'Position' --> 'Idx0' or 'Idx1'
- process data logging, RegulVal position logging
- changes for I11+I12, NOK yet
2014-09-10 12:05:49 +02:00

84 lines
2.5 KiB
C#

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
{
/// <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, Idx0);
}
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 Idx0; /// 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");
Idx0 = cfg.Idx0;
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[Idx0, 0] = A1;
ControlBoard.TempCalibData[Idx0, 1] = A2;
ControlBoard.TempCalibData[Idx0, 2] = A3;
ControlBoard.TempCalibData[Idx0, 3] = A4;
ControlBoard.TempCalibData[Idx0, 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);
}
}
}