92 lines
2.9 KiB
C#
92 lines
2.9 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)
|
|
public virtual double ErrLimHi { get; set; } /// [%] (usually > 0)
|
|
public virtual double Uncertainty { get; set; } /// [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
|
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;
|
|
Evaluate = test.Evaluate;
|
|
}
|
|
|
|
|
|
/// <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 (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)
|
|
{
|
|
TestData found = list.FirstOrDefault<TestData>(x => x.Equals(item));
|
|
|
|
if (found != null) return found;
|
|
|
|
list.Add(item);
|
|
return item;
|
|
}
|
|
}
|
|
}
|