Compare commits

..
Author SHA1 Message Date
Milan Hanajik 2c4b4f8460 Reconfigured for FLEX Chennai - Managed Oracle client v.19 2021-11-02 12:46:21 +01:00
742 changed files with 19346 additions and 29436 deletions
-2
View File
@@ -40,8 +40,6 @@ Results/bin/
Results/obj/
ResultsBrowser/bin/
ResultsBrowser/obj/
ResultsParser/bin/
ResultsParser/obj/
Statistics/bin/
Statistics/obj/
TBF/bin/
+7 -37
View File
@@ -42,56 +42,26 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BackgroundBeep.cs" />
<Compile Include="Const.cs" />
<Compile Include="DatabaseSettings.cs" />
<Compile Include="DBSettings.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviDateTimeColumnComparer.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviNameSurnameColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\MessageEventArgs.cs" />
<Compile Include="Forms\ModelessForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ModelessForm.designer.cs">
<DependentUpon>ModelessForm.cs</DependentUpon>
</Compile>
<Compile Include="IMeasurementCorrection.cs" />
<Compile Include="IOrderInfo.cs" />
<Compile Include="IParamsProvider.cs" />
<Compile Include="IUncertainty.cs" />
<Compile Include="IUser.cs" />
<Compile Include="Printers\PrintersCommon.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="QuitAppException.cs" />
<Compile Include="StatisticalMetrics.cs" />
<Compile Include="Iperl\OptoTelegramRaw.cs" />
<Compile Include="SerializableDictionary.cs" />
<Compile Include="Telegram.cs" />
<Compile Include="UIControls\CoolButtonCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UIControls\CoolButtonCtrl.Designer.cs">
<DependentUpon>CoolButtonCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UIControls\LviDateTimeColumnComparer.cs" />
<Compile Include="UIControls\RoundedRectangle.cs" />
<Compile Include="Units.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\ListViewEx.resx">
<DependentUpon>ListViewEx.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ModelessForm.resx">
<DependentUpon>ModelessForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="UIControls\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UIControls\ListViewExtensions.cs" />
<Compile Include="UIControls\LviIntColumnComparer.cs" />
<Compile Include="UIControls\LviTextColumnComparer.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-12
View File
@@ -1,12 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
namespace Common
{
public static class Const
{
public const string MySqlConnectTimeoutSec = "120";
}
}
-121
View File
@@ -1,121 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Text;
using System.Xml.Serialization;
namespace Common
{
/// <summary>
/// Test bench database settings, contains bench name and settings od several databases
/// </summary>
public class DatabaseSettings : ICloneable, IComparable
{
// Public fields
public string BenchName;
public bool IsRealBench;
public DBSettings ProceduresDBSettings; /// Configuration database settings
public DBSettings WaterMetersDBSettings; /// Results database settings
public DBSettings EventsDBSettings; /// Events database settings
public DBSettings UsersDBSettings; /// Shared configuration database settings
// Constructor
public DatabaseSettings()
{
BenchName = String.Empty; /// Empty string (avoid null)
IsRealBench = false;
ProceduresDBSettings = new DBSettings(DBType.MySql, string.Empty);
WaterMetersDBSettings = new DBSettings(DBType.MySql, string.Empty);
EventsDBSettings = new DBSettings(DBType.MySql, string.Empty);
UsersDBSettings = new DBSettings(DBType.MySql, string.Empty);
}
public object Clone()
{
DatabaseSettings result = new DatabaseSettings();
result.BenchName = BenchName;
result.IsRealBench = IsRealBench;
result.ProceduresDBSettings = (DBSettings)ProceduresDBSettings.Clone();
result.WaterMetersDBSettings = (DBSettings)WaterMetersDBSettings.Clone();
result.EventsDBSettings = (DBSettings)EventsDBSettings.Clone();
result.UsersDBSettings = (DBSettings)UsersDBSettings.Clone();
return result;
}
public int CompareTo(object dbs2)
{
if (!(dbs2 is DatabaseSettings)) return 0;
return String.Compare(BenchName, (dbs2 as DatabaseSettings).BenchName);
}
/// <summary>
/// Extract and return a DB server from a MySQL connection string.
/// </summary>
public static string GetDBServer(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "SERVER=" });
}
/// <summary>
/// Extract and return a DB name from a MySQL connection string.
/// </summary>
public static string GetDBName(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "DATABASE=" });
}
/// <summary>
/// Extract and return a username from a MySQL connection string
/// </summary>
public static string GetDBUser(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "USER=", "UID=" });
}
/// <summary>
/// Extract and return a password from a MySQL connection string
/// </summary>
public static string GetDBPassword(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=", "PWD=" });
}
/// <summary>
/// Extract and return an element of a MySQL connection string
/// (a host, a database, a user name or a password).
/// Return an empty string on any error.
/// </summary>
public static string GetFromConnectionString(string connectionString, string[] patterns)
{
foreach (var pattern in patterns)
{
int startIx = connectionString.IndexOf(pattern);
if (startIx >= 0)
{
/// pattern found, extract the subsequent element
startIx += pattern.Length;
int endIx = connectionString.IndexOf(';', startIx);
return (endIx > 0) ? connectionString.Substring(startIx, endIx - startIx) : string.Empty;
}
}
/// pattern NOT found
return string.Empty;
}
public override string ToString()
{
return string.Format("{0} config={1} results={2} events={3} users={4}",
BenchName,
ProceduresDBSettings.ConnectionString,
WaterMetersDBSettings.ConnectionString,
EventsDBSettings.ConnectionString,
UsersDBSettings.ConnectionString);
}
}
}
+16 -40
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -49,6 +49,15 @@ namespace Common
Count
}
/// <summary> Identifies the database based on the content </summary>
public enum DBKind
{
Config,
Results,
RemoteConfig,
Count
}
public enum ProcedureSelection
{
#if LANG_CS
@@ -61,8 +70,8 @@ namespace Common
[Description("None")] None,
[Description("Local procedures")] FromLocalDB,
[Description("Shared procedures")] FromSharedDB,
[Description("Orders from Oracle DB")] OrderFromOracleDB,
[Description("Orders from Tracing DB")] OrderFromTracingDB,
[Description("Orders from Oracle DB")] OrderNrFromOracleDB,
[Description("Orders from Tracing DB")] OrderNrFromTracingDB,
#endif
Count
}
@@ -94,17 +103,6 @@ namespace Common
}
}
/// <summary>
/// Test designation mode for IperlLogger and IperlHead opto data files
/// </summary>
public enum DesigMode
{
Auto,
Based_on_procedure,
As_specified,
Count
}
public enum LoginMethod
{
UserName, /// = alias, abbreviation
@@ -214,14 +212,6 @@ namespace Common
Count,
}
public enum FlowNames
{
QnQtQmin = 0,
Q3Q2Q1 = 1,
QpQi = 2,
Count,
}
public enum ProfileType
{
Q3R,
@@ -303,13 +293,11 @@ namespace Common
[Description("V")] V, /// vertical
[Description("STR")] S, /// standrohre
[Description("F")] F, /// fall
[Description("H/V")] HV, /// horizontal / vertical
#else
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("S")] S, /// steig
[Description("F")] F, /// fall
[Description("H/V")] HV, /// horizontal / vertical
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("S")] S, /// steig
[Description("F")] F, /// fall
#endif
Count
}
@@ -341,7 +329,6 @@ namespace Common
[Description("")] NotSpecified,
[Description("U0")] U0, /// ?
[Description("D0")] D0, /// ?
///
Count
}
@@ -390,17 +377,6 @@ namespace Common
Count
}
/// <summary>
/// State of water filled in the test bench.
/// </summary>
public enum FillState
{
Unknown, /// Test bench fill state is unknown
Empty, /// Test bench is empty, no water
Full, /// Test bench is full of water
Count
}
public enum MeretProtocol
{
[Description("<undefined>")] Undefined,
-10
View File
@@ -1,10 +0,0 @@
using System;
namespace Common.Forms
{
public class MessageEventArgs : EventArgs
{
public string Message;
public MessageEventArgs(string message) { Message = message; }
}
}
-63
View File
@@ -1,63 +0,0 @@
namespace Common.Forms
{
partial class ModelessForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(47, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// ModelessForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(191, 56);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "ModelessForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ModelessForm";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}
-79
View File
@@ -1,79 +0,0 @@
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Common.Forms
{
public partial class ModelessForm : Form
{
/// <summary>
/// Constructor to be used by the application
/// </summary>
/// <param name="title">Window title</param>
/// <param name="message">Displayed message</param>
public ModelessForm(string message, int backArgb = 0, int textArgb = 0, Font textFont = null, string title = null)
{
InitializeComponent();
ControlBox = false;
label1.Text = (message != null) ? message : "Please wait";
BackColor = (backArgb != 0) ? Color.FromArgb(backArgb) : Color.LightGreen;
ForeColor = (textArgb != 0) ? Color.FromArgb(textArgb) : Color.Black;
label1.Font = (textFont != null) ? textFont : new Font("Arial", 14, FontStyle.Regular);
Text = (title != null) ? title : string.Empty;
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
Width = (int)textWidth + 120; /// Form width calculated from the text width
Height += (int)textHeight; /// Form height calculated from the text height
UpdateMessageHandler += delegate(object sender, MessageEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<MessageEventArgs>(OnUpdateMessage), sender, args); }
else OnUpdateMessage(sender, args);
};
CloseFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }
else OnCloseForm(sender, args);
};
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public void UpdateMessage(MessageEventArgs args)
{
if (UpdateMessageHandler == null) return;
try { UpdateMessageHandler(null, args); }
catch (Exception) { }
}
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
void OnUpdateMessage(object sender, MessageEventArgs args)
{
if (args != null && args.Message != null) label1.Text = args.Message;
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public void CloseForm()
{
if (CloseFormHandler == null) return;
try { CloseFormHandler(null, null); }
catch (Exception) { }
}
public event EventHandler<EventArgs> CloseFormHandler;
void OnCloseForm(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}
-352
View File
@@ -1,352 +0,0 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
namespace Common
{
public static class Formulas
{
private static readonly ILog log = LogManager.GetLogger(typeof(Formulas));
///
/// Wrappers
///
public static double RealDensity() { return GlobalData.SampleDensity; }
public static double AtTemperature() { return GlobalData.SampleTemp; }
public static double Buoyancy() { return GlobalData.Buoyancy; }
/// Private tables with coeficients to calculate specific enthalpy
static readonly int[] Ii;
static readonly int[] Ji;
static readonly double[] ni;
/// Private table with coeficients to calculate temperature of a platinum thermometer
static readonly double[] Di;
/// <summary>
/// Constructor
/// </summary>
static Formulas()
{
///
/// Initialize tables to calculate specific enthalpies
///
Ii = new int[34] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 };
Ji = new int[34] { -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 };
ni = new double[34] {
0.14632971213167, /// 1
-0.84548187169114, /// 2
-0.37563603672040E1, /// 3
0.33855169168385E1, /// 4
-0.95791963387872, /// 5
0.15772038513228, /// 6
-0.16616417199501E-1, /// 7
0.81214629983568E-3, /// 8
0.28319080123804E-3, /// 9
-0.60706301565874E-3, /// 10
-0.18990068218419E-1, /// 11
-0.32529748770505E-1, /// 12
-0.21841717175414E-1, /// 13
-0.52838357969930E-4, /// 14
-0.47184321073267E-3, /// 15
-0.30001780793026E-3, /// 16
0.47661393906987E-4, /// 17
-0.44141845330846E-5, /// 18
-0.72694996297594E-15, /// 19
-0.31679644845054E-4, /// 20
-0.28270797985312E-5, /// 21
-0.85205128120103E-9, /// 22
-0.22425281908000E-5, /// 23
-0.65171222895601E-6, /// 24
-0.14341729937924E-12, /// 25
-0.40516996860117E-6, /// 26
-0.12734301741641E-8, /// 27
-0.17424871230634E-9, /// 28
-0.68762131295531E-18, /// 29
0.14478307828521E-19, /// 30
0.26335781662795E-22, /// 31
-0.11947622640071E-22, /// 32
0.18228094581404E-23, /// 33
-0.93537087292458E-25, /// 34
};
///
/// Initialize a table to calculate temperature of a platinum thermometer from resistance
///
Di = new double[]
{
439.932854,
472.418020,
37.684494,
7.472018,
2.920828,
0.005184,
-0.963864,
-0.188732,
0.191203,
0.049025,
};
}
/// <summary>
/// Calculate density of distilled water from temperature
/// </summary>
/// <param name="t">ITS-90 temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double DistilledWaterDensityFromTemp(double t)
{
if (t <= 40)
{
const double c0 = 999.839564;
const double c1 = 0.067998613;
const double c2 = -0.0091101468;
const double c3 = 0.00010058299;
const double c4 = -0.0000011275659;
const double c5 = 6.5985371e-09;
return ((((c5 * t + c4) * t + c3) * t + c2) * t + c1) * t + c0;
}
else
{
const double a0 = 9.9983952E2;
const double a1 = 1.6952577E1;
const double a2 = -7.9905127E-3;
const double a3 = -4.6241757E-5;
const double a4 = 1.0584601E-7;
const double a5 = -2.8103006E-10;
const double b = 1.6887236E-2;
return (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0) / (1.0 + b * t);
}
}
/// <summary>
/// Calculate density of distilled water from temperature (obsolete)
/// </summary>
/// <param name="t">IPTS-68 temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double DistilledWaterDensityFromTempIPTS68(double t)
{
const double a0 = 999.842594;
const double a1 = 0.06793952;
const double a2 = -0.009095290;
const double a3 = 0.0001001685;
const double a4 = -0.000001120083;
const double a5 = 6.536332e-09;
return ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0;
}
/// <summary>
/// Calculate density by comparing calculated data and data from a certificate
/// </summary>
/// <param name="realDensity">Density from a certificate in [kg/m3]</param>
/// <param name="atTemperature">Temperature from a certificate in [°C]</param>
/// <returns>Density correction in [kg/m3]</returns>
public static double DensityCorrection(double realDensity, double atTemperature)
{
/// Calculated data
double calculatedDensity = DistilledWaterDensityFromTemp(atTemperature);
return realDensity - calculatedDensity;
}
/// <summary>
/// Calculate corrected (real) water density from temperature
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTemp(double t)
{
return DistilledWaterDensityFromTemp(t) + DensityCorrection(RealDensity(), AtTemperature());
}
/// <summary>
/// Calculate corrected (real) water density from temperature
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTempPress(double temp, double pressure)
{
double x0 = 5.08821E-10;
double x1 = 1.2639418;
double x2 = 0.2660269;
double x3 = 0.3734838;
double x4 = 2.0205242;
double theta = temp / 100.0;
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
return WaterDensityFromTemp(temp) * (1 + B * Common.Units.ConvertTo(Common.Unit.Pa, pressure));
}
public static float AirDensityFromAmbientVales(float tempC, float pressureBar, float humiPct)
{
double pressurePa = 100000.0 * (double)pressureBar; /// [Pa]
double tempKelvin = 273.15 + (double)tempC;
double coef1 = 1.2811805 / 10000.0 * tempKelvin * tempKelvin
- 1.950987 / 100.0 * tempKelvin
+ 34.04926034
- 6.353631 * 1000.0 / tempKelvin;
double coef3 = humiPct / 100.0 * System.Math.Exp(coef1) / pressurePa;
double airDensityKgm3 = 0.00348353 * pressurePa * (1.0 - 0.378 * coef3) / tempKelvin; /// kg/m3
return (float)airDensityKgm3;
}
/// <summary>
/// Convert 'pulses' to 'volume', prevent division by zero
/// </summary>
public static double VolumeFromPulses(int pulses, double pulsesPerLiter)
{
if (pulsesPerLiter <= double.Epsilon) return 0;
return Convert.ToDouble(pulses) / pulsesPerLiter;
}
/// <summary>
/// Calculate the error in % from 'measured' and 'true' volume, prevent division by zero
/// </summary>
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
{
if (trueVolume <= float.Epsilon)
{
if (measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
}
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, 99.0);
return 99.0;
}
double error = 100.0 * (measuredVolume - trueVolume) / trueVolume;
log.InfoFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, error);
return error;
}
/// <summary>
/// Converts a measurement error to a correction (used when preparing correction tables).
/// </summary>
/// <param name="measuredValue">Measured value (in arbitrary units)</param>
/// <param name="error">Measurement error in %</param>
/// <returns>Correction in the same units as the measured value</returns>
public static double CorrectionFromError(double measuredValue, double error)
{
double trueValue = measuredValue / (1 + error/100);
double correction = trueValue - measuredValue;
return correction;
}
/// <summary>
/// Calculates the heat coefficient for water
/// </summary>
/// <param name="pressure">Pressure [bar]</param>
/// <param name="T_in">Inlet temperature [°C]</param>
/// <param name="T_out">Outlet temperature [°C]</param>
/// <param name="flowMeasuredAtInlet">true = flow measured @inlet, false = flow measured @outlet</param>
/// <returns> Heat coefficient for water [J/(m3 K)]</returns>
public static double HeatCoefficientWater(double pressure, double T_in, double T_out, bool flowMeasuredAtInlet)
{
if (T_in == T_out) return 0;
const double R = 461.526; /// [J kg^-1 K^-1]
const double p_star_Pa = 16.53E6; /// [Pa] (=16.53 MPa)
const double T_star = 1386.0; /// [K]
double T_in_K = Common.Units.ConvertTo(Common.Unit.K, T_in);
double T_out_K = Common.Units.ConvertTo(Common.Unit.K, T_out);
double tau_in = T_star / T_in_K;
double tau_out = T_star / T_out_K;
double pi = Common.Units.ConvertTo(Common.Unit.Pa, pressure) / p_star_Pa;
double h_in = tau_in * GammaTau(pi, tau_in) * R * T_in_K;
double h_out = tau_out * GammaTau(pi, tau_out) * R * T_out_K;
double ni = flowMeasuredAtInlet ? GammaPi(pi, tau_in) * R * T_in_K / p_star_Pa
: GammaPi(pi, tau_out) * R * T_out_K / p_star_Pa;
return (h_in - h_out) / (ni * (T_in - T_out));
}
/// <summary>
/// gamma(pi) see also STN EN 1434-1 Annex A (A.4)
/// </summary>
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
/// <returns>gamma(pi)</returns>
static double GammaPi(double pi, double tau)
{
double result = 0;
for (int i = 0; i < 34; i++)
{
result -= ni[i] * Ii[i] * Math.Pow(7.1 - pi, Ii[i] - 1) * Math.Pow(tau - 1.222, Ji[i]);
}
return result;
}
/// <summary>
/// gamma(tau) see also STN EN 1434-1 Annex A (A.7)
/// </summary>
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
/// <returns>gamma(tau)</returns>
static double GammaTau(double pi, double tau)
{
double result = 0;
for (int i = 0; i < 34; i++)
{
result += ni[i] * Math.Pow(7.1 - pi, Ii[i]) * Ji[i] * Math.Pow(tau - 1.222, Ji[i] - 1);
}
return result;
}
/// <summary>
/// Conversion of measured resistance of a platinum thermometer to temperature according to ITS-90
/// </summary>
/// <param name="R">Measured resistance in [°C]</param>
/// <param name="R001C">Calibrated resistance in Ohm at 0.01°C</param>
/// <param name="a7">Calibrated ITS-90 coefficient a7</param>
/// <param name="b7">Calibrated ITS-90 coefficient b7</param>
/// <param name="c7">Calibrated ITS-90 coefficient c7</param>
/// <returns>Temperature in [°C]</returns>
public static double PlatinumResistanceTM_ITS90_R2T(double R, double R001C, double a7, double b7, double c7)
{
double w = R / R001C; /// ratio
double r1 = w - 1.0;
double dw = r1 * (a7 + r1 * (b7 + r1 * c7)); /// = a7*r1 + b7*r1^2 + c7*r1^3
double wr = w - dw;
double x = (wr - 2.64) / 1.64;
double sum = 0;
for (int i = Di.Length - 1; i >= 0; i--)
{
sum = sum * x + Di[i];
}
return sum;
}
/// <summary>
/// Conversion of measured resistance of a platinum thermometer to temperature using Callendar-Van Dusen equations
/// </summary>
/// <param name="R">Measured resistance in [°C]</param>
/// <param name="R0">Calibrated resistance in Ohm at 0°C</param>
/// <param name="A">Calibration coefficient a</param>
/// <param name="B">Calibration coefficient b</param>
/// <returns>Temperature in [°C]</returns>
public static double PlatinumResistanceTM_ITS27_R2T(double R, double R0, double A, double B)
{
if (R0 * R0 * A * A - 4 * R0 * B * (R0 - R) <= 0) return 0; /// Out of range
return (-(R0 * A) + Math.Sqrt(R0 * R0 * A * A - 4 * R0 * B * (R0 - R))) / (2 * R0 * B);
}
}
}
-11
View File
@@ -1,11 +0,0 @@
using System;
namespace Common
{
public interface IMeasurementCorrection
{
int RangeIx { get; set; }
double Measurement { get; set; }
double Correction { get; set; }
}
}
-26
View File
@@ -1,26 +0,0 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
namespace Common
{
public interface IOrderInfo
{
string POName { get; }
string VariantCode { get; }
string ModuleParam { get; }
int PiecesCount { get; }
string SNPrefix { get; }
int SNFirst { get; }
int SNDigitsCount { get; }
string SNSuffix { get; }
string RAPrefix { get; }
int RAFirst { get; }
string RASuffix { get; }
string Remark { get; }
int CurrentPcsCount { get; set; }
int CurrentSN { get; set; }
int CurrentRA { get; set; }
}
}
-14
View File
@@ -1,14 +0,0 @@
using System;
namespace Common
{
public interface IUncertainty
{
float Measurement { get; }
float MainUncertainty { get; }
float Resolution { get; }
float DriftPerYr { get; }
float Conditions { get; }
float UncertaintyOfCorrection { get; }
}
}
-22
View File
@@ -1,22 +0,0 @@
using System;
namespace Common
{
public interface IUser
{
string UserName { get; } /// = name, alias, abbreviation
string FullName { get; } /// = description
string Tag { get; }
int Number { get; }
/// Access rights
bool IsMemberOf(GID group);
bool IsMemberOf(GID[] groups);
bool IsCorrectPassword(string password);
/// Password complexity, history, etc.
bool IsPasswordExpired();
bool IsPasswordUsedInPast(string passwordCandidate);
void SetPassword(string password);
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2020-2022")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
@@ -9,7 +9,7 @@ using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Common.Forms
namespace Common.UIControls
{
/// <summary>
/// Event Handler for SubItem events
@@ -61,9 +61,6 @@ namespace Common.Forms
private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
#endregion
public MySortOrder SortOrder = MySortOrder.None;
public int SortColumn = -1;
/// <summary>
/// Required designer variable.
/// </summary>
@@ -427,18 +424,12 @@ namespace Common.Forms
OnSubItemEndEditing(e);
if (_editSubItem >= 0 && _editSubItem < _editItem.SubItems.Count)
{
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
}
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
if (_editingControl != null)
{
_editingControl.Leave -= new EventHandler(_editControl_Leave);
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
_editingControl.Leave -= new EventHandler(_editControl_Leave);
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
_editingControl.Visible = false;
}
_editingControl.Visible = false;
_editingControl = null;
_editItem = null;
+107
View File
@@ -0,0 +1,107 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Common.UIControls
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ListViewExtensions
{
[StructLayout(LayoutKind.Sequential)]
public struct HDITEM
{
public Mask mask;
public int cxy;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszText;
public IntPtr hbm;
public int cchTextMax;
public Format fmt;
public IntPtr lParam;
// _WIN32_IE >= 0x0300
public int iImage;
public int iOrder;
// _WIN32_IE >= 0x0500
public uint type;
public IntPtr pvFilter;
// _WIN32_WINNT >= 0x0600
public uint state;
[Flags]
public enum Mask
{
Format = 0x4, // HDI_FORMAT
};
[Flags]
public enum Format
{
SortDown = 0x200, // HDF_SORTDOWN
SortUp = 0x400, // HDF_SORTUP
};
};
public const int LVM_FIRST = 0x1000;
public const int LVM_GETHEADER = LVM_FIRST + 31;
public const int HDM_FIRST = 0x1200;
public const int HDM_GETITEM = HDM_FIRST + 11;
public const int HDM_SETITEM = HDM_FIRST + 12;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, SortOrder order)
{
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
{
var columnPtr = new IntPtr(columnNumber);
var item = new HDITEM
{
mask = HDITEM.Mask.Format
};
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
if (order != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
item.fmt &= ~HDITEM.Format.SortUp;
item.fmt |= HDITEM.Format.SortDown;
break;
default:
break;
}
}
else
{
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
}
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
}
}
}
}
@@ -1,24 +1,24 @@
///
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.Forms
namespace Common.UIControls
{
public class LviDateTimeColumnComparer : IComparer
{
int column;
MySortOrder order;
SortOrder order;
public LviDateTimeColumnComparer()
{
column = 0;
order = MySortOrder.Ascending;
order = SortOrder.Ascending;
}
public LviDateTimeColumnComparer(int column, MySortOrder order)
public LviDateTimeColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
@@ -33,13 +33,13 @@ namespace Common.Forms
{
return 0;
}
else if ((order == MySortOrder.Descending || order == MySortOrder.Descending2))
else if (order == SortOrder.Ascending)
{
return (valY > valX) ? 1 : -1;
return (valX > valY) ? 1 : -1;
}
else
{
return (valX > valY) ? 1 : -1;
return (valY > valX) ? 1 : -1;
}
}
}
+34
View File
@@ -0,0 +1,34 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.UIControls
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
return (order == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}
@@ -0,0 +1,34 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.UIControls
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
string txtX = ((ListViewItem)x).SubItems[column].Text;
string txtY = ((ListViewItem)y).SubItems[column].Text;
return (order == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}
+1 -92
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.IO.Ports;
@@ -15,97 +15,6 @@ namespace Common
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
}
public static string ToNiceString(double value, int sigDigits)
{
string format = SignificantDigitsToFmt(value, sigDigits);
return (format == "F0") ? value.ToString("F0") : value.ToString(format).TrimEnd(new char[] { '0' });
}
public static FlowNames ProfileType2FlowNames(ProfileType pt)
{
switch (pt)
{
case ProfileType.Q3R: return FlowNames.Q3Q2Q1;
case ProfileType.QnClassColdWater: return FlowNames.QnQtQmin;
case ProfileType.QnClassHotWater: return FlowNames.QnQtQmin;
case ProfileType.QpQi: return FlowNames.QpQi;
default: return FlowNames.Q3Q2Q1;
}
}
public static string SignificantDigitsToFmt(double value, int sigDigits)
{
if (sigDigits == 6)
{
if (value >= 99999.5 || value < -99999.5) return "F0";
else if (value >= 9999.95 || value < -9999.95) return "F1";
else if (value >= 999.995 || value < -999.995) return "F2";
else if (value >= 99.9995 || value < -99.9995) return "F3";
else if (value >= 9.99995 || value < -9.99995) return "F4";
else if (value >= 0.999995 || value < -0.999995) return "F5";
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
else return "F10";
}
else if (sigDigits == 5)
{
if (value >= 9999.5 || value < -9999.5) return "F0";
else if (value >= 999.95 || value < -999.95) return "F1";
else if (value >= 99.995 || value < -99.995) return "F2";
else if (value >= 9.9995 || value < -9.9995) return "F3";
else if (value >= 0.99995 || value < -0.99995) return "F4";
else if (value >= 0.099995 || value < -0.099995) return "F5";
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
else return "F9";
}
else if (sigDigits == 4)
{
if (value >= 999.5 || value < -999.5) return "F0";
else if (value >= 99.95 || value < -99.95) return "F1";
else if (value >= 9.995 || value < -9.995) return "F2";
else if (value >= 0.9995 || value < -0.9995) return "F3";
else if (value >= 0.09995 || value < -0.09995) return "F4";
else if (value >= 0.009995 || value < -0.009995) return "F5";
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
else return "F8";
}
else if (sigDigits == 3)
{
if (value >= 99.5 || value < -99.5) return "F0";
else if (value >= 9.95 || value < -9.95) return "F1";
else if (value >= 0.995 || value < -0.995) return "F2";
else if (value >= 0.0995 || value < -0.0995) return "F3";
else if (value >= 0.00995 || value < -0.00995) return "F4";
else if (value >= 0.000995 || value < -0.000995) return "F5";
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
else return "F7";
}
else if (sigDigits == 2)
{
if (value >= 9.5 || value < -9.5) return "F0";
else if (value >= 0.95 || value < -0.95) return "F1";
else if (value >= 0.095 || value < -0.095) return "F2";
else if (value >= 0.0095 || value < -0.0095) return "F3";
else if (value >= 0.00095 || value < -0.00095) return "F4";
else if (value >= 0.000095 || value < -0.000095) return "F5";
else return "F6";
}
else /// if (sigDigits == 1)
{
if (value >= 0.95 || value < -0.95) return "F0";
else if (value >= 0.095 || value < -0.095) return "F1";
else if (value >= 0.0095 || value < -0.0095) return "F2";
else if (value >= 0.00095 || value < -0.00095) return "F3";
else if (value >= 0.000095 || value < -0.000095) return "F4";
else return "F5";
}
}
public static Parity GetParity(string str, Parity defaultParity = Parity.None)
{
if (str.Equals(Parity.None.ToString())) return Parity.None;
+4 -4
View File
@@ -122,7 +122,7 @@ namespace Config.CalendarEvent
}
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime dateTimeNow)
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime currentDate)
{
DateTime evntDT = evnt.AllDay
? new DateTime(evnt.Date.Year, evnt.Date.Month, evnt.Date.Day, 0, 0, 0)
@@ -133,17 +133,17 @@ namespace Config.CalendarEvent
DateTime dt1 = evntDT;
DateTime dt2 = evntDT + new TimeSpan(8, 0, 0);
DateTime dt3 = evntDT + new TimeSpan(16, 0, 0);
return (dateTimeNow >= dt1) || (dateTimeNow >= dt1) || (dateTimeNow >= dt3);
return (currentDate >= dt1) || (currentDate >= dt1) || (currentDate >= dt3);
}
else if (!evnt.TriggerOnExactDayOnly)
{
/// Trigger after event expires
return (dateTimeNow >= evntDT);
return (currentDate >= evntDT);
}
else
{
/// Trigger event on exact date only
return (dateTimeNow >= evntDT) && DayMatchesExactly(evnt, dateTimeNow);
return (currentDate >= evntDT) && DayMatchesExactly(evnt, currentDate);
}
}
+5 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEBUG;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -30,7 +30,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH</DefineConstants>
<DefineConstants>TRACE;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
@@ -69,6 +69,7 @@
<ItemGroup>
<Compile Include="CalendarEvent\ICalendarEvent.cs" />
<Compile Include="Data.cs" />
<Compile Include="DatabaseSettings.cs" />
<Compile Include="Entities\BenchPath.cs" />
<Compile Include="Entities\CustomEvent.cs" />
<Compile Include="Entities\Component.cs" />
@@ -80,6 +81,7 @@
<Compile Include="Entities\IHasItemNr.cs" />
<Compile Include="Entities\IHasName.cs" />
<Compile Include="Entities\IHasValves.cs" />
<Compile Include="Entities\IParamsProvider.cs" />
<Compile Include="Entities\MeasurementCorrection.cs" />
<Compile Include="Entities\MetersPath.cs" />
<Compile Include="Entities\OutputPath.cs" />
@@ -122,6 +124,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="Units.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
+2 -8
View File
@@ -2,7 +2,7 @@
namespace Config
{
public class Data : Users.CurrentUser
public class Data : Users.GlobalData
{
public const string AdminUsername = "admin";
public const string AdminPassword = "staratura";
@@ -26,7 +26,7 @@ namespace Config
public const int CompoundWMsCount = 0;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 1;
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50 || TURA_SPECIAL
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
@@ -44,12 +44,6 @@ namespace Config
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_SPECIAL
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif DEWA_300 || FUZHOU_100 || ROMA_200 || LUXEMBURG_40
public const int WMsCount = 10;
public const int LineSize = 10;
+64
View File
@@ -0,0 +1,64 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Text;
using System.Xml.Serialization;
namespace Config
{
/// <summary>
/// Test bench database settings, contains bench name and settings od several databases
/// </summary>
public class DatabaseSettings : ICloneable, IComparable
{
// Public fields
public string BenchName;
public bool IsRealBench;
public Users.DBSettings ProceduresDBSettings; /// Configuration database settings
public Users.DBSettings WaterMetersDBSettings; /// Results database settings
public Users.DBSettings EventsDBSettings; /// Events database settings
public Users.DBSettings UsersDBSettings; /// Shared configuration database settings
// Constructor
public DatabaseSettings()
{
BenchName = String.Empty; /// Empty string (avoid null)
IsRealBench = false;
ProceduresDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty);
WaterMetersDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty);
EventsDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty);
UsersDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty);
}
public object Clone()
{
DatabaseSettings result = new DatabaseSettings();
result.BenchName = BenchName;
result.IsRealBench = IsRealBench;
result.ProceduresDBSettings = (Users.DBSettings)ProceduresDBSettings.Clone();
result.WaterMetersDBSettings = (Users.DBSettings)WaterMetersDBSettings.Clone();
result.EventsDBSettings = (Users.DBSettings)EventsDBSettings.Clone();
result.UsersDBSettings = (Users.DBSettings)UsersDBSettings.Clone();
return result;
}
public int CompareTo(object dbs2)
{
if (!(dbs2 is DatabaseSettings)) return 0;
return String.Compare(BenchName, (dbs2 as DatabaseSettings).BenchName);
}
public override string ToString()
{
return string.Format("{0} config={1} results={2} events={3} users={4}",
BenchName,
ProceduresDBSettings.ConnectionString,
WaterMetersDBSettings.ConnectionString,
EventsDBSettings.ConnectionString,
UsersDBSettings.ConnectionString);
}
}
}
+2 -8
View File
@@ -1,9 +1,8 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using Common;
namespace Config.Entities
{
@@ -15,7 +14,6 @@ namespace Config.Entities
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
public virtual string Selector { get; set; }
public virtual string TempMtrUp { get; set; }
public virtual string TempMtrDown { get; set; }
@@ -28,16 +26,13 @@ namespace Config.Entities
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
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
/// ------------- Additional stuff not mapped into the database -------------
public BenchPath()
{
ValvesOpen = string.Empty;
ValvesClose = string.Empty;
}
}
public BenchPath(string name, int itemNr)
: this()
@@ -52,7 +47,6 @@ namespace Config.Entities
result.Qfrom = Qfrom;
result.Qto = Qto;
result.FlowUnit = FlowUnit;
result.Selector = Selector;
result.TempMtrUp = TempMtrUp;
result.TempMtrDown = TempMtrDown;
-1
View File
@@ -3,7 +3,6 @@
///
using System;
using System.IO;
using Common;
namespace Config.Entities
{
-1
View File
@@ -3,7 +3,6 @@
///
using System;
using System.IO;
using Common;
namespace Config.Entities
{
+2 -2
View File
@@ -46,8 +46,8 @@ namespace Config.Entities
Rank = 2;
Hidden = false;
ReadOnly = false;
BackColor = unchecked((int)0xFFFF5050); /// (MSB)AARRGGBB(LSB) ... pink
TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
BackColor = unchecked((int)0xFFFF5050);
TextColor = unchecked((int)0xFFFFFFFF);
TooltipEnabled = true;
CustomRecurringFunction = null;
}
+12 -17
View File
@@ -1,21 +1,19 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using Common;
namespace Config.Entities
{
public class FeedingPath : IHasName, IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string Selector { get; set; }
public virtual string Pump { get; set; }
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
@@ -24,9 +22,6 @@ namespace Config.Entities
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
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
/// ------------- Additional stuff not mapped into the database -------------
public FeedingPath()
@@ -46,14 +41,14 @@ namespace Config.Entities
{
FeedingPath result = new FeedingPath(name, itemNr);
result.Qfrom = Qfrom;
result.Qto = Qto;
result.FlowUnit = FlowUnit;
result.Selector = Selector;
result.Pump = Pump;
result.Qfrom = Qfrom;
result.Qto = Qto;
result.Selector = Selector;
result.Pump = Pump;
result.RegulValvesPct = RegulValvesPct;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
@@ -1,11 +1,12 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
namespace Common
namespace Config.Entities
{
public interface IParamsProvider
{
+5 -69
View File
@@ -1,17 +1,16 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class MeasurementCorrection : Common.IMeasurementCorrection, IComparable<MeasurementCorrection>
public class MeasurementCorrection
{
public virtual int Id { get; protected set; }
public virtual int RangeIx { get; set; } /// 0..5
public virtual double Measurement { get; set; }
public virtual double Correction { get; set; }
public virtual float Measurement { get; set; }
public virtual float Correction { get; set; }
public MeasurementCorrection()
{
@@ -22,68 +21,5 @@ namespace Config.Entities
{
RangeIx = rangeIx;
}
public virtual int CompareTo(MeasurementCorrection other)
{
return (Measurement > other.Measurement) ? 1 : ((Measurement == other.Measurement) ? 0 : -1);
}
/// <summary>
/// Calculates corrected value from a list of corrections by interpolation.
/// It is assumed that values in the list 'corrections' are sorted.
/// </summary>
/// <param name="rawMeasurement">Raw uncorrected value</param>
/// <param name="corrections">Sorted (value, correction) pairs</param>
/// <returns>Corrected value</returns>
public static double CorrectedValue(double rawValue, IList<MeasurementCorrection> corrections)
{
return rawValue + GetCorrection(rawValue, corrections);
}
/// <summary>
/// Get a correction from a list of corrections by interpolation.
/// It is assumed that values in the list 'corrections' are sorted.
/// </summary>
/// <param name="rawMeasurement">Raw uncorrected value</param>
/// <param name="corrections">Sorted (value, correction) pairs</param>
/// <returns>Corrected value</returns>
public static double GetCorrection(double rawValue, IList<MeasurementCorrection> corrections)
{
if ((corrections == null) || (corrections.Count == 0)) return 0; /// No correction
if (rawValue < corrections[0].Measurement)
{
/// rawValue is below the lowest value in the correction table
return corrections[0].Correction;
}
for (int i = 1; i < corrections.Count; i++)
{
if (rawValue < corrections[i].Measurement)
{
double d1 = rawValue - corrections[i - 1].Measurement;
double d2 = corrections[i].Measurement - rawValue;
if (d1 + d2 <= float.Epsilon)
{
/// Neigboring values in the corection table are close to each other -> calculate the average
return (corrections[i - 1].Correction + corrections[i].Correction) / 2.0;
}
else
{
/// Interpolate the correction from neigboring values in the corection table
return (corrections[i - 1].Correction * d2 + corrections[i].Correction * d1) / (d1 + d2);
}
}
}
/// rawValue is above the highest value in the correction table
return corrections[corrections.Count - 1].Correction;
}
public override string ToString()
{
return string.Format("{0} {1} ({2})", Measurement, Correction, RangeIx);
}
}
}
}
+20 -26
View File
@@ -1,25 +1,23 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using Common;
namespace Config.Entities
{
public class OutputPath : IHasName, IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string Selector { get; set; }
public virtual string RegulValve { get; set; }
public virtual string FlowMeter { get; set; }
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
public virtual string StartValve { get; set; }
public virtual string Diverter { get; set; }
public virtual string TempDiv { get; set; }
@@ -30,16 +28,13 @@ namespace Config.Entities
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
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
/// ------------- Additional stuff not mapped into the database -------------
public OutputPath()
{
ValvesOpen = string.Empty;
ValvesClose = string.Empty;
}
}
public OutputPath(string name, int itemNr)
: this()
@@ -52,21 +47,20 @@ namespace Config.Entities
{
OutputPath result = new OutputPath(name, itemNr);
result.Name = Name;
result.Qfrom = Qfrom;
result.Qto = Qto;
result.FlowUnit = FlowUnit;
result.Selector = Selector;
result.RegulValve = RegulValve;
result.FlowMeter = FlowMeter;
result.PidCoef = PidCoef;
result.StartValve = StartValve;
result.Diverter = Diverter;
result.TempDiv = TempDiv;
result.Scale = Scale;
result.Name = Name;
result.Qfrom = Qfrom;
result.Qto = Qto;
result.Selector = Selector;
result.RegulValve = RegulValve;
result.FlowMeter = FlowMeter;
result.PidCoef = PidCoef;
result.StartValve = StartValve;
result.Diverter = Diverter;
result.TempDiv = TempDiv;
result.Scale = Scale;
result.RegulValvesPct = RegulValvesPct;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
+3 -27
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
@@ -27,7 +27,6 @@ namespace Config.Entities
public virtual double PressLimHi { get; set; } /// [bar] max. water pressure
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool Evaluate { get; set; }
public virtual string Method { get; set; } /// Test method (component name)
public virtual sbyte E1 { get; set; } ///
public virtual sbyte E2 { get; set; } ///
@@ -82,7 +81,6 @@ namespace Config.Entities
PressLimHi = 16.0; /// [bar]
Publish = (sbyte)Common.Publish.Always;
Evaluate = true;
Method = string.Empty;
E1 = (sbyte)ErrorFlagsMode.On;
E2 = (sbyte)ErrorFlagsMode.On;
@@ -142,7 +140,6 @@ namespace Config.Entities
result.PressLimHi = PressLimHi;
result.Publish = Publish;
result.Evaluate = Evaluate;
result.Method = Method;
result.E1 = E1;
result.E2 = E2;
@@ -196,7 +193,6 @@ namespace Config.Entities
output.WriteLine(PressLimHi.ToString(ci));
output.WriteLine(Publish.ToString());
output.WriteLine(Evaluate.ToString());
output.WriteLine(Method);
output.WriteLine(E1.ToString());
output.WriteLine(E2.ToString());
@@ -251,29 +247,10 @@ namespace Config.Entities
tst.ErrLimHi = double.Parse(input.ReadLine(), ci);
tst.TempLimLo = double.Parse(input.ReadLine(), ci);
tst.TempLimHi = double.Parse(input.ReadLine(), ci);
tst.PressLimLo = double.Parse(input.ReadLine(), ci);
tst.PressLimHi = double.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine());
tst.Evaluate = bool.Parse(input.ReadLine());
tst.Method = input.ReadLine();
tst.E1 = sbyte.Parse(input.ReadLine(), ci);
tst.E2 = sbyte.Parse(input.ReadLine(), ci);
tst.E3 = sbyte.Parse(input.ReadLine(), ci);
tst.E4 = sbyte.Parse(input.ReadLine(), ci);
tst.E5 = sbyte.Parse(input.ReadLine(), ci);
tst.E6 = sbyte.Parse(input.ReadLine(), ci);
tst.E7 = sbyte.Parse(input.ReadLine(), ci);
tst.E8 = sbyte.Parse(input.ReadLine(), ci);
tst.E9 = sbyte.Parse(input.ReadLine(), ci);
tst.E10 = sbyte.Parse(input.ReadLine(), ci);
tst.E11 = sbyte.Parse(input.ReadLine(), ci);
tst.E12 = sbyte.Parse(input.ReadLine(), ci);
tst.E13 = sbyte.Parse(input.ReadLine(), ci);
tst.E14 = sbyte.Parse(input.ReadLine(), ci);
tst.E15 = sbyte.Parse(input.ReadLine(), ci);
tst.E16 = sbyte.Parse(input.ReadLine(), ci);
tst.E21 = sbyte.Parse(input.ReadLine(), ci);
/// TODO (E1 .. E21)
tst.Delta_Q_pct = double.Parse(input.ReadLine(), ci);
tst.Delta_T = double.Parse(input.ReadLine(), ci);
@@ -316,7 +293,6 @@ namespace Config.Entities
ln = inp.ReadLine(); if (ln != PressLimHi.ToString(ci)) { diff.AppendFormat(fmt, "Pressure_max", PressLimHi.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Publish.ToString()) { diff.AppendFormat(fmt, "Publish", Publish.ToString(), ln); };
ln = inp.ReadLine(); if (ln != Evaluate.ToString()) { diff.AppendFormat(fmt, "Evaluate", Evaluate.ToString(), ln); };
ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); };
ln = inp.ReadLine(); if (ln != E1.ToString()) { diff.AppendFormat(fmt, "E1", E1.ToString(), ln); };
ln = inp.ReadLine(); if (ln != E2.ToString()) { diff.AppendFormat(fmt, "E2", E2.ToString(), ln); };
+2 -2
View File
@@ -47,7 +47,7 @@ namespace Config.Entities
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
public virtual float DN { get; set; } /// Not mapped to DB, valid in ProceduresCtrl for procedure filtering only
public virtual double Qn { get; set; } /// - ' ' -
public virtual float Qn { get; set; } /// - ' ' -
public virtual string MClass { get; set; } /// - ' ' -
public virtual string Producer { get; set; } /// - ' ' -
@@ -75,7 +75,7 @@ namespace Config.Entities
///
/// Default values
///
CreationUser = Users.CurrentUser.UserName();
CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
CreationTime = DateTime.Now;
LastChgUser = CreationUser;
LastChgTime = CreationTime;
+2 -5
View File
@@ -36,7 +36,7 @@ namespace Config.Entities
///
/// Default values
///
CreationUser = Users.CurrentUser.UserName();
CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
CreationTime = DateTime.Now;
LastChgUser = CreationUser;
LastChgTime = CreationTime;
@@ -78,8 +78,6 @@ namespace Config.Entities
output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(LastChgUser);
output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(((sbyte)ProfileType).ToString());
output.WriteLine(((sbyte)ErrorLimitType).ToString());
foreach (var test in Tests) { test.Export(output); }
output.WriteLine();
@@ -98,8 +96,7 @@ namespace Config.Entities
result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.LastChgUser = input.ReadLine();
result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.ProfileType = (ProfileType)sbyte.Parse(input.ReadLine());
result.ErrorLimitType = (ErrorLimitType)sbyte.Parse(input.ReadLine());
string line = input.ReadLine();
while (true)
{
+38 -112
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -22,11 +22,11 @@ namespace Config.Entities
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
public virtual bool DoEvaluate { get; set; }
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]
public virtual float Qtg { get; set; } /// Target water flow [m3/h]
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual float Volume { get; set; } /// Test volume (target) in [l]
public virtual float TestTime { get; set; } /// Test time (estimate) in [s]
public virtual string Method { get; set; }
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
@@ -34,10 +34,10 @@ namespace Config.Entities
public virtual int Repeats { get; set; }
public virtual bool DoDraining { get; set; }
public virtual bool DoDrainingAfter { get; set; }
public virtual bool DoControlWaterTemp { get; set; }
public virtual float TempLimLo { get; set; } /// Lower limit for the controlled temperature
public virtual float TempLimHi { get; set; } /// Upper limit for the controlled temperature
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
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
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
@@ -57,29 +57,9 @@ namespace Config.Entities
public virtual string TransBefore { get; set; }
public virtual string TransBetween { get; set; }
public virtual string TransAfter { get; set; }
#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
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
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
public virtual IList<ComponentTest> MoreParams { get; set; }
@@ -98,36 +78,28 @@ namespace Config.Entities
Profile = TestProfile.UserDefined;
Publish = (sbyte)Common.Publish.Always;
DoEvaluate = true;
ErrLimLo = -2.0f; /// [%] lower error limit
ErrLimHi = 2.0f; /// [%] upper error limit
Uncertainty = 0;
Repeats = 1;
Repeats = 1;
DoDraining = false;
DoDrainingAfter = false;
DoControlWaterTemp = false;
TempLimLo = 15.0f;
TempLimHi = 25.0f;
TempControl = string.Empty;
ErrLimLo = -2.0f; /// [%] lower error limit
ErrLimHi = 2.0f; /// [%] upper error limit
Uncertainty = 0;
PumpPower = 60.0f; /// [%]
MassRepeats = 0; /// default
MassSpread = 0; /// default
MassMethod = MassMethod.Scale; /// default
MassMethod = MassMethod.Scale; /// default
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
ShortPulses = 0; /// Short pulses parameter (0 or 1)
TransBefore = string.Empty;
ShortPulses = 0; /// = Filter parameter
TransBefore = string.Empty;
TransBetween = string.Empty;
TransAfter = string.Empty;
#if ORACLE_DB
OraId = 0;
OraIdRepetMulti = 0;
OraDesignation = string.Empty;
RawDataId = 0;
RawDataIdRepetMulti = 0;
RawDataDesignation = string.Empty;
#endif
}
}
public Test(string name, int itemNr, Procedure procedure)
: this()
@@ -153,16 +125,6 @@ namespace Config.Entities
return autoTests.Contains(action);
}
public virtual void ResetChngdFlags()
{
QtgTextChngd = false;
QfromTextChngd = false;
QtoTextChngd = false;
VolumeTextChngd = false;
TempLimLoTextChngd = false;
TempLimHiTextChngd = false;
}
// Makes a new copy of this object (not just a reference)
public virtual Test Clone()
{
@@ -184,10 +146,10 @@ namespace Config.Entities
result.Repeats = Repeats;
result.DoDraining = DoDraining;
result.DoDrainingAfter = DoDrainingAfter;
result.DoControlWaterTemp = DoControlWaterTemp;
result.TempLimLo = TempLimLo;
result.TempLimHi = TempLimHi;
result.TempControl = TempControl;
result.PumpPower = PumpPower;
result.PumpPower = PumpPower;
result.MassRepeats = MassRepeats;
result.MassSpread = MassSpread;
result.MassMethod = MassMethod;
@@ -207,21 +169,7 @@ namespace Config.Entities
result.TransBefore = TransBefore;
result.TransBetween = TransBetween;
result.TransAfter = TransAfter;
#if ORACLE_DB
result.OraId = OraId;
result.OraIdRepetMulti = OraIdRepetMulti;
result.OraDesignation = OraDesignation;
result.RawDataId = RawDataId;
result.RawDataIdRepetMulti = RawDataIdRepetMulti;
result.RawDataDesignation = RawDataDesignation;
#endif
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()); }
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
return result;
}
@@ -246,10 +194,10 @@ namespace Config.Entities
output.WriteLine(Repeats.ToString(ci));
output.WriteLine(DoDraining.ToString());
output.WriteLine(DoDrainingAfter.ToString());
output.WriteLine(DoControlWaterTemp.ToString());
output.WriteLine(TempLimLo.ToString(ci));
output.WriteLine(TempLimHi.ToString(ci));
output.WriteLine((TempControl != null) ? TempControl : string.Empty);
output.WriteLine(PumpPower.ToString(ci));
output.WriteLine(PumpPower.ToString(ci));
output.WriteLine(MassRepeats.ToString(ci));
output.WriteLine(MassSpread.ToString(ci));
output.WriteLine(((byte)MassMethod).ToString(ci));
@@ -265,14 +213,7 @@ namespace Config.Entities
output.WriteLine(TransBetween);
output.WriteLine(Profile);
output.WriteLine(TransAfter);
#if ORACLE_DB
output.WriteLine(OraId);
output.WriteLine(OraIdRepetMulti);
output.WriteLine(OraDesignation);
output.WriteLine(RawDataId);
output.WriteLine(RawDataIdRepetMulti);
output.WriteLine(RawDataDesignation);
#endif
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
}
@@ -292,11 +233,11 @@ namespace Config.Entities
tst.Part = int.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.DoEvaluate = bool.Parse(input.ReadLine());
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);
tst.Qtg = float.Parse(input.ReadLine(), ci);
tst.Qfrom = float.Parse(input.ReadLine(), ci);
tst.Qto = float.Parse(input.ReadLine(), ci);
tst.Volume = float.Parse(input.ReadLine(), ci);
tst.TestTime = float.Parse(input.ReadLine(), ci);
tst.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);
@@ -304,10 +245,10 @@ namespace Config.Entities
tst.Repeats = int.Parse(input.ReadLine(), ci);
tst.DoDraining = bool.Parse(input.ReadLine());
tst.DoDrainingAfter = bool.Parse(input.ReadLine());
tst.DoControlWaterTemp = bool.Parse(input.ReadLine());
tst.TempLimLo = float.Parse(input.ReadLine(), ci);
tst.TempLimHi = float.Parse(input.ReadLine(), ci);
tst.TempControl = input.ReadLine();
tst.PumpPower = float.Parse(input.ReadLine(), ci);
tst.PumpPower = float.Parse(input.ReadLine(), ci);
tst.MassRepeats = int.Parse(input.ReadLine(), ci);
tst.MassSpread = float.Parse(input.ReadLine(), ci);
tst.MassMethod = (MassMethod)byte.Parse(input.ReadLine(), ci);
@@ -326,14 +267,6 @@ namespace Config.Entities
: line.Equals(TestProfile.UserDefinedHeatMeter.ToString()) ? TestProfile.UserDefinedHeatMeter
: line.Equals(TestProfile.Protected.ToString()) ? TestProfile.Protected : TestProfile.UserDefined; /// UserDefined is the default
tst.TransAfter = input.ReadLine();
#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
while (true)
{
@@ -374,9 +307,9 @@ namespace Config.Entities
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); };
ln = inp.ReadLine(); if (ln != DoDrainingAfter.ToString(ci)) { diff.AppendFormat(fmt, "Zeroing", DoDrainingAfter.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != DoControlWaterTemp.ToString()) { diff.AppendFormat(fmt, "DoControlWaterTemp", DoControlWaterTemp.ToString(ci), ln); };
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); };
ln = inp.ReadLine(); if (ln != TempControl) { diff.AppendFormat(fmt, "TempController", TempControl, ln); };
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); };
@@ -389,18 +322,11 @@ namespace Config.Entities
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); };
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); };
#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
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); };
return diff.ToString();
}
+2 -2
View File
@@ -1,11 +1,11 @@
///
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
namespace Config.Entities
{
public class Uncertainty : Common.IUncertainty
public class Uncertainty
{
public virtual int Id { get; protected set; }
public virtual float Measurement { get; set; }
+138
View File
@@ -1,10 +1,148 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Config.Resources;
namespace Config
{
public static class FluentCommon
{
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(Common.DBKind database, Common.DBType dbType, string connectionString, bool createDB)
{
try
{
FluentConfiguration cfg = Fluently.Configure();
switch (dbType)
{
default:
case Common.DBType.SQLite:
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
break;
case Common.DBType.MySql:
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
break;
}
switch (database)
{
default:
case Common.DBKind.Config:
case Common.DBKind.RemoteConfig:
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
break;
case Common.DBKind.Results:
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
break;
}
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
}
}
catch (Exception exc)
{
MessageBox.Show(string.Format(Strings.Cannot_open_DB_Cause_0, exc.Message),
Strings.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return null;
}
}
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);
}
/// <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 CreateEmptyConfigDB(Common.DBType dbType, string connectionString)
{
ISessionFactory sessionFactory = CreateSessionFactory(Common.DBKind.Config, dbType, connectionString, true);
if (sessionFactory == null) return false;
/// Populate the database
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
///
/// Create user 'admin'
///
var admin = new Config.Entities.User
{
UserName = Data.AdminUsername,
FullName = Strings.Administrator,
LastPwChange = DateTime.Now
};
admin.SetPassword(Data.AdminPassword);
///
/// Prepare all groups, add some of them to admin
///
for (Common.GID gid = 0; gid < Common.GID.NrOfGroups; gid++)
{
Config.Entities.Group group = new Config.Entities.Group(gid);
switch (gid)
{
case Common.GID.Testers:
case Common.GID.TestingSpecialists:
case Common.GID.HeadOfLab:
case Common.GID.MaintenanceSpecialists:
case Common.GID.Metrologists:
case Common.GID.CalibrationSpecialists:
case Common.GID.Administrators:
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
case Common.GID.TraceabilityManagement:
#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END
case Common.GID.MetrologicalAuthority:
case Common.GID.WaterMeterAuthority:
#endif
admin.AddGroup(group);
session.SaveOrUpdate(group); /// Save this group
break;
}
}
session.SaveOrUpdate(admin); /// Save user 'admin'
transaction.Commit();
}
}
return true;
}
}
}
+8 -9
View File
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using log4net;
using Common;
namespace Config
{
@@ -183,7 +182,7 @@ namespace Config
double theta = temp / 100.0;
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
return WaterDensityFromTemp(temp) * (1 + B * Units.ConvertTo(Unit.Pa, pressure));
return WaterDensityFromTemp(temp) * (1 + B * Config.Units.ConvertTo(Config.Unit.Pa, pressure));
}
@@ -214,9 +213,9 @@ namespace Config
/// </summary>
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
{
if (-float.Epsilon <= trueVolume && trueVolume <= float.Epsilon)
if (trueVolume <= float.Epsilon)
{
if (-float.Epsilon <= measuredVolume && measuredVolume <= float.Epsilon)
if (measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
@@ -239,7 +238,7 @@ namespace Config
/// <param name="rawMeasurement">Raw uncorrected value</param>
/// <param name="corrections">Sorted (value, correction) pairs</param>
/// <returns>Corrected value</returns>
public static double CorrectedValue(double rawValue, IList<IMeasurementCorrection> corrections)
public static double CorrectedValue(double rawValue, IList<Config.Entities.MeasurementCorrection> corrections)
{
return rawValue + GetCorrection(rawValue, corrections);
}
@@ -251,7 +250,7 @@ namespace Config
/// <param name="rawMeasurement">Raw uncorrected value</param>
/// <param name="corrections">Sorted (value, correction) pairs</param>
/// <returns>Corrected value</returns>
public static double GetCorrection(double rawValue, IList<IMeasurementCorrection> corrections)
public static double GetCorrection(double rawValue, IList<Config.Entities.MeasurementCorrection> corrections)
{
if ((corrections == null) || (corrections.Count == 0)) return 0; /// No correction
@@ -317,11 +316,11 @@ namespace Config
const double p_star_Pa = 16.53E6; /// [Pa] (=16.53 MPa)
const double T_star = 1386.0; /// [K]
double T_in_K = Units.ConvertTo(Unit.K, T_in);
double T_out_K = Units.ConvertTo(Unit.K, T_out);
double T_in_K = Config.Units.ConvertTo(Config.Unit.K, T_in);
double T_out_K = Config.Units.ConvertTo(Config.Unit.K, T_out);
double tau_in = T_star / T_in_K;
double tau_out = T_star / T_out_K;
double pi = Units.ConvertTo(Unit.Pa, pressure) / p_star_Pa;
double pi = Config.Units.ConvertTo(Config.Unit.Pa, pressure) / p_star_Pa;
double h_in = tau_in * GammaTau(pi, tau_in) * R * T_in_K;
double h_out = tau_out * GammaTau(pi, tau_out) * R * T_out_K;
+2 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,8 +15,7 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Selector);
Map(x => x.TempMtrUp).Column("TempIn");
Map(x => x.TempMtrUp).Column("TempIn");
Map(x => x.TempMtrDown).Column("TempOut");
Map(x => x.PressMtrUp).Column("PressIn");
Map(x => x.PressMtrDown).Column("PressOut");
+2 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,8 +15,7 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Selector);
Map(x => x.Pump);
Map(x => x.Pump);
Map(x => x.RegulValvesPct);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
+2 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,8 +15,7 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Selector);
Map(x => x.RegulValve);
Map(x => x.RegulValve);
Map(x => x.FlowMeter);
Map(x => x.PidCoef);
Map(x => x.StartValve);
-1
View File
@@ -24,7 +24,6 @@ namespace Config.Mappings
Map(x => x.PressLimHi);
Map(x => x.Publish);
Map(x => x.Evaluate);
Map(x => x.Method);
Map(x => x.E1);
Map(x => x.E2);
Map(x => x.E3);
+3 -11
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -29,10 +29,10 @@ namespace Config.Mappings
.Column("Emptying");
Map(x => x.DoDrainingAfter)
.Column("Zeroing");
Map(x => x.DoControlWaterTemp);
Map(x => x.TempLimLo);
Map(x => x.TempLimHi);
Map(x => x.TempControl);
Map(x => x.PumpPower);
Map(x => x.PumpPower);
Map(x => x.MassRepeats);
Map(x => x.MassSpread);
Map(x => x.MassMethod)
@@ -62,14 +62,6 @@ namespace Config.Mappings
.Column("RelTransBetween");
Map(x => x.TransAfter)
.Column("TransitionAfter");
#if ORACLE_DB
Map(x => x.OraId);
Map(x => x.OraIdRepetMulti);
Map(x => x.OraDesignation);
Map(x => x.RawDataId);
Map(x => x.RawDataIdRepetMulti);
Map(x => x.RawDataDesignation);
#endif
HasMany(x => x.MoreParams)
.Cascade.All();
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("Config")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2018 Sensus Slovensko a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.31.1990.0")]
[assembly: AssemblyFileVersion("2.31.1990.0")]
[assembly: AssemblyVersion("2.26.1519.0")]
[assembly: AssemblyFileVersion("2.26.1519.0")]
+27 -51
View File
@@ -2,8 +2,11 @@
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
///
using System;
using System.Reflection;
using Common;
using Config.Entities;
namespace Common
namespace Config
{
public enum Unit
{
@@ -245,14 +248,14 @@ namespace Common
unit == Unit.J || unit == Unit.uSpcm || unit == Unit.ppl || unit == Unit.ppkWh;
}
public static bool IsQuantity(Unit unit, Quantity quantity)
public static bool IsQuantity(Unit units, Quantity quantity)
{
return (quantity == GetQuantity(unit));
return (quantity == GetQuantity(units));
}
public static Quantity GetQuantity(Unit unit)
public static Quantity GetQuantity(Unit units)
{
switch (unit)
switch (units)
{
case Unit.pulse:
case Unit.degree:
@@ -357,32 +360,26 @@ namespace Common
}
}
public static bool IsVolume(Unit unit) { return IsQuantity(unit, Quantity.Volume); }
public static bool IsFlow(Unit unit) { return IsQuantity(unit, Quantity.Flow); }
public static bool IsMass(Unit unit) { return IsQuantity(unit, Quantity.Mass); }
public static bool IsTime(Unit unit) { return IsQuantity(unit, Quantity.Time); }
public static bool IsTemperature(Unit unit) { return IsQuantity(unit, Quantity.Temperature); }
public static bool IsPressure(Unit unit) { return IsQuantity(unit, Quantity.Pressure); }
public static bool IsHumidity(Unit unit) { return IsQuantity(unit, Quantity.Humidity); }
public static bool IsError(Unit unit) { return IsQuantity(unit, Quantity.Error); }
public static bool IsLength(Unit unit) { return IsQuantity(unit, Quantity.Length); }
public static bool IsDensity(Unit unit) { return IsQuantity(unit, Quantity.Density); }
public static bool IsEnergy(Unit unit) { return IsQuantity(unit, Quantity.Energy); }
public static bool IsPulses(Unit unit) { return IsQuantity(unit, Quantity.Pulses); }
public static bool IsPulsePerLtr(Unit unit) { return IsQuantity(unit, Quantity.PulsePerLtr); }
public static bool IsPulsePerKWh(Unit unit) { return IsQuantity(unit, Quantity.PulsePerKWh); }
public static bool IsConductivity(Unit unit) { return IsQuantity(unit, Quantity.Conductivity); }
public static bool IsVolume(Unit units) { return IsQuantity(units, Config.Quantity.Volume); }
public static bool IsFlow(Unit units) { return IsQuantity(units, Config.Quantity.Flow); }
public static bool IsMass(Unit units) { return IsQuantity(units, Config.Quantity.Mass); }
public static bool IsTime(Unit units) { return IsQuantity(units, Config.Quantity.Time); }
public static bool IsTemperature(Unit units) { return IsQuantity(units, Config.Quantity.Temperature); }
public static bool IsPressure(Unit units) { return IsQuantity(units, Config.Quantity.Pressure); }
public static bool IsHumidity(Unit units) { return IsQuantity(units, Config.Quantity.Humidity); }
public static bool IsError(Unit units) { return IsQuantity(units, Config.Quantity.Error); }
public static bool IsLength(Unit units) { return IsQuantity(units, Config.Quantity.Length); }
public static bool IsDensity(Unit units) { return IsQuantity(units, Config.Quantity.Density); }
public static bool IsEnergy(Unit units) { return IsQuantity(units, Config.Quantity.Energy); }
public static bool IsPulses(Unit units) { return IsQuantity(units, Config.Quantity.Pulses); }
public static bool IsPulsePerLtr(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerLtr); }
public static bool IsPulsePerKWh(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerKWh); }
public static bool IsConductivity(Unit units) { return IsQuantity(units, Config.Quantity.Conductivity); }
public static float ConvertTo(Unit unit, float v)
public static double ConvertTo(Unit units, double v)
{
return (float)ConvertTo(unit, (double)v);
}
public static double ConvertTo(Unit unit, double v)
{
switch (unit)
switch (units)
{
/// Volume: internal representation in l
case Unit.ml: return 1000 * v; /// 1 ml = 0.001 l
@@ -460,15 +457,9 @@ namespace Common
}
}
public static float ConvertFrom(Unit unit, float v)
public static double ConvertFrom(Unit units, double v)
{
return (float)ConvertFrom(unit, (double)v);
}
public static double ConvertFrom(Unit unit, double v)
{
switch (unit)
switch (units)
{
/// Volume: internal representation in l
case Unit.ml: return 0.001 * v; /// 0.001 l
@@ -545,20 +536,5 @@ namespace Common
default: return v; /// Do not convert
}
}
/// <summary>
/// Converts a string to a unit
/// </summary>
/// <param name="description">Unit description string</param>
/// <returns>Converted unit or Unit.None if not recognized</returns>
public static Unit FromDescription(string description)
{
for (Unit unit = 0; unit < Unit.Count; unit++)
{
if (unit.ToDescription() == description) return unit;
}
return Unit.None;
}
}
}
+190 -1
View File
@@ -1,15 +1,90 @@
///
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
namespace Config
{
public static class Utils
{
public static string SignificantDigitsToFmt(double value, int sigDigits)
{
if (sigDigits == 6)
{
if (value >= 99999.5 || value < -99999.5) return "F0";
else if (value >= 9999.95 || value < -9999.95) return "F1";
else if (value >= 999.995 || value < -999.995) return "F2";
else if (value >= 99.9995 || value < -99.9995) return "F3";
else if (value >= 9.99995 || value < -9.99995) return "F4";
else if (value >= 0.999995 || value < -0.999995) return "F5";
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
else return "F10";
}
else if (sigDigits == 5)
{
if (value >= 9999.5 || value < -9999.5) return "F0";
else if (value >= 999.95 || value < -999.95) return "F1";
else if (value >= 99.995 || value < -99.995) return "F2";
else if (value >= 9.9995 || value < -9.9995) return "F3";
else if (value >= 0.99995 || value < -0.99995) return "F4";
else if (value >= 0.099995 || value < -0.099995) return "F5";
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
else return "F9";
}
else if (sigDigits == 4)
{
if (value >= 999.5 || value < -999.5) return "F0";
else if (value >= 99.95 || value < -99.95) return "F1";
else if (value >= 9.995 || value < -9.995) return "F2";
else if (value >= 0.9995 || value < -0.9995) return "F3";
else if (value >= 0.09995 || value < -0.09995) return "F4";
else if (value >= 0.009995 || value < -0.009995) return "F5";
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
else return "F8";
}
else if (sigDigits == 3)
{
if (value >= 99.5 || value < -99.5) return "F0";
else if (value >= 9.95 || value < -9.95) return "F1";
else if (value >= 0.995 || value < -0.995) return "F2";
else if (value >= 0.0995 || value < -0.0995) return "F3";
else if (value >= 0.00995 || value < -0.00995) return "F4";
else if (value >= 0.000995 || value < -0.000995) return "F5";
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
else return "F7";
}
else if (sigDigits == 2)
{
if (value >= 9.5 || value < -9.5) return "F0";
else if (value >= 0.95 || value < -0.95) return "F1";
else if (value >= 0.095 || value < -0.095) return "F2";
else if (value >= 0.0095 || value < -0.0095) return "F3";
else if (value >= 0.00095 || value < -0.00095) return "F4";
else if (value >= 0.000095 || value < -0.000095) return "F5";
else return "F6";
}
else /// if (sigDigits == 1)
{
if (value >= 0.95 || value < -0.95) return "F0";
else if (value >= 0.095 || value < -0.095) return "F1";
else if (value >= 0.0095 || value < -0.0095) return "F2";
else if (value >= 0.00095 || value < -0.00095) return "F3";
else if (value >= 0.000095 || value < -0.000095) return "F4";
else return "F5";
}
}
/// <summary>
/// Extract and return a DB server from a MySQL connection string.
/// </summary>
@@ -64,5 +139,119 @@ namespace Config
/// pattern NOT found
return string.Empty;
}
/// <summary>
/// Get either Q1 or Qmin flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q1 or Qmin flow in m3/h</returns>
public static double GetQ1Qmin(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
int metroClassRatio;
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
{
return Qn / (double)metroClassRatio;
}
else
{
if (medium == Medium.HotWater)
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.04 * Qn);
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.02 * Qn);
case "D": return (Qn < 15) ? (0.01 * Qn) : Qdflt;
default: break;
}
}
else
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.03 * Qn);
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.006 * Qn);
default: break;
}
}
}
return Qdflt;
}
/// <summary>
/// Get either Q2 or Qt flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q2 or Qt flow in m3/h</returns>
public static double GetQ2Qt(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
int metroClassRatio;
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
{
return 1.6 * Qn / (double)metroClassRatio;
}
if (medium == Medium.HotWater)
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.2 * Qn);
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.15 * Qn);
case "C": return (Qn < 15) ? (0.06 * Qn) : (0.1 * Qn);
case "D": return (Qn < 15) ? (0.015 * Qn) : Qdflt;
default: break;
}
}
else
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.3 * Qn);
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.2 * Qn);
case "C": return (Qn < 15) ? (0.015 * Qn) : (0.015 * Qn);
default: break;
}
}
return Qdflt;
}
/// <summary>
/// Get either Q4 or Qmax flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q4 or Qmax flow in m3/h</returns>
public static double GetQ4Qmax(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
switch (metroClass[0])
{
case 'A':
case 'B':
case 'C':
case 'D':
return 2 * Qn;
case 'R':
return 1.25 * Qn;
default:
return Qdflt;
}
}
}
}
+13 -13
View File
@@ -422,7 +422,7 @@ namespace DeviceTest
{
parentCfg = parentFactory.DefaultConfig();
}
ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
cfgForm.CmpntEntities = new List<Config.Entities.Component>();
IComponentCfgCtrl cfgControl = parentCfg.GetControl(cfgForm.CmpntEntities);
@@ -451,7 +451,7 @@ namespace DeviceTest
{
component1Cfg = component1Factory.DefaultConfig();
}
ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
///
var compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -485,7 +485,7 @@ namespace DeviceTest
{
component2Cfg = component2Factory.DefaultConfig();
}
ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
///
var compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -520,7 +520,7 @@ namespace DeviceTest
{
component3Cfg = component3Factory.DefaultConfig();
}
ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
///
var compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -677,10 +677,10 @@ namespace DeviceTest
{
operation1 = (tbfComponent1forOp as TBF.Rig.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent1forOp is TBF.Rig.Modbus.TempControl.Easytherm.Easytherm)
else if (tbfComponent1forOp is TBF.Rig.Modbus.Easytherm.Easytherm)
{
operation1 = (tbfComponent1forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(10);
operation2 = (tbfComponent1forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(20);
operation1 = (tbfComponent1forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation2 = (tbfComponent1forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent1forOp is TBF.Rig.Modbus.UltrasoundLevelMeter.LevelMeter)
{
@@ -716,10 +716,10 @@ namespace DeviceTest
{
operation21 = (tbfComponent2forOp as TBF.Rig.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent2forOp is TBF.Rig.Modbus.TempControl.Easytherm.Easytherm)
else if (tbfComponent2forOp is TBF.Rig.Modbus.Easytherm.Easytherm)
{
operation21 = (tbfComponent2forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(10);
operation22 = (tbfComponent2forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(20);
operation21 = (tbfComponent2forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation22 = (tbfComponent2forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent2forOp is TBF.Rig.Modbus.UltrasoundLevelMeter.LevelMeter)
{
@@ -755,10 +755,10 @@ namespace DeviceTest
{
operation31 = (tbfComponent3forOp as TBF.Rig.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent3forOp is TBF.Rig.Modbus.TempControl.Easytherm.Easytherm)
else if (tbfComponent3forOp is TBF.Rig.Modbus.Easytherm.Easytherm)
{
operation31 = (tbfComponent3forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(10);
operation32 = (tbfComponent3forOp as TBF.Rig.Modbus.TempControl.Easytherm.Easytherm).SetTemperatureOp(20);
operation31 = (tbfComponent3forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation32 = (tbfComponent3forOp as TBF.Rig.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent3forOp is TBF.Rig.Modbus.UltrasoundLevelMeter.LevelMeter)
{
-143
View File
@@ -1,143 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Common;
using Events;
namespace EventViewer
{
public static class EViewerDB
{
/// <summary> Session factory for all regular sessions, not for CreateEmptyResultsDB(). </summary>
public static ISessionFactory SessionFactory;
/// <summary> Connection string for all sessions </summary>
static string connectionString;
///
public static string ConnectionString
{
get { return connectionString; }
set
{
if (value != connectionString)
{
connectionString = value;
SessionFactory = null; /// Clear SessionFactory on connection string change
}
}
}
/// <summary> Database type (MySQL or SQLite) for all sessions </summary>
private static DBType dbType;
///
public static DBType DbType
{
get { return dbType; }
set { dbType = value; SessionFactory = null; }
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
static ISessionFactory CreateSessionFactory()
{
return CreateSessionFactory(false);
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <param name="createDB">true = Create a new DB, false = Regular DB</param>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(bool createDB)
{
FluentConfiguration cfg = Fluently.Configure();
switch (dbType)
{
default:
case DBType.MySql:
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
break;
case DBType.SQLite:
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
break;
}
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<global::Events.Entities.Event>());
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
}
static void BuildSchema(Configuration config)
{
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
new SchemaExport(config).SetOutputFile("db_schema");
}
static void BuildSchemaCreate(Configuration config)
{
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
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();
return SessionFactory.OpenSession();
}
/// <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 CreateEmptyDB()
{
ISessionFactory sessionFactory = CreateSessionFactory(true);
if (sessionFactory == null) return false;
/// Populate the database
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
transaction.Commit();
}
}
return true;
}
}
}
-1
View File
@@ -66,7 +66,6 @@
<Compile Include="EventViewerWnd.Designer.cs">
<DependentUpon>EventViewerWnd.cs</DependentUpon>
</Compile>
<Compile Include="EViewerDB.cs" />
<Compile Include="Forms\EventDetailsDlg.cs">
<SubType>Form</SubType>
</Compile>
+2 -2
View File
@@ -35,7 +35,7 @@
this.unreadEventsRadioButton = new System.Windows.Forms.RadioButton();
this.allEventsRadioButton = new System.Windows.Forms.RadioButton();
this.settingsButton = new System.Windows.Forms.Button();
this.eventsListView = new Common.Forms.ListViewEx();
this.eventsListView = new Common.UIControls.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -176,7 +176,7 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button settingsButton;
private Common.Forms.ListViewEx eventsListView;
private Common.UIControls.ListViewEx eventsListView;
private System.Windows.Forms.GroupBox eventsSelectionGroupBox;
private System.Windows.Forms.RadioButton unreadEventsRadioButton;
private System.Windows.Forms.RadioButton allEventsRadioButton;
+9 -9
View File
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using NHibernate;
using Common;
using Common.Forms;
using Common.UIControls;
using Events;
using Events.Entities;
using EventViewer.Resources;
@@ -33,7 +33,7 @@ namespace EventViewer
ISession session;
IList<Subscriber> subscribers;
IList<Event> events;
MySortOrder sortOrder = MySortOrder.Ascending;
SortOrder sortOrder = SortOrder.Ascending;
int sortColumn = -1; /// 0-based index of column to be used for sorting
EViewerOption eViewerOption;
@@ -102,9 +102,9 @@ namespace EventViewer
{
try
{
EViewerDB.DbType = DBType.MySql;
EViewerDB.ConnectionString = Program.LocalSettings.ConnectionString;
session = EViewerDB.CreateSession();
DB.DbType = DBType.MySql;
DB.ConnectionString = Program.LocalSettings.ConnectionString;
session = DB.CreateSession();
subscribers = session.QueryOver<Subscriber>().List();
unreadEventsRadioButton.Checked = true;
}
@@ -222,13 +222,13 @@ namespace EventViewer
{
if (e.Column == sortColumn)
{
sortOrder = (sortOrder == MySortOrder.Ascending) ? MySortOrder.Descending : MySortOrder.Ascending;
sortOrder = (sortOrder == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending;
}
else
{
/// Clicked on another column header => set sortOrder to SortOrder.Ascending
sortColumn = e.Column;
sortOrder = MySortOrder.Ascending;
sortOrder = SortOrder.Ascending;
}
switch ((Column)sortColumn)
@@ -277,7 +277,7 @@ namespace EventViewer
private void settingsButton_Click(object sender, EventArgs e)
{
//Common.GID[] groupsWithAccess = new Common.GID[] { Common.GID.Administrators };
Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg();
Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg(true);
if (dlg.ShowDialog() == DialogResult.OK)
{
if ((new Forms.SettingsDlg()).ShowDialog() == DialogResult.OK)
@@ -291,7 +291,7 @@ namespace EventViewer
{
try
{
Users.CurrentUser.RemoteUsersDB = new Common.DBSettings(Common.DBType.MySql, Program.LocalSettings.UsersDBConnString);
Users.GlobalData.RemoteUsersDB = new Users.DBSettings(Common.DBType.MySql, Program.LocalSettings.UsersDBConnString);
Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg();
if (dlg.ShowDialog() == DialogResult.OK)
{
+155 -7
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -15,6 +15,156 @@ namespace Events
{
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>
static string connectionString;
///
public static string ConnectionString
{
get { return connectionString; }
set
{
if (value != connectionString)
{
connectionString = value;
SessionFactory = null; /// Clear SessionFactory on connection string change
}
}
}
/// <summary> Database type (MySQL or SQLite) for all sessions </summary>
private static DBType dbType;
///
public static DBType DbType
{
get { return dbType; }
set { dbType = value; SessionFactory = null; }
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
static ISessionFactory CreateSessionFactory()
{
return CreateSessionFactory(false);
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <param name="createDB">true = Create a new DB, false = Regular DB</param>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(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<Entities.Event>());
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
}
}
static void BuildSchema(Configuration config)
{
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
new SchemaExport(config).SetOutputFile("db_schema");
}
static void BuildSchemaCreate(Configuration config)
{
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
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();
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 CreateEmptyDB()
{
ISessionFactory sessionFactory = CreateSessionFactory(true);
if (sessionFactory == null) return false;
/// Populate the database
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
transaction.Commit();
}
}
return true;
}
/// <summary>
/// Shared data (initially empty)
/// </summary>
@@ -30,7 +180,7 @@ namespace Events
DB.BenchName = benchName;
}
/// <summary>
/// <summary>
/// Loads shared data from the database
/// </summary>
public static void LoadSubscribers(ISession session)
@@ -43,7 +193,6 @@ namespace Events
/// </summary>
public static void LoadRecentEvents(ISession session, string benchName, int days)
{
BenchName = benchName;
RecentEvents = session.QueryOver<Event>()
.Where(e => (e.Bench == benchName))
.And(e => (e.TimeStamp >= DateTime.Now - new TimeSpan(days, 0, 0, 0)))
@@ -52,8 +201,7 @@ namespace Events
public static void SaveEvent(ISession session, Event evnt, SubscriberGroup groups)
{
if (allSubscribers == null) LoadSubscribers(session);
if (allSubscribers == null) return;
IList<Subscriber> thisEventSubscribers = new List<Subscriber>();
foreach (var s in allSubscribers)
{
@@ -63,10 +211,10 @@ namespace Events
thisEventSubscribers.Add(s);
}
}
evnt.Subscribers = thisEventSubscribers;
evnt.Bench = BenchName;
evnt.Subscribers = thisEventSubscribers;
session.SaveOrUpdate(evnt);
session.Flush();
}
}
}
+3 -33
View File
@@ -55,42 +55,12 @@ namespace FeatureVectorCalculator
// cl.ToPosition = Math.Log10(xs[j] / spacer);
// chArea.AxisX.CustomLabels.Add(cl);
// }
chArea.AxisY.Title = captionY;
chArea.AxisY.IsLogarithmic = false;
chArea.AxisY.IsLabelAutoFit = true;
if (!fromZero)
{
/// fromZero = false
chArea.AxisY.IsStartedFromZero = false;
float diff = maxY - minY;
chArea.AxisY.Minimum = minY - 0.05 * diff;
chArea.AxisY.Maximum = maxY + 0.05 * diff;
}
else if (minY >= 0)
{
/// fromZero = true, All points are above zero
chArea.AxisY.IsStartedFromZero = true;
chArea.AxisY.Minimum = 0;
chArea.AxisY.Maximum = 1.05 * maxY;
}
else if (maxY <= 0)
{
/// fromZero = true, All points are below zero
chArea.AxisY.IsStartedFromZero = true;
chArea.AxisY.Minimum = 1.05 * minY;
chArea.AxisY.Maximum = 0;
}
else
{
/// Points are both below and above zero
chArea.AxisY.IsStartedFromZero = false;
float diff = maxY - minY;
chArea.AxisY.Minimum = minY - 0.05 * diff;
chArea.AxisY.Maximum = maxY + 0.05 * diff;
}
chArea.AxisY.IsStartedFromZero = fromZero;
chArea.AxisY.Minimum = chArea.AxisY.IsStartedFromZero ? 0 : minY;
chArea.AxisY.Maximum = 1.1 * maxY;
if (chArea.AxisY.Maximum == chArea.AxisY.Minimum)
{
chArea.AxisY.Maximum = chArea.AxisY.Maximum + 1;
+50 -58
View File
@@ -199,8 +199,7 @@ namespace GemCard
{
Disconnect(DISCONNECT.Unpower);
try { ReleaseContext(); }
catch { }
ReleaseContext();
}
#region ICard Members
@@ -216,73 +215,66 @@ namespace GemCard
/// <returns>A string array of the readers</returns>
public override string[] ListReaders()
{
try
{
EstablishContext(SCOPE.User);
EstablishContext(SCOPE.User);
string[] sListReaders = null;
UInt32 pchReaders = 0;
IntPtr szListReaders = IntPtr.Zero;
string[] sListReaders = null;
UInt32 pchReaders = 0;
IntPtr szListReaders = IntPtr.Zero;
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
szListReaders = Marshal.AllocHGlobal((int)pchReaders);
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
char[] caReadersData = new char[pchReaders];
int nbReaders = 0;
for (int nI = 0; nI < pchReaders; nI++)
{
caReadersData[nI] = (char)Marshal.ReadByte(szListReaders, nI);
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
szListReaders = Marshal.AllocHGlobal((int) pchReaders);
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
char[] caReadersData = new char[pchReaders];
int nbReaders = 0;
for (int nI = 0; nI < pchReaders; nI++)
{
caReadersData[nI] = (char) Marshal.ReadByte(szListReaders, nI);
if (caReadersData[nI] == 0)
nbReaders++;
}
if (caReadersData[nI] == 0)
nbReaders++;
}
// Remove last 0
--nbReaders;
// Remove last 0
--nbReaders;
if (nbReaders != 0)
{
sListReaders = new string[nbReaders];
char[] caReader = new char[pchReaders];
int nIdx = 0;
int nIdy = 0;
int nIdz = 0;
// Get the nJ string from the multi-string
if (nbReaders != 0)
{
sListReaders = new string[nbReaders];
char[] caReader = new char[pchReaders];
int nIdx = 0;
int nIdy = 0;
int nIdz = 0;
// Get the nJ string from the multi-string
while (nIdx < pchReaders - 1)
{
caReader[nIdy] = caReadersData[nIdx];
if (caReader[nIdy] == 0)
{
sListReaders[nIdz] = new string(caReader, 0, nIdy);
++nIdz;
nIdy = 0;
caReader = new char[pchReaders];
}
else
++nIdy;
while(nIdx < pchReaders - 1)
{
caReader[nIdy] = caReadersData[nIdx];
if (caReader[nIdy] == 0)
{
sListReaders[nIdz] = new string(caReader, 0, nIdy);
++nIdz;
nIdy = 0;
caReader = new char[pchReaders];
}
else
++nIdy;
++nIdx;
}
}
++nIdx;
}
}
}
}
Marshal.FreeHGlobal(szListReaders);
}
Marshal.FreeHGlobal(szListReaders);
}
ReleaseContext();
ReleaseContext();
return sListReaders;
}
catch
{
return new string[0];
}
return sListReaders;
}
/// <summary>
+1 -3
View File
@@ -35,7 +35,7 @@
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OldToolsVersion>2.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
@@ -76,7 +76,6 @@
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
@@ -100,7 +99,6 @@
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
+3 -3
View File
@@ -48,9 +48,9 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
<ProjectReference Include="..\Config\Config.csproj">
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648fd92-cda1-4c3a-b5f9-fe547ce1fa48}</Project>
+1 -2
View File
@@ -105,7 +105,6 @@ namespace Results
foreach (var ti in procedure.GetTestInstances())
{
TestData td = TestData.UpdateList(d.TestDataList, new TestData(ti.Test));
if (!d.Batch.Tests.Contains(td)) d.Batch.Tests.Add(td);
/// Create an empty test result and add it to the list
TestRslt tr = new TestRslt(d.Batch, td, ti.Test.Part, ti.Repetition);
@@ -174,7 +173,7 @@ namespace Results
return Batch.GetTestRslt(name, part);
}
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId = CompoundMeterId.Single)
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId)
{
if (Batch.WaterMeters != null && Batch.WaterMeters.Count > wmNr0 && !Batch.WaterMeters[wmNr0].Disabled)
{
+16 -48
View File
@@ -78,17 +78,11 @@ namespace Results
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
}
}
@@ -186,55 +180,29 @@ namespace Results
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static void LoadSharedData(ISession session = null)
public static void LoadSharedData()
{
bool openAndCloseSession = (session == null);
ISession session = DB.CreateSession();
try
{
if (openAndCloseSession) session = Results.DB.CreateSession();
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
}
catch (Exception e)
{
log.ErrorFormat("Cannot open results DB: {0}", e.Message);
}
finally
{
if (openAndCloseSession && session != null && session.IsOpen) session.Close();
}
}
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
}
/// <summary>
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static int GetMaxSavedBatchNr(ISession session = null)
public static int GetMaxSavedBatchNr()
{
bool openAndCloseSession = (session == null);
int maxBatchNr = 0;
try
{
if (openAndCloseSession) session = Results.DB.CreateSession();
IList<Entities.Batch> batches = session.QueryOver<Batch>().List();
foreach (var b in batches)
{
if (b.BatchNr > maxBatchNr) maxBatchNr = b.BatchNr;
}
}
catch (Exception e)
{
log.ErrorFormat("Cannot open results DB: {0}", e.Message);
}
finally
{
if (openAndCloseSession && session != null && session.IsOpen) session.Close();
}
ISession session = DB.CreateSession();
IList<Entities.Batch> batches = session.QueryOver<Batch>().List();
int maxBatchNr = 0;
foreach (var b in batches)
{
if (b.BatchNr > maxBatchNr) maxBatchNr = b.BatchNr;
}
return maxBatchNr;
}
-2
View File
@@ -40,8 +40,6 @@ namespace Results
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entities.WaterMeterData>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
+18 -27
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -24,8 +24,6 @@ namespace Results.Entities
public virtual int UserNumber { get; set; }
public virtual string ProcedureName { get; set; }
public virtual bool IsRemoteProcedure { get; set; } /// Stara Tura, not mapped to DB
public virtual string PurchaseOrder { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string Workflow { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
public virtual int ProcedureRevision { get; set; }
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
@@ -41,7 +39,6 @@ namespace Results.Entities
public virtual int Counter10 { get; set; }
public virtual DateTime StartTime { get; set; }
public virtual DateTime EndTime { get; set; }
public virtual DateTime SaveTime { get; set; }
public virtual bool Dirty { get; set; }
public virtual bool RsltsSent { get; set; }
public virtual bool RsltsPrinted { get; set; }
@@ -160,7 +157,6 @@ namespace Results.Entities
Counter10 = oriBatch.Counter10;
StartTime = oriBatch.StartTime;
EndTime = oriBatch.EndTime;
SaveTime = oriBatch.SaveTime;
Dirty = oriBatch.Dirty;
RsltsSent = oriBatch.RsltsSent;
RsltsPrinted = oriBatch.RsltsPrinted;
@@ -211,7 +207,7 @@ namespace Results.Entities
foreach (var tr in TestRslts)
{
if (tr.TestDone && tr.AmbTempMean != 0)
if (tr.TestDone)
{
double duration = (tr.EndTime - tr.StartTime).TotalSeconds;
timeSum += duration;
@@ -229,7 +225,7 @@ namespace Results.Entities
foreach (var tr in TestRslts)
{
if (tr.TestDone && tr.AmbPressMean != 0)
if (tr.TestDone)
{
double duration = (tr.EndTime - tr.StartTime).TotalSeconds;
timeSum += duration;
@@ -247,7 +243,7 @@ namespace Results.Entities
foreach (var tr in TestRslts)
{
if (tr.TestDone && tr.AmbHumiMean != 0)
if (tr.TestDone)
{
double duration = (tr.EndTime - tr.StartTime).TotalSeconds;
timeSum += duration;
@@ -262,7 +258,7 @@ namespace Results.Entities
{
for (int i = 0; i < TestRslts.Count; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbTempStart != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbTempStart;
}
return 0;
@@ -271,7 +267,7 @@ namespace Results.Entities
{
for (int i = 0; i < TestRslts.Count; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbPressStart != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbPressStart;
}
return 0;
@@ -280,7 +276,7 @@ namespace Results.Entities
{
for (int i = 0; i < TestRslts.Count; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbHumiStart != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbHumiStart;
}
return 0;
@@ -288,27 +284,27 @@ namespace Results.Entities
public virtual double AmbTempEnd()
{
for (int i = TestRslts.Count - 1; i >= 0; i--)
for (int i = TestRslts.Count - 1; i >= 0; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbTempEnd != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbTempEnd;
}
return 0;
}
public virtual double AmbPressEnd()
{
for (int i = TestRslts.Count - 1; i >= 0; i--)
for (int i = TestRslts.Count - 1; i >= 0; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbPressEnd != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbPressEnd;
}
return 0;
}
public virtual double AmbHumiEnd()
{
for (int i = TestRslts.Count - 1; i >= 0; i--)
for (int i = TestRslts.Count - 1; i >= 0; i++)
{
if (TestRslts[i].Publish() == Common.Publish.Always && TestRslts[i].AmbHumiEnd != 0)
if (TestRslts[i].Publish() == Publish.Always)
return TestRslts[i].AmbHumiEnd;
}
return 0;
@@ -325,19 +321,16 @@ namespace Results.Entities
public override string ToString()
{
return string.Format("Batch {0} ({1}s) Start {2}, End {3}, Proc={4}",
BatchNr, (EndTime - StartTime).TotalSeconds, StartTime, EndTime, ProcedureName);
return string.Format("Batch #{0}, Start:{1}, End:{2}, Procedure:{3}", BatchNr, StartTime, EndTime, ProcedureName);
}
public virtual string ToString(int i)
{
return string.Format("Batch {0} ({1}s) ver={2} TestBenchId={3} User={4}/{5} Proc={6}{7} Rev={8} Remark={9} RealDensity={10} AtTemperature={11} Buoyancy={12} StartTime={13} EndTime={14} SaveTime={15} RsltsSent={16} RsltsPrinted={17}",
BatchNr,
(EndTime - StartTime).TotalSeconds,
ProgramVersion, TestBenchId, UserName, UserNumber,
return string.Format("Batch: BatchNr={0} ProgramVersion={1} TestBenchId={2} UserName={3} UserNumber={4} ProcedureName={5}{6} ProcRev={7} ProtocolTitle={8} Remark={9} RealDensity={10} AtTemperature={11} Buoyancy={12} StartTime={13} EndTime={14} Dirty={15} RsltsSent={16} RsltsPrinted={17}",
BatchNr, ProgramVersion, TestBenchId, UserName, UserNumber,
ProcedureName, (IsRemoteProcedure ? "(R)" : ""), ProcedureRevision,
Remark, RealDensity, AtTemperature, Buoyancy,
StartTime, EndTime, SaveTime, RsltsSent, RsltsPrinted);
ProtocolTitle, Remark, RealDensity, AtTemperature, Buoyancy,
StartTime, EndTime, Dirty, RsltsSent, RsltsPrinted);
}
public virtual void WriteBinary(BinaryWriter writer)
@@ -371,7 +364,6 @@ namespace Results.Entities
writer.Write(Counter10);
writer.Write(StartTime.ToString());
writer.Write(EndTime.ToString());
writer.Write(SaveTime.ToString());
writer.Write(Dirty);
writer.Write(RsltsSent);
writer.Write(RsltsPrinted);
@@ -439,7 +431,6 @@ namespace Results.Entities
Counter10 = reader.ReadInt32();
StartTime = DateTime.Parse(reader.ReadString());
EndTime = DateTime.Parse(reader.ReadString());
SaveTime = DateTime.Parse(reader.ReadString());
Dirty = reader.ReadBoolean();
RsltsSent = reader.ReadBoolean();
RsltsPrinted = reader.ReadBoolean();
-7
View File
@@ -106,13 +106,6 @@ namespace Results.Entities
public virtual bool IsDataStream() { return (RegReaderType == (int)RegisterReaderType.DataStream); }
public virtual bool IsManual() { return (RegReaderType == (int)RegisterReaderType.Manual); }
public virtual string PassedOrErrorFlagsStr()
{
string eFlags = Utils.ErrorFlagsStr(ErrorIndicators);
var str = string.IsNullOrEmpty(eFlags) ? PassedColorStr(null) : eFlags;
return str;
}
public virtual string PassedColorStr(string yesNoFormatOrEmpty)
{
if (string.IsNullOrEmpty(yesNoFormatOrEmpty))
+47 -96
View File
@@ -1,11 +1,10 @@
///
/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Common;
using Config.Entities;
namespace Results.Entities
@@ -27,19 +26,12 @@ namespace Results.Entities
public virtual double ErrLimLo { get; set; } /// [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
public virtual double ErrLimHi { get; set; } /// [%] usually > 0, in case of heat meters: -Qn in m3/h
public virtual double ErrLimMargin { get; set; } /// [%] makes error limits tighter: 0 <= ErrLimMargin <= abs(ErrLimXx)
public virtual bool DoControlWaterTemp { get; set; }
public virtual float TempLimLo { get; set; }
public virtual float TempLimHi { get; set; }
public virtual string TempControl { get; set; }
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool Evaluate { get; set; }
#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
/// <summary>
/// Default constructor, safe values
@@ -53,61 +45,45 @@ namespace Results.Entities
public TestData(Test test)
: this()
{
Name = test.Name;
Repeats = test.Repeats;
Qtg = test.Qtg;
Qfrom = test.Qfrom;
Qto = test.Qto;
TargetVolume = test.Volume;
TargetTime = test.TestTime;
Method = test.Method;
ErrLimLo = test.ErrLimLo;
ErrLimHi = test.ErrLimHi;
ErrLimMargin = test.Uncertainty;
TempLimLo = test.TempLimLo;
TempLimHi = test.TempLimHi;
TempControl = test.TempControl;
Publish = test.Publish;
Evaluate = test.DoEvaluate;
#if ORACLE_DB
OraId = test.OraId;
OraIdRepetMulti = test.OraIdRepetMulti;
OraDesignation = test.OraDesignation;
RawDataId = test.RawDataId;
RawDataIdRepetMulti = test.RawDataIdRepetMulti;
RawDataDesignation = test.RawDataDesignation;
#endif
}
Name = test.Name;
Repeats = test.Repeats;
Qtg = (double)test.Qtg;
Qfrom = (double)test.Qfrom;
Qto = (double)test.Qto;
TargetVolume = (double)test.Volume;
TargetTime = (double)test.TestTime;
Method = test.Method;
ErrLimLo = (double)test.ErrLimLo;
ErrLimHi = (double)test.ErrLimHi;
ErrLimMargin = (double)test.Uncertainty;
DoControlWaterTemp = test.DoControlWaterTemp;
TempLimLo = test.TempLimLo;
TempLimHi = test.TempLimHi;
Publish = test.Publish;
Evaluate = test.DoEvaluate;
}
/// <summary>
/// Copy constructor, copies all except of Id
/// </summary>
public TestData(TestData oriTestData)
{
Name = oriTestData.Name;
Repeats = oriTestData.Repeats;
Qtg = oriTestData.Qtg;
Qfrom = oriTestData.Qfrom;
Qto = oriTestData.Qto;
TargetVolume = oriTestData.TargetVolume;
TargetTime = oriTestData.TargetTime;
Method = oriTestData.Method;
ErrLimLo = oriTestData.ErrLimLo;
ErrLimHi = oriTestData.ErrLimHi;
ErrLimMargin = oriTestData.ErrLimMargin;
TempLimLo = oriTestData.TempLimLo;
TempLimHi = oriTestData.TempLimHi;
TempControl = oriTestData.TempControl;
Publish = oriTestData.Publish;
Evaluate = oriTestData.Evaluate;
#if ORACLE_DB
OraId = oriTestData.OraId;
OraIdRepetMulti = oriTestData.OraIdRepetMulti;
OraDesignation = oriTestData.OraDesignation;
RawDataId = oriTestData.RawDataId;
RawDataIdRepetMulti = oriTestData.RawDataIdRepetMulti;
RawDataDesignation = oriTestData.RawDataDesignation;
#endif
Name = oriTestData.Name;
Repeats = oriTestData.Repeats;
Qtg = oriTestData.Qtg;
Qfrom = oriTestData.Qfrom;
Qto = oriTestData.Qto;
TargetVolume = oriTestData.TargetVolume;
TargetTime = oriTestData.TargetTime;
Method = oriTestData.Method;
ErrLimLo = oriTestData.ErrLimLo;
ErrLimHi = oriTestData.ErrLimHi;
ErrLimMargin = oriTestData.ErrLimMargin;
DoControlWaterTemp = oriTestData.DoControlWaterTemp;
TempLimLo = oriTestData.TempLimLo;
TempLimHi = oriTestData.TempLimHi;
Publish = oriTestData.Publish;
Evaluate = oriTestData.Evaluate;
}
@@ -129,19 +105,15 @@ namespace Results.Entities
if (ErrLimLo != td.ErrLimLo) return false;
if (ErrLimHi != td.ErrLimHi) return false;
if (ErrLimMargin != td.ErrLimMargin) return false;
if (TempLimLo != td.TempLimLo) return false;
if (TempLimHi != td.TempLimHi) return false;
if (TempControl != td.TempControl) return false;
if (Publish != td.Publish) return false;
if (DoControlWaterTemp != td.DoControlWaterTemp) return false;
if (DoControlWaterTemp)
{
if (TempLimLo != td.TempLimLo) return false;
if (TempLimHi != td.TempLimHi) return false;
}
if (Publish != td.Publish) return false;
if (Evaluate != td.Evaluate) return false;
#if ORACLE_DB
if (OraId != td.OraId) return false;
if (OraIdRepetMulti != td.OraIdRepetMulti) return false;
if (OraDesignation != td.OraDesignation) return false;
if (RawDataId != td.RawDataId) return false;
if (RawDataIdRepetMulti != td.RawDataIdRepetMulti) return false;
if (RawDataDesignation != td.RawDataDesignation) return false;
#endif
return true;
}
@@ -178,19 +150,11 @@ namespace Results.Entities
writer.Write(ErrLimLo);
writer.Write(ErrLimHi);
writer.Write(ErrLimMargin);
writer.Write(DoControlWaterTemp);
writer.Write(TempLimLo);
writer.Write(TempLimHi);
writer.Write((TempControl != null) ? TempControl : string.Empty);
writer.Write(Publish);
writer.Write(Evaluate);
#if ORACLE_DB
writer.Write(OraId);
writer.Write(OraIdRepetMulti);
writer.Write((OraDesignation != null) ? OraDesignation : string.Empty);
writer.Write(RawDataId);
writer.Write(RawDataIdRepetMulti);
writer.Write((RawDataDesignation != null) ? RawDataDesignation : string.Empty);
#endif
}
public virtual void ReadBinary(BinaryReader reader)
@@ -207,24 +171,11 @@ namespace Results.Entities
ErrLimLo = reader.ReadDouble();
ErrLimHi = reader.ReadDouble();
ErrLimMargin = reader.ReadDouble();
DoControlWaterTemp = reader.ReadBoolean();
TempLimLo = reader.ReadSingle();
TempLimHi = reader.ReadSingle();
TempControl = reader.ReadString();
Publish = reader.ReadSByte();
Evaluate = reader.ReadBoolean();
#if ORACLE_DB
OraId = reader.ReadInt32();
OraIdRepetMulti = reader.ReadInt32();
OraDesignation = reader.ReadString();
RawDataId = reader.ReadInt32();
RawDataIdRepetMulti = reader.ReadInt32();
RawDataDesignation = reader.ReadString();
#endif
}
public override string ToString()
{
return string.Format("{0} (P.{1},{2})", Name, ((Publish)Publish).ToString(), Evaluate ? "E" : "-");
}
}
}
+2 -12
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -147,8 +147,7 @@ namespace Results.Entities
public virtual int Counter5 { get; set; }
/// Wrappers
public virtual string Name() { return Common.Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual string Key() { return string.Format("{0}~{1}~{2}~{3}", TestData.Name, Part, TestData.Repeats, RepetitionNr); } /// Unique key
public virtual string Name() { return Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual int Repeats() { return TestData.Repeats; }
public virtual double Qfrom() { return TestData.Qfrom; }
public virtual double Qto() { return TestData.Qto; }
@@ -165,15 +164,6 @@ namespace Results.Entities
public virtual bool IsDiverter() { return (MethodClass != null) ? ((MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) || MethodClass.Contains("DiverterTest")) : true; }
public virtual bool IsVolumeMethod() { return (MethodClass != null) ? (MethodClass.Contains("TestMethods.FixedStart.") || MethodClass.Contains("TestMethods.FlyingStart.")) : false; }
#if ORACLE_DB
public virtual int OraId() { return TestData.OraId; }
public virtual int OraIdRepetMulti() { return TestData.OraIdRepetMulti; }
public virtual string OraDesignation() { return TestData.OraDesignation; }
public virtual int RawDataId() { return TestData.RawDataId; }
public virtual int RawDataIdRepetMulti() { return TestData.RawDataIdRepetMulti; }
public virtual string RawDataDesignation() { return TestData.RawDataDesignation; }
#endif
public virtual string MethodElde()
{
if (MethodClass == null) return string.Empty;
+92 -65
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -93,14 +93,16 @@ namespace Results.Entities
public virtual string Prefix { get; set; }
public virtual string Suffix { get; set; }
public virtual string CompleteSerialNr { get; set; }
public virtual string OriRadioAddress { get; set; } /// Original radio address of a 640 water meter (AlbatrosID)
public virtual string OriRadioAddress { get; set; } /// Not mapped to DB !!! Original radio address of a 640 water meter (albatrosID)
public virtual int WMTypeRevision { get; set; }
public virtual int Pruefindex { get; set; } /// >=1 ... pruefindex, 0 ... unknown (no reading from DB yet)
public virtual int Pruefindex { get; set; } /// >= 1 ... pruefindex
public virtual int HydrPruefung { get; set; }
public virtual object RawTestInfos { get; set; } /// IList<SensusTestInfo> fetched from Oracle at the beginning of the cycle, not mapped to DB !!!
public virtual object CompleteTestInfos { get; set; } /// SensusTestInfo[] obtained as a best match at the beginning of the cycle, not mapped to DB !!!
#endif
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual bool PrintLabel { get; set; } /// Not mapped to DB !!!
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual int SessionId { get; set; } /// Not mapped to DB !!! 1 (regular tracing DB session) or 2 (alternative tracing DB session)
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual WaterMeterData WaterMeterData { get; set; }
public virtual Batch Batch { get; set; }
@@ -109,23 +111,15 @@ namespace Results.Entities
///
/// Wrappers
///
public virtual string GetEndStateAux() { return Compound() ? EndStateAux : string.Empty; }
public virtual void SetEndStateAux(string s) { if (Compound()) EndStateAux = s; }
public virtual string GetStartState() { return Compound() ? string.Empty : EndStateAux; }
public virtual void SetStartState(string s) { if (!Compound()) EndStateAux = s; }
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string Producer() { return WaterMeterData.Producer; }
public virtual string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
public virtual string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
public virtual FlowNames Qnames() { return (FlowNames)WaterMeterData.Qnames; }
public virtual bool NewQnames() { return WaterMeterData.NewQnames; }
public virtual double Q4_Qmax() { return WaterMeterData.Q4_Qmax; }
public virtual double Q3_Qn() { return WaterMeterData.Q3_Qn; }
public virtual double Q2_Qt() { return WaterMeterData.Q2_Qt; }
public virtual double Q1_Qmin() { return WaterMeterData.Q1_Qmin; }
public virtual double ErrLimHiQ() { return WaterMeterData.ErrLimHiQ; }
public virtual double ErrLimLoQ() { return WaterMeterData.ErrLimLoQ; }
public virtual bool Compound() { return WaterMeterData.Compound; }
public virtual bool HeatMeter() { return WaterMeterData.HeatMeter; }
@@ -134,10 +128,8 @@ namespace Results.Entities
public virtual double Q3_Qn_Aux() { return WaterMeterData.Q3_Qn_Aux; }
public virtual string MetrologicalClassAux() { return WaterMeterData.MetrologicalClassAux; }
public virtual string ApprovalInfoAux() { return WaterMeterData.ApprovalInfoAux; }
#if ORACLE_DB
public virtual int WMTypeId() { return WaterMeterData.WMTypeId; }
#endif
public virtual int BatchNr() { return Batch.BatchNr; }
public virtual int BatchNr() { return Batch.BatchNr; }
public virtual int BenchId() { return Batch.TestBenchId; }
public virtual string ProcedureName() { return Batch.ProcedureName; }
public virtual int ProcedureRevision() { return Batch.ProcedureRevision; }
@@ -260,9 +252,7 @@ namespace Results.Entities
break;
}
}
#if ORACLE_DB
if (Utils.MaxTestIndex != 0 && (Pruefindex % 100) > Utils.MaxTestIndex) passed = false;
#endif
return passed;
}
@@ -340,7 +330,7 @@ namespace Results.Entities
return GetMeterTestRslt(testName, CompoundMeterId.SingleOrCompound);
}
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId = CompoundMeterId.Single)
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId)
{
if (string.IsNullOrEmpty(testName)) return null;
if (Disabled) return null;
@@ -428,38 +418,38 @@ namespace Results.Entities
public WaterMeter()
{
MeterTestRslts = new List<MeterTestRslt>();
/// Initialize strings
SerialNr = string.Empty;
SerialNrAux = string.Empty;
RadioAddress = string.Empty;
PurchaseOrder = string.Empty;
EndState = string.Empty;
EndStateAux = string.Empty;
ErrorFlags = 0;
InfoFlags = 0;
ArchivePath = string.Empty;
Remark = string.Empty;
#if IPERL
FWVersion = string.Empty;
#endif
#if TURA_SPECIAL
ProdUserName = string.Empty;
ProdPurchaseOrder = string.Empty;
#endif
#if ORACLE_DB
AssignedSerialNr = 0;
Prefix = string.Empty;
Suffix = string.Empty;
CompleteSerialNr = string.Empty;
OriRadioAddress = string.Empty;
WMTypeRevision = 0;
Pruefindex = 0;
Pruefindex = 1;
HydrPruefung = 0;
RawTestInfos = null;
CompleteTestInfos = null;
#endif
ProcessId = 0;
SessionId = 0;
ErrorFlags = 0;
LastRecordIsNok = false;
PrintLabel = true;
/// Initialize strings
SerialNr = string.Empty;
SerialNrAux = string.Empty;
PurchaseOrder = string.Empty;
EndState = string.Empty;
EndStateAux = string.Empty;
ArchivePath = string.Empty;
Remark = string.Empty;
#if TURA_SPECIAL
RadioAddress = string.Empty;
ProdUserName = string.Empty;
ProdPurchaseOrder = string.Empty;
#endif
#if IPERL
FWVersion = string.Empty;
#endif
}
@@ -469,7 +459,6 @@ namespace Results.Entities
SerialNr = src.SerialNr;
SerialNrAux = src.SerialNrAux;
RadioAddress = src.RadioAddress;
PurchaseOrder = src.PurchaseOrder;
YearOfProduction = src.YearOfProduction;
WMPosition = src.WMPosition;
@@ -498,30 +487,32 @@ namespace Results.Entities
FWVersion = src.FWVersion;
#endif
#if TURA_SPECIAL
PaletteNr = src.PaletteNr;
UmkartonNr = src.UmkartonNr;
ProdTestBench = src.ProdTestBench;
ProdWMPosition = src.ProdWMPosition;
ProdUserName = src.ProdUserName;
ProdPurchaseOrder = src.ProdPurchaseOrder;
ProdPassed = src.ProdPassed;
ProdResultCode = src.ProdResultCode;
ProdQ2CorrRL = src.ProdQ2CorrRL;
ProdQ2CorrLR = src.ProdQ2CorrLR;
RadioAddress = src.RadioAddress;
PaletteNr = src.PaletteNr;
UmkartonNr = src.UmkartonNr;
ProdTestBench = src.ProdTestBench;
ProdWMPosition = src.ProdWMPosition;
ProdUserName = src.ProdUserName;
ProdPurchaseOrder = src.ProdPurchaseOrder;
ProdPassed = src.ProdPassed;
ProdResultCode = src.ProdResultCode;
ProdQ2CorrRL = src.ProdQ2CorrRL;
ProdQ2CorrLR = src.ProdQ2CorrLR;
#endif
#if ORACLE_DB
AssignedSerialNr = src.AssignedSerialNr;
Prefix = src.Prefix;
Suffix = src.Suffix;
CompleteSerialNr = src.CompleteSerialNr;
OriRadioAddress = src.OriRadioAddress;
WMTypeRevision = src.WMTypeRevision;
Pruefindex = src.Pruefindex;
HydrPruefung = src.HydrPruefung;
RawTestInfos = src.RawTestInfos; /// Not mapped to DB
CompleteTestInfos = src.CompleteTestInfos; /// Not mapped to DB
#endif
ProcessId = src.ProcessId; /// Not mapped to DB
SessionId = src.SessionId; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@@ -649,7 +640,6 @@ namespace Results.Entities
writer.Write(Id);
writer.Write((SerialNr != null) ? SerialNr : string.Empty);
writer.Write((SerialNrAux != null) ? SerialNrAux : string.Empty);
writer.Write((RadioAddress != null) ? RadioAddress : string.Empty);
writer.Write((PurchaseOrder != null) ? PurchaseOrder : string.Empty);
writer.Write(YearOfProduction);
writer.Write(WMPosition);
@@ -678,6 +668,7 @@ namespace Results.Entities
writer.Write((FWVersion != null) ? FWVersion : string.Empty);
#endif
#if TURA_SPECIAL
writer.Write((RadioAddress != null) ? RadioAddress : string.Empty);
writer.Write(PaletteNr);
writer.Write(UmkartonNr);
writer.Write((ProdTestBench != null) ? ProdTestBench : string.Empty);
@@ -694,14 +685,29 @@ namespace Results.Entities
writer.Write((Prefix != null) ? Prefix : string.Empty);
writer.Write((Suffix != null) ? Suffix : string.Empty);
writer.Write((CompleteSerialNr != null) ? CompleteSerialNr : string.Empty);
writer.Write((OriRadioAddress != null) ? OriRadioAddress : string.Empty);
writer.Write(WMTypeRevision);
writer.Write(Pruefindex);
writer.Write(HydrPruefung);
/// Write RawTestInfos
IList<Results.Output.SensusTestInfo> rawTestInfos = RawTestInfos as IList<Results.Output.SensusTestInfo>;
writer.Write((rawTestInfos != null) ? rawTestInfos.Count : 0);
if (rawTestInfos != null)
{
for (int i = 0; i < rawTestInfos.Count; i++) rawTestInfos[i].WriteBinary(writer);
}
/// Write CompleteTestInfos
Results.Output.SensusTestInfo[] completeTestInfos = CompleteTestInfos as Results.Output.SensusTestInfo[];
writer.Write((completeTestInfos != null) ? completeTestInfos.Length : 0);
if (completeTestInfos != null)
{
for (int i = 0; i < completeTestInfos.Length; i++) completeTestInfos[i].WriteBinary(writer);
}
#endif
writer.Write(ProcessId);
writer.Write(SessionId);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@@ -729,7 +735,6 @@ namespace Results.Entities
Id = reader.ReadInt32();
SerialNr = reader.ReadString();
SerialNrAux = reader.ReadString();
RadioAddress = reader.ReadString();
PurchaseOrder = reader.ReadString();
YearOfProduction = reader.ReadInt32();
WMPosition = reader.ReadInt32();
@@ -758,6 +763,7 @@ namespace Results.Entities
FWVersion = reader.ReadString();
#endif
#if TURA_SPECIAL
RadioAddress = reader.ReadString();
PaletteNr = reader.ReadInt32();
UmkartonNr = reader.ReadInt32();
ProdTestBench = reader.ReadString();
@@ -774,14 +780,35 @@ namespace Results.Entities
Prefix = reader.ReadString();
Suffix = reader.ReadString();
CompleteSerialNr = reader.ReadString();
OriRadioAddress = reader.ReadString();
WMTypeRevision = reader.ReadInt32();
Pruefindex = reader.ReadInt32();
HydrPruefung = reader.ReadInt32();
/// Read RawTestInfos
int rawTestInfosCount = reader.ReadInt32();
IList<Results.Output.SensusTestInfo> rawTestInfos = new List<Results.Output.SensusTestInfo>();
for (int i = 0; i < rawTestInfosCount; i++)
{
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
ti.ReadBinary(reader);
rawTestInfos.Add(ti);
}
RawTestInfos = rawTestInfos;
/// Read CompleteTestInfos
int completeTestInfosLen = reader.ReadInt32();
Results.Output.SensusTestInfo[] completeTestInfos = new Results.Output.SensusTestInfo[completeTestInfosLen];
for (int i = 0; i < completeTestInfosLen; i++)
{
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
ti.ReadBinary(reader);
completeTestInfos[i] = ti;
}
CompleteTestInfos = completeTestInfos;
#endif
ProcessId = reader.ReadInt32();
SessionId = reader.ReadInt32();
LastRecordIsNok = reader.ReadBoolean();
PrintLabel = reader.ReadBoolean();
/// Retrieve TestData
if (reader.ReadBoolean())
+5 -16
View File
@@ -17,14 +17,11 @@ namespace Results.Entities
public virtual double DN { get; set; } /// [mm]
public virtual double L { get; set; } /// [mm]
public virtual Mounting Mounting { get; set; } /// H / V / S / F
public virtual sbyte Qnames { get; set; } /// see Common.Enums.FlowNames
public virtual bool NewQnames { get; set; } /// Yes = Q3... No = Qn...
public virtual double Q4_Qmax { get; set; } /// [m3/h]
public virtual double Q3_Qn { get; set; } /// [m3/h]
public virtual double Q2_Qt { get; set; } /// [m3/h]
public virtual double Q1_Qmin { get; set; } /// [m3/h]
public virtual double ErrLimHiQ { get; set; } /// [%]
public virtual double ErrLimLoQ { get; set; } /// [%]
public virtual string MetrologicalClass { get; set; }
public virtual TemperatureClass TemperatureClass { get; set; }
public virtual PressureLossClass PressureLossClass { get; set; }
@@ -69,13 +66,11 @@ namespace Results.Entities
DN = oriWMData.DN;
L = oriWMData.L;
Mounting = oriWMData.Mounting;
Qnames = oriWMData.Qnames;
NewQnames = oriWMData.NewQnames;
Q4_Qmax = oriWMData.Q4_Qmax;
Q3_Qn = oriWMData.Q3_Qn;
Q2_Qt = oriWMData.Q2_Qt;
Q1_Qmin = oriWMData.Q1_Qmin;
ErrLimHiQ = oriWMData.ErrLimHiQ;
ErrLimLoQ = oriWMData.ErrLimLoQ;
MetrologicalClass = oriWMData.MetrologicalClass;
TemperatureClass = oriWMData.TemperatureClass;
PressureLossClass = oriWMData.PressureLossClass;
@@ -114,13 +109,11 @@ namespace Results.Entities
if (DN != wmd.DN) return false;
if (L != wmd.L) return false;
if (Mounting != wmd.Mounting) return false;
if (Qnames != wmd.Qnames) return false;
if (NewQnames != wmd.NewQnames) return false;
if (Q4_Qmax != wmd.Q4_Qmax) return false;
if (Q3_Qn != wmd.Q3_Qn) return false;
if (Q2_Qt != wmd.Q2_Qt) return false;
if (Q1_Qmin != wmd.Q1_Qmin) return false;
if (ErrLimHiQ != wmd.ErrLimHiQ) return false;
if (ErrLimLoQ != wmd.ErrLimLoQ) return false;
if (MetrologicalClass != wmd.MetrologicalClass) return false;
if (TemperatureClass != wmd.TemperatureClass) return false;
if (PressureLossClass != wmd.PressureLossClass) return false;
@@ -174,13 +167,11 @@ namespace Results.Entities
writer.Write(DN);
writer.Write(L);
writer.Write((int)Mounting);
writer.Write((int)Qnames);
writer.Write(NewQnames);
writer.Write(Q4_Qmax);
writer.Write(Q3_Qn);
writer.Write(Q2_Qt);
writer.Write(Q1_Qmin);
writer.Write(ErrLimHiQ);
writer.Write(ErrLimLoQ);
writer.Write((MetrologicalClass != null) ? MetrologicalClass : string.Empty);
writer.Write((int)TemperatureClass);
writer.Write((int)PressureLossClass);
@@ -214,13 +205,11 @@ namespace Results.Entities
DN = reader.ReadDouble();
L = reader.ReadDouble();
Mounting = (Mounting)reader.ReadInt32();
Qnames = (sbyte)reader.ReadInt32();
NewQnames = reader.ReadBoolean();
Q4_Qmax = reader.ReadDouble();
Q3_Qn = reader.ReadDouble();
Q2_Qt = reader.ReadDouble();
Q1_Qmin = reader.ReadDouble();
ErrLimHiQ = reader.ReadDouble();
ErrLimLoQ = reader.ReadDouble();
MetrologicalClass = reader.ReadString();
TemperatureClass = (TemperatureClass)reader.ReadInt32();
PressureLossClass = (PressureLossClass)reader.ReadInt32();
@@ -1,4 +1,4 @@
namespace TBF.UI.ResultsMI
namespace Results.Forms
{
partial class BatchResultsDlg
{
@@ -47,7 +47,6 @@
this.ClientSize = new System.Drawing.Size(1058, 721);
this.Controls.Add(this.flowLayoutPanel);
this.Name = "BatchResultsDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Results";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BatchResultsDlg_FormClosing);
this.Load += new System.EventHandler(this.BatchResultsDlg_Load);
@@ -1,17 +1,13 @@
///
/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
///
using System;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common;
using Results.Forms;
using Results.Resources;
using NHibernate;
using TracingDB.Entities;
using TBF.Resources;
namespace TBF.UI.ResultsMI
namespace Results.Forms
{
public partial class BatchResultsDlg : Form
{
@@ -33,7 +29,6 @@ namespace TBF.UI.ResultsMI
public int PopupResultsWidth;
public int PopupResultsHeight;
public int[] RsltsClmnWidths;
public IList<string> SerialNrs;
///
@@ -131,8 +126,7 @@ namespace TBF.UI.ResultsMI
int displayedControlsCount = 0;
for (int i = 0; i < results.Batch.WaterMeters.Count; i++)
{
if ((ShowDisabledPositions || !results.Batch.WaterMeters[i].Disabled) &&
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[i].SerialNr)))
if ((!results.Batch.WaterMeters[i].Disabled) || ShowDisabledPositions)
{
displayedControlsCount++;
}
@@ -173,8 +167,7 @@ namespace TBF.UI.ResultsMI
firstEnabledControl = null;
for (int i = 0; i < results.Batch.WaterMeters.Count; i++)
{
if ((ShowDisabledPositions || !results.Batch.WaterMeters[i].Disabled) &&
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[i].SerialNr)))
if (!results.Batch.WaterMeters[i].Disabled || ShowDisabledPositions)
{
/// Create one water meter position / control
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
@@ -223,8 +216,7 @@ namespace TBF.UI.ResultsMI
int ctrlIx = 0;
for (int wmNr0 = 0; wmNr0 < results.Batch.WaterMeters.Count; wmNr0++)
{
if ((ShowDisabledPositions || !results.Batch.WaterMeters[wmNr0].Disabled) &&
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[wmNr0].SerialNr)))
if (!results.Batch.WaterMeters[wmNr0].Disabled || ShowDisabledPositions)
{
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(results.Batch.WaterMeters[wmNr0]);
}
@@ -237,7 +229,7 @@ namespace TBF.UI.ResultsMI
{
if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(wm.SerialNr))
{
new MoreWMResultsDlg(wm, null).ShowDialog();
new Results.Forms.MoreWMResultsDlg(wm, null).ShowDialog();
}
else
{
@@ -270,7 +262,7 @@ namespace TBF.UI.ResultsMI
}
}
new MoreWMResultsDlg(wm, refRecords).ShowDialog();
new Results.Forms.MoreWMResultsDlg(wm, refRecords).ShowDialog();
}
}
}
+486
View File
@@ -0,0 +1,486 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Results.Forms
{
/// <summary>
/// Event Handler for SubItem events
/// </summary>
public delegate void SubItemEventHandler(object sender, SubItemEventArgs e);
/// <summary>
/// Event Handler for SubItemEndEditing events
/// </summary>
public delegate void SubItemEndEditingEventHandler(object sender, SubItemEndEditingEventArgs e);
/// <summary>
/// Inherited ListView to allow in-place editing of subitems
/// </summary>
public class ListViewEx : System.Windows.Forms.ListView
{
#region Interop structs, imports and constants
/// <summary>
/// MessageHeader for WM_NOTIFY
/// </summary>
private struct NMHDR
{
#pragma warning disable
public IntPtr hwndFrom;
public Int32 idFrom;
public Int32 code;
#pragma warning restore
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar);
[DllImport("user32.dll", CharSet=CharSet.Ansi)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int len, ref int [] order);
// ListView messages
private const int LVM_FIRST = 0x1000;
private const int LVM_GETCOLUMNORDERARRAY = (LVM_FIRST + 59);
// Windows Messages that will abort editing
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int WM_SIZE = 0x05;
private const int WM_NOTIFY = 0x4E;
private const int HDN_FIRST = -300;
private const int HDN_BEGINDRAG = (HDN_FIRST-10);
private const int HDN_ITEMCHANGINGA = (HDN_FIRST-0);
private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
#endregion
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public event SubItemEventHandler SubItemClicked;
public event SubItemEventHandler SubItemRightClicked;
public event SubItemEventHandler SubItemBeginEditing;
public event SubItemEndEditingEventHandler SubItemEndEditing;
public ListViewEx()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
base.FullRowSelect = true;
base.View = View.Details;
base.AllowColumnReorder = true;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
private bool _doubleClickActivation = false;
/// <summary>
/// Is a double click required to start editing a cell?
/// </summary>
public bool DoubleClickActivation
{
get { return _doubleClickActivation; }
set { _doubleClickActivation = value; }
}
/// <summary>
/// Retrieve the order in which columns appear
/// </summary>
/// <returns>Current display order of column indices</returns>
public int[] GetColumnOrder()
{
IntPtr lPar = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * Columns.Count);
IntPtr res = SendMessage(Handle, LVM_GETCOLUMNORDERARRAY, new IntPtr(Columns.Count), lPar);
if (res.ToInt32() == 0) // Something went wrong
{
Marshal.FreeHGlobal(lPar);
return null;
}
int [] order = new int[Columns.Count];
Marshal.Copy(lPar, order, 0, Columns.Count);
Marshal.FreeHGlobal(lPar);
return order;
}
/// <summary>
/// Find ListViewItem and SubItem Index at position (x,y)
/// </summary>
/// <param name="x">relative to ListView</param>
/// <param name="y">relative to ListView</param>
/// <param name="item">Item at position (x,y)</param>
/// <returns>SubItem index</returns>
public int GetSubItemAt(int x, int y, out ListViewItem item)
{
item = this.GetItemAt(x, y);
if (item != null)
{
int[] order = GetColumnOrder();
Rectangle lviBounds;
int subItemX;
lviBounds = item.GetBounds(ItemBoundsPortion.Entire);
subItemX = lviBounds.Left;
for (int i=0; i<order.Length; i++)
{
ColumnHeader h = this.Columns[order[i]];
if (x < subItemX+h.Width)
{
return h.Index;
}
subItemX += h.Width;
}
}
return -1;
}
/// <summary>
/// Get bounds for a SubItem
/// </summary>
/// <param name="Item">Target ListViewItem</param>
/// <param name="SubItem">Target SubItem index</param>
/// <returns>Bounds of SubItem (relative to ListView)</returns>
public Rectangle GetSubItemBounds(ListViewItem Item, int SubItem)
{
int[] order = GetColumnOrder();
Rectangle subItemRect = Rectangle.Empty;
if (SubItem >= order.Length)
throw new IndexOutOfRangeException("SubItem "+SubItem+" out of range");
if (Item == null)
throw new ArgumentNullException("Item");
Rectangle lviBounds = Item.GetBounds(ItemBoundsPortion.Entire);
int subItemX = lviBounds.Left;
ColumnHeader col;
int i;
for (i=0; i<order.Length; i++)
{
col = this.Columns[order[i]];
if (col.Index == SubItem)
break;
subItemX += col.Width;
}
subItemRect = new Rectangle(subItemX, lviBounds.Top, this.Columns[order[i]].Width, lviBounds.Height);
return subItemRect;
}
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
{
// Look for WM_VSCROLL,WM_HSCROLL or WM_SIZE messages.
case WM_VSCROLL:
case WM_HSCROLL:
case WM_SIZE:
EndEditing(false);
break;
case WM_NOTIFY:
// Look for WM_NOTIFY of events that might also change the
// editor's position/size: Column reordering or resizing
NMHDR h = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR));
if (h.code == HDN_BEGINDRAG ||
h.code == HDN_ITEMCHANGINGA ||
h.code == HDN_ITEMCHANGINGW)
EndEditing(false);
break;
}
base.WndProc(ref msg);
}
#region Initialize editing depending of DoubleClickActivation property
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
base.OnMouseUp(e);
MouseEventArgs me = (MouseEventArgs)e;
if (me.Button == MouseButtons.Right)
{
/// Right mouse button click function
RightClickFunctionSubitemAt(new Point(e.X, e.Y));
}
else
{
/// Normal function (=edit item)
if (DoubleClickActivation)
{
return;
}
EditSubitemAt(new Point(e.X, e.Y));
}
}
protected override void OnDoubleClick(EventArgs e)
{
base.OnDoubleClick (e);
if (!DoubleClickActivation)
{
return;
}
Point pt = this.PointToClient(Cursor.Position);
EditSubitemAt(pt);
}
///<summary>
/// Fire SubItemClicked
///</summary>
///<param name="p">Point of click/doubleclick</param>
private void EditSubitemAt(Point p)
{
ListViewItem item;
int idx = GetSubItemAt(p.X, p.Y, out item);
if (idx >= 0)
{
OnSubItemClicked(new SubItemEventArgs(item, idx));
}
}
///<summary>
/// Fire SubItemRightClicked
///</summary>
///<param name="p">Point of click/doubleclick</param>
private void RightClickFunctionSubitemAt(Point p)
{
ListViewItem item;
int idx = GetSubItemAt(p.X, p.Y, out item);
if (idx >= 0)
{
OnSubItemRightClicked(new SubItemEventArgs(item, idx));
}
}
#endregion
#region In-place editing functions
// The control performing the actual editing
private Control _editingControl;
// The LVI being edited
private ListViewItem _editItem;
// The SubItem being edited
private int _editSubItem;
protected void OnSubItemBeginEditing(SubItemEventArgs e)
{
if (SubItemBeginEditing != null) SubItemBeginEditing(this, e);
}
protected void OnSubItemEndEditing(SubItemEndEditingEventArgs e)
{
if (SubItemEndEditing != null) SubItemEndEditing(this, e);
}
protected void OnSubItemClicked(SubItemEventArgs e)
{
if (SubItemClicked != null) SubItemClicked(this, e);
}
protected void OnSubItemRightClicked(SubItemEventArgs e)
{
if (SubItemRightClicked != null) SubItemRightClicked(this, e);
}
/// <summary>
/// Begin in-place editing of given cell
/// </summary>
/// <param name="c">Control used as cell editor</param>
/// <param name="Item">ListViewItem to edit</param>
/// <param name="SubItem">SubItem index to edit</param>
public void StartEditing(Control c, ListViewItem Item, int SubItem)
{
OnSubItemBeginEditing(new SubItemEventArgs(Item, SubItem));
Rectangle rcSubItem = GetSubItemBounds(Item, SubItem);
if (rcSubItem.X < 0)
{
// Left edge of SubItem not visible - adjust rectangle position and width
rcSubItem.Width += rcSubItem.X;
rcSubItem.X=0;
}
if (rcSubItem.X+rcSubItem.Width > this.Width)
{
// Right edge of SubItem not visible - adjust rectangle width
rcSubItem.Width = this.Width-rcSubItem.Left;
}
// Subitem bounds are relative to the location of the ListView!
rcSubItem.Offset(Left, Top);
// In case the editing control and the listview are on different parents,
// account for different origins
Point origin = new Point(0,0);
Point lvOrigin = this.Parent.PointToScreen(origin);
Point ctlOrigin = c.Parent.PointToScreen(origin);
rcSubItem.Offset(lvOrigin.X-ctlOrigin.X, lvOrigin.Y-ctlOrigin.Y);
// Position and show editor
c.Bounds = rcSubItem;
c.Text = Item.SubItems[SubItem].Text;
c.Visible = true;
c.BringToFront();
c.Focus();
_editingControl = c;
_editingControl.Leave += new EventHandler(_editControl_Leave);
_editingControl.KeyPress += new KeyPressEventHandler(_editControl_KeyPress);
_editItem = Item;
_editSubItem = SubItem;
}
private void _editControl_Leave(object sender, EventArgs e)
{
// cell editor losing focus
EndEditing(true);
}
private void _editControl_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case (char)(int)Keys.Escape:
{
EndEditing(false);
break;
}
case (char)(int)Keys.Enter:
{
EndEditing(true);
break;
}
}
}
/// <summary>
/// Accept or discard current value of cell editor control
/// </summary>
/// <param name="AcceptChanges">Use the _editingControl's Text as new SubItem text or discard changes?</param>
public void EndEditing(bool AcceptChanges)
{
if (_editingControl == null)
return;
SubItemEndEditingEventArgs e = new SubItemEndEditingEventArgs(
_editItem, // The item being edited
_editSubItem, // The subitem index being edited
AcceptChanges ?
_editingControl.Text : // Use editControl text if changes are accepted
_editItem.SubItems[_editSubItem].Text, // or the original subitem's text, if changes are discarded
!AcceptChanges // Cancel?
);
OnSubItemEndEditing(e);
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
_editingControl.Leave -= new EventHandler(_editControl_Leave);
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
_editingControl.Visible = false;
_editingControl = null;
_editItem = null;
_editSubItem = -1;
}
#endregion
}
/// <summary>
/// Event Args for SubItemClicked event
/// </summary>
public class SubItemEventArgs : EventArgs
{
int subItem = -1; /// Sub-item index
ListViewItem item = null;
public int SubItem { get { return subItem; } }
public ListViewItem Item { get { return item; } }
public SubItemEventArgs(ListViewItem item, int subItem)
{
this.subItem = subItem;
this.item = item;
}
}
/// <summary>
/// Event Args for SubItemEndEditingClicked event
/// </summary>
public class SubItemEndEditingEventArgs : SubItemEventArgs
{
string displayText = string.Empty;
bool cancel = true;
public SubItemEndEditingEventArgs(ListViewItem item, int subItem, string displayText, bool cancel) :
base(item, subItem)
{
this.displayText = displayText;
this.cancel = cancel;
}
public string DisplayText
{
get { return displayText; }
set { displayText = value; }
}
public bool Cancel
{
get { return cancel; }
set { cancel = value; }
}
}
}
+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="ResMimeType">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="Version">
<value>1.0.0.0</value>
</resheader>
<resheader name="Reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="Writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+104
View File
@@ -0,0 +1,104 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Results.Forms
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ListViewExtensions
{
[StructLayout(LayoutKind.Sequential)]
public struct HDITEM
{
public Mask mask;
public int cxy;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszText;
public IntPtr hbm;
public int cchTextMax;
public Format fmt;
public IntPtr lParam;
// _WIN32_IE >= 0x0300
public int iImage;
public int iOrder;
// _WIN32_IE >= 0x0500
public uint type;
public IntPtr pvFilter;
// _WIN32_WINNT >= 0x0600
public uint state;
[Flags]
public enum Mask
{
Format = 0x4, // HDI_FORMAT
};
[Flags]
public enum Format
{
SortDown = 0x200, // HDF_SORTDOWN
SortUp = 0x400, // HDF_SORTUP
};
};
public const int LVM_FIRST = 0x1000;
public const int LVM_GETHEADER = LVM_FIRST + 31;
public const int HDM_FIRST = 0x1200;
public const int HDM_GETITEM = HDM_FIRST + 11;
public const int HDM_SETITEM = HDM_FIRST + 12;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, SortOrder order)
{
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
{
var columnPtr = new IntPtr(columnNumber);
var item = new HDITEM
{
mask = HDITEM.Mask.Format
};
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
if (order != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
item.fmt &= ~HDITEM.Format.SortUp;
item.fmt |= HDITEM.Format.SortDown;
break;
default:
break;
}
}
else
{
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
}
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
}
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace Results.Forms
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
return (order == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace Results.Forms
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
string txtX = ((ListViewItem)x).SubItems[column].Text;
string txtY = ((ListViewItem)y).SubItems[column].Text;
return (order == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}
+2 -2
View File
@@ -37,7 +37,7 @@
this.availableAlphabeticTreeView = new System.Windows.Forms.TreeView();
this.downButton = new System.Windows.Forms.Button();
this.upButton = new System.Windows.Forms.Button();
this.selectedResultsListViewEx = new Common.Forms.ListViewEx();
this.selectedResultsListViewEx = new Results.Forms.ListViewEx();
this.removeAllButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
@@ -247,7 +247,7 @@
private System.Windows.Forms.TreeView availableAlphabeticTreeView;
private System.Windows.Forms.Button downButton;
private System.Windows.Forms.Button upButton;
private Common.Forms.ListViewEx selectedResultsListViewEx;
private ListViewEx selectedResultsListViewEx;
private System.Windows.Forms.Button removeAllButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.Button addButton;
+8 -9
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Common;
using Common.Forms;
using Config.Entities;
using Results.Resources;
@@ -115,12 +114,12 @@ namespace Results.Forms
{
if (e.SubItem == (int)Column.Units)
{
Quantity quantity = (e.Item.Tag as ManualEntryItemSpec).Quantity;
Config.Quantity quantity = (e.Item.Tag as ManualEntryItemSpec).Quantity;
unitsCB.Items.Clear();
unitsCB.Items.Add(Unit.None.ToDescription()); /// "---"
for (Unit u = (Unit)1; u < Unit.Count; u++)
unitsCB.Items.Add(Config.Unit.None.ToDescription()); /// "---"
for (Config.Unit u = (Config.Unit)1; u < Config.Unit.Count; u++)
{
if (Units.IsQuantity(u, quantity)) unitsCB.Items.Add(u.ToDescription());
if (Config.Units.IsQuantity(u, quantity)) unitsCB.Items.Add(u.ToDescription());
}
selectedResultsListViewEx.StartEditing(unitsCB, e.Item, e.SubItem);
}
@@ -139,7 +138,7 @@ namespace Results.Forms
{
case Column.Caption: item.Caption = e.DisplayText; return;
case Column.Units:
for (Unit u = 0; u < Unit.Count; u++)
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
{
if (u.ToDescription().Equals(unitsCB.Text))
{
@@ -190,10 +189,10 @@ namespace Results.Forms
{
treeView.Nodes.Clear();
IList<Quantity> quantities = new List<Quantity>();
for (Quantity q = 0; q < Quantity.Count; q++) quantities.Add(q);
IList<Config.Quantity> quantities = new List<Config.Quantity>();
for (Config.Quantity q = 0; q < Config.Quantity.Count; q++) quantities.Add(q);
IList<Quantity> sortedQuantities = quantities.OrderBy(x => x.ToDescription()).ToList();
IList<Config.Quantity> sortedQuantities = quantities.OrderBy(x => x.ToDescription()).ToList();
foreach (var q in sortedQuantities)
{
+10 -24
View File
@@ -29,15 +29,13 @@
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.graphsTabPage = new System.Windows.Forms.TabPage();
this.productionTracingTabPage = new System.Windows.Forms.TabPage();
this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer();
this.messageLabel = new System.Windows.Forms.Label();
this.tracingResultsListView = new System.Windows.Forms.ListView();
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsRowsCtrl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.tabControl1.SuspendLayout();
this.allResultsTabPage.SuspendLayout();
this.productionTracingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
this.productionTracingSplitContainer.Panel1.SuspendLayout();
@@ -57,17 +55,6 @@
this.tabControl1.Size = new System.Drawing.Size(1195, 448);
this.tabControl1.TabIndex = 0;
//
// allResultsTabPage
//
this.allResultsTabPage.Controls.Add(this.oneWMResultsCtrl);
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// graphsTabPage
//
this.graphsTabPage.Location = new System.Drawing.Point(4, 22);
@@ -126,7 +113,6 @@
//
this.tracingResultsListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.tracingResultsListView.GridLines = true;
this.tracingResultsListView.HideSelection = false;
this.tracingResultsListView.Location = new System.Drawing.Point(0, 0);
this.tracingResultsListView.Name = "tracingResultsListView";
this.tracingResultsListView.Size = new System.Drawing.Size(1187, 366);
@@ -134,14 +120,15 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// oneWMResultsRowsCtrl
// allResultsTabPage
//
this.oneWMResultsCtrl.Caption = "---";
this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3);
this.oneWMResultsCtrl.Name = "oneWMResultsRowsCtrl";
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
this.oneWMResultsCtrl.TabIndex = 0;
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// MoreWMResultsDlg
//
@@ -153,7 +140,6 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Water meter results";
this.tabControl1.ResumeLayout(false);
this.allResultsTabPage.ResumeLayout(false);
this.productionTracingTabPage.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.PerformLayout();
@@ -167,12 +153,12 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage graphsTabPage;
private System.Windows.Forms.TabPage productionTracingTabPage;
private System.Windows.Forms.SplitContainer productionTracingSplitContainer;
private System.Windows.Forms.Label messageLabel;
private System.Windows.Forms.ListView tracingResultsListView;
private System.Windows.Forms.TabPage allResultsTabPage;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
}
}
+57 -61
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -14,13 +14,6 @@ namespace Results.Forms
{
public partial class MoreWMResultsDlg : Form
{
enum Tabs
{
Results = 0,
Graph,
Tracing,
}
public MoreWMResultsDlg(Results.Entities.WaterMeter wm, IList<ReferenceRecord> refRecords)
{
InitializeComponent();
@@ -30,15 +23,14 @@ namespace Results.Forms
ShowAllResults(wm);
ShowChart(wm);
/// Select the initial tab page to be displayed
if (refRecords == null)
{
tabControl1.SelectTab((int)Tabs.Graph);
tabControl1.TabPages.RemoveAt((int)Tabs.Tracing);
tabControl1.SelectTab(1);
tabControl1.TabPages.RemoveAt(2);
}
else
{
tabControl1.SelectTab((int)Tabs.Tracing);
tabControl1.SelectTab(2);
ShowTracingResults(wm, refRecords);
}
}
@@ -47,9 +39,9 @@ namespace Results.Forms
void Localize()
{
Text = Strings.Water_meter_results;
tabControl1.TabPages[(int)Tabs.Results].Text = Strings.All_results;
tabControl1.TabPages[(int)Tabs.Graph].Text = Strings.Graphs;
tabControl1.TabPages[(int)Tabs.Tracing].Text = Strings.Production_tracing_results;
tabControl1.TabPages[0].Text = Strings.All_results;
tabControl1.TabPages[1].Text = Strings.Graphs;
tabControl1.TabPages[2].Text = Strings.Production_tracing_results;
}
@@ -59,63 +51,67 @@ namespace Results.Forms
/// <param name="wMtr">Water meter entity</param>
void ShowAllResults(Results.Entities.WaterMeter wMtr)
{
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
#if ORACLE_DB
oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", wMtr.SerialNr ?? string.Empty, wMtr.Pruefindex % 100, message);
#else
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", wMtr.SerialNr ?? string.Empty);
#endif
// string message;
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
//#if ORACLE_DB
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
//#else
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
//#endif
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// Header
oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
oneWMResultsCtrl.Columns.Add(str, 100);
i++;
}
// // Header
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
// int i = 1;
// foreach (var str in wMtr.GetAllDecoratedTestNames())
// {
// oneWMResultsCtrl.Columns.Add(str, 100);
// i++;
// }
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Name);
// foreach (var item in items)
// {
// ListViewItem lvi = new ListViewItem(item.Name);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Common.Publish.Never &&
mtr.Publish() != Common.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
// foreach (var mtr in wMtr.MeterTestRslts)
// {
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Publish.Never &&
// mtr.Publish() != Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
// string[] texts = str.Split(new char[] { '|' });
// if (texts.Length == 1)
// {
// lvi.SubItems.Add(str);
// }
// else if (texts.Length == 2)
// {
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
// lvi.UseItemStyleForSubItems = false;
// lvi.SubItems.Add(texts[0]);
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
// }
// else
// {
// lvi.SubItems.Add(string.Empty);
// }
// }
// }
oneWMResultsCtrl.Items.Add(lvi);
}
// oneWMResultsCtrl.Items.Add(lvi);
// }
}
void ShowChart(Results.Entities.WaterMeter wm)
{
tabControl1.TabPages[(int)Tabs.Graph].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
//chart.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yy";
//chart.ChartAreas[0].AxisX.Interval = 1;
//chart.ChartAreas[0].AxisX.IntervalType = ;
tabControl1.TabPages[1].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
}
+5 -7
View File
@@ -41,7 +41,6 @@
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
@@ -49,13 +48,12 @@
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tBox);
this.splitContainer1.Panel1MinSize = 26;
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.lView);
this.splitContainer1.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.SplitterDistance = 26;
this.splitContainer1.SplitterDistance = 25;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 0;
//
@@ -64,7 +62,7 @@
this.tBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.tBox.Location = new System.Drawing.Point(0, 0);
this.tBox.Name = "tBox";
this.tBox.Size = new System.Drawing.Size(352, 26);
this.tBox.Size = new System.Drawing.Size(352, 20);
this.tBox.TabIndex = 0;
this.tBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tBox_MouseDoubleClick);
//
@@ -75,17 +73,17 @@
this.lView.GridLines = true;
this.lView.Location = new System.Drawing.Point(0, 0);
this.lView.Name = "lView";
this.lView.Size = new System.Drawing.Size(352, 291);
this.lView.Size = new System.Drawing.Size(352, 292);
this.lView.TabIndex = 0;
this.lView.UseCompatibleStateImageBehavior = false;
this.lView.View = System.Windows.Forms.View.Details;
//
// OneWMResultsColumnsCtrl
// OneWMResultsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "OneWMResultsColumnsCtrl";
this.Name = "OneWMResultsCtrl";
this.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
+6 -10
View File
@@ -79,18 +79,14 @@ namespace Results.Forms
return;
}
/// Update background color and caption
/// Update background color
string message = string.Empty;
#if ORACLE_DB
bool maxRepeatsExceeded = (Utils.MaxTestIndex != 0 && (wMtr.Pruefindex % 100) > Utils.MaxTestIndex);
UpdateBkColor(wMtr.GetColorOfResults(maxRepeatsExceeded, out message));
tBox.Text = caption = string.Format("{0} ({1}) {2} {3}",
wMtr.WMPosition,
wMtr.Pruefindex == 0 ? "?" : string.Format("{0}x", wMtr.Pruefindex % 100),
(string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr),
message);
#else
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
+5 -7
View File
@@ -48,23 +48,21 @@
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tBox);
this.splitContainer1.Panel1MinSize = 26;
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.lView);
this.splitContainer1.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.SplitterDistance = 26;
this.splitContainer1.SplitterDistance = 25;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 0;
//
// tBox
//
this.tBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.tBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.tBox.Location = new System.Drawing.Point(0, 0);
this.tBox.Name = "tBox";
this.tBox.Size = new System.Drawing.Size(352, 26);
this.tBox.Size = new System.Drawing.Size(352, 20);
this.tBox.TabIndex = 0;
this.tBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tBox_MouseDoubleClick);
//
@@ -75,17 +73,17 @@
this.lView.GridLines = true;
this.lView.Location = new System.Drawing.Point(0, 0);
this.lView.Name = "lView";
this.lView.Size = new System.Drawing.Size(352, 291);
this.lView.Size = new System.Drawing.Size(352, 292);
this.lView.TabIndex = 0;
this.lView.UseCompatibleStateImageBehavior = false;
this.lView.View = System.Windows.Forms.View.Details;
//
// OneWMResultsRowsCtrl
// OneWMResultsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "OneWMResultsRowsCtrl";
this.Name = "OneWMResultsCtrl";
this.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
+11 -18
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
@@ -24,16 +24,13 @@ namespace Results.Forms
}
}
public string Caption { set { caption = value; } get { return caption; } }
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<WMeterRsltItemSpec> items;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
@@ -48,7 +45,7 @@ namespace Results.Forms
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<WMeterRsltItemSpec>();
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
@@ -65,7 +62,7 @@ namespace Results.Forms
}
}
public void Update(IList<WMeterRsltItemSpec> items)
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
@@ -94,21 +91,17 @@ namespace Results.Forms
return;
}
/// Update background color and caption
/// Update background color
string message = string.Empty;
#if ORACLE_DB
bool maxRepeatsExceeded = (Utils.MaxTestIndex != 0 && (wMtr.Pruefindex % 100) > Utils.MaxTestIndex);
UpdateBkColor(wMtr.GetColorOfResults(maxRepeatsExceeded, out message));
tBox.Text = caption = string.Format("{0} ({1}) {2} {3}",
wMtr.WMPosition,
wMtr.Pruefindex == 0 ? "?" : string.Format("{0}x", wMtr.Pruefindex % 100),
(string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr),
message);
#else
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
UpdateWMPos(wMtr.WMPosition);
/// Update test results
+2 -2
View File
@@ -37,7 +37,7 @@
this.availableAlphabeticTreeView = new System.Windows.Forms.TreeView();
this.downButton = new System.Windows.Forms.Button();
this.upButton = new System.Windows.Forms.Button();
this.selectedResultsListViewEx = new Common.Forms.ListViewEx();
this.selectedResultsListViewEx = new Results.Forms.ListViewEx();
this.removeAllButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
@@ -247,7 +247,7 @@
private System.Windows.Forms.TreeView availableAlphabeticTreeView;
private System.Windows.Forms.Button downButton;
private System.Windows.Forms.Button upButton;
private Common.Forms.ListViewEx selectedResultsListViewEx;
private ListViewEx selectedResultsListViewEx;
private System.Windows.Forms.Button removeAllButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.Button addButton;
+8 -9
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Common;
using Common.Forms;
using Results.Resources;
namespace Results.Forms
@@ -140,12 +139,12 @@ namespace Results.Forms
{
if (e.SubItem == (int)Column.Units)
{
Quantity quantity = (e.Item.Tag as WMeterRsltItemSpec).Quantity;
Config.Quantity quantity = (e.Item.Tag as WMeterRsltItemSpec).Quantity;
unitsCB.Items.Clear();
unitsCB.Items.Add(Unit.None.ToDescription()); /// "---"
for (Unit u = (Unit)1; u < Unit.Count; u++)
unitsCB.Items.Add(Config.Unit.None.ToDescription()); /// "---"
for (Config.Unit u = (Config.Unit)1; u < Config.Unit.Count; u++)
{
if (Units.IsQuantity(u, quantity)) unitsCB.Items.Add(u.ToDescription());
if (Config.Units.IsQuantity(u, quantity)) unitsCB.Items.Add(u.ToDescription());
}
selectedResultsListViewEx.StartEditing(unitsCB, e.Item, e.SubItem);
}
@@ -164,7 +163,7 @@ namespace Results.Forms
{
case Column.Caption: item.Caption = e.DisplayText; return;
case Column.Units:
for (Unit u = 0; u < Unit.Count; u++)
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
{
if (u.ToDescription().Equals(unitsCB.Text))
{
@@ -241,10 +240,10 @@ namespace Results.Forms
{
treeView.Nodes.Clear();
IList<Quantity> quantities = new List<Quantity>();
for (Quantity q = 0; q < Quantity.Count; q++) quantities.Add(q);
IList<Config.Quantity> quantities = new List<Config.Quantity>();
for (Config.Quantity q = 0; q < Config.Quantity.Count; q++) quantities.Add(q);
IList<Quantity> sortedQuantities = quantities.OrderBy(x => x.ToDescription()).ToList();
IList<Config.Quantity> sortedQuantities = quantities.OrderBy(x => x.ToDescription()).ToList();
foreach (var q in sortedQuantities)
{
-5
View File
@@ -343,11 +343,6 @@ namespace Results
X9, /// 291
RadioAddress, /// 292
OriRadioAddress, /// 293
Pls_per_ltr_aux, /// 294 Compound water meter constant (water meter data, not used in calculations)
Pulses_main, /// 295 Compound main meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Pulses_aux, /// 296 Compound aux meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Count,
}
+2 -2
View File
@@ -22,7 +22,7 @@ namespace Results
public readonly Quantity Quantity; /// Quantity
public readonly ItemCategory Category; ///
public string Caption; /// Specifies item description to be printed as a caption (in the header, etc.)
public Unit Units; /// Specifies units for the output
public Config.Unit Units; /// Specifies units for the output
public ManualEntryItemSpec Clone()
@@ -198,7 +198,7 @@ namespace Results
///
item.Caption = field[1].Replace("\n", "~");
item.Units = 0;
for (Unit u = 0; u < Unit.Count; u++)
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
{
if (u.ToString().Equals(field[2])) { item.Units = u; break; }
}
+1 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Results.Entities;
@@ -35,7 +35,6 @@ namespace Results.Mappings
Map(x => x.StartTime);
Map(x => x.EndTime);
Map(x => x.SaveTime);
Map(x => x.Dirty);
Map(x => x.RsltsSent);
Map(x => x.RsltsPrinted);
+2 -10
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Results.Entities;
@@ -24,14 +24,6 @@ namespace Results.Mappings
Map(x => x.ErrLimMargin).Column("Uncertainty");
Map(x => x.Publish);
Map(x => x.Evaluate);
#if ORACLE_DB
Map(x => x.OraId);
Map(x => x.OraIdRepetMulti);
Map(x => x.OraDesignation);
Map(x => x.RawDataId);
Map(x => x.RawDataIdRepetMulti);
Map(x => x.RawDataDesignation);
#endif
}
}
}
}
+3 -3
View File
@@ -18,13 +18,13 @@ namespace Results.Mappings
Map(x => x.L);
Map(x => x.Mounting);
Map(x => x.Qnames);
#if MUNICH && LANG_DE
Map(x => x.NewQnames);
#endif
Map(x => x.Q4_Qmax);
Map(x => x.Q3_Qn);
Map(x => x.Q2_Qt);
Map(x => x.Q1_Qmin);
Map(x => x.ErrLimHiQ);
Map(x => x.ErrLimLoQ);
Map(x => x.MetrologicalClass);
Map(x => x.TemperatureClass);
+1 -1
View File
@@ -61,9 +61,9 @@ namespace Results.Mappings
Map(x => x.Suffix);
Map(x => x.CompleteSerialNr);
Map(x => x.OriRadioAddress);
Map(x => x.WMTypeRevision);
Map(x => x.Pruefindex);
Map(x => x.HydrPruefung);
Map(x => x.WMTypeRevision);
#endif
References(x => x.WaterMeterData);
References(x => x.Batch);
@@ -14,7 +14,7 @@ using GenCode128;
namespace Results.Output.Printers.Label
{
public class LabelPrintDocument : Common.Printers.PrintersCommon
public class LabelPrintDocument : PrintersCommon
{
static QrEncoder encoder = new QrEncoder();
@@ -14,7 +14,7 @@ using GenCode128;
namespace Results.Output.Printers.MultiLabel
{
public class MultiLabelPrintDocument : Common.Printers.PrintersCommon
public class MultiLabelPrintDocument : PrintersCommon
{
static QrEncoder encoder = new QrEncoder();
@@ -393,7 +393,7 @@ namespace Results.Output.Printers.Munich
Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
table.AddRow(new string[] { mtr.Name(),
Units.ConvertTo(Unit.lph, flow_ctv).ToString("F1"),
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
mtr.TestRslt.VolumeCTV.ToString("F2"),
mainMtr.VolumeMeter.ToString("F2"),
auxMtr.VolumeMeter.ToString("F2"),
@@ -405,7 +405,7 @@ namespace Results.Output.Printers.Munich
else
{
table.AddRow(new string[] { mtr.Name(),
Units.ConvertTo(Unit.lph, flow_ctv).ToString("F1"),
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
mtr.TestRslt.VolumeCTV.ToString("F2"),
mtr.VolumeMeter.ToString("F2"),
"-",
@@ -456,12 +456,12 @@ namespace Results.Output.Printers.Munich
double flow_ctv = (mtr.TestRslt.TestTime != 0) ? (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime) : 0;
table.AddRow(new string[] { mtr.Name(),
Units.ConvertTo(Unit.lph, flow_ctv).ToString("F1"),
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
mtr.TestRslt.TempDownMean.ToString("F2"),
mtr.TestRslt.DensityDiv.ToString("F2"),
mtr.TestTime.ToString("F1"),
Units.ConvertTo(Unit.bar, mtr.TestRslt.PressUpMean).ToString("F3"),
Units.ConvertTo(Unit.bar, mtr.TestRslt.PressDownMean).ToString("F3") },
Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressUpMean).ToString("F3"),
Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressDownMean).ToString("F3") },
horizontalAlignment,
verticalAlignment);
}
@@ -526,11 +526,11 @@ namespace Results.Output.Printers.Munich
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab1, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab3, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
}
lineNr++;
@@ -592,7 +592,7 @@ namespace Results.Output.Printers.Munich
iTop += SpacingOne;
PrintAt(e, Tab1, iTop, "Luftdruck");
PrintAt(e, Tab2, iTop, Units.ConvertTo(Unit.mbar, wm.Batch.AmbPressMean()).ToString("F0") + " mbar");
PrintAt(e, Tab2, iTop, Config.Units.ConvertTo(Config.Unit.mbar, wm.Batch.AmbPressMean()).ToString("F0") + " mbar");
iTop += SpacingOne;
@@ -11,7 +11,7 @@ using Results.Resources;
namespace Results.Output.Printers.OnePerBatch
{
public class OnePerBatchPrintDocument : Common.Printers.PrintersCommon
public class OnePerBatchPrintDocument : PrintersCommon
{
const float GapBetweenTableColumns = 10;
const float GapBetweenCommonColumns = 10;
@@ -14,7 +14,7 @@ using Results.Resources;
namespace Results.Output.Printers.OnePerMeter
{
public class OnePerMeterPrintDocument : Common.Printers.PrintersCommon
public class OnePerMeterPrintDocument : PrintersCommon
{
const float GapBetweenTableColumns = 10;
const float GapBetweenCommonColumns = 10;
@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using Common;
namespace Common.Printers
namespace Results.Output.Printers
{
public class PrintersCommon : PrintDocument
{
+7 -23
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018-2022 Sensus Slovensko a.s.
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -15,7 +15,6 @@ namespace Results.Output
Just_Q3Q2adjQ1_Alt, /// pNrs = -1,5,2,1
JustA0A4_Q3Q2adjQ1, /// pNrs = -2,-1,3,2,1 (Australia 169 MHz, raw data pNrs: -2,-1,4,3,2,1)
JustA0A4_Q3Q2Q1, /// pNrs = -2,-1,3,2,1 (Australia 169 MHz smart, raw data pNrs: -2,-1,3,2,1)
JustA0_Q3Q2Q1, /// pNrs = -1,3,2,1 (Australia 169 MHz smart, raw data pNrs: -1,3,2,1)
DEWA, /// Q4, Q3, Q2adj, Q2, Q1
DEWA_wo_Q2, /// Q4, Q3, Q2adj, Q1
Suez, /// Two directions, with Q2 and Q2ac
@@ -102,8 +101,7 @@ namespace Results.Output
}
/// <summary>
/// Determines whether test infos are compatible with procedure tests:
/// For each 'cti'in candidate SensusTestInfo array there must exist a string 'cti.TestName' in testNames.
/// Determines whether test infos are compatible with procedure tests.
/// </summary>
/// <returns>true when compatible</returns>
public static bool AreCompatible(SensusTestInfo[] completeTestInfo, IList<string> testNames)
@@ -128,15 +126,11 @@ namespace Results.Output
/// <summary>
/// Determines whether Oracle and complete test infos are compatible:
/// For each 'oti' in OracleTestInfo there must exist a compatible ...
/// ... cti.PruefungsNrDB + cti.QBezeichnungDB pair in candidate SensusTestInfo.
/// Determines whether Oracle and complete test infos are compatible.
/// </summary>
/// <returns>true when compatible</returns>
public static bool AreCompatible(IList<SensusTestInfo> oracleTestInfo, SensusTestInfo[] completeTestInfo)
{
if (oracleTestInfo == null) return false;
/// All tests in oracleTestInfo must exist in completeTestInfo
foreach (var oti in oracleTestInfo)
{
@@ -182,7 +176,7 @@ namespace Results.Output
SensusTestInfo[] candidateTinfo = SensusTestInfo.GetTestInfos(lt);
if (AreCompatible(candidateTinfo, testNames) && AreCompatible(oracleTestInfo, candidateTinfo) &&
((bestMatch == null) || (candidateTinfo.Length < bestMatchLen)))
((bestMatch == null) || (candidateTinfo.Length > bestMatchLen)))
{
bestLT = lt;
bestMatch = candidateTinfo;
@@ -296,16 +290,6 @@ namespace Results.Output
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
};
case LogType.JustA0_Q3Q2Q1: /// Australia 169 MHz with default Q2 corrections and conditional update at the end of cycle
return new SensusTestInfo[]
{
/// TBF Oracle DB Opto RAW LU logfiles
new SensusTestInfo("Qjust_A0", -1, "Just", -1, "-1", -1, "Q-1", Range.R95_105),
new SensusTestInfo("Q3", 3, "Q3", 3, "03", 3, "Q3", Range.R90_100),
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
};
case LogType.DEWA: /// DEWA (with Q4 and Q2 after correction)
return new SensusTestInfo[]
@@ -463,7 +447,7 @@ namespace Results.Output
return new SensusTestInfo[]
{
/// TBF Oracle DB Opto RAW LU logfiles
new SensusTestInfo("Q3", 3, "Q3", 3, "03", 3, "Q3", Range.R90_100),
new SensusTestInfo("Q3", 3, "Q3", 3, "04", 3, "Q3", Range.R90_100),
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
};
@@ -472,7 +456,7 @@ namespace Results.Output
return new SensusTestInfo[]
{
/// TBF Oracle DB Opto RAW LU logfiles
new SensusTestInfo("Q3", 5, "Q3", 5, "05", 5, "Q3", Range.R90_100),
new SensusTestInfo("Q3", 5, "Q3", 5, "04", 5, "Q3", Range.R90_100),
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
};
@@ -481,7 +465,7 @@ namespace Results.Output
return new SensusTestInfo[]
{
/// TBF Oracle DB Opto RAW LU logfiles
new SensusTestInfo("Q4", 5, "Q4", 5, "05", 5, "Q4", Range.R90_100),
new SensusTestInfo("Q4", 5, "Q4", 5, "04", 5, "Q4", Range.R90_100),
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
};
+3 -3
View File
@@ -96,7 +96,7 @@ namespace Results.Output
else
{
bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount);
SizeF size = Common.Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font);
SizeF size = Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font);
if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width;
if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height;
}
@@ -159,7 +159,7 @@ namespace Results.Output
{
/// In not a separator line
bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount);
SizeF size = Common.Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font);
SizeF size = Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font);
if ((Style.ColumnWidths != null) && (Style.ColumnWidths.Length > colIx))
{
size.Width = Style.ColumnWidths[colIx]; /// Override measurement if column width is defined
@@ -246,7 +246,7 @@ namespace Results.Output
for (int colIndex = 0; colIndex < tblColumnsCount; colIndex++)
{
bool isHeader = (colIndex < Style.LeftHeadersCount) || (rowIndex < Style.TopHeadersCount);
Common.Printers.PrintersCommon.PrintAt(e, oneTableRow[colIndex],
Printers.PrintersCommon.PrintAt(e, oneTableRow[colIndex],
isHeader ? Style.HeaderFont : Style.Font,
columnPos[colIndex],
rowPos[rowIndex],
+34 -124
View File
@@ -1,7 +1,4 @@
///
/// Copyright (c) 2019-2023 Sensus Metering Systems
///
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -16,28 +13,34 @@ namespace Results.Output
{
public static Chart GetChart(WaterMeter wm, bool isPrinter)
{
return GetChart(wm, isPrinter, Unit.lph);
return GetChart(wm, isPrinter, Config.Unit.lph);
}
public static Chart GetChart(WaterMeter wm, bool isPrinter, Unit flowUnit)
public static Chart GetChart(WaterMeter wm, bool isPrinter, Config.Unit flowUnit)
{
double maxFlow = 0;
double maxFlow_m3h = 0;
IList<PointF> unsortedPoints = new List<PointF>();
foreach (var mtr in wm.RegularMeterTestRslts())
{
double flow = mtr.TestRslt.FlowVolume;
var td = mtr.TestRslt.TestData;
if (mtr.IsPilotRslt() && flow > 0 && td.Evaluate &&
(td.Publish == (sbyte)Publish.Always || (!isPrinter && td.Publish == (sbyte)Publish.OnScreen)))
if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestRslt.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0))
{
if (flow > maxFlow) maxFlow = flow;
unsortedPoints.Add(new PointF((float)Units.ConvertTo(flowUnit, flow), (float)mtr.Error));
double flow_m3h = (mtr.TestTime != 0)
? (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestTime * mtr.PulsesMaster / mtr.TestRslt.PulsesMaster)
: (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime);
if (flow_m3h > maxFlow_m3h) maxFlow_m3h = flow_m3h;
double flow = Config.Units.ConvertTo(flowUnit, flow_m3h); /// Convert to specified units
if (flow > 0)
{
unsortedPoints.Add(new PointF((float)flow, (float)mtr.Error));
}
}
}
IEnumerable<PointF> sortedPoints = unsortedPoints.OrderBy(x => x.X);
bool isQ4 = (maxFlow > 1.1 * wm.WaterMeterData.Q3_Qn);
bool isQ4 = (maxFlow_m3h > 1.1 * wm.WaterMeterData.Q3_Qn);
Chart chart = new Chart
{
@@ -55,9 +58,6 @@ namespace Results.Output
chArea.AxisX.LogarithmBase = 10;
chArea.AxisX.IsLabelAutoFit = true;
Series upperLimit = new Series { Name = Strings.Upper_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
List<double> xs = new List<double>() { 0.0001, 0.0002, 0.0005,
0.001, 0.002, 0.005,
0.01, 0.02, 0.05,
@@ -71,11 +71,9 @@ namespace Results.Output
1000000, 2000000, 5000000,
10000000 };
double spacer = 0.8;
double from = Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin);
double to = Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn);
double from = Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin);
double to = Config.Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn);
bool inRange = false;
double qSharp = (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi) ? GetQsharp(wm, flowUnit) : 0;
double lastXs = 0;
for (int i = 0; i < xs.Count - 3; i += 3)
{
if (xs[i] <= from && from < xs[i + 3])
@@ -93,37 +91,6 @@ namespace Results.Output
cl.FromPosition = Math.Log10(xs[j] * spacer);
cl.ToPosition = Math.Log10(xs[j] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi)
{
if (lastXs != 0)
{
double insertedXs = Math.Sqrt(lastXs * xs[j]);
if (lastXs < qSharp && qSharp < insertedXs)
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
double errLim2 = GetErrorLimit(wm, flowUnit, insertedXs);
lowerLimit.Points.AddXY(insertedXs, -errLim2);
upperLimit.Points.AddXY(insertedXs, +errLim2);
if (insertedXs < qSharp && qSharp < xs[j])
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
}
lastXs = xs[j];
double errLim = GetErrorLimit(wm, flowUnit, xs[j]);
lowerLimit.Points.AddXY(xs[j], -errLim);
upperLimit.Points.AddXY(xs[j], +errLim);
}
}
}
@@ -137,36 +104,6 @@ namespace Results.Output
cl.ToPosition = Math.Log10(xs[i + 3] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi)
{
if (lastXs != 0)
{
double insertedXs = Math.Sqrt(lastXs * xs[i + 3]);
if (lastXs < qSharp && qSharp < insertedXs)
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
double errLim2 = GetErrorLimit(wm, flowUnit, insertedXs);
lowerLimit.Points.AddXY(insertedXs, -errLim2);
upperLimit.Points.AddXY(insertedXs, +errLim2);
if (insertedXs < qSharp && qSharp < xs[i + 3])
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
}
double errLim = GetErrorLimit(wm, flowUnit, xs[i + 3]);
lowerLimit.Points.AddXY(xs[i + 3], -errLim);
upperLimit.Points.AddXY(xs[i + 3], +errLim);
}
break;
}
}
@@ -177,20 +114,19 @@ namespace Results.Output
Legend legend1 = new Legend { Name = "Legend1" };
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.Q3Q2Q1 || wm.WaterMeterData.Qnames == (sbyte)FlowNames.QnQtQmin)
{
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), wm.WaterMeterData.ErrLimLoQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), wm.WaterMeterData.ErrLimLoQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), wm.WaterMeterData.ErrLimHiQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), wm.WaterMeterData.ErrLimHiQ);
if (isQ4) upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), wm.WaterMeterData.ErrLimHiQ);
Series upperLimit = new Series { Name = Strings.Upper_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), 5);
upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 5);
upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 2);
upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), 2);
if (isQ4) upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), 2);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -wm.WaterMeterData.ErrLimLoQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -wm.WaterMeterData.ErrLimLoQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -wm.WaterMeterData.ErrLimHiQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -wm.WaterMeterData.ErrLimHiQ);
if (isQ4) lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), -wm.WaterMeterData.ErrLimHiQ);
}
Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -5);
lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -5);
lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -2);
lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -2);
if (isQ4) lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), -2);
Series line = new Series { Name = Strings.Relative_error, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.DeepSkyBlue };
Series dots = new Series { Name = Strings.Relative_error + " ", ChartArea = "ChartArea1", ChartType = SeriesChartType.Point, Color = Color.RoyalBlue };
@@ -204,38 +140,12 @@ namespace Results.Output
chart.ChartAreas.Add(chArea);
chart.Legends.Add(legend1);
if (upperLimit.Points.Count > 1) chart.Series.Add(upperLimit);
if (lowerLimit.Points.Count > 1) chart.Series.Add(lowerLimit);
chart.Series.Add(upperLimit);
chart.Series.Add(lowerLimit);
chart.Series.Add(dots);
chart.Series.Add(line);
return chart;
}
static double GetErrorLimit(WaterMeter wm, Unit flowUnit, double x)
{
double flow_m3 = Units.ConvertFrom(flowUnit, x);
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: return Math.Min(3.5, 1.0 + 0.01 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 2: return Math.Min(5.0, 2.0 + 0.02 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 3: return Math.Min(5.0, 3.0 + 0.05 * wm.WaterMeterData.Q3_Qn / flow_m3);
}
}
static double GetQsharp(WaterMeter wm, Unit flowUnit)
{
double qSharp;
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: qSharp = (0.01 / 2.5) * wm.WaterMeterData.Q3_Qn; break;
case 2: qSharp = (0.02 / 3.0) * wm.WaterMeterData.Q3_Qn; break;
case 3: qSharp = (0.05 / 2.0) * wm.WaterMeterData.Q3_Qn; break;
}
return Units.ConvertTo(flowUnit, qSharp);
}
}
}

Some files were not shown because too many files have changed in this diff Show More