2015-04-15 18:32:56 +00:00
///
2023-03-31 11:16:58 +00:00
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
2015-04-15 18:32:56 +00:00
///
using System ;
2014-07-28 07:54:35 +00:00
using System.Collections.Generic ;
2017-04-11 10:49:07 +00:00
using System.Globalization ;
2017-03-31 16:14:21 +00:00
using System.IO ;
2021-09-23 09:46:40 +00:00
using Common ;
2014-07-28 07:54:35 +00:00
2015-12-04 16:17:20 +00:00
namespace Config.Entities
2014-07-28 07:54:35 +00:00
{
/// <summary>
/// Test, consisting of one or more repetitions of the test 'SingleTest'.
/// </summary>
2017-06-29 14:58:59 +00:00
public class Test : IHasName , IHasItemNr
2014-07-28 07:54:35 +00:00
{
public virtual int Id { get ; protected set ; }
public virtual int ItemNr { get ; set ; }
2015-01-04 22:21:12 +00:00
public virtual string Name { get ; set ; }
2017-06-08 13:42:47 +00:00
public virtual int Part { get ; set ; } /// Part=0 ... test of all WM-s
/// Part>0 ... part of a set of tests with the same Name: subset of WM-s is given by MetersPath
2019-11-27 10:22:32 +00:00
public virtual TestProfile Profile { get ; set ; } /// UserDefined, Protected, UserDefinedHeatMeter, ProtectedHeatMeter
public virtual sbyte Publish { get ; set ; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
2019-09-21 16:03:25 +00:00
public virtual bool DoEvaluate { get ; set ; }
2023-03-31 11:16:58 +00:00
public virtual double Qtg { get ; set ; } /// Target water flow [m3/h]
public virtual double Qfrom { get ; set ; } /// Water flow low limit in [m3/h]
public virtual double Qto { get ; set ; } /// Water flow high limit in [m3/h]
public virtual double Volume { get ; set ; } /// Test volume (target) in [l]
public virtual double TestTime { get ; set ; } /// Test time (estimate) in [s]
2016-04-14 15:03:33 +00:00
public virtual string Method { get ; set ; }
2019-01-25 15:31:26 +00:00
public virtual float ErrLimLo { get ; set ; } /// in [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
public virtual float ErrLimHi { get ; set ; } /// in [%] usually > 0, in case of heat meters: -Qn in m3/h
2017-06-08 13:42:47 +00:00
public virtual float Uncertainty { get ; set ; } /// int [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
2014-07-28 07:54:35 +00:00
public virtual int Repeats { get ; set ; }
2017-06-08 13:42:47 +00:00
public virtual bool DoDraining { get ; set ; }
2019-10-24 12:38:36 +00:00
public virtual bool DoDrainingAfter { get ; set ; }
2017-06-08 13:42:47 +00:00
public virtual float TempLimLo { get ; set ; } /// Lower limit for the controlled temperature
public virtual float TempLimHi { get ; set ; } /// Upper limit for the controlled temperature
2022-05-19 13:58:13 +00:00
public virtual string TempControl { get ; set ; } /// Water temperature controller, null or empty = Do not control water temp
public virtual float PumpPower { get ; set ; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
2017-03-28 19:40:27 +00:00
public virtual int MassRepeats { get ; set ; } /// Number of mass. measurements at the beginning/end of test, 0 = default (=5)
public virtual float MassSpread { get ; set ; } /// Max spread of mass. measurements at the beginning/end of test, 0 = default
public virtual MassMethod MassMethod { get ; set ; } /// method of mass. measurement at the beginning/end of test: false=slow (precise), true=using immediate mass measurement and evaluation
public virtual int TimeBeforeFlow { get ; set ; } /// Delay time before the start of flow control in [s]
public virtual int TimeFlow2Mass { get ; set ; } /// Delay time from the flow stable to the 1st mass measurement in [s]
public virtual int TimePump2StartV { get ; set ; } /// Delay time from the start of the pump to opening the start valve in [s]
public virtual int TimeStop2Mass { get ; set ; } /// Delay time from the test end (diverted) to the 2nd mass measuremen in [s]
2021-09-23 09:46:40 +00:00
public virtual double ShortPulses { get ; set ; } /// = Filter
2019-10-30 07:29:16 +00:00
public virtual string RedType { get ; set ; }
2014-07-28 07:54:35 +00:00
public virtual string FeedingPath { get ; set ; }
public virtual string BenchPath { get ; set ; }
public virtual string OutputPath { get ; set ; }
public virtual string MetersPath { get ; set ; }
2017-02-14 12:25:43 +00:00
#if HEAT_METERS
2016-06-28 16:04:52 +00:00
public virtual string HeatMetersPath { get ; set ; }
#endif
2021-09-23 09:46:40 +00:00
public virtual string TransBefore { get ; set ; }
public virtual string TransBetween { get ; set ; }
public virtual string TransAfter { get ; set ; }
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
public virtual int OraId { get ; set ; }
public virtual int OraIdRepetMulti { get ; set ; }
public virtual string OraDesignation { get ; set ; }
public virtual int RawDataId { get ; set ; }
public virtual int RawDataIdRepetMulti { get ; set ; }
public virtual string RawDataDesignation { get ; set ; }
#endif
2021-11-03 10:09:34 +00:00
public virtual bool IsOuterLoopStart { get ; set ; } /// Not mapped to database
public virtual bool IsOuterLoopEnd { get ; set ; } /// Not mapped to database
public virtual bool QtgTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual bool QfromTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual bool QtoTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual bool VolumeTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual bool TempLimLoTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual bool TempLimHiTextChngd { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit VolumeUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit FlowUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit MassUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit TempUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit PressUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit LengthUnit { get ; set ; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
2019-08-08 10:43:20 +00:00
2014-07-28 07:54:35 +00:00
public virtual IList < ComponentTest > MoreParams { get ; set ; }
public virtual Procedure Procedure { get ; set ; }
/// ------------- Additional stuff not mapped into the database -------------
public Test ( )
{
MoreParams = new List < ComponentTest > ( ) ;
2015-02-02 13:45:06 +00:00
///
/// Default values
///
2019-11-27 10:22:32 +00:00
Part = 0 ;
Profile = TestProfile . UserDefined ;
2021-09-23 09:46:40 +00:00
Publish = ( sbyte ) Common . Publish . Always ;
2017-06-08 13:42:47 +00:00
DoEvaluate = true ;
2022-05-19 13:58:13 +00:00
ErrLimLo = - 2.0f ; /// [%] lower error limit
ErrLimHi = 2.0f ; /// [%] upper error limit
Uncertainty = 0 ;
Repeats = 1 ;
2017-06-08 13:42:47 +00:00
DoDraining = false ;
2019-10-24 12:38:36 +00:00
DoDrainingAfter = false ;
2017-06-08 13:42:47 +00:00
TempLimLo = 15.0f ;
TempLimHi = 25.0f ;
2022-05-19 13:58:13 +00:00
TempControl = string . Empty ;
2017-03-28 19:40:27 +00:00
PumpPower = 60.0f ; /// [%]
MassRepeats = 0 ; /// default
MassSpread = 0 ; /// default
2022-05-19 13:58:13 +00:00
MassMethod = MassMethod . Scale ; /// default
2017-03-28 19:40:27 +00:00
TimeBeforeFlow = 10 ; /// [s] time before the start of flow control in [s]
TimeFlow2Mass = 5 ; /// [s] time from the flow stable to the 1st mass measurement in [s]
TimePump2StartV = 1 ; /// [s] time from the 1st mass measurement to the test start in [s]
TimeStop2Mass = 5 ; /// [s] between the test end and the final mass measurement
2022-05-19 13:58:13 +00:00
ShortPulses = 0 ; /// Short pulses parameter (0 or 1)
TransBefore = string . Empty ;
2021-09-23 09:46:40 +00:00
TransBetween = string . Empty ;
TransAfter = string . Empty ;
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
OraId = 0 ;
OraIdRepetMulti = 0 ;
OraDesignation = string . Empty ;
RawDataId = 0 ;
RawDataIdRepetMulti = 0 ;
RawDataDesignation = string . Empty ;
#endif
}
2014-07-28 07:54:35 +00:00
public Test ( string name , int itemNr , Procedure procedure )
: this ( )
{
Name = name ;
ItemNr = itemNr ;
Procedure = procedure ;
}
2021-01-21 14:00:55 +00:00
public virtual bool IsRegular ( )
{
/// Irregular / event triggered test names have form "[event] TestName"
return ( Name . Length > 0 & & Name [ 0 ] ! = '[' ) | | ! Name . Contains ( "]" ) ;
}
public virtual bool BelongsTo ( IList < string > autoTests )
{
if ( IsRegular ( ) ) return true ;
if ( autoTests = = null ) return false ;
string action = Name . Substring ( 1 , Name . IndexOf ( ']' ) - 1 ) ;
return autoTests . Contains ( action ) ;
}
2021-11-03 10:09:34 +00:00
public virtual void ResetChngdFlags ( )
{
QtgTextChngd = false ;
QfromTextChngd = false ;
QtoTextChngd = false ;
VolumeTextChngd = false ;
TempLimLoTextChngd = false ;
TempLimHiTextChngd = false ;
}
2014-07-28 07:54:35 +00:00
// Makes a new copy of this object (not just a reference)
public virtual Test Clone ( )
{
Test result = new Test ( Name , ItemNr , Procedure ) ;
2015-01-04 22:21:12 +00:00
result . Part = Part ;
2019-11-27 10:22:32 +00:00
result . Profile = Profile ;
result . Publish = Publish ;
2017-06-08 13:42:47 +00:00
result . DoEvaluate = DoEvaluate ;
2019-09-21 16:03:25 +00:00
result . Qtg = Qtg ;
2014-07-28 07:54:35 +00:00
result . Qfrom = Qfrom ;
result . Qto = Qto ;
result . Volume = Volume ;
2021-09-23 09:46:40 +00:00
result . TestTime = TestTime ;
2017-10-26 17:29:53 +00:00
result . Method = Method ;
result . ErrLimLo = ErrLimLo ;
result . ErrLimHi = ErrLimHi ;
result . Uncertainty = Uncertainty ;
2014-07-28 07:54:35 +00:00
result . Repeats = Repeats ;
2017-06-08 13:42:47 +00:00
result . DoDraining = DoDraining ;
2019-10-24 12:38:36 +00:00
result . DoDrainingAfter = DoDrainingAfter ;
2017-06-08 13:42:47 +00:00
result . TempLimLo = TempLimLo ;
result . TempLimHi = TempLimHi ;
2022-05-19 13:58:13 +00:00
result . TempControl = TempControl ;
result . PumpPower = PumpPower ;
2016-04-14 15:03:33 +00:00
result . MassRepeats = MassRepeats ;
result . MassSpread = MassSpread ;
result . MassMethod = MassMethod ;
2015-05-19 13:38:58 +00:00
result . TimeBeforeFlow = TimeBeforeFlow ;
result . TimeFlow2Mass = TimeFlow2Mass ;
2016-03-17 04:05:30 +00:00
result . TimePump2StartV = TimePump2StartV ;
2015-05-19 13:38:58 +00:00
result . TimeStop2Mass = TimeStop2Mass ;
2021-09-23 09:46:40 +00:00
result . ShortPulses = ShortPulses ;
2014-07-28 07:54:35 +00:00
result . RedType = RedType ;
result . FeedingPath = FeedingPath ;
result . BenchPath = BenchPath ;
result . OutputPath = OutputPath ;
result . MetersPath = MetersPath ;
2017-02-14 12:25:43 +00:00
#if HEAT_METERS
2016-06-28 16:04:52 +00:00
result . HeatMetersPath = HeatMetersPath ;
#endif
2021-09-23 09:46:40 +00:00
result . TransBefore = TransBefore ;
result . TransBetween = TransBetween ;
result . TransAfter = TransAfter ;
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
result . OraId = OraId ;
result . OraIdRepetMulti = OraIdRepetMulti ;
result . OraDesignation = OraDesignation ;
result . RawDataId = RawDataId ;
result . RawDataIdRepetMulti = RawDataIdRepetMulti ;
result . RawDataDesignation = RawDataDesignation ;
#endif
2021-11-03 10:09:34 +00:00
result . VolumeUnit = VolumeUnit ;
result . FlowUnit = FlowUnit ;
result . MassUnit = MassUnit ;
result . TempUnit = TempUnit ;
result . PressUnit = PressUnit ;
result . LengthUnit = LengthUnit ;
foreach ( var prms in MoreParams ) { result . MoreParams . Add ( prms . Clone ( ) ) ; }
2014-07-28 07:54:35 +00:00
return result ;
}
2016-01-10 11:39:20 +00:00
2017-03-31 16:14:21 +00:00
public virtual void Export ( StreamWriter output )
{
2017-07-14 14:28:18 +00:00
CultureInfo ci = CultureInfo . InvariantCulture ;
2017-03-31 16:14:21 +00:00
output . WriteLine ( Name ) ;
2017-07-14 14:28:18 +00:00
output . WriteLine ( Part . ToString ( ci ) ) ;
output . WriteLine ( Publish . ToString ( ci ) ) ;
2017-06-08 13:42:47 +00:00
output . WriteLine ( DoEvaluate . ToString ( ) ) ;
2019-09-21 16:03:25 +00:00
output . WriteLine ( Qtg . ToString ( ci ) ) ;
2017-07-14 14:28:18 +00:00
output . WriteLine ( Qfrom . ToString ( ci ) ) ;
output . WriteLine ( Qto . ToString ( ci ) ) ;
output . WriteLine ( Volume . ToString ( ci ) ) ;
2021-09-23 09:46:40 +00:00
output . WriteLine ( TestTime . ToString ( ci ) ) ;
2017-03-31 16:14:21 +00:00
output . WriteLine ( Method ) ;
2017-07-14 14:28:18 +00:00
output . WriteLine ( ErrLimLo . ToString ( ci ) ) ;
output . WriteLine ( ErrLimHi . ToString ( ci ) ) ;
output . WriteLine ( Uncertainty . ToString ( ci ) ) ;
output . WriteLine ( Repeats . ToString ( ci ) ) ;
2017-06-08 13:42:47 +00:00
output . WriteLine ( DoDraining . ToString ( ) ) ;
2019-10-24 12:38:36 +00:00
output . WriteLine ( DoDrainingAfter . ToString ( ) ) ;
2017-07-14 14:28:18 +00:00
output . WriteLine ( TempLimLo . ToString ( ci ) ) ;
output . WriteLine ( TempLimHi . ToString ( ci ) ) ;
2022-05-27 06:46:43 +00:00
output . WriteLine ( ( TempControl ! = null ) ? TempControl : string . Empty ) ;
2022-05-19 13:58:13 +00:00
output . WriteLine ( PumpPower . ToString ( ci ) ) ;
2017-07-14 14:28:18 +00:00
output . WriteLine ( MassRepeats . ToString ( ci ) ) ;
output . WriteLine ( MassSpread . ToString ( ci ) ) ;
output . WriteLine ( ( ( byte ) MassMethod ) . ToString ( ci ) ) ;
output . WriteLine ( TimeBeforeFlow . ToString ( ci ) ) ;
output . WriteLine ( TimeFlow2Mass . ToString ( ci ) ) ;
output . WriteLine ( TimePump2StartV . ToString ( ci ) ) ;
output . WriteLine ( TimeStop2Mass . ToString ( ci ) ) ;
2017-03-31 16:14:21 +00:00
output . WriteLine ( FeedingPath ) ;
output . WriteLine ( BenchPath ) ;
output . WriteLine ( OutputPath ) ;
output . WriteLine ( MetersPath ) ;
2021-09-23 09:46:40 +00:00
output . WriteLine ( TransBefore ) ;
output . WriteLine ( TransBetween ) ;
2019-11-27 10:22:32 +00:00
output . WriteLine ( Profile ) ;
2021-09-23 09:46:40 +00:00
output . WriteLine ( TransAfter ) ;
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
output . WriteLine ( OraId ) ;
output . WriteLine ( OraIdRepetMulti ) ;
output . WriteLine ( OraDesignation ) ;
output . WriteLine ( RawDataId ) ;
output . WriteLine ( RawDataIdRepetMulti ) ;
output . WriteLine ( RawDataDesignation ) ;
#endif
2017-03-31 16:14:21 +00:00
foreach ( var prms in MoreParams ) { prms . Export ( output ) ; }
output . WriteLine ( ) ;
}
public static Test Import ( StreamReader input , Procedure newProcedure )
{
string firstLine = input . ReadLine ( ) ;
2017-07-14 14:28:18 +00:00
if ( string . IsNullOrEmpty ( firstLine ) )
{
return null ;
}
2017-03-31 16:14:21 +00:00
2017-07-14 14:28:18 +00:00
CultureInfo ci = CultureInfo . InvariantCulture ;
2017-03-31 16:14:21 +00:00
Test tst = new Test ( ) ;
2017-07-14 14:28:18 +00:00
2017-03-31 16:14:21 +00:00
tst . Name = firstLine ;
2017-07-14 14:28:18 +00:00
tst . Part = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . Publish = sbyte . Parse ( input . ReadLine ( ) , ci ) ;
2017-06-08 13:42:47 +00:00
tst . DoEvaluate = bool . Parse ( input . ReadLine ( ) ) ;
2023-03-31 11:16:58 +00:00
tst . Qtg = double . Parse ( input . ReadLine ( ) , ci ) ;
tst . Qfrom = double . Parse ( input . ReadLine ( ) , ci ) ;
tst . Qto = double . Parse ( input . ReadLine ( ) , ci ) ;
tst . Volume = double . Parse ( input . ReadLine ( ) , ci ) ;
tst . TestTime = double . Parse ( input . ReadLine ( ) , ci ) ;
2017-03-31 16:14:21 +00:00
tst . Method = input . ReadLine ( ) ;
2017-07-14 14:28:18 +00:00
tst . ErrLimLo = float . Parse ( input . ReadLine ( ) , ci ) ;
tst . ErrLimHi = float . Parse ( input . ReadLine ( ) , ci ) ;
tst . Uncertainty = float . Parse ( input . ReadLine ( ) , ci ) ;
tst . Repeats = int . Parse ( input . ReadLine ( ) , ci ) ;
2017-06-08 13:42:47 +00:00
tst . DoDraining = bool . Parse ( input . ReadLine ( ) ) ;
2019-10-24 12:38:36 +00:00
tst . DoDrainingAfter = bool . Parse ( input . ReadLine ( ) ) ;
2017-07-14 14:28:18 +00:00
tst . TempLimLo = float . Parse ( input . ReadLine ( ) , ci ) ;
tst . TempLimHi = float . Parse ( input . ReadLine ( ) , ci ) ;
2022-05-19 13:58:13 +00:00
tst . TempControl = input . ReadLine ( ) ;
tst . PumpPower = float . Parse ( input . ReadLine ( ) , ci ) ;
2017-07-14 14:28:18 +00:00
tst . MassRepeats = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . MassSpread = float . Parse ( input . ReadLine ( ) , ci ) ;
tst . MassMethod = ( MassMethod ) byte . Parse ( input . ReadLine ( ) , ci ) ;
tst . TimeBeforeFlow = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . TimeFlow2Mass = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . TimePump2StartV = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . TimeStop2Mass = int . Parse ( input . ReadLine ( ) , ci ) ;
2017-03-31 16:14:21 +00:00
tst . FeedingPath = input . ReadLine ( ) ;
tst . BenchPath = input . ReadLine ( ) ;
tst . OutputPath = input . ReadLine ( ) ;
tst . MetersPath = input . ReadLine ( ) ;
2021-09-23 09:46:40 +00:00
tst . TransBefore = input . ReadLine ( ) ;
tst . TransBetween = input . ReadLine ( ) ;
2019-11-27 10:22:32 +00:00
string line = input . ReadLine ( ) ;
tst . Profile = line . Equals ( TestProfile . ProtectedHeatMeter . ToString ( ) ) ? TestProfile . ProtectedHeatMeter
: line . Equals ( TestProfile . UserDefinedHeatMeter . ToString ( ) ) ? TestProfile . UserDefinedHeatMeter
: line . Equals ( TestProfile . Protected . ToString ( ) ) ? TestProfile . Protected : TestProfile . UserDefined ; /// UserDefined is the default
2021-09-23 09:46:40 +00:00
tst . TransAfter = input . ReadLine ( ) ;
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
tst . OraId = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . OraIdRepetMulti = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . OraDesignation = input . ReadLine ( ) ;
tst . RawDataId = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . RawDataIdRepetMulti = int . Parse ( input . ReadLine ( ) , ci ) ;
tst . RawDataDesignation = input . ReadLine ( ) ;
#endif
2017-03-31 16:14:21 +00:00
while ( true )
{
ComponentTest prms = ComponentTest . Import ( input , tst ) ;
if ( prms = = null )
break ;
else
tst . MoreParams . Add ( prms ) ;
}
tst . Procedure = newProcedure ;
return tst ;
}
2017-07-14 14:28:18 +00:00
public virtual string Compare ( StreamReader inp )
{
System . Text . StringBuilder diff = new System . Text . StringBuilder ( ) ;
string fmt = string . Format ( "Test {0} : " , Name ) + "{0} = {1}\r\n (in the file {2})\r\n" ;
string ln ;
CultureInfo ci = CultureInfo . InvariantCulture ;
string firstLine = inp . ReadLine ( ) ;
if ( string . IsNullOrEmpty ( firstLine ) ) return string . Format ( "Test {0} is missing in the file\r\n" , Name ) ;
if ( Name ! = firstLine ) { diff . AppendFormat ( fmt , "Name" , Name , firstLine ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Part . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Part" , Part . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Publish . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Publish" , Publish . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = DoEvaluate . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Evaluate" , DoEvaluate . ToString ( ci ) , ln ) ; } ;
2019-09-21 16:03:25 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = Qtg . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Qtg" , Qtg . ToString ( ci ) , ln ) ; } ;
2017-07-14 14:28:18 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = Qfrom . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Qfrom" , Qfrom . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Qto . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Qto" , Qto . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Volume . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Volume" , Volume . ToString ( ci ) , ln ) ; } ;
2021-09-23 09:46:40 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = TestTime . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TstTime" , TestTime . ToString ( ci ) , ln ) ; } ;
2017-07-14 14:28:18 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = Method ) { diff . AppendFormat ( fmt , "Method" , Method , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = ErrLimLo . ToString ( ci ) ) { diff . AppendFormat ( fmt , "ErrLimLo" , ErrLimLo . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = ErrLimHi . ToString ( ci ) ) { diff . AppendFormat ( fmt , "ErrLimHi" , ErrLimHi . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Uncertainty . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Uncertainty" , Uncertainty . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Repeats . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Repeats" , Repeats . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = DoDraining . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Draining" , DoDraining . ToString ( ci ) , ln ) ; } ;
2019-11-27 10:22:32 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = DoDrainingAfter . ToString ( ci ) ) { diff . AppendFormat ( fmt , "Zeroing" , DoDrainingAfter . ToString ( ci ) , ln ) ; } ;
2017-07-14 14:28:18 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = TempLimLo . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TempLimLo" , TempLimLo . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TempLimHi . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TempLimHi" , TempLimHi . ToString ( ci ) , ln ) ; } ;
2022-05-19 13:58:13 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = TempControl ) { diff . AppendFormat ( fmt , "TempController" , TempControl , ln ) ; } ;
2017-07-14 14:28:18 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = PumpPower . ToString ( ci ) ) { diff . AppendFormat ( fmt , "PumpPower" , PumpPower . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = MassRepeats . ToString ( ci ) ) { diff . AppendFormat ( fmt , "MassRepeats" , MassRepeats . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = MassSpread . ToString ( ci ) ) { diff . AppendFormat ( fmt , "MassSpread" , MassSpread . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = ( ( byte ) MassMethod ) . ToString ( ci ) ) { diff . AppendFormat ( fmt , "MassMethod" , ( ( byte ) MassMethod ) . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TimeBeforeFlow . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TimeBeforeFlow" , TimeBeforeFlow . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TimeFlow2Mass . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TimeFlow2Mass" , TimeFlow2Mass . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TimePump2StartV . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TimePump2StartV" , TimePump2StartV . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TimeStop2Mass . ToString ( ci ) ) { diff . AppendFormat ( fmt , "TimeStop2Mass" , TimeStop2Mass . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = FeedingPath ) { diff . AppendFormat ( fmt , "FeedingPath" , FeedingPath , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = BenchPath ) { diff . AppendFormat ( fmt , "BenchPath" , BenchPath , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = OutputPath ) { diff . AppendFormat ( fmt , "OutputPath" , OutputPath , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = MetersPath ) { diff . AppendFormat ( fmt , "MetersPath" , MetersPath , ln ) ; } ;
2021-11-03 10:09:34 +00:00
ln = inp . ReadLine ( ) ; if ( ln ! = TransBefore ) { diff . AppendFormat ( fmt , "RelTransBefore" , TransBefore , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TransBetween ) { diff . AppendFormat ( fmt , "RelTransBetween" , TransBetween , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = Profile . ToString ( ) ) { diff . AppendFormat ( fmt , "RelTransAfter" , Profile , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = TransAfter ) { diff . AppendFormat ( fmt , "TransitionAfter" , TransAfter , ln ) ; } ;
2022-12-05 12:42:48 +00:00
#if ORACLE_DB
ln = inp . ReadLine ( ) ; if ( ln ! = OraId . ToString ( ci ) ) { diff . AppendFormat ( fmt , "OraId" , OraId . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = OraIdRepetMulti . ToString ( ci ) ) { diff . AppendFormat ( fmt , "OraIdRepetMulti" , OraIdRepetMulti . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = OraDesignation ) { diff . AppendFormat ( fmt , "OraDesignation" , OraDesignation , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = RawDataId . ToString ( ci ) ) { diff . AppendFormat ( fmt , "RawDataId" , RawDataId . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = RawDataIdRepetMulti . ToString ( ci ) ) { diff . AppendFormat ( fmt , "RawDataIdRepetMulti" , RawDataIdRepetMulti . ToString ( ci ) , ln ) ; } ;
ln = inp . ReadLine ( ) ; if ( ln ! = RawDataDesignation ) { diff . AppendFormat ( fmt , "RawDataDesignation" , RawDataDesignation , ln ) ; } ;
#endif
2017-07-14 14:28:18 +00:00
return diff . ToString ( ) ;
}
2018-05-10 11:25:46 +00:00
public virtual ComponentTest GetTestParamsEntity ( string cmpntName )
{
foreach ( var tstPrms in MoreParams )
{
if ( tstPrms . CmpntName = = cmpntName ) return tstPrms ;
}
return null ;
}
2019-10-15 08:03:28 +00:00
/// <summary>
/// Return test title for a this test and a given repetition number
/// </summary>
/// <param name="repetitonNr">1 .. Nr. repetitions</param>
/// <returns>Test title (string)</returns>
public virtual string GetExpandedTestName ( int repetitionNr )
{
if ( Repeats = = 1 )
{
if ( Part = = 0 )
{
/// Single test
return Name ;
}
else
{
/// A part of a single test
return string . Format ( "{0} ({1})" , Name , Part ) ;
}
}
else
{
/// More test repetitions
return string . Format ( "{0} ({1}/{2})" , Name , repetitionNr , Repeats ) ;
}
}
2019-01-25 15:31:26 +00:00
public virtual double GetErrLimLo ( double volumeCTV , double testTime )
2017-10-17 22:30:26 +00:00
{
if ( ErrLimLo < = ErrLimHi )
{
2019-01-25 15:31:26 +00:00
return ErrLimLo ; /// Error limit of a water meter
2017-10-17 22:30:26 +00:00
}
else
{
/// Metrological class and nominal flow of a heat meter
int metrClass = ( int ) Math . Round ( ErrLimLo ) ;
2019-01-25 15:31:26 +00:00
double Qp = Math . Abs ( ErrLimHi ) ;
double Q = ( testTime = = 0 ) ? 1 : Math . Max ( 3.6 * volumeCTV / testTime , 0.00001 ) ; /// Div. by zero avoided
2017-10-17 22:30:26 +00:00
/// Calculate the error limit of a heat meter
switch ( metrClass )
{
default :
2019-01-25 15:31:26 +00:00
case 1 : return - Math . Min ( 3.5 , 1.0 + 0.01 * Qp / Q ) ;
case 2 : return - Math . Min ( 5.0 , 2.0 + 0.02 * Qp / Q ) ;
case 3 : return - Math . Min ( 5.0 , 3.0 + 0.05 * Qp / Q ) ;
2017-10-17 22:30:26 +00:00
}
}
}
2019-01-25 15:31:26 +00:00
public virtual double GetErrLimHi ( double volumeCTV , double testTime )
2017-10-17 22:30:26 +00:00
{
if ( ErrLimLo < = ErrLimHi )
{
2019-01-25 15:31:26 +00:00
return ErrLimHi ; /// Error limit of a water meter
2017-10-17 22:30:26 +00:00
}
else
{
/// Metrological class and nominal flow of a heat meter
int metrClass = ( int ) Math . Round ( ErrLimLo ) ;
2019-01-25 15:31:26 +00:00
double Qp = Math . Abs ( ErrLimHi ) ;
double Q = ( testTime = = 0 ) ? 1 : Math . Max ( 3.6 * volumeCTV / testTime , 0.00001 ) ; /// Div. by zero avoided
2017-10-17 22:30:26 +00:00
/// Calculate the error limit of a heat meter
switch ( metrClass )
{
default :
2019-01-25 15:31:26 +00:00
case 1 : return + Math . Min ( 3.5 , 1.0 + 0.01 * Qp / Q ) ;
case 2 : return + Math . Min ( 5.0 , 2.0 + 0.02 * Qp / Q ) ;
case 3 : return + Math . Min ( 5.0 , 3.0 + 0.05 * Qp / Q ) ;
2017-10-17 22:30:26 +00:00
}
}
}
2019-01-14 13:32:26 +00:00
public virtual bool IsPartCompatible ( int waterMeterPartNr )
{
if ( ( this . Part = = 0 ) | | ( waterMeterPartNr = = 0 ) ) return true ;
if ( ( this . Part % 10 ) = = waterMeterPartNr ) return true ;
if ( ( ( this . Part / 10 ) % 10 ) = = waterMeterPartNr ) return true ;
if ( ( ( this . Part / 100 ) % 10 ) = = waterMeterPartNr ) return true ;
if ( ( ( this . Part / 1000 ) % 10 ) = = waterMeterPartNr ) return true ;
return false ;
}
2016-01-10 11:39:20 +00:00
public override string ToString ( )
{
string partStr = ( Part > 0 ) ? string . Format ( ", part {0}" , Part ) : string . Empty ;
2017-06-08 13:42:47 +00:00
return string . Format ( "{0}(P.{1},{2}){3}" , Name , ( ( Publish ) Publish ) . ToString ( ) , DoEvaluate ? "E" : "-" , partStr ) ;
2016-01-10 11:39:20 +00:00
}
2014-07-28 07:54:35 +00:00
}
}