182 lines
6.9 KiB
C#
182 lines
6.9 KiB
C#
|
|
///
|
|||
|
|
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
|
|||
|
|
///
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.IO;
|
|||
|
|
using Common;
|
|||
|
|
|
|||
|
|
namespace SharedDatabase.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 Qtg { get; set; } /// [m3/h] flow range low limit
|
|||
|
|
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 ErrLimMargin { get; set; } /// [%] makes error limits tighter: 0 <= ErrLimMargin <= 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; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Default constructor, safe values
|
|||
|
|
/// </summary>
|
|||
|
|
public TestData()
|
|||
|
|
{
|
|||
|
|
Name = string.Empty;
|
|||
|
|
Method = string.Empty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public TestData(Config.Entities.Test test)
|
|||
|
|
: this()
|
|||
|
|
{
|
|||
|
|
Name = test.Name;
|
|||
|
|
Repeats = test.Repeats;
|
|||
|
|
Qtg = (double)test.Qtg;
|
|||
|
|
Qfrom = (double)test.Qfrom;
|
|||
|
|
Qto = (double)test.Qto;
|
|||
|
|
TargetVolume = (double)test.Volume;
|
|||
|
|
TargetTime = (double)test.TestTime;
|
|||
|
|
Method = test.Method;
|
|||
|
|
ErrLimLo = (double)test.ErrLimLo;
|
|||
|
|
ErrLimHi = (double)test.ErrLimHi;
|
|||
|
|
ErrLimMargin = (double)test.Uncertainty;
|
|||
|
|
DoControlWaterTemp = test.DoControlWaterTemp;
|
|||
|
|
TempLimLo = test.TempLimLo;
|
|||
|
|
TempLimHi = test.TempLimHi;
|
|||
|
|
Publish = test.Publish;
|
|||
|
|
Evaluate = test.DoEvaluate;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Copy constructor, copies all except of Id
|
|||
|
|
/// </summary>
|
|||
|
|
public TestData(TestData oriTestData)
|
|||
|
|
{
|
|||
|
|
Name = oriTestData.Name;
|
|||
|
|
Repeats = oriTestData.Repeats;
|
|||
|
|
Qtg = oriTestData.Qtg;
|
|||
|
|
Qfrom = oriTestData.Qfrom;
|
|||
|
|
Qto = oriTestData.Qto;
|
|||
|
|
TargetVolume = oriTestData.TargetVolume;
|
|||
|
|
TargetTime = oriTestData.TargetTime;
|
|||
|
|
Method = oriTestData.Method;
|
|||
|
|
ErrLimLo = oriTestData.ErrLimLo;
|
|||
|
|
ErrLimHi = oriTestData.ErrLimHi;
|
|||
|
|
ErrLimMargin = oriTestData.ErrLimMargin;
|
|||
|
|
DoControlWaterTemp = oriTestData.DoControlWaterTemp;
|
|||
|
|
TempLimLo = oriTestData.TempLimLo;
|
|||
|
|
TempLimHi = oriTestData.TempLimHi;
|
|||
|
|
Publish = oriTestData.Publish;
|
|||
|
|
Evaluate = oriTestData.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 != td.Name) return false;
|
|||
|
|
if (Repeats != td.Repeats) return false;
|
|||
|
|
if (Qtg != td.Qtg) 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 != td.Method) return false;
|
|||
|
|
if (ErrLimLo != td.ErrLimLo) return false;
|
|||
|
|
if (ErrLimHi != td.ErrLimHi) return false;
|
|||
|
|
if (ErrLimMargin != td.ErrLimMargin) 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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual void WriteBinary(BinaryWriter writer)
|
|||
|
|
{
|
|||
|
|
writer.Write(Id);
|
|||
|
|
writer.Write((Name != null) ? Name : string.Empty);
|
|||
|
|
writer.Write(Repeats);
|
|||
|
|
writer.Write(Qtg);
|
|||
|
|
writer.Write(Qfrom);
|
|||
|
|
writer.Write(Qto);
|
|||
|
|
writer.Write(TargetVolume);
|
|||
|
|
writer.Write(TargetTime);
|
|||
|
|
writer.Write((Method != null) ? Method : string.Empty);
|
|||
|
|
writer.Write(ErrLimLo);
|
|||
|
|
writer.Write(ErrLimHi);
|
|||
|
|
writer.Write(ErrLimMargin);
|
|||
|
|
writer.Write(DoControlWaterTemp);
|
|||
|
|
writer.Write(TempLimLo);
|
|||
|
|
writer.Write(TempLimHi);
|
|||
|
|
writer.Write(Publish);
|
|||
|
|
writer.Write(Evaluate);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual void ReadBinary(BinaryReader reader)
|
|||
|
|
{
|
|||
|
|
Id = reader.ReadInt32();
|
|||
|
|
Name = reader.ReadString();
|
|||
|
|
Repeats = reader.ReadInt32();
|
|||
|
|
Qtg = reader.ReadDouble();
|
|||
|
|
Qfrom = reader.ReadDouble();
|
|||
|
|
Qto = reader.ReadDouble();
|
|||
|
|
TargetVolume = reader.ReadDouble();
|
|||
|
|
TargetTime = reader.ReadDouble();
|
|||
|
|
Method = reader.ReadString();
|
|||
|
|
ErrLimLo = reader.ReadDouble();
|
|||
|
|
ErrLimHi = reader.ReadDouble();
|
|||
|
|
ErrLimMargin = reader.ReadDouble();
|
|||
|
|
DoControlWaterTemp = reader.ReadBoolean();
|
|||
|
|
TempLimLo = reader.ReadSingle();
|
|||
|
|
TempLimHi = reader.ReadSingle();
|
|||
|
|
Publish = reader.ReadSByte();
|
|||
|
|
Evaluate = reader.ReadBoolean();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|