DB.SensusOracle : Automatic WMTypeId assignment in progress.
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using Common;
|
||||
|
||||
namespace TBF.Rig.Output.DB.SensusOracle
|
||||
{
|
||||
public class VtPruefpunktSollSd
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(VtPruefpunktSollSd));
|
||||
|
||||
public int Pruefungsnr;
|
||||
public float Q_soll;
|
||||
public float Pruefzeit;
|
||||
public float Posfehlerkalt;
|
||||
public float Negfehlerkalt;
|
||||
public float Posfehlerwarm;
|
||||
public float Negfehlerwarm;
|
||||
public int Pruefbereichmin;
|
||||
public int Pruefbereichmax;
|
||||
public string Qbezeichnung;
|
||||
public float Mindruck;
|
||||
public float Maxdruck;
|
||||
public float Fkorrektur;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public VtPruefpunktSollSd()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create VtPruefpunktSollSd object from a test result.
|
||||
/// </summary>
|
||||
/// <param name="tr">Test result</param>
|
||||
/// <param name="pruefungsnr">Test ix</param>
|
||||
/// <returns>Created object</returns>
|
||||
public static VtPruefpunktSollSd FromTestRslt(Results.Entities.TestRslt tr, int pruefungsnr = 0, float Qn = 0)
|
||||
{
|
||||
bool isQ3orQ4 = (Qn > 0 && (tr.Qfrom() + tr.Qto()) / 2 >= 0.9 * Qn) ||
|
||||
tr.Name().ToLower().Contains("q3") ||
|
||||
tr.Name().ToLower().Contains("q4");
|
||||
|
||||
var rslt = new VtPruefpunktSollSd
|
||||
{
|
||||
Pruefungsnr = pruefungsnr,
|
||||
Q_soll = (float)Units.ConvertTo(Unit.lph, isQ3orQ4 ? tr.Qto() : tr.Qfrom()),
|
||||
Pruefzeit = (float)tr.TargetTime(),
|
||||
Posfehlerkalt = (float)tr.ErrLimHi(),
|
||||
Negfehlerkalt = (float)tr.ErrLimLo(),
|
||||
Posfehlerwarm = 0,
|
||||
Negfehlerwarm = 0,
|
||||
Pruefbereichmin = isQ3orQ4 ? 90 : 100,
|
||||
Pruefbereichmax = isQ3orQ4 ? 100 : 110,
|
||||
Qbezeichnung = tr.Name(),
|
||||
Mindruck = 0,
|
||||
Maxdruck = 0,
|
||||
Fkorrektur = 0,
|
||||
};
|
||||
|
||||
log.DebugFormat("FromTest: [{0}] created from test {1}", rslt, tr.Name());
|
||||
|
||||
return rslt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create VtPruefpunktSollSd object from a test.
|
||||
/// </summary>
|
||||
/// <param name="test">Test</param>
|
||||
/// <param name="pruefungsnr">Test ix</param>
|
||||
/// <returns>Created object</returns>
|
||||
public static VtPruefpunktSollSd FromTest(Config.Entities.Test test, int pruefungsnr = 0)
|
||||
{
|
||||
bool isQ3orQ4 = (test.Procedure.Qn > 0 && (test.Qfrom + test.Qto) / 2 >= 0.9 * test.Procedure.Qn) ||
|
||||
test.Name.ToLower().Contains("q3") ||
|
||||
test.Name.ToLower().Contains("q4");
|
||||
|
||||
var rslt = new VtPruefpunktSollSd
|
||||
{
|
||||
Pruefungsnr = pruefungsnr,
|
||||
Q_soll = Units.ConvertTo(Unit.lph, isQ3orQ4 ? test.Qto : test.Qfrom),
|
||||
Pruefzeit = test.TestTime,
|
||||
Posfehlerkalt = test.ErrLimHi,
|
||||
Negfehlerkalt = test.ErrLimLo,
|
||||
Posfehlerwarm = 0,
|
||||
Negfehlerwarm = 0,
|
||||
Pruefbereichmin = isQ3orQ4 ? 90 : 100,
|
||||
Pruefbereichmax = isQ3orQ4 ? 100 : 110,
|
||||
Qbezeichnung = test.Name,
|
||||
Mindruck = 0,
|
||||
Maxdruck = 0,
|
||||
Fkorrektur = 0,
|
||||
};
|
||||
|
||||
log.DebugFormat("FromTest: [{0}] created from test {1}", rslt, test.Name);
|
||||
|
||||
return rslt;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2}l/h time={3}s Elo={4}% Ehi={5}% Rlo={6} Rhi={7}",
|
||||
Pruefungsnr, Qbezeichnung, Q_soll, Pruefzeit,
|
||||
Negfehlerkalt, Posfehlerkalt, Pruefbereichmin, Pruefbereichmax);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two VtPruefpunktSollSd objects.
|
||||
/// Tollerance for float values is 1/1000 (0.1%).
|
||||
/// </summary>
|
||||
/// <param name="t1">VtPruefpunktSollSd object 1</param>
|
||||
/// <param name="t2">VtPruefpunktSollSd object 2</param>
|
||||
/// <returns>true when equal</returns>
|
||||
public static bool AreEqual(VtPruefpunktSollSd t1, VtPruefpunktSollSd t2)
|
||||
{
|
||||
if (t1 == null && t2 == null) return true; /// Both are null --> are equal
|
||||
if (t1 == null || t2 == null) return false; /// One is null --> not equal
|
||||
|
||||
return t1.Pruefungsnr == t2.Pruefungsnr &&
|
||||
((t1.Q_soll == 0 && t2.Q_soll == 0) || 2 * Math.Abs(t1.Q_soll - t2.Q_soll) / (t1.Q_soll + t2.Q_soll) < 0.001) &&
|
||||
((t1.Pruefzeit == 0 && t2.Pruefzeit == 0) || 2 * Math.Abs(t1.Pruefzeit - t2.Pruefzeit) / (t1.Pruefzeit + t2.Pruefzeit) < 0.001) &&
|
||||
((t1.Posfehlerkalt == 0 && t2.Posfehlerkalt == 0) || 2 * Math.Abs(t1.Posfehlerkalt - t2.Posfehlerkalt) / (t1.Posfehlerkalt + t2.Posfehlerkalt) < 0.001) &&
|
||||
((t1.Negfehlerkalt == 0 && t2.Negfehlerkalt == 0) || 2 * Math.Abs(t1.Negfehlerkalt - t2.Negfehlerkalt) / (t1.Negfehlerkalt + t2.Negfehlerkalt) < 0.001) &&
|
||||
((t1.Posfehlerwarm == 0 && t2.Posfehlerwarm == 0) || 2 * Math.Abs(t1.Posfehlerwarm - t2.Posfehlerwarm) / (t1.Posfehlerwarm + t2.Posfehlerwarm) < 0.001) &&
|
||||
((t1.Negfehlerwarm == 0 && t2.Negfehlerwarm == 0) || 2 * Math.Abs(t1.Negfehlerwarm - t2.Negfehlerwarm) / (t1.Negfehlerwarm + t2.Negfehlerwarm) < 0.001) &&
|
||||
t1.Pruefbereichmin == t2.Pruefbereichmin &&
|
||||
t1.Pruefbereichmax == t2.Pruefbereichmax &&
|
||||
t1.Qbezeichnung == t2.Qbezeichnung &&
|
||||
((t1.Mindruck == 0 && t2.Mindruck == 0) || 2 * Math.Abs(t1.Mindruck - t2.Mindruck) / (t1.Mindruck + t2.Mindruck) < 0.001) &&
|
||||
((t1.Maxdruck == 0 && t2.Maxdruck == 0) || 2 * Math.Abs(t1.Maxdruck - t2.Maxdruck) / (t1.Maxdruck + t2.Maxdruck) < 0.001) &&
|
||||
t1.Fkorrektur == t2.Fkorrektur;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user