65 lines
2.4 KiB
C#
65 lines
2.4 KiB
C#
|
|
///
|
|||
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|||
|
|
/// Author: Milan Hanajik
|
|||
|
|
///
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using log4net;
|
|||
|
|
using TBF.BenchControl.Generic;
|
|||
|
|
using TBF.Boxes;
|
|||
|
|
|
|||
|
|
namespace TBF.BenchControl.Elde.PressureMeterInternal
|
|||
|
|
{
|
|||
|
|
public class PressureMeter : ComponentBase, GenericDevices.IPressureMeter
|
|||
|
|
{
|
|||
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(PressureMeter));
|
|||
|
|
public override string ToString() { return string.Format("PressureMeter({0})", Cfg.ToString(1)); }
|
|||
|
|
|
|||
|
|
readonly PressureMeterCfg pressureMeterCfg;
|
|||
|
|
|
|||
|
|
public readonly ControlBoardDev ControlBoard;
|
|||
|
|
|
|||
|
|
public int Idx0 { get { return pressureMeterCfg.Idx0; } } /// 0..7
|
|||
|
|
|
|||
|
|
public PressureMeter(PressureMeterCfg cfg, IList<Generic.IComponent> components)
|
|||
|
|
: base(cfg)
|
|||
|
|
{
|
|||
|
|
pressureMeterCfg = cfg;
|
|||
|
|
|
|||
|
|
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[pressureMeterCfg.CoefsIdx0, 0] = pressureMeterCfg.A1;
|
|||
|
|
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 1] = pressureMeterCfg.A2;
|
|||
|
|
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 2] = pressureMeterCfg.A3;
|
|||
|
|
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 3] = pressureMeterCfg.A4;
|
|||
|
|
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 4] = pressureMeterCfg.A5;
|
|||
|
|
|
|||
|
|
ControlBoard.MeretRS485Address[0] = 0; /// This disables Merets, Groch temperatures, enables on-board A/D pressure and temperature
|
|||
|
|
log.Debug(this.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Events: PressureDone, Error
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
|
|||
|
|
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
|
|||
|
|
public IOperation ReadPressureOp(ref FloatBox pressure)
|
|||
|
|
{
|
|||
|
|
return new ReadPressureOp(this, ref pressure);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Events: pressureDone, Error
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
|
|||
|
|
/// <param name="pressureDone">Event returned when measurement done</param>
|
|||
|
|
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
|
|||
|
|
public IOperation ReadPressureOp(ref FloatBox pressure, Event pressureDone)
|
|||
|
|
{
|
|||
|
|
return new ReadPressureOp(this, ref pressure, pressureDone);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|