249 lines
12 KiB
C#
249 lines
12 KiB
C#
///
|
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Results.Entities
|
|
{
|
|
public class MeterTestRslt
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual byte CompoundMeterId { get; set; } /// 0=single, 1=compound/main, 2=compound/aux., 3=compound/overal, 4=heat meter volume, 5=heat meter energy
|
|
public virtual int RegReaderType { get; set; } /// Not mapped to the DB, does not depend on localization and customer
|
|
public virtual double PulsesMeter { get; set; } /// # of water meter or heat meter pulses
|
|
public virtual double PulsesMaster { get; set; } /// # of reference flowmeter pulses (gated by this water meter pulses)
|
|
public virtual double PulsesPerLiter { get; set; } /// [l ^ -1], in case of heat meters (CompoundMeterId==5) pulses per kWh in [kWh ^ -1]
|
|
public virtual double VolumeStart { get; set; } /// Volume or energy (CompoundMeterId==5) on test start in [l] or [J]
|
|
public virtual double VolumeEnd { get; set; } /// Volume or energy (CompoundMeterId==5) on test end in [l] or [J]
|
|
public virtual double VolumeMeter { get; set; } /// Measured volume or energy (CompoundMeterId==5) in [l] or [J]
|
|
public virtual double VolumeRef { get; set; } /// Reference volume or energy (CompoundMeterId==5) in [l] or [J]
|
|
public virtual double TimestampStart { get; set; } /// [s]
|
|
public virtual double TimestampEnd { get; set; } /// [s]
|
|
public virtual double TestTime { get; set; } /// [s]
|
|
|
|
/// Main result
|
|
public virtual double Error { get; set; } /// [%]
|
|
public virtual long ErrorIndicators { get; set; } /// Not mapped to DB !!!, bit24=E25, bit25=E26, bit26=E27, bit27=E28 (error flags)
|
|
public virtual long InfoIndicators { get; set; } /// Not mapped to DB !!!, bit24=E25, bit25=E26, bit26=E27, bit27=E28 (info flags)
|
|
public virtual double KorrErrQ { get; set; } /// [%] not mapped to results DB, saved to Oracle DB
|
|
public virtual bool TestDone { get; set; } /// true = test was completed
|
|
public virtual bool Passed { get; set; } /// true = test passed, water meter is OK
|
|
#if ORACLE_DB
|
|
public virtual double LastError { get; set; } /// [%] Previous test error at this Q in case Pruefindex > 1
|
|
#endif
|
|
|
|
public virtual WaterMeter WaterMeter { get; set; } /// reference to the WaterMeter entity
|
|
public virtual TestRslt TestRslt { get; set; } /// reference to the TestRslt entity
|
|
|
|
///
|
|
/// Wrappers
|
|
///
|
|
public virtual string Name() { return TestRslt.Name(); }
|
|
public virtual DateTime StartTime() { return TestRslt.StartTime; }
|
|
public virtual DateTime EndTime() { return TestRslt.EndTime; }
|
|
public virtual double FlowSetTime() { return TestRslt.FlowSetTime; } /// [s]
|
|
public virtual double FlowMass() { return TestRslt.FlowMass; } /// [kg/h]
|
|
public virtual double FlowVolume() { return TestRslt.FlowVolume; } /// [m3/h]
|
|
public virtual double ErrorMaster() { return TestRslt.ErrorMaster; } /// [%]
|
|
public virtual double DensityLine() { return TestRslt.DensityLine; }
|
|
public virtual Components Components(){ return TestRslt.Components; }
|
|
///
|
|
public virtual TestData TestData() { return TestRslt.TestData; }
|
|
///
|
|
public virtual int Repeats() { return TestData().Repeats; }
|
|
public virtual double Qtg() { return TestData().Qtg; } /// [m3/h]
|
|
public virtual double Qfrom() { return TestData().Qfrom; } /// [m3/h]
|
|
public virtual double Qto() { return TestData().Qto; } /// [m3/h]
|
|
public virtual double TargetVolume() { return TestData().TargetVolume; } /// [l]
|
|
public virtual double TargetTime() { return TestData().TargetTime; } /// [s]
|
|
public virtual string Method() { return TestData().Method; }
|
|
public virtual double ErrLimLo() { return TestData().ErrLimLo; } /// [%]
|
|
public virtual double ErrLimHi() { return TestData().ErrLimHi; } /// [%]
|
|
public virtual double Uncertainty() { return TestData().ErrLimMargin; } /// [%]
|
|
|
|
public virtual string ProcedureName() { return WaterMeter.Batch.ProcedureName; }
|
|
public virtual int BatchNr() { return WaterMeter.Batch.BatchNr; }
|
|
public virtual string SerialNr() { return WaterMeter.SerialNr; }
|
|
public virtual string EndState() { return WaterMeter.EndState; }
|
|
public virtual double QRise() { return WaterMeter.QRise; } /// [m3/h]
|
|
public virtual double QFall() { return WaterMeter.QFall; } /// [m3/h]
|
|
|
|
public virtual bool Evaluate() { return TestData().Evaluate; }
|
|
public virtual Config.Entities.Publish Publish() { return (Config.Entities.Publish)TestData().Publish; }
|
|
|
|
public virtual WaterMeterData WaterMeterData() { return WaterMeter.WaterMeterData; }
|
|
public virtual Batch Batch() { return WaterMeter.Batch; }
|
|
|
|
public virtual bool IsPilotRslt()
|
|
{
|
|
return (CompoundMeterId == (byte)Config.Entities.CompoundMeterId.Single) ||
|
|
(CompoundMeterId == (byte)Config.Entities.CompoundMeterId.Compound) ||
|
|
(CompoundMeterId == (byte)Config.Entities.CompoundMeterId.HeatMeterEnergy);
|
|
}
|
|
|
|
public virtual bool IsPulses() { return (RegReaderType == (int)Config.Entities.RegisterReaderType.Pulses || RegReaderType == (int)Config.Entities.RegisterReaderType.Unknown); }
|
|
public virtual bool IsCamera() { return (RegReaderType == (int)Config.Entities.RegisterReaderType.Camera); }
|
|
public virtual bool IsDataStream() { return (RegReaderType == (int)Config.Entities.RegisterReaderType.DataStream); }
|
|
public virtual bool IsManual() { return (RegReaderType == (int)Config.Entities.RegisterReaderType.Manual); }
|
|
|
|
public virtual string PassedColorStr(string yesNoFormatOrEmpty)
|
|
{
|
|
if (string.IsNullOrEmpty(yesNoFormatOrEmpty))
|
|
{
|
|
return Utils.PassedColorStr(Passed, Evaluate());
|
|
}
|
|
else
|
|
{
|
|
string[] yesNo = yesNoFormatOrEmpty.Split(new char[] { '~' });
|
|
return Passed ? yesNo[0] : ((yesNo.Length >= 2) ? yesNo[1] : Results.Resources.Strings.No);
|
|
}
|
|
}
|
|
|
|
public MeterTestRslt()
|
|
{
|
|
TestDone = false;
|
|
Passed = false;
|
|
}
|
|
|
|
public MeterTestRslt(WaterMeter waterMeterRslt, TestRslt testRslt, Config.Entities.CompoundMeterId compoundMeterId)
|
|
: this()
|
|
{
|
|
WaterMeter = waterMeterRslt;
|
|
TestRslt = testRslt;
|
|
CompoundMeterId = (byte)compoundMeterId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy constructor, copies all except of Id
|
|
/// TestRslt and WaterMeter references arenot set.
|
|
/// They have to be copied/ser manually.
|
|
/// </summary>
|
|
public MeterTestRslt(MeterTestRslt oriMTR)
|
|
{
|
|
CompoundMeterId = oriMTR.CompoundMeterId;
|
|
RegReaderType = oriMTR.RegReaderType;
|
|
PulsesMeter = oriMTR.PulsesMeter;
|
|
PulsesMaster = oriMTR.PulsesMaster;
|
|
PulsesPerLiter = oriMTR.PulsesPerLiter;
|
|
VolumeStart = oriMTR.VolumeStart;
|
|
VolumeEnd = oriMTR.VolumeEnd;
|
|
VolumeMeter = oriMTR.VolumeMeter;
|
|
VolumeRef = oriMTR.VolumeRef;
|
|
TimestampStart = oriMTR.TimestampStart;
|
|
TimestampEnd = oriMTR.TimestampEnd;
|
|
TestTime = oriMTR.TestTime;
|
|
Error = oriMTR.Error;
|
|
ErrorIndicators = oriMTR.ErrorIndicators;
|
|
InfoIndicators = oriMTR.InfoIndicators;
|
|
KorrErrQ = oriMTR.KorrErrQ;
|
|
TestDone = oriMTR.TestDone;
|
|
Passed = oriMTR.Passed;
|
|
#if ORACLE_DB
|
|
LastError = oriMTR.LastError;
|
|
#endif
|
|
}
|
|
|
|
public virtual void CopyContentFrom(MeterTestRslt src)
|
|
{
|
|
if (src == null) return;
|
|
|
|
CompoundMeterId = src.CompoundMeterId;
|
|
RegReaderType = src.RegReaderType;
|
|
PulsesMeter = src.PulsesMeter;
|
|
PulsesMaster = src.PulsesMaster;
|
|
PulsesPerLiter = src.PulsesPerLiter;
|
|
VolumeStart = src.VolumeStart;
|
|
VolumeEnd = src.VolumeEnd;
|
|
VolumeMeter = src.VolumeMeter;
|
|
VolumeRef = src.VolumeRef;
|
|
TimestampStart = src.TimestampStart;
|
|
TimestampEnd = src.TimestampEnd;
|
|
TestTime = src.TestTime;
|
|
Error = src.Error;
|
|
ErrorIndicators = src.ErrorIndicators;
|
|
InfoIndicators = src.InfoIndicators;
|
|
KorrErrQ = src.KorrErrQ;
|
|
TestDone = src.TestDone;
|
|
Passed = src.Passed;
|
|
#if ORACLE_DB
|
|
LastError = src.LastError;
|
|
#endif
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return (TestRslt != null) ? Name() : base.ToString();
|
|
}
|
|
|
|
public virtual void WriteBinary(BinaryWriter writer)
|
|
{
|
|
writer.Write(Id);
|
|
writer.Write(CompoundMeterId);
|
|
writer.Write(RegReaderType);
|
|
writer.Write(PulsesMeter);
|
|
writer.Write(PulsesMaster);
|
|
writer.Write(PulsesPerLiter);
|
|
writer.Write(VolumeStart);
|
|
writer.Write(VolumeEnd);
|
|
writer.Write(VolumeMeter);
|
|
writer.Write(VolumeRef);
|
|
writer.Write(TimestampStart);
|
|
writer.Write(TimestampEnd);
|
|
writer.Write(TestTime);
|
|
writer.Write(Error);
|
|
writer.Write(ErrorIndicators);
|
|
writer.Write(InfoIndicators);
|
|
writer.Write(KorrErrQ);
|
|
writer.Write(TestDone);
|
|
writer.Write(Passed);
|
|
#if ORACLE_DB
|
|
writer.Write(LastError);
|
|
#endif
|
|
writer.Write((TestRslt != null && TestRslt.Name() != null) ? TestRslt.Name() : string.Empty);
|
|
writer.Write(TestRslt != null ? TestRslt.Part : 0);
|
|
}
|
|
|
|
public virtual void ReadBinary(BinaryReader reader, IList<TestRslt> testResults)
|
|
{
|
|
Id = reader.ReadInt32();
|
|
CompoundMeterId = reader.ReadByte();
|
|
RegReaderType = reader.ReadInt32();
|
|
PulsesMeter = reader.ReadDouble();
|
|
PulsesMaster = reader.ReadDouble();
|
|
PulsesPerLiter = reader.ReadDouble();
|
|
VolumeStart = reader.ReadDouble();
|
|
VolumeEnd = reader.ReadDouble();
|
|
VolumeMeter = reader.ReadDouble();
|
|
VolumeRef = reader.ReadDouble();
|
|
TimestampStart = reader.ReadDouble();
|
|
TimestampEnd = reader.ReadDouble();
|
|
TestTime = reader.ReadDouble();
|
|
Error = reader.ReadDouble();
|
|
ErrorIndicators = reader.ReadInt64();
|
|
InfoIndicators = reader.ReadInt64();
|
|
KorrErrQ = reader.ReadDouble();
|
|
TestDone = reader.ReadBoolean();
|
|
Passed = reader.ReadBoolean();
|
|
#if ORACLE_DB
|
|
LastError = reader.ReadDouble();
|
|
#endif
|
|
TestRslt = null;
|
|
string trName = reader.ReadString();
|
|
int trPart = reader.ReadInt32();
|
|
if (testResults != null && !string.IsNullOrEmpty(trName))
|
|
{
|
|
foreach (var tr in testResults)
|
|
{
|
|
if ((tr.Name() == trName) && (tr.Part == trPart))
|
|
{
|
|
TestRslt = tr;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|