109 lines
3.8 KiB
C#
109 lines
3.8 KiB
C#
///
|
|
/// Copyright (c) 2016 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Results.Entities
|
|
{
|
|
/// <summary>
|
|
/// Test, consisting of one or more repetitions of the test 'SingleTest'.
|
|
/// </summary>
|
|
public class TestData
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual string Name { get; set; }
|
|
public virtual int Repeats { get; set; }
|
|
public virtual double Qfrom { get; set; } /// [m3/h] flow range low limit
|
|
public virtual double Qto { get; set; } /// [m3/h] flow range high limit
|
|
public virtual double TargetVolume { get; set; } /// [l] target test volume
|
|
public virtual double TargetTime { get; set; } /// [s] target test time
|
|
public virtual string Method { get; set; }
|
|
public virtual double ErrLimLo { get; set; } /// [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
|
|
public virtual double ErrLimHi { get; set; } /// [%] usually > 0, in case of heat meters: -Qn in m3/h
|
|
public virtual double Uncertainty { get; set; } /// [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
|
public virtual bool DoControlWaterTemp { get; set; }
|
|
public virtual float TempLimLo { get; set; }
|
|
public virtual float TempLimHi { get; set; }
|
|
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
|
|
public virtual bool Evaluate { get; set; }
|
|
|
|
|
|
protected TestData()
|
|
{
|
|
Name = string.Empty;
|
|
Method = string.Empty;
|
|
}
|
|
|
|
public TestData(Config.Entities.Test test)
|
|
: this()
|
|
{
|
|
Name = test.Name;
|
|
Repeats = test.Repeats;
|
|
Qfrom = (double)test.Qfrom;
|
|
Qto = (double)test.Qto;
|
|
TargetVolume = (double)test.Volume;
|
|
TargetTime = (double)test.TstTime;
|
|
Method = test.Method;
|
|
ErrLimLo = (double)test.ErrLimLo;
|
|
ErrLimHi = (double)test.ErrLimHi;
|
|
Uncertainty = (double)test.Uncertainty;
|
|
DoControlWaterTemp = test.DoControlWaterTemp;
|
|
TempLimLo = test.TempLimLo;
|
|
TempLimHi = test.TempLimHi;
|
|
Publish = test.Publish;
|
|
Evaluate = test.DoEvaluate;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Method to compare the content of two entities
|
|
/// </summary>
|
|
/// <param name="wmd">Second entity to compare with</param>
|
|
/// <returns>first = two entities are equal (except of Id)</returns>
|
|
public virtual bool Equals(TestData td)
|
|
{
|
|
if (!Name.Equals(td.Name)) return false;
|
|
if (Repeats != td.Repeats) return false;
|
|
if (Qfrom != td.Qfrom) return false;
|
|
if (Qto != td.Qto) return false;
|
|
if (TargetVolume != td.TargetVolume) return false;
|
|
if (TargetTime != td.TargetTime) return false;
|
|
if (!Method.Equals(td.Method)) return false;
|
|
if (ErrLimLo != td.ErrLimLo) return false;
|
|
if (ErrLimHi != td.ErrLimHi) return false;
|
|
if (Uncertainty != td.Uncertainty) return false;
|
|
if (DoControlWaterTemp != td.DoControlWaterTemp) return false;
|
|
if (DoControlWaterTemp)
|
|
{
|
|
if (TempLimLo != td.TempLimLo) return false;
|
|
if (TempLimHi != td.TempLimHi) return false;
|
|
}
|
|
if (Publish != td.Publish) return false;
|
|
if (Evaluate != td.Evaluate) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Adds an item to the list if it does not occur there
|
|
/// </summary>
|
|
/// <param name="list">List of items</param>
|
|
/// <param name="item">Item to add to the list or find there</param>
|
|
/// <returns>Item from the list (existing or added)</returns>
|
|
public static TestData UpdateList(IList<TestData> list, TestData item)
|
|
{
|
|
if (item == null) return null; /// Null item is not stored in the list
|
|
|
|
TestData found = list.FirstOrDefault<TestData>(x => x.Equals(item));
|
|
|
|
if (found != null) return found; /// The same item found in the list, The found item returned
|
|
|
|
list.Add(item); /// Item not fund in the list, it is added to the list
|
|
return item;
|
|
}
|
|
}
|
|
}
|