Results.Entities and Mappings added, Results.DB (based on FluentCommon).
This commit is contained in:
parent
2b7f6a8dac
commit
35c449bd0c
167
Results/DB.cs
Normal file
167
Results/DB.cs
Normal file
@ -0,0 +1,167 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the type of a database
|
||||
/// </summary>
|
||||
public enum DBType
|
||||
{
|
||||
SQLite, /// SQLite
|
||||
MySql, /// MySQL database
|
||||
DbTypesCount,
|
||||
}
|
||||
|
||||
|
||||
public static class DB
|
||||
{
|
||||
/// <summary> Session factory for all regular sessions, not for CreateEmptyResultsDB(). </summary>
|
||||
public static ISessionFactory SessionFactory;
|
||||
|
||||
/// <summary> Connection string for all sessions </summary>
|
||||
private static string connectionString;
|
||||
///
|
||||
public static string ConnectionString
|
||||
{
|
||||
get { return connectionString; }
|
||||
set
|
||||
{
|
||||
connectionString = value;
|
||||
SessionFactory = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
static ISessionFactory CreateSessionFactory(DBType dbType)
|
||||
{
|
||||
return CreateSessionFactory(dbType, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
public static ISessionFactory CreateSessionFactory(DBType dbType, bool createDB)
|
||||
{
|
||||
FluentConfiguration cfg = Fluently.Configure();
|
||||
|
||||
switch (dbType)
|
||||
{
|
||||
default:
|
||||
case DBType.SQLite:
|
||||
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
|
||||
break;
|
||||
case DBType.MySql:
|
||||
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
|
||||
break;
|
||||
}
|
||||
|
||||
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<DataDeposit>());
|
||||
|
||||
if (createDB)
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void BuildSchemaDlgt(Configuration config);
|
||||
|
||||
static void BuildSchema(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).SetOutputFile("db_schema");
|
||||
}
|
||||
|
||||
static void BuildSchemaCreate(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).Create(true, true);
|
||||
}
|
||||
|
||||
/// Create a NHibernate session for the given database
|
||||
public static ISession CreateSession()
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
throw new Exception("Connection string was not specified");
|
||||
}
|
||||
|
||||
if (SessionFactory == null)
|
||||
{
|
||||
SessionFactory = CreateSessionFactory(DBType.MySql);
|
||||
}
|
||||
|
||||
return SessionFactory.OpenSession();
|
||||
}
|
||||
|
||||
public static void SaveObject(object obj)
|
||||
{
|
||||
SaveObject(CreateSession(), obj);
|
||||
}
|
||||
|
||||
public static void SaveObject(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.SaveOrUpdate(obj);
|
||||
try { transaction.Commit(); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteObject(object obj)
|
||||
{
|
||||
DeleteObject(CreateSession(), obj);
|
||||
}
|
||||
|
||||
public static void DeleteObject(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.Delete(obj);
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty users database.
|
||||
/// Database contains only the user 'admin' and the control board component 'CB'.
|
||||
/// </summary>
|
||||
/// <param name="dbType">DBType.SQLite or DBType.MySql</param>
|
||||
/// <param name="connectionString">Connection string</param>
|
||||
/// <returns>true=success, false=error</returns>
|
||||
public static bool CreateEmptyResultsDB(DBType dbType)
|
||||
{
|
||||
ISessionFactory sessionFactory = CreateSessionFactory(dbType, true);
|
||||
if (sessionFactory == null) return false;
|
||||
|
||||
/// Populate the database
|
||||
using (var session = sessionFactory.OpenSession())
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public class Class1
|
||||
public class DataDeposit
|
||||
{
|
||||
}
|
||||
}
|
||||
29
Results/Entities/Batch.cs
Normal file
29
Results/Entities/Batch.cs
Normal file
@ -0,0 +1,29 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class Batch
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int BenchId { get; set; }
|
||||
public virtual int BatchNr { get; set; }
|
||||
public virtual string ProcedureName { get; set; }
|
||||
public virtual int ProcedureRevision { get; set; }
|
||||
public virtual DateTime StartTime { get; set; }
|
||||
public virtual DateTime EndTime { get; set; }
|
||||
public virtual IList<TestData> Tests { get; set; }
|
||||
public virtual IList<WaterMeter> WaterMeters { get; set; }
|
||||
public virtual IList<TestRslt> TestRslts { get; set; }
|
||||
|
||||
public Batch()
|
||||
{
|
||||
Tests = new List<TestData>();
|
||||
WaterMeters = new List<WaterMeter>();
|
||||
TestRslts = new List<TestRslt>();
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Results/Entities/MeterTestRslt.cs
Normal file
63
Results/Entities/MeterTestRslt.cs
Normal file
@ -0,0 +1,63 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class MeterTestRslt
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
|
||||
public virtual double PulsesMeter { get; set; } /// # of pulses
|
||||
public virtual double PulsesMaster { get; set; }
|
||||
public virtual double VolumeStart { get; set; } /// liter
|
||||
public virtual double VolumeEnd { get; set; } /// liter
|
||||
public virtual double VolumeMeter { get; set; } /// liter
|
||||
public virtual double VolumeRef { get; set; } /// liter
|
||||
public virtual double TimestampStart { get; set; } /// sec.
|
||||
public virtual double TimestampEnd { get; set; } /// sec.
|
||||
public virtual double TestTime { get; set; } /// sec.
|
||||
public virtual double Error { get; set; } /// %
|
||||
public virtual bool Passed { get; set; } /// true=test passed - Not mapped to DB !!!
|
||||
|
||||
public virtual WaterMeter WaterMeter { get; set; } /// reference to the TestData entity
|
||||
public virtual TestRslt TestRslt { get; set; } /// reference to the TestData entity
|
||||
|
||||
/// Wrappers
|
||||
public string Name() { return TestRslt.Name(); }
|
||||
public DateTime StartTime() { return TestRslt.StartTime; }
|
||||
public DateTime EndTime() { return TestRslt.EndTime; }
|
||||
public double FlowSetTime() { return TestRslt.FlowSetTime; }
|
||||
public double FlowMass() { return TestRslt.FlowMass; }
|
||||
public double FlowCTV() { return TestRslt.FlowCTV; }
|
||||
public double FlowMin() { return TestRslt.FlowMin; }
|
||||
public double FlowMax() { return TestRslt.FlowMax; }
|
||||
public double ErrorMaster() { return TestRslt.ErrorMaster; }
|
||||
///
|
||||
private TestData TestData() { return TestRslt.TestData; }
|
||||
///
|
||||
public double Qfrom() { return TestData().Qfrom; }
|
||||
public double Qto() { return TestData().Qto; }
|
||||
public double TargetVolume() { return TestData().TargetVolume; }
|
||||
public double TargetTime() { return TestData().TargetTime; }
|
||||
public int Repeats() { return TestData().Repeats; }
|
||||
public string Method() { return TestData().Method; }
|
||||
public double ErrLimLo() { return TestData().ErrLimLo; }
|
||||
public double ErrLimHi() { return TestData().ErrLimHi; }
|
||||
public double Uncertainty() { return TestData().Uncertainty; }
|
||||
public string Components() { return TestData().Components; }
|
||||
|
||||
|
||||
private MeterTestRslt()
|
||||
{
|
||||
}
|
||||
|
||||
public MeterTestRslt(WaterMeter waterMeterRslt, TestRslt testRslt)
|
||||
: this()
|
||||
{
|
||||
WaterMeter = waterMeterRslt;
|
||||
TestRslt = testRslt;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Results/Entities/TestData.cs
Normal file
50
Results/Entities/TestData.cs
Normal file
@ -0,0 +1,50 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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 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 int Repeats { get; set; }
|
||||
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 string Components { get; set; } /// TODO: Representation of components
|
||||
|
||||
|
||||
private TestData()
|
||||
{
|
||||
}
|
||||
|
||||
public TestData(Config.Entities.Test test, string components)
|
||||
: this()
|
||||
{
|
||||
Name = test.Name;
|
||||
Qfrom = (double)test.Qfrom;
|
||||
Qto = (double)test.Qto;
|
||||
TargetVolume = test.Volume;
|
||||
TargetTime = (double)test.TstTime;
|
||||
Repeats = test.Repeats;
|
||||
Method = test.Method;
|
||||
ErrLimLo = (double)test.ErrLimLo;
|
||||
ErrLimHi = (double)test.ErrLimHi;
|
||||
Uncertainty = (double)test.Uncertainty;
|
||||
|
||||
/// TODO:
|
||||
Components = components;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Results/Entities/TestRslt.cs
Normal file
107
Results/Entities/TestRslt.cs
Normal file
@ -0,0 +1,107 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class TestRslt
|
||||
{
|
||||
/// Identity
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual Batch Batch { get; set; }
|
||||
public virtual TestData TestData { get; set; }
|
||||
public virtual int Part { get; set; }
|
||||
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
|
||||
|
||||
/// Results
|
||||
public virtual DateTime StartTime { get; set; } /// Date and time of the test start
|
||||
public virtual DateTime EndTime { get; set; } /// Date and time of the test end
|
||||
public virtual double FlowSetTime { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual double TestTime { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual float AmbientTempAve { get; set; } /// [deg.C] Average ambient air temperature
|
||||
public virtual float AmbientPressAve { get; set; } /// Average ambient air pressure
|
||||
public virtual float AmbientHumiAve { get; set; } /// [%] Average ambient air relative humidity
|
||||
public virtual float PressUpAvrg { get; set; } /// [Bar] Input water pressure (average)
|
||||
public virtual float PressUpStart { get; set; } /// [Bar]
|
||||
public virtual float PressUpEnd { get; set; } /// [Bar]
|
||||
public virtual float PressUpMin { get; set; } /// [Bar]
|
||||
public virtual float PressUpMax { get; set; } /// [Bar]
|
||||
public virtual float PressDownAvrg { get; set; } /// [Bar]
|
||||
public virtual float PressDownStart { get; set; } /// [Bar]
|
||||
public virtual float PressDownEnd { get; set; } /// [Bar]
|
||||
public virtual float PressDownMin { get; set; } /// [Bar]
|
||||
public virtual float PressDownMax { get; set; } /// [Bar]
|
||||
public virtual float TempInAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempInStart { get; set; } /// [deg.C]
|
||||
public virtual float TempInEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempInMin { get; set; } /// [deg.C]
|
||||
public virtual float TempInMax { get; set; } /// [deg.C]
|
||||
public virtual float TempOutAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempOutStart { get; set; } /// [deg.C]
|
||||
public virtual float TempOutEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempOutMin { get; set; } /// [deg.C]
|
||||
public virtual float TempOutMax { get; set; } /// [deg.C]
|
||||
public virtual float TempDivAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempDivStart { get; set; } /// [deg.C]
|
||||
public virtual float TempDivEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempDivMin { get; set; } /// [deg.C]
|
||||
public virtual float TempDivMax { get; set; } /// [deg.C]
|
||||
public virtual double MassStartRaw { get; set; } /// [kg]
|
||||
public virtual double MassStart { get; set; } /// [kg]
|
||||
public virtual double MassEndRaw { get; set; } /// [kg]
|
||||
public virtual double MassEnd { get; set; } /// [kg]
|
||||
public virtual double MassDiff { get; set; } /// [kg]
|
||||
public virtual double DensityIn { get; set; } /// [kg/m3]
|
||||
public virtual double DensityOut { get; set; } /// [kg/m3]
|
||||
public virtual double DensityDiv { get; set; } /// [kg/m3]
|
||||
public virtual double Buoyancy { get; set; }
|
||||
public virtual double FlowMass { get; set; } /// [kg/h] calculated from conventional true value
|
||||
public virtual double FlowCTV { get; set; } /// [l/h] calculated from conventional true value
|
||||
public virtual double FlowMin { get; set; } /// [l/h] minimum flow
|
||||
public virtual double FlowMax { get; set; } /// [l/h] maximum flow
|
||||
public virtual double VolumeCTV { get; set; } /// [l] Volume conventional true value
|
||||
public virtual double VolumeMaster { get; set; } /// [l] Volume from the master flow meter
|
||||
public virtual double ErrorMaster { get; set; } /// [%]
|
||||
public virtual double PulsesMaster { get; set; }
|
||||
public virtual double ConstMaster { get; set; } /// [pls/l] Pulses per liter master flow meter
|
||||
|
||||
|
||||
/// Wrappers
|
||||
public string Name()
|
||||
{
|
||||
if (TestData.Repeats == 1) { return TestData.Name; }
|
||||
else { return string.Format("{0} ({1}/{2})", TestData.Name, RepetitionNr, TestData.Repeats); }
|
||||
}
|
||||
public double Qfrom() { return TestData.Qfrom; }
|
||||
public double Qto() { return TestData.Qto; }
|
||||
public double TargetVolume() { return TestData.TargetVolume; }
|
||||
public double TargetTime() { return TestData.TargetTime; }
|
||||
public int Repeats() { return TestData.Repeats; }
|
||||
public string Method() { return TestData.Method; }
|
||||
public double ErrLimLo() { return TestData.ErrLimLo; }
|
||||
public double ErrLimHi() { return TestData.ErrLimHi; }
|
||||
public double Uncertainty() { return TestData.Uncertainty; }
|
||||
public string Components() { return TestData.Components; }
|
||||
|
||||
|
||||
public TestRslt()
|
||||
{
|
||||
}
|
||||
|
||||
public TestRslt(Batch batch, TestData testData, int part, int repetitionNr)
|
||||
: this()
|
||||
{
|
||||
Batch = batch;
|
||||
TestData = testData;
|
||||
Part = part;
|
||||
RepetitionNr = repetitionNr;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", Batch.BatchNr, Batch.ProcedureName, Name(), StartTime.ToShortDateString(), StartTime.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Results/Entities/WaterMeter.cs
Normal file
107
Results/Entities/WaterMeter.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class WaterMeter
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string SerialNr { get; set; } /// PCB Number for iPerl water meter
|
||||
public virtual string PurchaseOrder { get; set; }
|
||||
public virtual string EndState { get; set; }
|
||||
public virtual double QRise { get; set; } /// [l/h] detected Q_rise of a composed meter
|
||||
public virtual double QFall { get; set; } /// [l/h] detected Q_fall of a composed meter
|
||||
public virtual int YearOfProduction { get; set; }
|
||||
public virtual bool Passed { get; set; }
|
||||
#if IPERLST
|
||||
public virtual int SerialNrEx { get; set; } /// iPerl : This is the serial number assigned later
|
||||
public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!!
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!!
|
||||
#endif
|
||||
|
||||
public virtual WaterMeterData WaterMeterData { get; set; }
|
||||
public virtual Batch Batch { get; set; }
|
||||
public virtual IList<MeterTestRslt> MeterTestRslts { get; set; }
|
||||
|
||||
///
|
||||
/// Wrappers
|
||||
///
|
||||
public string ProductName() { return WaterMeterData.ProductName; }
|
||||
public string Producer() { return WaterMeterData.Producer; }
|
||||
public string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
|
||||
public string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
|
||||
public double Q4_Qmax() { return WaterMeterData.Q4_Qmax; }
|
||||
public double Qn() { return WaterMeterData.Qn; }
|
||||
public double Q3() { return WaterMeterData.Q3; }
|
||||
public double Q2_Qt() { return WaterMeterData.Q2_Qt; }
|
||||
public double Q1_Qmin() { return WaterMeterData.Q1_Qmin; }
|
||||
public bool Compound() { return WaterMeterData.Compound; }
|
||||
|
||||
public int BatchNr() { return Batch.BatchNr; }
|
||||
public int BenchId() { return Batch.BenchId; }
|
||||
public string ProcedureName() { return Batch.ProcedureName; }
|
||||
public int ProcedureRevision() { return Batch.ProcedureRevision; }
|
||||
public DateTime StartTime() { return Batch.StartTime; }
|
||||
public DateTime EndTime() { return Batch.EndTime; }
|
||||
|
||||
public MeterTestRslt MeterTestRslt(string testName)
|
||||
{
|
||||
foreach (var tr in MeterTestRslts)
|
||||
{
|
||||
if (tr.Name().ToLower().Equals(testName.ToLower())) return tr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestRslt TestRslt(string testName)
|
||||
{
|
||||
MeterTestRslt mtr = MeterTestRslt(testName);
|
||||
if (mtr != null) return mtr.TestRslt;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Private constructor, initializes a list, used as a base
|
||||
/// </summary>
|
||||
private WaterMeter()
|
||||
{
|
||||
MeterTestRslts = new List<MeterTestRslt>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used to construct WaterMeterResults from the first meter test result
|
||||
/// </summary>
|
||||
public WaterMeter(MeterTestResult meterTestResult, int benchId)
|
||||
: this()
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to append result to a list of results and update start/end dates
|
||||
/// </summary>
|
||||
public void Append(MeterTestResult meterTestResult)
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
#if IPERLST
|
||||
sb.AppendFormat("PCB:{0} S/N:{1} ", SerialNr, SerialNrEx);
|
||||
#else
|
||||
sb.AppendFormat("S/N:{0} ", SerialNr);
|
||||
#endif
|
||||
|
||||
foreach (var tr in MeterTestRslts) sb.AppendFormat(" {0}:{1}%", tr.Name(), tr.Error.ToString("F1"));
|
||||
sb.AppendFormat(" test start: {0} {1} batch={2}", StartTime().ToShortDateString(), StartTime().ToShortTimeString(), BatchNr());
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Results/Entities/WaterMeterData.cs
Normal file
27
Results/Entities/WaterMeterData.cs
Normal file
@ -0,0 +1,27 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class WaterMeterData
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string ProductName { get; set; }
|
||||
public virtual string Producer { get; set; }
|
||||
public virtual string MetrologicalClass { get; set; }
|
||||
public virtual string ApprovalInfo { get; set; }
|
||||
public virtual double Q4_Qmax { get; set; } /// [m3/h]
|
||||
public virtual double Qn { get; set; } /// [m3/h]
|
||||
public virtual double Q3 { get; set; } /// [m3/h]
|
||||
public virtual double Q2_Qt { get; set; } /// [m3/h]
|
||||
public virtual double Q1_Qmin { get; set; } /// [m3/h]
|
||||
public bool Compound { get; set; }
|
||||
|
||||
public WaterMeterData()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,113 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class WaterMeterResult
|
||||
{
|
||||
/// Set only once, used as a reference in some getters
|
||||
private readonly MeterTestResult firstMeterTestResult;
|
||||
|
||||
///
|
||||
/// Hard water meter data
|
||||
///
|
||||
public string SerialNr; /// iPerl : This is PCB Number
|
||||
public int SerialNrEx; /// iPerl : This is the serial number assigned later
|
||||
public int BenchId;
|
||||
public int BatchNr { get { return firstMeterTestResult.TestResult.BatchNr; } }
|
||||
public string ProcedureName { get { return firstMeterTestResult.TestResult.ProcedureName; } }
|
||||
public DateTime TestStart;
|
||||
public DateTime TestEnd;
|
||||
public IList<MeterTestResult> MeterTestResults;
|
||||
|
||||
///
|
||||
/// Soft water meter data
|
||||
///
|
||||
public string Type;
|
||||
public string TypeApproval;
|
||||
public string MetrologicalClass;
|
||||
public string ProtocolTitle { get { return firstMeterTestResult.TestResult.ProtocolTitle; } }
|
||||
public string PurchaseOrder;
|
||||
|
||||
|
||||
public TestResult TestResult(string testName)
|
||||
{
|
||||
foreach (var tr in MeterTestResults)
|
||||
{
|
||||
if (tr.TestResult.TestName.ToLower().Equals(testName.ToLower())) return tr.TestResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MeterTestResult MeterTestResult(string testName)
|
||||
{
|
||||
foreach (var tr in MeterTestResults)
|
||||
{
|
||||
if (tr.TestResult.TestName.ToLower().Equals(testName.ToLower())) return tr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Private constructor, initializes a list, used as a base
|
||||
/// </summary>
|
||||
private WaterMeterResult()
|
||||
{
|
||||
MeterTestResults = new List<MeterTestResult>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used to construct WaterMeterResults from the first meter test result
|
||||
/// </summary>
|
||||
public WaterMeterResult(MeterTestResult meterTestResult, int benchId)
|
||||
: this()
|
||||
{
|
||||
if (meterTestResult == null) throw new Exception("meterTestResult cannot be null");
|
||||
MeterTestResults.Add(firstMeterTestResult = meterTestResult);
|
||||
|
||||
SerialNr = meterTestResult.SerialNr;
|
||||
BenchId = (benchId == 5) ? 20033 : ((benchId == 6) ? 20034 : 0);
|
||||
TestStart = meterTestResult.TestResult.TimeStart;
|
||||
TestEnd = meterTestResult.TestResult.TimeEnd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to append result to a list of results and update start/end dates
|
||||
/// </summary>
|
||||
public void Append(MeterTestResult meterTestResult)
|
||||
{
|
||||
MeterTestResults.Add(meterTestResult);
|
||||
if (meterTestResult.TestResult.TimeStart < TestStart) TestStart = meterTestResult.TestResult.TimeStart;
|
||||
if (meterTestResult.TestResult.TimeEnd > TestEnd) TestEnd = meterTestResult.TestResult.TimeEnd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns 'tests passed' information based on so far appended results
|
||||
/// </summary>
|
||||
public bool Passed()
|
||||
{
|
||||
bool passed = true;
|
||||
foreach (var tr in MeterTestResults)
|
||||
{
|
||||
if (tr.TestResult.DoNotEvaluate) continue;
|
||||
if (tr.VolumeErrorPct < tr.TestResult.ErrLimLo || tr.VolumeErrorPct > tr.TestResult.ErrLimHi) passed = false;
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
sb.AppendFormat("PCB:{0} s/n:{1} ", SerialNr, SerialNrEx);
|
||||
|
||||
foreach (var tr in MeterTestResults) sb.AppendFormat(" {0}:{1}%", tr.TestResult.TestName, tr.VolumeErrorPct.ToString("F1"));
|
||||
sb.AppendFormat(" test start: {0} {1} batch={2}", TestStart.ToShortDateString(), TestStart.ToShortTimeString(), BatchNr);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Results/Mappings/BatchMap.cs
Normal file
28
Results/Mappings/BatchMap.cs
Normal file
@ -0,0 +1,28 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class BatchMap : ClassMap<Batch>
|
||||
{
|
||||
public BatchMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.BenchId);
|
||||
Map(x => x.BatchNr);
|
||||
Map(x => x.ProcedureName);
|
||||
Map(x => x.ProcedureRevision);
|
||||
Map(x => x.StartTime);
|
||||
Map(x => x.EndTime);
|
||||
HasMany(x => x.Tests)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.WaterMeters)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.TestRslts)
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Results/Mappings/MeterTestRsltMap.cs
Normal file
30
Results/Mappings/MeterTestRsltMap.cs
Normal file
@ -0,0 +1,30 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class MeterTestRsltMap : ClassMap<MeterTestRslt>
|
||||
{
|
||||
public MeterTestRsltMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.PulsesMeter);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.VolumeStart);
|
||||
Map(x => x.VolumeEnd);
|
||||
Map(x => x.VolumeMeter);
|
||||
Map(x => x.VolumeRef);
|
||||
Map(x => x.TimestampStart);
|
||||
Map(x => x.TimestampEnd);
|
||||
Map(x => x.TestTime);
|
||||
Map(x => x.Error);
|
||||
Map(x => x.Passed);
|
||||
|
||||
References(x => x.WaterMeter);
|
||||
References(x => x.TestRslt);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Results/Mappings/TestDataMap.cs
Normal file
27
Results/Mappings/TestDataMap.cs
Normal file
@ -0,0 +1,27 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class TestDataMap : ClassMap<TestData>
|
||||
{
|
||||
public TestDataMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.TargetVolume);
|
||||
Map(x => x.TargetTime);
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
Map(x => x.Components);
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Results/Mappings/TestRsltMap.cs
Normal file
70
Results/Mappings/TestRsltMap.cs
Normal file
@ -0,0 +1,70 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class TestRsltMap : ClassMap<TestRslt>
|
||||
{
|
||||
public TestRsltMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
References<Batch>(x => x.Batch);
|
||||
References<TestData>(x => x.TestData);
|
||||
Map(x => x.Part);
|
||||
Map(x => x.RepetitionNr);
|
||||
Map(x => x.StartTime);
|
||||
Map(x => x.EndTime);
|
||||
Map(x => x.FlowSetTime);
|
||||
Map(x => x.TestTime);
|
||||
Map(x => x.AmbientTempAve);
|
||||
Map(x => x.AmbientPressAve);
|
||||
Map(x => x.AmbientHumiAve);
|
||||
Map(x => x.PressUpAvrg);
|
||||
Map(x => x.PressUpStart);
|
||||
Map(x => x.PressUpEnd);
|
||||
Map(x => x.PressUpMin);
|
||||
Map(x => x.PressUpMax);
|
||||
Map(x => x.PressDownAvrg);
|
||||
Map(x => x.PressDownStart);
|
||||
Map(x => x.PressDownEnd);
|
||||
Map(x => x.PressDownMin);
|
||||
Map(x => x.PressDownMax);
|
||||
Map(x => x.TempInAvrg);
|
||||
Map(x => x.TempInStart);
|
||||
Map(x => x.TempInEnd);
|
||||
Map(x => x.TempInMin);
|
||||
Map(x => x.TempInMax);
|
||||
Map(x => x.TempOutAvrg);
|
||||
Map(x => x.TempOutStart);
|
||||
Map(x => x.TempOutEnd);
|
||||
Map(x => x.TempOutMin);
|
||||
Map(x => x.TempOutMax);
|
||||
Map(x => x.TempDivAvrg);
|
||||
Map(x => x.TempDivStart);
|
||||
Map(x => x.TempDivEnd);
|
||||
Map(x => x.TempDivMin);
|
||||
Map(x => x.TempDivMax);
|
||||
Map(x => x.MassStartRaw);
|
||||
Map(x => x.MassStart);
|
||||
Map(x => x.MassEndRaw);
|
||||
Map(x => x.MassEnd);
|
||||
Map(x => x.MassDiff);
|
||||
Map(x => x.DensityIn);
|
||||
Map(x => x.DensityOut);
|
||||
Map(x => x.DensityDiv);
|
||||
Map(x => x.Buoyancy);
|
||||
Map(x => x.FlowMass);
|
||||
Map(x => x.FlowCTV);
|
||||
Map(x => x.FlowMin);
|
||||
Map(x => x.FlowMax);
|
||||
Map(x => x.VolumeCTV);
|
||||
Map(x => x.VolumeMaster);
|
||||
Map(x => x.ErrorMaster);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.ConstMaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Results/Mappings/WaterMeterDataMap.cs
Normal file
26
Results/Mappings/WaterMeterDataMap.cs
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class WaterMeterDataMap : ClassMap<WaterMeterData>
|
||||
{
|
||||
public WaterMeterDataMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ProductName);
|
||||
Map(x => x.Producer);
|
||||
Map(x => x.MetrologicalClass);
|
||||
Map(x => x.ApprovalInfo);
|
||||
Map(x => x.Q4_Qmax);
|
||||
Map(x => x.Qn);
|
||||
Map(x => x.Q3);
|
||||
Map(x => x.Q2_Qt);
|
||||
Map(x => x.Q1_Qmin);
|
||||
Map(x => x.Compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Results/Mappings/WaterMeterMap.cs
Normal file
31
Results/Mappings/WaterMeterMap.cs
Normal file
@ -0,0 +1,31 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class WaterMeterMap : ClassMap<WaterMeter>
|
||||
{
|
||||
public WaterMeterMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.SerialNr);
|
||||
Map(x => x.PurchaseOrder);
|
||||
Map(x => x.EndState);
|
||||
Map(x => x.QRise);
|
||||
Map(x => x.QFall);
|
||||
Map(x => x.Passed);
|
||||
#if IPERLST
|
||||
Map(x => x.SerialNrEx);
|
||||
Map(x => x.CalibFactor);
|
||||
Map(x => x.Q2Correction);
|
||||
#endif
|
||||
References(x => x.WaterMeterData);
|
||||
References(x => x.Batch);
|
||||
HasMany(x => x.MeterTestRslts)
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,8 +53,20 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Entities\WaterMeterResult.cs" />
|
||||
<Compile Include="DataDeposit.cs" />
|
||||
<Compile Include="Entities\Batch.cs" />
|
||||
<Compile Include="Entities\MeterTestRslt.cs" />
|
||||
<Compile Include="Entities\TestData.cs" />
|
||||
<Compile Include="Entities\TestRslt.cs" />
|
||||
<Compile Include="Entities\WaterMeterData.cs" />
|
||||
<Compile Include="Entities\WaterMeter.cs" />
|
||||
<Compile Include="DB.cs" />
|
||||
<Compile Include="Mappings\BatchMap.cs" />
|
||||
<Compile Include="Mappings\MeterTestRsltMap.cs" />
|
||||
<Compile Include="Mappings\TestDataMap.cs" />
|
||||
<Compile Include="Mappings\TestRsltMap.cs" />
|
||||
<Compile Include="Mappings\WaterMeterDataMap.cs" />
|
||||
<Compile Include="Mappings\WaterMeterMap.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -65,7 +77,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="FileWriters\" />
|
||||
<Folder Include="Mappings\" />
|
||||
<Folder Include="Printers\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@ -13,10 +13,10 @@ namespace ResultsBrowser
|
||||
public static class DataDeposit
|
||||
{
|
||||
public static IList<TestResult> ReportTestResults;
|
||||
public static IList<Results.Entities.WaterMeterResult> ReportWaterMeterResults;
|
||||
public static IList<Results.Entities.WaterMeter> ReportWaterMeterResults;
|
||||
|
||||
public static IList<TestResult> QueryTestResults;
|
||||
public static IList<Results.Entities.WaterMeterResult> QueryWaterMeterResults;
|
||||
public static IList<Results.Entities.WaterMeter> QueryWaterMeterResults;
|
||||
|
||||
static DataDeposit()
|
||||
{
|
||||
@ -26,10 +26,10 @@ namespace ResultsBrowser
|
||||
public static void Clear()
|
||||
{
|
||||
ReportTestResults = new List<TestResult>();
|
||||
ReportWaterMeterResults = new List<Results.Entities.WaterMeterResult>();
|
||||
ReportWaterMeterResults = new List<Results.Entities.WaterMeter>();
|
||||
|
||||
QueryTestResults = new List<TestResult>();
|
||||
QueryWaterMeterResults = new List<Results.Entities.WaterMeterResult>();
|
||||
QueryWaterMeterResults = new List<Results.Entities.WaterMeter>();
|
||||
}
|
||||
|
||||
public static void ProcessQueryTestResults(IList<TestResult> testResults, bool resolveManually)
|
||||
@ -60,7 +60,7 @@ namespace ResultsBrowser
|
||||
///
|
||||
foreach (var batchNr in batchNrs)
|
||||
{
|
||||
IList<Results.Entities.WaterMeterResult> wmResults = new List<Results.Entities.WaterMeterResult>();
|
||||
IList<Results.Entities.WaterMeter> wmResults = new List<Results.Entities.WaterMeter>();
|
||||
bool waterMetersCreated = false;
|
||||
|
||||
foreach (var tr in selectedTestResults)
|
||||
@ -71,7 +71,7 @@ namespace ResultsBrowser
|
||||
{
|
||||
if (!waterMetersCreated)
|
||||
{
|
||||
foreach (var mtr in tr.Meters) wmResults.Add(new Results.Entities.WaterMeterResult(mtr, 5));
|
||||
foreach (var mtr in tr.Meters) wmResults.Add(new Results.Entities.WaterMeter(mtr, 5));
|
||||
waterMetersCreated = true;
|
||||
}
|
||||
else
|
||||
@ -88,7 +88,7 @@ namespace ResultsBrowser
|
||||
/// Exclude 'failed' water meters
|
||||
for (int i = wmResults.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (string.IsNullOrEmpty(wmResults[i].SerialNr) || !wmResults[i].Passed())
|
||||
if (string.IsNullOrEmpty(wmResults[i].SerialNr) || !wmResults[i].Passed)
|
||||
{
|
||||
wmResults.RemoveAt(i);
|
||||
}
|
||||
@ -101,12 +101,12 @@ namespace ResultsBrowser
|
||||
foreach (var tr in selectedTestResults) QueryTestResults.Add(tr);
|
||||
}
|
||||
|
||||
public static int AddWMResultsAvoidDuplicates(IList<Results.Entities.WaterMeterResult> wmResults, bool resolveManually)
|
||||
public static int AddWMResultsAvoidDuplicates(IList<Results.Entities.WaterMeter> wmResults, bool resolveManually)
|
||||
{
|
||||
int added = 0;
|
||||
foreach (var wmr in wmResults)
|
||||
{
|
||||
Results.Entities.WaterMeterResult foundWM = null;
|
||||
Results.Entities.WaterMeter foundWM = null;
|
||||
|
||||
foreach (var wm in QueryWaterMeterResults)
|
||||
{
|
||||
|
||||
@ -298,6 +298,7 @@ namespace ResultsBrowser
|
||||
|
||||
private void addOracleDataButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
#if IPERLST
|
||||
if (DataDeposit.ReportWaterMeterResults.Count == 0) return;
|
||||
|
||||
const int Step = 100;
|
||||
@ -311,7 +312,7 @@ namespace ResultsBrowser
|
||||
|
||||
for (int j = i; j < Math.Min(j + Step, DataDeposit.ReportWaterMeterResults.Count); j++)
|
||||
{
|
||||
Results.Entities.WaterMeterResult wm = DataDeposit.ReportWaterMeterResults[j];
|
||||
Results.Entities.WaterMeter wm = DataDeposit.ReportWaterMeterResults[j];
|
||||
|
||||
IList<int> serialNrExes = new List<int>();
|
||||
{
|
||||
@ -343,6 +344,7 @@ namespace ResultsBrowser
|
||||
}
|
||||
|
||||
RedrawLists();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void makeAscFileButton_Click(object sender, EventArgs e)
|
||||
@ -364,9 +366,10 @@ namespace ResultsBrowser
|
||||
{
|
||||
foreach (var wm in DataDeposit.ReportWaterMeterResults)
|
||||
{
|
||||
wm.Type = dlg.Type;
|
||||
wm.TypeApproval = dlg.TypeApproval;
|
||||
wm.MetrologicalClass = dlg.MetrologicalClass;
|
||||
/// TODO: Rewrite
|
||||
//wm.Type = dlg.Type;
|
||||
//wm.ApprovalInfo() = dlg.TypeApproval;
|
||||
//wm.MetrologicalClass = dlg.MetrologicalClass;
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,26 +381,30 @@ namespace ResultsBrowser
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
#if IPERLST
|
||||
sb.Append(wm.SerialNrEx);
|
||||
sb.Append(';'); sb.Append(wm.Type);
|
||||
sb.Append(';'); sb.Append(wm.TypeApproval);
|
||||
sb.Append(';'); sb.Append(wm.MetrologicalClass);
|
||||
#else
|
||||
sb.Append(wm.SerialNr);
|
||||
#endif
|
||||
sb.Append(';'); sb.Append(wm.ProductName());
|
||||
sb.Append(';'); sb.Append(wm.ApprovalInfo());
|
||||
sb.Append(';'); sb.Append(wm.MetrologicalClass());
|
||||
sb.Append(';'); sb.Append("0");
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestResult("q1") != null ? wm.TestResult("q1").Qfrom : 0)).ToString("F0")); /// Q1 nominal
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestResult("q2") != null ? wm.TestResult("q2").Qfrom : 0)).ToString("F0")); /// Q2 nominal
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestResult("q3") != null ? wm.TestResult("q3").Qto : 0)).ToString("F0")); /// Q3 nominal
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestRslt("q1") != null ? wm.TestRslt("q1").Qfrom() : 0)).ToString("F0")); /// Q1 nominal
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestRslt("q2") != null ? wm.TestRslt("q2").Qfrom() : 0)).ToString("F0")); /// Q2 nominal
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestRslt("q3") != null ? wm.TestRslt("q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
|
||||
sb.Append(';'); sb.Append("0"); /// Q4 nominal
|
||||
sb.Append(';'); sb.Append("6"); /// Worker code
|
||||
sb.Append(';'); sb.Append(ToShortStr(wm.TestEnd));
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q1") != null ? wm.MeterTestResult("q1").VolumeErrorPct : 99).ToString("F1")); /// Q1 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q2") != null ? wm.MeterTestResult("q2").VolumeErrorPct : 99).ToString("F1")); /// Q2 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q3") != null ? wm.MeterTestResult("q3").VolumeErrorPct : 99).ToString("F1")); /// Q3 Error [%]
|
||||
sb.Append(';'); sb.Append(ToShortStr(wm.EndTime()));
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q1") != null ? wm.MeterTestRslt("q1").Error : 99).ToString("F1")); /// Q1 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q2") != null ? wm.MeterTestRslt("q2").Error : 99).ToString("F1")); /// Q2 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q3") != null ? wm.MeterTestRslt("q3").Error : 99).ToString("F1")); /// Q3 Error [%]
|
||||
sb.Append(';'); sb.Append("0"); /// Q4 Error [%]
|
||||
sb.Append(';'); sb.Append(wm.BenchId.ToString()); ///
|
||||
sb.Append(';'); sb.Append(wm.BenchId().ToString()); ///
|
||||
sb.Append(';'); sb.Append(wm.PurchaseOrder);
|
||||
sb.Append(';'); sb.Append("");
|
||||
sb.Append(';'); sb.Append("10000");
|
||||
sb.Append(';'); sb.Append(wm.ProcedureName.Substring(0, 8));
|
||||
sb.Append(';'); sb.Append(wm.ProcedureName().Substring(0, 8));
|
||||
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"');
|
||||
|
||||
report.WriteLine(sb);
|
||||
@ -439,16 +446,20 @@ namespace ResultsBrowser
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
#if IPERLST
|
||||
sb.Append(wm.SerialNrEx);
|
||||
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"'); /// PCB number
|
||||
sb.Append(";\""); sb.Append(wm.ProcedureName); sb.Append('"'); /// Procedure name
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestResult("q3") != null ? wm.TestResult("q3").Qto : 0)).ToString("F0")); /// Q3 nominal
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("adjustment") != null ? wm.MeterTestResult("adjustment").VolumeErrorPct : 99).ToString("F2"));/// Adjustment Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q3") != null ? wm.MeterTestResult("q1").VolumeErrorPct : 99).ToString("F2")); /// Q1 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q2") != null ? wm.MeterTestResult("q2").VolumeErrorPct : 99).ToString("F2")); /// Q2 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestResult("q1") != null ? wm.MeterTestResult("q3").VolumeErrorPct : 99).ToString("F2")); /// Q3 Error [%]
|
||||
sb.Append(';'); sb.Append(wm.TestStart.ToShortTimeString());
|
||||
sb.Append(';'); sb.Append(wm.TestEnd.ToShortTimeString());
|
||||
#else
|
||||
sb.Append(wm.SerialNr);
|
||||
#endif
|
||||
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"'); /// PCB number
|
||||
sb.Append(";\""); sb.Append(wm.ProcedureName()); sb.Append('"'); /// Procedure name
|
||||
sb.Append(';'); sb.Append((1000 * (wm.TestRslt("q3") != null ? wm.TestRslt("q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("adjustment") != null ? wm.MeterTestRslt("adjustment").Error : 99).ToString("F2"));/// Adjustment Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q3") != null ? wm.MeterTestRslt("q1").Error : 99).ToString("F2")); /// Q1 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q2") != null ? wm.MeterTestRslt("q2").Error : 99).ToString("F2")); /// Q2 Error [%]
|
||||
sb.Append(';'); sb.Append((wm.MeterTestRslt("q1") != null ? wm.MeterTestRslt("q3").Error : 99).ToString("F2")); /// Q3 Error [%]
|
||||
sb.Append(';'); sb.Append(wm.StartTime().ToShortTimeString());
|
||||
sb.Append(';'); sb.Append(wm.EndTime().ToShortTimeString());
|
||||
|
||||
report.WriteLine(sb);
|
||||
}
|
||||
|
||||
@ -182,6 +182,9 @@
|
||||
<Name>Results</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Printers\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
9
TODO.txt
9
TODO.txt
@ -1,10 +1,7 @@
|
||||
iPerl:
|
||||
- naimplementovat Spooler pre OracleDB
|
||||
- updatovat progress bary pre iPerl comm.
|
||||
- neukaldat process data pre UnknownPcbNr... vodomery
|
||||
|
||||
- 'publish' a 'evaluate' pre vsetky metody
|
||||
- prechadzat na double (results)
|
||||
- neukladat process data pre UnknownPcbNr... vodomery
|
||||
|
||||
- log pre pevny start, podobne (zarazky) ako pre letmy
|
||||
- 'Q2 corrected from ...' Evaluate a Publish parametre
|
||||
@ -20,6 +17,10 @@ iPerl:
|
||||
|
||||
|
||||
|
||||
- 'publish' a 'evaluate' pre vsetky metody
|
||||
- prechadzat na double (results)
|
||||
- make results item config a process parameter
|
||||
|
||||
- ak sa skusa s pevnym startom treba merat priemerny prietok az po uplynuti
|
||||
urcitej doby inak bude vzdy nizsi ako ma byt - rozbeh
|
||||
- bude potrebne doregulovavat pocas merania, Jano poslal moznosti - inak nam
|
||||
|
||||
@ -940,7 +940,7 @@ namespace TBF.BenchControl.Sequences
|
||||
/// </summary>
|
||||
/// <param name="test">Test to be simulated</param>
|
||||
/// <returns>Test result</returns>
|
||||
protected TestResult MakeSimulated(Test test, int repetitionNr, float errorPct)
|
||||
protected TestResult MakeSimulated(Test test, int repetitionNr, float errorPctBase)
|
||||
{
|
||||
TestResult tstRslt = new TestResult(test, repetitionNr, MetersKind.Single);
|
||||
|
||||
@ -989,6 +989,8 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++)
|
||||
{
|
||||
float errorPct = errorPctBase + 0.05f * i;
|
||||
|
||||
/// Reference to iPerl water meter or null:
|
||||
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
|
||||
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
|
||||
|
||||
@ -93,9 +93,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
TestResult tstRslt;
|
||||
|
||||
if (testParams.Activity.ToLower().Contains("q3")) tstRslt = MakeSimulated(test, 1, 0.5f);
|
||||
else if (testParams.Activity.ToLower().Contains("q2")) tstRslt = MakeSimulated(test, 1, 1.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("q1")) tstRslt = MakeSimulated(test, 1, 2.2f);
|
||||
if (testParams.Activity.ToLower().Contains("q3")) tstRslt = MakeSimulated(test, 1, -0.5f);
|
||||
else if (testParams.Activity.ToLower().Contains("q2")) tstRslt = MakeSimulated(test, 1, 0.5f);
|
||||
else if (testParams.Activity.ToLower().Contains("q1")) tstRslt = MakeSimulated(test, 1, -5.1f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound ok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 0.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound nok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 4.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound rise")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.DetectionRise, 1, 0.7f);
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
@ -72,6 +73,7 @@
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>TBF.Program</StartupObject>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user