146 lines
3.6 KiB
C#
146 lines
3.6 KiB
C#
|
|
///
|
|||
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|||
|
|
///
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using log4net;
|
|||
|
|
using TBF.BenchControl;
|
|||
|
|
|
|||
|
|
namespace TBF.BenchControl.WaterMeters.iPerl
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// This component = instance of this class is a placeholder for a combined main watermeter
|
|||
|
|
/// </summary>
|
|||
|
|
public class WaterMeter : ComponentBase, GenericDevices.IWaterMeter, GenericDevices.IRegisterReader, IOperation
|
|||
|
|
{
|
|||
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(WaterMeter));
|
|||
|
|
public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); }
|
|||
|
|
|
|||
|
|
readonly WaterMeterCfg iPerlCfg;
|
|||
|
|
|
|||
|
|
public float PulsesPerLtr { get { return iPerlCfg.ProcParams.PulsesPerLtr; } }
|
|||
|
|
|
|||
|
|
/// <summary>WaterMeter producer</summary>
|
|||
|
|
public string Producer { get { return iPerlCfg.ProcParams.Producer; } }
|
|||
|
|
|
|||
|
|
/// <summary>Nominal water flow in [m3/h]</summary>
|
|||
|
|
public float Qn { get { return iPerlCfg.ProcParams.Qn; } }
|
|||
|
|
|
|||
|
|
/// <summary>WaterMeter approval information or signature</summary>
|
|||
|
|
public string ApprovalInfo { get { return iPerlCfg.ProcParams.ApprovalInfo; } }
|
|||
|
|
|
|||
|
|
/// <summary>Metrological class</summary>
|
|||
|
|
public string MetrologicalClass { get { return iPerlCfg.ProcParams.MetrologicalClass; } }
|
|||
|
|
|
|||
|
|
/// Properties set by the Begin and the End form
|
|||
|
|
public string SerialNr
|
|||
|
|
{
|
|||
|
|
get { return serialNr; }
|
|||
|
|
set { serialNr = value; }
|
|||
|
|
}
|
|||
|
|
string serialNr;
|
|||
|
|
|
|||
|
|
public string EndState
|
|||
|
|
{
|
|||
|
|
get { return endState; }
|
|||
|
|
set { endState = value; }
|
|||
|
|
}
|
|||
|
|
string endState;
|
|||
|
|
|
|||
|
|
public string BeginState
|
|||
|
|
{
|
|||
|
|
get { return beginState; }
|
|||
|
|
set { beginState = value; }
|
|||
|
|
}
|
|||
|
|
string beginState;
|
|||
|
|
|
|||
|
|
public bool Disabled
|
|||
|
|
{
|
|||
|
|
get { return disabled; }
|
|||
|
|
set { disabled = value; }
|
|||
|
|
}
|
|||
|
|
bool disabled;
|
|||
|
|
|
|||
|
|
|
|||
|
|
Boxes.IntBox pulses;
|
|||
|
|
Boxes.IntBox refPulses;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public WaterMeter()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public WaterMeter(WaterMeterCfg cfg)
|
|||
|
|
: base(cfg)
|
|||
|
|
{
|
|||
|
|
iPerlCfg = cfg;
|
|||
|
|
log.Debug(this.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Events: Event.ReadRegisterDone, Event.Error
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|||
|
|
/// <returns>ReadWaterMeter instance reference casted to IOperaton</returns>
|
|||
|
|
public IOperation ReadRegisterOp(ref Boxes.IntBox pulses)
|
|||
|
|
{
|
|||
|
|
this.pulses = pulses;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Events: Event.ReadRegisterDone, Event.Error
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|||
|
|
/// <param name="pulses">Reference to a variable for the related reference flowmeter pulses</param>
|
|||
|
|
/// <returns>Reference to operation object instance</returns>
|
|||
|
|
public IOperation ReadRegisterOp(ref Boxes.IntBox pulses, ref Boxes.IntBox refPulses)
|
|||
|
|
{
|
|||
|
|
this.pulses = pulses;
|
|||
|
|
this.refPulses = refPulses;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Events: ReadReferenceDone, Error
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|||
|
|
/// <returns>Reference to operation object instance</returns>
|
|||
|
|
public IOperation ReadReferenceForRegisterOp(ref Boxes.IntBox pulses, ref Boxes.IntBox refPulses)
|
|||
|
|
{
|
|||
|
|
this.pulses = pulses;
|
|||
|
|
this.refPulses = refPulses;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>Start this operation</summary>
|
|||
|
|
public void Start()
|
|||
|
|
{
|
|||
|
|
ReadPulses();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>Run this operation</summary>
|
|||
|
|
/// <returns>eventDone</returns>
|
|||
|
|
public Event Run()
|
|||
|
|
{
|
|||
|
|
ReadPulses();
|
|||
|
|
return Event.ReadRegisterDone;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>Stop this operation</summary>
|
|||
|
|
public void Stop()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void ReadPulses()
|
|||
|
|
{
|
|||
|
|
/// Do something meaningfull here
|
|||
|
|
pulses.Val = 1;
|
|||
|
|
refPulses.Val = 2;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|