2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
2014-07-31 15:04:09 +00:00
|
|
|
|
using TBF.Boxes;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Elde.PressureMeter
|
|
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public class PressureMeter : ComponentBase, GenericDevices.IPressureMeter
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(PressureMeter));
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override string ToString() { return string.Format("PressureMeter({0})", Cfg.ToString(1)); }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
readonly PressureMeterCfg pressureMeterCfg;
|
|
|
|
|
|
|
|
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
|
|
|
|
|
2014-09-10 10:05:49 +00:00
|
|
|
|
public readonly int Idx0; /// 0..3
|
2014-07-28 07:54:35 +00:00
|
|
|
|
public readonly byte RS485Address; /// 0..255
|
|
|
|
|
|
|
|
|
|
|
|
public PressureMeter(PressureMeterCfg cfg, IList<Generic.IComponent> components)
|
2014-12-31 12:46:33 +00:00
|
|
|
|
: base(cfg)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
pressureMeterCfg = cfg;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
|
|
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
|
|
|
2014-09-10 10:05:49 +00:00
|
|
|
|
Idx0 = cfg.Idx0;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
RS485Address = cfg.RS485Address;
|
|
|
|
|
|
|
|
|
|
|
|
/// Prepare data for SendCalibData() control board component method
|
2014-09-10 10:05:49 +00:00
|
|
|
|
ControlBoard.MeretRS485Address[Idx0] = RS485Address;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|