Compare commits

..
Author SHA1 Message Date
Milan Hanajik 9235984d30 WMsCount = 6, ver. 2.30.1963 2022-09-19 15:29:48 +02:00
Milan Hanajik 113a7c927a Reconfigured for IPERL_SPECIAL (PT7) 2022-09-19 09:26:10 +02:00
370 changed files with 8827 additions and 17589 deletions
-24
View File
@@ -54,30 +54,6 @@ Users/bin/
Users/obj/
UserManagement/bin/
UserManagement/obj/
DataMatrix4Net/bin/
DataMatrix4Net/obj/
GenericTest/bin/
GenericTest/obj/
LabelPrinting/bin/
LabelPrinting/obj/
OrderManagement/bin/
OrderManagement/obj/
ProductionTracing/bin/
ProductionTracing/obj/
RecordProcessing/bin/
RecordProcessing/obj/
S640TestApp/bin/
S640TestApp/obj/
SchematicDrawing/bin/
SchematicDrawing/obj/
SharedDatabase/bin/
SharedDatabase/obj/
WorkflowConfigurator/bin/
WorkflowConfigurator/obj/
Workplace/bin/
Workplace/obj/
MonitoringDB/bin/
MonitoringDB/obj/
.vs/
*.suo
*.bak
-1
View File
@@ -42,7 +42,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BackgroundBeep.cs" />
<Compile Include="Const.cs" />
<Compile Include="DatabaseSettings.cs" />
<Compile Include="DBSettings.cs" />
<Compile Include="Enums.cs" />
-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";
}
}
-1
View File
@@ -12,7 +12,6 @@ namespace Common
{
public DBType DbType;
public string ConnectionString;
public bool IsValid { get { return (DbType != DBType.None) && !string.IsNullOrEmpty(ConnectionString); } }
public DBSettings()
{
+3 -3
View File
@@ -15,10 +15,10 @@ namespace Common
// Public fields
public string BenchName;
public bool IsRealBench;
public DBSettings ProceduresDBSettings; /// Configuration database settings
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
public DBSettings EventsDBSettings; /// Events database settings
public DBSettings UsersDBSettings; /// Shared configuration database settings
// Constructor
public DatabaseSettings()
+14 -27
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
@@ -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
}
+4 -7
View File
@@ -1,7 +1,4 @@
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -56,20 +53,20 @@ namespace Common.Forms
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
void OnUpdateMessage(object sender, MessageEventArgs args)
{
if (args != null && args.Message != null) label1.Text = args.Message;
if (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()
public static void CloseForm()
{
if (CloseFormHandler == null) return;
try { CloseFormHandler(null, null); }
catch (Exception) { }
}
public event EventHandler<EventArgs> CloseFormHandler;
static public event EventHandler<EventArgs> CloseFormHandler;
void OnCloseForm(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
+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("")]
-41
View File
@@ -2,7 +2,6 @@
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
///
using System;
using System.IO.Ports;
namespace Common
{
@@ -21,18 +20,6 @@ namespace Common
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)
@@ -105,33 +92,5 @@ namespace Common
else return "F5";
}
}
public static Parity GetParity(string str, Parity defaultParity = Parity.None)
{
if (str.Equals(Parity.None.ToString())) return Parity.None;
if (str.Equals(Parity.Even.ToString())) return Parity.Even;
if (str.Equals(Parity.Odd.ToString())) return Parity.Odd;
if (str.Equals(Parity.Mark.ToString())) return Parity.Mark;
if (str.Equals(Parity.Space.ToString())) return Parity.Space;
return defaultParity;
}
public static StopBits GetStopBits(string str, StopBits defaultStopBits = StopBits.One)
{
if (str.Equals(StopBits.None.ToString())) return StopBits.None;
if (str.Equals(StopBits.One.ToString())) return StopBits.One;
if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive;
if (str.Equals(StopBits.Two.ToString())) return StopBits.Two;
return defaultStopBits;
}
public static Handshake GetHandshake(string str, Handshake defaultHandshake = Handshake.None)
{
if (str.Equals(Handshake.None.ToString())) return Handshake.None;
if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend;
if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff;
if (str.Equals(Handshake.RequestToSendXOnXOff.ToString())) return Handshake.RequestToSendXOnXOff;
return defaultHandshake;
}
}
}
+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);
}
}
+2 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;DEBUG;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</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;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+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;
}
+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); };
+1 -1
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; } /// - ' ' -
+1 -4
View File
@@ -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)
{
+15 -60
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
@@ -57,14 +57,7 @@ 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
@@ -119,15 +112,7 @@ namespace Config.Entities
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()
@@ -207,14 +192,6 @@ 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;
@@ -265,14 +242,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 +262,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);
@@ -326,14 +296,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)
{
@@ -393,14 +355,7 @@ namespace Config.Entities
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
return diff.ToString();
}
+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.MySql:
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
break;
case Common.DBType.SQLite:
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(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;
}
}
}
+2 -2
View File
@@ -214,9 +214,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;
-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);
+1 -9
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;
@@ -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")]
-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>
+4 -4
View File
@@ -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;
}
@@ -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)
+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.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<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();
}
}
}
+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();
}
+6 -15
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;
@@ -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))
+3 -55
View File
@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Common;
using Config.Entities;
namespace Results.Entities
@@ -32,14 +31,7 @@ namespace Results.Entities
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 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
@@ -69,15 +61,7 @@ namespace Results.Entities
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
}
}
/// <summary>
/// Copy constructor, copies all except of Id
@@ -100,14 +84,6 @@ namespace Results.Entities
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
}
@@ -134,14 +110,7 @@ namespace Results.Entities
if (TempControl != td.TempControl) 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;
}
@@ -183,14 +152,6 @@ namespace Results.Entities
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)
@@ -212,19 +173,6 @@ namespace Results.Entities
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;
+56 -24
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;
@@ -97,10 +97,12 @@ namespace Results.Entities
public virtual int WMTypeRevision { get; set; }
public virtual int Pruefindex { get; set; } /// >=1 ... pruefindex, 0 ... unknown (no reading from DB yet)
public virtual int HydrPruefung { get; set; }
public virtual object RawTestInfos { get; set; } /// Not mapped to DB !!! IList<SensusTestInfo> fetched from Oracle at the beginning of the cycle, not mapped to DB !!!
public virtual object CompleteTestInfos { get; set; } /// Not mapped to DB !!! 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 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 bool PrintLabel { get; set; } /// Not mapped to DB !!!
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;
@@ -456,10 +446,12 @@ namespace Results.Entities
WMTypeRevision = 0;
Pruefindex = 0;
HydrPruefung = 0;
RawTestInfos = null;
CompleteTestInfos = null;
#endif
ProcessId = 0;
SessionId = 0;
LastRecordIsNok = false;
PrintLabel = true;
}
@@ -518,10 +510,12 @@ namespace Results.Entities
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)
{
@@ -698,10 +692,26 @@ namespace Results.Entities
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))
@@ -778,10 +788,32 @@ namespace Results.Entities
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();
}
}
}
+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));
}
+4 -4
View File
@@ -79,18 +79,18 @@ namespace Results.Forms
return;
}
/// Update background color and caption
/// Update background color
string message = string.Empty;
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#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));
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
+9 -12
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,21 @@ namespace Results.Forms
return;
}
/// Update background color and caption
/// Update background color
string message = string.Empty;
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#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));
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
UpdateWMPos(wMtr.WMPosition);
/// Update test results
-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,
}
+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);
@@ -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++;
+15 -108
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Metering Systems
/// Copyright (c) 2019-2022 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -55,9 +55,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,
@@ -74,8 +71,6 @@ namespace Results.Output
double from = Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin);
double to = 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 +88,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 +101,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 +111,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(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), 5);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 5);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 2);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), 2);
if (isQ4) upperLimit.Points.AddXY(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(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -5);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -5);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -2);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -2);
if (isQ4) lowerLimit.Points.AddXY(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 +137,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);
}
}
}
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("Results")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko, a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2019 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.27.1844.0")]
[assembly: AssemblyFileVersion("2.27.1844.0")]
+11 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;DEBUG;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
@@ -75,6 +75,12 @@
<Compile Include="Entities\WaterMeterData.cs" />
<Compile Include="Entities\WaterMeter.cs" />
<Compile Include="DB.cs" />
<Compile Include="Forms\BatchResultsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ManualEntryConfigCtrl.cs">
<SubType>UserControl</SubType>
@@ -207,6 +213,9 @@
<Folder Include="Output\FileWriters\OneFilePerMeter\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\BatchResultsDlg.resx">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ManualEntryConfigCtrl.resx">
<DependentUpon>ManualEntryConfigCtrl.cs</DependentUpon>
</EmbeddedResource>
+6 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
///
using System;
using System.Text;
@@ -9,9 +9,12 @@ namespace Results
{
public static class Utils
{
public static int MaxTestIndex = 0;
public static string GetTestName(string name, int repeats, int repetitionNr)
{
return Common.Utils.GetTestName(name, repeats, repetitionNr);
}
public static int BenchIdOracle2Asc(int benchIdOracle)
{
switch (benchIdOracle)
+5 -6
View File
@@ -331,12 +331,11 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(ItemID.ThreeState, "Three state result", Quantity.Enumerated, ItemCategory.MeterResult, (w, t, u, f, p) => FormatThreeState(f, w.ThreeStateFromTests())));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Scale, "Scale", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Scale()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Diverter, "Diverter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Diverter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RegValve, "Reg. valve", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RegValve()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult,(w, t, u, f, p) => (w.GetMeterTestRslt(t) != null) ? FormatStr(f, w.GetMeterTestRslt(t).PassedOrErrorFlagsStr())
: FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Scale, "Scale", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Scale()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Diverter, "Diverter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Diverter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RegValve, "Reg. valve", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RegValve()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
///
/// Water meter info
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("ResultsBrowser")]
[assembly: AssemblyCopyright("Copyright © 2015 - 2022 Sensus Slovensko a.s.")]
[assembly: AssemblyCopyright("Copyright © 2015 - 2020 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.1577.0")]
[assembly: AssemblyFileVersion("2.26.1577.0")]
+2 -2
View File
@@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;DEBUG;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -32,7 +32,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;FUZHOU_100</DefineConstants>
<DefineConstants>TRACE;TURA_SPECIAL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
-2
View File
@@ -31,8 +31,6 @@ namespace ResultsParser
.Database(MySQLConfiguration.Standard.ConnectionString(connStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<WaterMeterData>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory()
.OpenSession();
+8 -6
View File
@@ -239,7 +239,7 @@ namespace Statistics
"SERVER=localhost; DATABASE=genesis-r; UID=root; PASSWORD=; CHARSET=utf8;",
};
#else
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "WR18", "WR19", "PT7" };
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "WR18", "WR19", "WR20", "WR21", "PT7" };
MidNames = new string[] { string.Empty, "I1", "I2", "I3", "I4" }; /// Index is MID-id
#if true
/// Production Stara Tura
@@ -247,14 +247,16 @@ namespace Statistics
ConnectionStrings = new string[]
{
"SERVER=10.42.129.242; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.69; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.129.27; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.0; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.146; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.70; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.52; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.61; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.71; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.165; DATABASE=st-wr18-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.159; DATABASE=st-wr19-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.89; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.76; DATABASE=st-wr20-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.156; DATABASE=st-wr21-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.131; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
};
#else
/// Off-line demo
-4
View File
@@ -133,10 +133,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\Results\Results.csproj">
<Project>{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}</Project>
<Name>Results</Name>
-3
View File
@@ -13,7 +13,6 @@ using NHibernate;
using FluentNHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Common;
using Results;
using Results.Entities;
using Statistics.Resources;
@@ -99,8 +98,6 @@ namespace Statistics
.Database(MySQLConfiguration.Standard.ConnectionString(connStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Results.Entities.Batch>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
catch (Exception)
+1 -41
View File
@@ -1,8 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}"
ProjectSection(ProjectDependencies) = postProject
{C8939821-BA5C-4988-A3D0-BF53B74865C7} = {C8939821-BA5C-4988-A3D0-BF53B74865C7}
@@ -10,18 +8,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8
{0C0A1F4D-1363-4544-A7C5-196C76D26CCA} = {0C0A1F4D-1363-4544-A7C5-196C76D26CCA}
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE} = {46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}
{5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0} = {5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0}
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Results", "Results\Results.csproj", "{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}"
ProjectSection(ProjectDependencies) = postProject
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Config", "Config\Config.csproj", "{743DF7DB-C7B6-42EB-986D-0F485E5588E4}"
ProjectSection(ProjectDependencies) = postProject
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsBrowser", "ResultsBrowser\ResultsBrowser.csproj", "{07BA543A-54CA-4A59-9AD9-DDE7038E1BF9}"
ProjectSection(ProjectDependencies) = postProject
@@ -94,10 +85,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatureVectorCalculator", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsParser", "ResultsParser\ResultsParser.csproj", "{2E08C19B-C0A9-4056-8564-E5B74477959D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sensus.iPerl.RfidCom", "..\iPerlHead\Sensus.iPerl.RfidCom\Sensus.iPerl.RfidCom.csproj", "{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NfcS5_DLL", "..\NfcS5_DLL\NfcS5_DLL.csproj", "{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -392,35 +379,8 @@ Global
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|x86.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|x86.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Any CPU.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|x86.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7C8EF35-DF72-4DFC-83F7-9641AC1178CF}
EndGlobalSection
EndGlobal
+33 -183
View File
@@ -1,17 +1,11 @@
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Common;
using Events;
using TBF.Resources;
using System.Collections.Generic;
using Config;
using Users.Entities;
namespace TBF
{
@@ -22,196 +16,52 @@ namespace TBF
///
public static DatabaseSettings CurrentBench;
public static ISessionFactory ConfigDBSessionFactory = null; /// Configuration DB session factory (always != null)
public static ISessionFactory SharedDBSessionFactory = null; /// Shared configuration DB session factory or null
public static ISessionFactory ResultsDBSessionFactory = null; /// Results DB session factory (always != null)
public static ISessionFactory EventsDBSessionFactory = null; /// Events DB session factory or null
public static ISessionFactory LocalUsersDBSessionFactory = null; /// Local users DB session factory (always != null)
public static ISessionFactory SharedUsersDBSessionFactory = null; /// Shared users DB session factory or null
public static ISessionFactory[] UserSessionFactories
{
get
{
return (SharedUsersDBSessionFactory != null)
? new ISessionFactory[] { SharedUsersDBSessionFactory, LocalUsersDBSessionFactory }
: new ISessionFactory[] { LocalUsersDBSessionFactory };
}
}
/// <summary>
/// Create all database session factories
/// Session factories for regular sessions.
/// </summary>
public static void CreateSessionFactories(DatabaseSettings dbSettings)
public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)DBKind.Count];
/// Create a NHibernate session for the given database
public static ISession CreateSession(DBKind database)
{
/// Configuration database (local, always non-null)
if (dbSettings.ProceduresDBSettings != null && dbSettings.ProceduresDBSettings.IsValid)
{
ConfigDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
dbSettings.ProceduresDBSettings.DbType,
dbSettings.ProceduresDBSettings.ConnectionString);
if (database < 0 || database >= DBKind.Count) return null;
LocalUsersDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Users.Entities.User>(),
dbSettings.ProceduresDBSettings.DbType,
dbSettings.ProceduresDBSettings.ConnectionString);
int ix = (int)database;
if (SessionFactories[ix] == null)
{
SessionFactories[ix] = CreateSessionFactory(database);
}
/// Shared configuration database (remote)
if (dbSettings.UsersDBSettings != null && dbSettings.UsersDBSettings.IsValid)
{
SharedDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
dbSettings.UsersDBSettings.DbType,
dbSettings.UsersDBSettings.ConnectionString);
SharedUsersDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Users.Entities.User>(),
dbSettings.UsersDBSettings.DbType,
dbSettings.UsersDBSettings.ConnectionString);
}
/// Results database (local, always non-null)
if (dbSettings.WaterMetersDBSettings != null && dbSettings.WaterMetersDBSettings.IsValid)
{
Results.DB.SessionFactory = ResultsDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Results.Entities.Batch>(),
dbSettings.WaterMetersDBSettings.DbType,
dbSettings.WaterMetersDBSettings.ConnectionString);
}
/// Events database (remote or local)
if (dbSettings.EventsDBSettings != null && dbSettings.EventsDBSettings.IsValid)
{
EventsDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Events.Entities.Event>(),
dbSettings.EventsDBSettings.DbType,
dbSettings.EventsDBSettings.ConnectionString);
}
return SessionFactories[ix].OpenSession();
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(Action<MappingConfiguration> mappings, DBType dbType,
string connectionString, bool createDB = false)
static ISessionFactory CreateSessionFactory(DBKind database)
{
try
DBType dbType;
string connectionString;
switch (database)
{
var buildSchema = createDB ? (Action<Configuration>)BuildSchemaCreate : (Action<Configuration>)BuildSchema;
switch (dbType)
{
default:
case DBType.MySql:
return Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(mappings)
.ExposeConfiguration(buildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
case DBType.SQLite:
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.UsingFile(connectionString))
.Mappings(mappings)
.ExposeConfiguration(buildSchema)
.BuildSessionFactory();
}
}
catch (Exception exc)
{
MessageBox.Show(string.Format("{0}: {1}", Strings.Cannot_connect_to_the_database, exc.Message),
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
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(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
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 = Config.Data.AdminUsername,
FullName = Strings.Administrator,
LastPwChange = DateTime.Now
};
admin.SetPassword(Config.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_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();
}
default:
case DBKind.Config:
dbType = CurrentBench.ProceduresDBSettings.DbType;
connectionString = CurrentBench.ProceduresDBSettings.ConnectionString;
break;
case DBKind.Results:
dbType = CurrentBench.WaterMetersDBSettings.DbType;
connectionString = CurrentBench.WaterMetersDBSettings.ConnectionString;
break;
case DBKind.RemoteConfig:
dbType = CurrentBench.UsersDBSettings.DbType;
connectionString = CurrentBench.UsersDBSettings.ConnectionString;
break;
}
return true;
return Config.FluentCommon.CreateSessionFactory(database, dbType, connectionString, false);
}
}
}
-21
View File
@@ -231,27 +231,6 @@ namespace TBF
public string LastText3;
public string LastRemark;
/// DataEntry.Uni history
public string[] LastBgComm1;
public string[] LastBgComm2;
public string[] LastBgComm3;
///
public string[] LastBgColA;
public string[] LastBgColB;
public string[] LastBgColC;
public string[] LastBgColD;
public string[] LastBgColE;
///
public string[] LastEnComm1;
public string[] LastEnComm2;
public string[] LastEnComm3;
///
public string[] LastEnColA;
public string[] LastEnColB;
public string[] LastEnColC;
public string[] LastEnColD;
public string[] LastEnColE;
/// Purchase order history
public string[] PurchaseOrderHistory;
[XmlIgnore]
+77 -131
View File
@@ -1,20 +1,19 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using NHibernate;
using Common;
using Config.Entities;
using Users;
using Users.Entities;
using TBF.Resources;
using TBF.Rig.Sequences;
using TBF.UI.Shared;
using System.Threading;
using NHibernate;
namespace TBF
{
@@ -70,9 +69,7 @@ namespace TBF
[STAThread]
static void Main()
{
Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
/// Program version string
System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
@@ -217,7 +214,7 @@ namespace TBF
/// Ask what to do, ask for the password, open 'DatabaseSetingsDlg' and continue on OK
if ((new NoBenchOrDatabaseDlg { Message = Strings.NoBenchMsg }.ShowDialog() != DialogResult.OK) ||
(new Users.Forms.LoginDlg().ShowDialog() == DialogResult.Cancel) ||
(new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel) ||
(new TBF.UI.Settings.BenchesDlg().ShowDialog() == DialogResult.Cancel))
{
return; /// Exit program
@@ -232,8 +229,6 @@ namespace TBF
bool retryLogin = true; /// true = stay in a login loop
do
{
LoadingConfigEnd();
LoginDlgWithBenchSelection loginDlgBench;
if (LocalSettings.LastBenchName != null)
{
@@ -256,11 +251,10 @@ namespace TBF
{
if (LocalSettings.TestBenches[i].BenchName == loginDlgBench.BenchName)
{
log.FatalFormat("Test bench name: {0}", loginDlgBench.BenchName);
log.FatalFormat("Test bench name: {0}", loginDlgBench.BenchName);
LoadingConfigStart();
TBF.DB.CurrentBench = LocalSettings.TestBenches[i].Clone() as DatabaseSettings;
TBF.DB.CreateSessionFactories(LocalSettings.TestBenches[i]);
Users.CurrentUser.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings;
Users.CurrentUser.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings;
Users.Entities.User loadedUser = null;
try
@@ -276,10 +270,11 @@ namespace TBF
if (Users.Entities.User.IsPowerUser(loginDlgBench.Alias, loginDlgBench.Password))
{
loadedUser = new Users.Entities.User(loginDlgBench.Alias, 6, true);
CurrentUser.Change(loadedUser, null);
CurrentUser.LastAuthorization = DateTime.Now;
CurrentUser.AuthorizedAs = Common.AuthorizedAs.PowerUser;
authorized = true;
authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
if (authorized)
{
Users.CurrentUser.AuthorizedAs = Common.AuthorizedAs.PowerUser;
}
}
///
@@ -287,57 +282,42 @@ namespace TBF
///
if (!authorized)
{
DBSettings[] dbs = new DBSettings[] { Users.CurrentUser.RemoteUsersDB, Users.CurrentUser.LocalUsersDB };
authorizedAs = Common.AuthorizedAs.RemoteUser; /// Try remote DB first
foreach (var sf in TBF.DB.UserSessionFactories)
foreach (var db in dbs)
{
/// Load and authorise user from the UsersDB database
try
{
if (sf != null)
if (loginDlgBench.Password == LoginDlgWithBenchSelection.UseTheTagPassword)
{
var session = sf.OpenSession();
if (loginDlgBench.Password == LoginDlgWithBenchSelection.UseTheTagPassword)
{
loadedUser = Users.Entities.User.LoadUserByTag(session, loginDlgBench.Alias);
if (loadedUser != null) authorized = loadedUser.AuthorizeTag(loginDlgBench.Alias, reqGrpMembership, null);
}
else
{
switch (loginDlgBench.Method)
{
default:
case Common.LoginMethod.UserName:
loadedUser = Users.Entities.User.LoadUserByName(session, loginDlgBench.Alias);
if (loadedUser != null)
{
authorized = loadedUser.Authorize(session, loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
}
break;
case Common.LoginMethod.FullName:
loadedUser = Users.Entities.User.LoadUserByFullName(session, loginDlgBench.Alias);
if (loadedUser != null)
{
authorized = loadedUser.AuthorizeFullName(session, loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
}
break;
case Common.LoginMethod.Number:
int number;
if (!int.TryParse(loginDlgBench.Alias, out number)) break;
loadedUser = Users.Entities.User.LoadUserByNumber(session, number);
if (loadedUser != null)
{
authorized = loadedUser.AuthorizeNumber(session, number, loginDlgBench.Password, reqGrpMembership, null);
}
break;
}
}
session.Close();
loadedUser = Users.Entities.User.LoadUserByTag(loginDlgBench.Alias, db);
if (loadedUser != null) authorized = loadedUser.AuthorizeTag(loginDlgBench.Alias, reqGrpMembership, null);
}
}
else
{
switch (loginDlgBench.Method)
{
default:
case Common.LoginMethod.UserName:
loadedUser = Users.Entities.User.LoadUserByName(loginDlgBench.Alias, db);
if (loadedUser != null) authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
break;
case Common.LoginMethod.FullName:
loadedUser = Users.Entities.User.LoadUserByFullName(loginDlgBench.Alias, db);
if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
break;
case Common.LoginMethod.Number:
int number;
if (!int.TryParse(loginDlgBench.Alias, out number)) break;
loadedUser = Users.Entities.User.LoadUserByNumber(number, db);
if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlgBench.Password, reqGrpMembership, null);
break;
}
}
}
catch
{
authorized = false;
@@ -373,11 +353,7 @@ namespace TBF
/// Copy the selected bench settings to CurrentBench.
/// Clone() guarantees that current bench settings wont be modified
/// when user modifies the database settings in DatabaseSettingsDlg.
if (TBF.DB.CurrentBench == null)
{
TBF.DB.CurrentBench = LocalSettings.TestBenches[i].Clone() as DatabaseSettings;
TBF.DB.CreateSessionFactories(TBF.DB.CurrentBench);
}
TBF.DB.CurrentBench = (DatabaseSettings)LocalSettings.TestBenches[i].Clone();
Results.DB.DbType = TBF.DB.CurrentBench.WaterMetersDBSettings.DbType;
Results.DB.ConnectionString = TBF.DB.CurrentBench.WaterMetersDBSettings.ConnectionString;
@@ -388,7 +364,7 @@ namespace TBF
/// Connect to Config database.
/// This triggers an exception in case user is a power user and there is no Config database.
///
var session = TBF.DB.ConfigDBSessionFactory.OpenSession();
ISession session = TBF.DB.CreateSession(DBKind.Config);
if (!string.IsNullOrEmpty(LocalSettings.LastProcedureName))
{
@@ -404,9 +380,9 @@ namespace TBF
.List();
if (components.Count > 0)
{
var factory = new TBF.Rig.DataContainers.BenchInfo.Extended.ComponentFactory();
var factory = new TBF.Rig.DataContainers.BenchInfo.Extended.ComponentFactory();
var cfg = factory.CmpntCfgFromCmpntEntity(components[0])
as TBF.Rig.DataContainers.BenchInfo.Extended.ComponentCfg;
as TBF.Rig.DataContainers.BenchInfo.Extended.ComponentCfg;
ProcessData.BenchInfo = new TBF.Rig.DataContainers.BenchInfo.Extended.Component(cfg);
}
else
@@ -417,20 +393,20 @@ namespace TBF
.List();
if (components.Count > 0)
{
var factory = new TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentFactory();
var factory = new TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentFactory();
var cfg = factory.CmpntCfgFromCmpntEntity(components[0])
as TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentCfg;
as TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentCfg;
ProcessData.BenchInfo = new TBF.Rig.DataContainers.BenchInfo.iPerl.Component(cfg);
}
}
session.Close();
///
/// Connect to Results database and determine the last saved batch number.
///
var rsltDBSession = TBF.DB.ResultsDBSessionFactory.OpenSession();
Results.DB.LoadSharedData(rsltDBSession);
int maxBatchNr = Results.DB.GetMaxSavedBatchNr(rsltDBSession);
Results.DB.LoadSharedData();
int maxBatchNr = Results.DB.GetMaxSavedBatchNr();
if (!TBF.DB.CurrentBench.IsRealBench || Program.LocalSettings.BatchNr <= maxBatchNr)
{
log.FatalFormat("Max. BatchNr in DB = {0}, LocalSettings.BatchNr = {1}", maxBatchNr, Program.LocalSettings.BatchNr);
@@ -438,7 +414,17 @@ namespace TBF
Program.LocalSettings.Save();
log.FatalFormat("LocalSettings.BatchNr updated to {0}", Program.LocalSettings.BatchNr);
}
if (rsltDBSession != null && rsltDBSession.IsOpen) rsltDBSession.Close();
///
/// Connect to Events database (if any) and load recent events from this test bench.
///
if (TBF.DB.CurrentBench.EventsDBSettings.DbType != Common.DBType.None &&
!string.IsNullOrEmpty(TBF.DB.CurrentBench.EventsDBSettings.ConnectionString))
{
Events.DB.DbType = (DBType)TBF.DB.CurrentBench.EventsDBSettings.DbType;
Events.DB.ConnectionString = TBF.DB.CurrentBench.EventsDBSettings.ConnectionString;
Events.DB.LoadRecentEvents(Events.DB.CreateSession(), loginDlgBench.BenchName, 7); /// Last 7 days
}
retryLogin = false;
break;
@@ -474,7 +460,7 @@ namespace TBF
default:
/// Open 'DatabaseSetingsDlg' and retry DB connect on OK
if (new Users.Forms.LoginDlg().ShowDialog() == DialogResult.Cancel ||
if (new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel ||
new TBF.UI.Settings.BenchesDlg().ShowDialog() == DialogResult.Cancel)
{
return; /// Exit program
@@ -496,31 +482,26 @@ namespace TBF
///
if (LocalSettings.LastProcedureName != null)
{
using (var session = TBF.DB.ConfigDBSessionFactory.OpenSession())
IList<Procedure> listOfProcedures = TBF.DB.CreateSession(Common.DBKind.Config)
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == Common.ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
if (listOfProcedures.Count == 1)
{
var listOfProcedures = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == Common.ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
if (listOfProcedures.Count == 1)
{
log.InfoFormat("Pre-selecting the procedure {0}", LocalSettings.LastProcedureName);
SelectedProcedure = listOfProcedures[0];
}
session.Close();
log.InfoFormat("Pre-selecting the procedure {0}", LocalSettings.LastProcedureName);
SelectedProcedure = listOfProcedures[0];
}
}
try
{
/// Open the main application window
{
/// Open the main application window
log.Info("Creating the main window");
MainWnd = new UI.MainWnd();
log.Info("Opening the main window");
LoadingConfigEnd();
Application.Run(MainWnd);
Application.Run(MainWnd);
log.Info("The main window was closed");
}
catch (Exception e)
@@ -539,12 +520,7 @@ namespace TBF
log.Info("Exiting application.");
}
private static void Form1_UIThreadException(object sender, ThreadExceptionEventArgs e)
{
LogException(log, "Unhandled thread exception", (Exception)e.Exception);
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
LogException(log, "Unhandled exception", (Exception)args.ExceptionObject);
}
@@ -560,35 +536,5 @@ namespace TBF
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
log.Fatal("--------------------------------------");
}
static UI.Shared.ModelessActivityForm form;
static System.Threading.Thread formThread;
static void LoadingConfigStart()
{
form = new UI.Shared.ModelessActivityForm()
{
Message = Strings.Starting_system,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.LightBlue,
};
formThread = new System.Threading.Thread(() => form.ShowDialog());
formThread.Start();
System.Threading.Thread.Sleep(500);
}
static void LoadingConfigEnd()
{
if (form != null && formThread != null)
{
form.CloseForm(null, new EventArgs());
formThread.Join();
}
form = null;
formThread = null;
}
}
}
}
}
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("TestBenchFramework")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2023 Sensus Slovensko, a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko, a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.33.2146.0")]
[assembly: AssemblyFileVersion("2.33.2146.0")]
[assembly: AssemblyVersion("2.30.1963.0")]
[assembly: AssemblyFileVersion("2.30.1963.0")]
+41 -113
View File
@@ -19,7 +19,7 @@ namespace TBF.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
@@ -294,15 +294,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to All files.
/// </summary>
internal static string All_files {
get {
return ResourceManager.GetString("All_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All tests must be completed.
/// </summary>
@@ -366,15 +357,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to any profile.
/// </summary>
internal static string any_profile {
get {
return ResourceManager.GetString("any_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Approval.
/// </summary>
@@ -654,15 +636,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate.
/// </summary>
internal static string Calibration_certificate {
get {
return ResourceManager.GetString("Calibration_certificate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate validity expired.
/// </summary>
@@ -691,7 +664,7 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Legalizator.
/// Looks up a localized string similar to Calibration Specialist.
/// </summary>
internal static string Calibration_Specialist {
get {
@@ -1293,15 +1266,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to default printer.
/// </summary>
internal static string default_printer {
get {
return ResourceManager.GetString("default_printer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Default units.
/// </summary>
@@ -1923,15 +1887,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Error reading configuration database.
/// </summary>
internal static string Error_reading_configuration_database {
get {
return ResourceManager.GetString("Error_reading_configuration_database", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error saving parameters of {0}.
/// </summary>
@@ -1941,15 +1896,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Error when saving and printing results.
/// </summary>
internal static string Error_when_saving_and_printing_results {
get {
return ResourceManager.GetString("Error_when_saving_and_printing_results", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error while creating the database. Reason: .
/// </summary>
@@ -2301,15 +2247,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Get number of cycles to bypass.
/// </summary>
internal static string Get_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Get_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Grab.
/// </summary>
@@ -3327,15 +3264,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to no profile.
/// </summary>
internal static string no_profile {
get {
return ResourceManager.GetString("no_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No results to print.
/// </summary>
@@ -3651,15 +3579,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to PDF files.
/// </summary>
internal static string PDF_files {
get {
return ResourceManager.GetString("PDF_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PID.
/// </summary>
@@ -3886,11 +3805,11 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Print.
/// Looks up a localized string similar to Print again.
/// </summary>
internal static string Print {
internal static string Print_again {
get {
return ResourceManager.GetString("Print", resourceCulture);
return ResourceManager.GetString("Print_again", resourceCulture);
}
}
@@ -3948,15 +3867,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Printer selection.
/// </summary>
internal static string Printer_selection {
get {
return ResourceManager.GetString("Printer_selection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Printer.
/// </summary>
@@ -4353,6 +4263,33 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Qmax [m3/h].
/// </summary>
internal static string Qmax {
get {
return ResourceManager.GetString("Qmax", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qmin [m3/h].
/// </summary>
internal static string Qmin {
get {
return ResourceManager.GetString("Qmin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qn [m3/h].
/// </summary>
internal static string Qn {
get {
return ResourceManager.GetString("Qn", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qrise.
/// </summary>
@@ -4362,6 +4299,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Qt [m3/h].
/// </summary>
internal static string Qt {
get {
return ResourceManager.GetString("Qt", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Question.
/// </summary>
@@ -5136,15 +5082,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Set number of cycles to bypass.
/// </summary>
internal static string Set_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Set_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set route.
/// </summary>
@@ -6318,15 +6255,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Unlock a bypass.
/// </summary>
internal static string Unlock_bypass {
get {
return ResourceManager.GetString("Unlock_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unlock.
/// </summary>
+14 -35
View File
@@ -673,10 +673,10 @@
<value>Tiskárna</value>
</data>
<data name="Procedure" xml:space="preserve">
<value>Procedura</value>
<value>Postup</value>
</data>
<data name="Procedures" xml:space="preserve">
<value>Procedury</value>
<value>Postupy</value>
</data>
<data name="Producer" xml:space="preserve">
<value>Výrobce</value>
@@ -688,7 +688,7 @@
<value>Restart programu vyžaduje použít některá nastavení</value>
</data>
<data name="Progress" xml:space="preserve">
<value>Postup</value>
<value>V činnosti</value>
</data>
<data name="Properties" xml:space="preserve">
<value>Vlastnosti</value>
@@ -732,9 +732,18 @@
<data name="Qfall" xml:space="preserve">
<value>Qfall</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Qrise</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>Otázka</value>
</data>
@@ -1177,7 +1186,7 @@
<value>Tisk výsledků</value>
</data>
<data name="Procedure_name" xml:space="preserve">
<value>Jméno procedury</value>
<value>Jméno postupu</value>
</data>
<data name="Process" xml:space="preserve">
<value>Proces</value>
@@ -1213,7 +1222,7 @@
<value>Objem</value>
</data>
<data name="PrintBtnText" xml:space="preserve">
<value>Tisknout</value>
<value>Vytisknout</value>
</data>
<data name="Do_you_want_to_save_changes" xml:space="preserve">
<value>Chcete uložit změny?</value>
@@ -1674,34 +1683,4 @@
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Konfigurace testu {0} : chybí {1}</value>
</data>
<data name="Print" xml:space="preserve">
<value>Tisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>předvolená tiskárna</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Zjisti počet cyklů bez kontroly</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Nastav počet cyklů bez kontroly</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Odemknout vypnutí kontroly</value>
</data>
<data name="All_files" xml:space="preserve">
<value>Všechny soubory</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Kalibrační certifikát</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF soubory</value>
</data>
<data name="Error_when_saving_and_printing_results" xml:space="preserve">
<value>Chyba při ukládání a tisknutí výsledků</value>
</data>
</root>
+14 -2
View File
@@ -1278,8 +1278,8 @@
<data name="Volume" xml:space="preserve">
<value>Volumen</value>
</data>
<data name="Print" xml:space="preserve">
<value>Drucken</value>
<data name="Print_again" xml:space="preserve">
<value>Druck wiederholen</value>
</data>
<data name="Show" xml:space="preserve">
<value>Anzeigen</value>
@@ -1545,6 +1545,9 @@
<data name="Invalid_username_or_password" xml:space="preserve">
<value>Ungültiger Benutzername oder Passwort </value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_Meter_States" xml:space="preserve">
<value>WZ-Stand</value>
</data>
@@ -1572,6 +1575,12 @@
<data name="Main_" xml:space="preserve">
<value>Hauptzähler</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Wasser</value>
</data>
@@ -1635,6 +1644,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Ungültige Einstellung. Bitte um Korrektur!</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax [m3/h]</value>
</data>
<data name="L" xml:space="preserve">
<value>Länge</value>
</data>
+12 -3
View File
@@ -633,6 +633,9 @@
<data name="Producer" xml:space="preserve">
<value>Producteur</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Compteurs eau</value>
</data>
@@ -984,6 +987,12 @@
<data name="Main_" xml:space="preserve">
<value>Principale</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Eau</value>
</data>
@@ -1134,6 +1143,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Informations d'étalonnage non valides. Corrigez le s'il vous plaît.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificat</value>
</data>
@@ -1998,7 +2010,4 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimer</value>
</data>
</root>
+15 -3
View File
@@ -648,6 +648,9 @@
<data name="Producer" xml:space="preserve">
<value>produttore</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>contatori acqua</value>
</data>
@@ -999,6 +1002,12 @@
<data name="Main_" xml:space="preserve">
<value>principale:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Q minimo</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Water" xml:space="preserve">
<value>acqua</value>
</data>
@@ -1149,6 +1158,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Informazioni di calibrazione non valida. Prego correggere</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Q massimo</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificato</value>
</data>
@@ -1521,6 +1533,9 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>stampa ancora</value>
</data>
<data name="Show" xml:space="preserve">
<value>mostrare</value>
</data>
@@ -1764,7 +1779,4 @@
<data name="Start_cycle" xml:space="preserve">
<value>Avviare il ciclo</value>
</data>
<data name="Print" xml:space="preserve">
<value>Stampa</value>
</data>
</root>
+16 -5
View File
@@ -199,8 +199,7 @@
<value>Parametry stanowiska</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Legalizator</value>
<comment>Specjalistyczna kalibracja</comment>
<value>Specjalistyczna kalibracja</value>
</data>
<data name="Camera_error" xml:space="preserve">
<value>Błąd kamery</value>
@@ -691,6 +690,9 @@
<data name="Qfall" xml:space="preserve">
<value>Qopad</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Qwzras</value>
</data>
@@ -1027,6 +1029,12 @@
<data name="Main_" xml:space="preserve">
<value>Główny:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Water" xml:space="preserve">
<value>Woda</value>
</data>
@@ -1168,6 +1176,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Nieprawidłowa nivormacje o kalibracji. Proszę poprawić.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certyfikat</value>
</data>
@@ -1531,6 +1542,9 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Wydrukuj jeszcze raz</value>
</data>
<data name="Show" xml:space="preserve">
<value>Pokaż</value>
</data>
@@ -1612,7 +1626,4 @@
<data name="Start_cycle" xml:space="preserve">
<value>Start cyklu</value>
</data>
<data name="Print" xml:space="preserve">
<value>Wydruk</value>
</data>
</root>
+15 -39
View File
@@ -424,7 +424,7 @@
<value>Administrator</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Legalizator</value>
<value>Calibration Specialist</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Head of Lab</value>
@@ -643,6 +643,9 @@
<data name="Producer" xml:space="preserve">
<value>Producer</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Water meters</value>
</data>
@@ -994,6 +997,12 @@
<data name="Main_" xml:space="preserve">
<value>Main:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Water</value>
</data>
@@ -1144,6 +1153,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Invalid calibration information. Correct it please.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax [m3/h]</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificate</value>
</data>
@@ -1519,8 +1531,8 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print" xml:space="preserve">
<value>Print</value>
<data name="Print_again" xml:space="preserve">
<value>Print again</value>
</data>
<data name="Show" xml:space="preserve">
<value>Show</value>
@@ -2302,40 +2314,4 @@
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Test {0} config. error : {1} is missing</value>
</data>
<data name="any_profile" xml:space="preserve">
<value>any profile</value>
</data>
<data name="no_profile" xml:space="preserve">
<value>no profile</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Printer selection</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>default printer</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Get number of cycles to bypass</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Set number of cycles to bypass</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Unlock a bypass</value>
</data>
<data name="Error_reading_configuration_database" xml:space="preserve">
<value>Error reading configuration database</value>
</data>
<data name="All_files" xml:space="preserve">
<value>All files</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Calibration certificate</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF files</value>
</data>
<data name="Error_when_saving_and_printing_results" xml:space="preserve">
<value>Error when saving and printing results</value>
</data>
</root>
+6 -3
View File
@@ -546,6 +546,12 @@
<data name="Q_to_lph" xml:space="preserve">
<value>Q pana la [l/h]</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>Intrebare</value>
</data>
@@ -825,7 +831,4 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimanta</value>
</data>
</root>
+15 -3
View File
@@ -633,6 +633,9 @@
<data name="Producer" xml:space="preserve">
<value>Производитель</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Счетчики воды</value>
</data>
@@ -987,6 +990,12 @@
<data name="Main_" xml:space="preserve">
<value>Главн:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="cold" xml:space="preserve">
<value>холодный</value>
</data>
@@ -1134,6 +1143,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Неверная информация калибровки. Исправьте это, пожалуйста.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Сертификат</value>
</data>
@@ -1506,6 +1518,9 @@
<data name="P_delta" xml:space="preserve">
<value>P дельта</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Печатать снова</value>
</data>
<data name="Show" xml:space="preserve">
<value>Показать</value>
</data>
@@ -1584,7 +1599,4 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Print" xml:space="preserve">
<value>Печатать</value>
</data>
</root>
+9 -3
View File
@@ -753,9 +753,18 @@
<data name="Qfall" xml:space="preserve">
<value>Q下降</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Q上升</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>问题</value>
</data>
@@ -1182,7 +1191,4 @@
<data name="Evaporation" xml:space="preserve">
<value>蒸发</value>
</data>
<data name="Print" xml:space="preserve">
<value>打印机</value>
</data>
</root>
+3 -3
View File
@@ -88,10 +88,10 @@ namespace TBF.Rig.Ambient.Comet
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Common.Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.SetDtrToOne = setDtrCheckBox.Checked;
return flags;
+3 -3
View File
@@ -86,10 +86,10 @@ namespace TBF.Rig.Ambient.Greco
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Common.Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
return flags;
}
+2 -2
View File
@@ -96,9 +96,9 @@ namespace TBF.Rig.Danfoss.VLT2800
config.BusAddress = int.Parse(busAddressTextBox.Text);
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
return flags;
}
-19
View File
@@ -1,19 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
namespace TBF.Rig
{
public class DataChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public object Data;
public DataChangeArgs(CfgChangeCmd command, object data)
{
Command = command;
Data = data;
}
}
}
@@ -10,7 +10,6 @@ using Config;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.BenchInfo.iPerl
{
@@ -57,51 +56,35 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -47,7 +47,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -89,7 +88,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
MaxTestIndex = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -351,10 +349,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
prms.LenghtUnit = this.LenghtUnit;
prms.Side = this.Side;
prms.MaxTestIndex = this.MaxTestIndex;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
+22 -39
View File
@@ -1,11 +1,10 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Buoyancy
{
@@ -37,51 +36,35 @@ namespace TBF.Rig.DataContainers.Buoyancy
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -27,7 +27,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -51,7 +50,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
Buoyancy = 1.00103;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -114,10 +112,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
void CopyContentTo(ComponentCfg prms)
{
prms.Buoyancy = this.Buoyancy;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+22 -39
View File
@@ -1,11 +1,10 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Density
{
@@ -40,51 +39,35 @@ namespace TBF.Rig.DataContainers.Density
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -28,7 +28,6 @@ namespace TBF.Rig.DataContainers.Density
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -53,7 +52,6 @@ namespace TBF.Rig.DataContainers.Density
AtTemperature = 20.0; /// °C
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -124,10 +122,6 @@ namespace TBF.Rig.DataContainers.Density
{
prms.RealDensity = this.RealDensity;
prms.AtTemperature = this.AtTemperature;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Density
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+22 -39
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;
@@ -7,7 +7,6 @@ using log4net;
using Config.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Evaporation
{
@@ -41,51 +40,35 @@ namespace TBF.Rig.DataContainers.Evaporation
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -21,7 +21,6 @@ namespace TBF.Rig.DataContainers.Evaporation
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -43,7 +42,6 @@ namespace TBF.Rig.DataContainers.Evaporation
public void InitializeAll()
{
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -16,7 +16,7 @@ namespace TBF.Rig.DataContainers.Evaporation
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
-131
View File
@@ -1,131 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using Common;
namespace TBF.Rig.DataEntry
{
/// <summary>
/// Action of a DataEntry field
/// </summary>
public enum Ac
{
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
[Description("Last from history")] HistoryLast,
[Description("Load")] Load, /// Load from water meters when the form is open, save on OK
[Description("Load (readonly)")] LoadReadOnly, /// Load from water meters when the form is open, prevent changes, do not save
[Description("Set")] Set, /// Set to 'yes' when the form is open
Count,
}
/// <summary>
/// Content of a DataEntry field
/// </summary>
public enum Ct
{
[Description("None")] None,
[Description("Serial nr.")] SerialNr,
[Description("Serial nr. aux")] SerialNrAux,
[Description("Radio address")] RadioAddress,
[Description("Year of calibration")] YearOfCalibration,
[Description("Start state")] StartState,
[Description("Start state aux")] StartStateAux,
[Description("End state")] EndState,
[Description("End state aux")] EndStateAux,
[Description("Archive path")] ArchivePath,
[Description("WM Order")] WmOrder,
[Description("Batch order")] BatchOrder,
[Description("Batch and WM order")] BatchAndWmOrder,
[Description("WM Remark")] WmRemark,
[Description("Batch remark")] BatchRemark,
[Description("Batch and WM remark")] BatchAndWmRemark,
[Description("Print label")] PrintLabel,
#if ORACLE_DB
[Description("Prefix")] Prefix,
[Description("Suffix")] Suffix,
#endif
Count
}
/// <summary>
/// Function of the multi purpose button
/// </summary>
public enum MultiPurposeBtnFunction
{
None,
AutoSN,
PrintLabelsOnOff,
}
///
/// Identifies image instance
///
public enum Tst
{
Start,
End,
Both,
}
///
/// Image rotation
///
public enum Rotation
{
R0,
R90,
R180,
R270,
Count
}
public class DEItem
{
public readonly Ct Content;
public readonly string Caption;
public readonly Ac Action;
public readonly int Width;
public DEItem(Ct content, string caption, Ac action, int width)
{
Content = content;
Caption = caption;
Action = action;
Width = width;
}
static IList<DEItem> items = new List<DEItem>();
///
public static void ClearItems() { items.Clear(); }
public static void AddItem(DEItem item) { items.Add(item); }
public static void AddItem(Ct content, string caption, Ac action, int width)
{
items.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetItems() { return items; }
static IList<DEItem> columns = new List<DEItem>();
///
public static void ClearColumns() { columns.Clear(); }
public static void AddColumn(DEItem column) { columns.Add(column); }
public static void AddColumn(Ct content, string caption, Ac action, int width)
{
columns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetColumns() { return columns; }
static IList<DEItem> summaryColumns = new List<DEItem>();
///
public static void ClearSummaryColumns() { summaryColumns.Clear(); }
public static void AddSummaryColumn(DEItem column) { summaryColumns.Add(column); }
public static void AddSummaryColumn(Ct content, string caption, Ac action, int width)
{
summaryColumns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetSummaryColumns() { return summaryColumns; }
}
}
+2 -84
View File
@@ -1,95 +1,13 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry
{
public class DEUtils
{
public static string GetContent(Ct content, WaterMeter wm)
{
if (wm == null) return string.Empty;
switch (content)
{
default:
case Ct.None: return string.Empty;
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.StartStateAux: return string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.EndStateAux: return (!wm.Disabled && wm.GetEndStateAux() != null) ? wm.GetEndStateAux() : string.Empty;
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.PrintLabel: return wm.PrintLabel ? Strings.yes : Strings.no;
#if ORACLE_DB
case Ct.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Ct.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
#endif
}
}
public static void PutContent(Ct content, WaterMeter wm, string value)
{
if (wm == null || wm.Disabled) return;
int year;
switch (content)
{
default:
case Ct.None: return;
case Ct.SerialNr: wm.SerialNr = value; return;
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
case Ct.RadioAddress: wm.RadioAddress = value; return;
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
case Ct.StartState: wm.SetStartState(value); return;
case Ct.StartStateAux: return;
case Ct.EndState: wm.EndState = value; return;
case Ct.EndStateAux: wm.SetEndStateAux(value); return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
wm.PurchaseOrder = value;
return;
case Ct.BatchOrder:
case Ct.BatchAndWmOrder:
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
return;
case Ct.WmRemark:
wm.Remark = value;
return;
case Ct.BatchRemark:
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
case Ct.PrintLabel:
wm.PrintLabel = (value == Strings.yes);
return;
#if ORACLE_DB
case Ct.Prefix: wm.Prefix = value; return;
case Ct.Suffix: wm.Suffix = value; return;
#endif
}
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
@@ -7,7 +7,11 @@ using System.Windows.Forms;
using log4net;
using TBF.Rig.Sequences;
using TBF.Resources;
#if MANAGED
using Oracle.ManagedDataAccess.Client;
#else
using Oracle.DataAccess.Client;
#endif
using System.Diagnostics;
using System.Drawing;
@@ -484,13 +488,6 @@ namespace TBF.Rig.DataEntry.S620
/// <param name="currentFocusOwner">TextBox control which received the event</param>
private void ProcKeyPress(object sender, KeyPressEventArgs e, ComboBox currentFocusOwner)
{
if (e.KeyChar == 'ľ' || e.KeyChar == 'š' || e.KeyChar == 'č' || e.KeyChar == 'ť' || e.KeyChar == 'ž' || e.KeyChar == 'ý' || e.KeyChar == 'á' || e.KeyChar == 'í' || e.KeyChar == 'é')
{
MessageBox.Show("Zlá klávesnica !!!");
e.Handled = true;
return;
}
if (e.KeyChar == '+')
{
/// Process '+' key ..... Form completed
@@ -7,7 +7,11 @@ using System.Drawing;
using System.Windows.Forms;
using log4net;
using NHibernate;
#if MANAGED
using Oracle.ManagedDataAccess.Client;
#else
using Oracle.DataAccess.Client;
#endif
using TracingDB;
using TracingDB.Entities;
using TBF.Rig.Sequences;
@@ -855,13 +859,6 @@ namespace TBF.Rig.DataEntry.S620
/// <param name="currentFocusOwner">TextBox control which received the event</param>
private void BodyNoTextBoxKeyPress(object sender, KeyPressEventArgs e, int wmNr0)
{
if (e.KeyChar == 'ľ' || e.KeyChar == 'š' || e.KeyChar == 'č' || e.KeyChar == 'ť' || e.KeyChar == 'ž' || e.KeyChar == 'ý' || e.KeyChar == 'á' || e.KeyChar == 'í' || e.KeyChar == 'é')
{
MessageBox.Show("Zlá klávesnica !!!");
e.Handled = true;
return;
}
if (closeButton != '\0' && e.KeyChar == closeButton)
{
/// Process '+' key ..... Form completed
+26 -84
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -16,24 +16,8 @@ namespace TBF.Rig.DataEntry.StandardCamera
private static readonly ILog log = LogManager.GetLogger(typeof(EntryForm));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
const string DfltOcrWorkspaceFolder = "C:\\TBF\\OCR\\";
const string DfltOcrWorkspaceExt = ".vrws";
static Dictionary<string, OcrVidi> ocrDictionary = new Dictionary<string, OcrVidi>();
readonly EntryFormCfg entryFormCfg;
public string OcrWorkspace
{
get { return (entryFormCfg != null && entryFormCfg.ProcParams != null) ? entryFormCfg.ProcParams.OcrWorkspace : string.Empty; }
}
public string OcrStream
{
get { return (entryFormCfg != null && entryFormCfg.ProcParams != null) ? entryFormCfg.ProcParams.OcrStream : string.Empty; }
}
IRegReader[] regReaders;
@@ -44,13 +28,26 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (entryFormCfg.DebugLevel == DebugMode.Simulate)
{
startImages = new string[] { "C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg", "C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg", "C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg", "C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg", "C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg" };
startImages = new string[] { "C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg" };
}
else
{
@@ -113,6 +110,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
CurrentOp currentOp;
public EntryForm() { }
public EntryForm(Generic.IComponentCfg cfg)
@@ -215,75 +213,21 @@ namespace TBF.Rig.DataEntry.StandardCamera
///
void OpenTestStartStatesDlg(EntryForm myRef)
{
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, disabled);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, startImages, disabled);
modelessDlg.Show();
}
///
void OpenTestEndStatesDlg(EntryForm myRef)
{
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, wmStartState, wmStartStateStr, endImages, disabled,
refVolume, errLimLo, errLimHi);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, endImages, wmStartState, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
///
void OpenDeferredTestEvalDlg(EntryForm myRef)
{
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, endImages, disabled,
refVolume, errLimLo, errLimHi);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, startImages, endImages, disabled, refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
///
OcrVidi GetOcr(string ocrWorkspace, out string message)
{
message = string.Empty;
if (string.IsNullOrEmpty(ocrWorkspace)) return null; /// No OCR was configured
string fullPath = (ocrWorkspace.Contains("\\") || ocrWorkspace.Contains("/"))
? ocrWorkspace.Replace('/', '\\')
: System.IO.Path.Combine(DfltOcrWorkspaceFolder, ocrWorkspace);
if (!fullPath.Contains(".")) fullPath = fullPath + DfltOcrWorkspaceExt;
OcrVidi ocrVidi;
if (ocrDictionary.TryGetValue(fullPath, out ocrVidi))
{
log.InfoFormat("existing OcrVidi({0}) was retrieved from dictionary", fullPath);
return ocrVidi;
}
try
{
ocrVidi = new OcrVidi(fullPath);
ocrDictionary.Add(fullPath, ocrVidi);
log.WarnFormat("new OcrVidi({0}) was added to dictionary", fullPath);
return ocrVidi;
}
catch (Exception e)
{
if (e.InnerException != null)
{
log.ErrorFormat("new OcrVidi({0}) thrown {1}: {2} / {3}",
fullPath, e.GetType().ToString(), e.Message,e.InnerException.Message);
}
else
{
log.ErrorFormat("new OcrVidi({0}) thrown {1}: {2}",
fullPath, e.GetType().ToString(), e.Message);
}
log.ErrorFormat("Stack trace:\r\n{0}", e.StackTrace);
message = string.Format("Cannot load OCR workspace:\r\n{0}\r\nOCR workspace file is {1}", e.Message, fullPath);
return null;
}
}
/// <summary>Start this operation</summary>
public void Start()
@@ -405,9 +349,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
for (int i = 0; i < dlg.WaterMetersCount; i++)
{
wmStartState[i] = dlg.WMStartState[i];
wmStartStateStr[i] = dlg.WMStartStateStr[i];
wmEndState[i] = dlg.WMEndState[i];
wmEndState[i] = dlg.WMEndState[i];
}
}
}
@@ -1,10 +1,9 @@
///
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.StandardCamera
@@ -28,18 +27,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
public string ProtocolTitle3;
public string ProtocolTitle4;
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public ProcParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
EntryFormCfg()
{
ProcParams = new ProcParams(true);
Name = "DataEntry-for-Camera";
ParentName = string.Empty;
HideOrder = false;
@@ -1,97 +0,0 @@
using System.Collections.Generic;
#if OCR
using ViDi2;
#endif
namespace TBF.Rig.DataEntry.StandardCamera
{
public class OcrVidi
{
#if OCR
/// Static variable: OCR ViDi control can only have one instance
static ViDi2.Runtime.IControl control;
readonly IWorkspace workspace;
#endif
readonly string ocrWorkspaceFile;
/// <summary>
/// Create OcrVidi wrapper class
/// </summary>
/// <param name="ocrWorkspaceFile">Cognex runtime workspace file (vrws)</param>
public OcrVidi(string ocrWorkspaceFile)
{
this.ocrWorkspaceFile = ocrWorkspaceFile;
#if OCR
if (control == null)
{
/// Create and initialize the main control
control = new ViDi2.Runtime.Local.Control(GpuMode.NoSupport);
control.InitializeComputeDevices(GpuMode.NoSupport, new List<int>() { }); /// Initializes all CUDA devices
}
/// Open a runtime workspace from file
workspace = control.Workspaces.Add(string.Format("ws{0}", control.Workspaces.Count + 1), ocrWorkspaceFile);
#endif
}
public string Recognize(string streamName, string imagePath, double denominator = 1000, string format = "F3")
{
#if OCR
IStream stream;
try { stream = workspace.Streams[streamName]; }
catch (Exception) { return string.Empty; }
if (stream == null) return string.Empty;
string findedText = string.Empty; /// Hladane cislo - stav vodomera - string
double findedValue = 0; /// Hladane cislo - stav vodomera
bool finded = false; /// Ci sme nasli hodnotu
// load an image from file
using (IImage image = new ViDi2.Local.LibraryImage(imagePath)) //disposing the image when we do not need it anymore
{
// allocates a sample with the image
using (ISample sample = stream.CreateSample(image))
{
ITool tool = stream.Tools["Read"];
// process image with the blue read tool
sample.Process(tool);
IBlueMarking blueReadMarking = sample.Markings[tool.Name] as IBlueMarking;
foreach (IBlueView view in blueReadMarking.Views)
{
foreach (IMatch match in view.Matches)
{
//System.Console.WriteLine($"This model says \" {(match as IReadModelMatch).FeatureString} \" with a score of {match.Score}");
string word = (match as IReadModelMatch).FeatureString;
if (word.Length >= 7 && word.Length <= 8 // hladane cislo ma od 7 do 8 znakov
&& double.TryParse(word,out findedValue)) // a ak najdeny text je cislo
{
findedValue /= denominator; // Convert to m3, red digits are fractions of m3
finded = true;
break;
}
}
if (finded) break;
}
}
}
if (finded)
{
findedText = findedValue.ToString(format);
}
return findedText;
#else
return null;
#endif
}
public override string ToString()
{
return ocrWorkspaceFile;
}
}
}
@@ -1,132 +0,0 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System.IO;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.StandardCamera
{
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public string OcrWorkspace; /// Path to a Cognex workspace file
public string OcrStream; /// Cognex workspace stream name
public override void InitializeAll()
{
OcrWorkspace = string.Empty;
OcrStream = "default";
}
string[] paramNames = new string[]
{
"OCR workspace file",
"OCR stream",
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return OcrWorkspace;
case 1: return OcrStream;
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string str)
{
switch (i)
{
case 0: OcrWorkspace = str; return CfgUpdateFlags.None;
case 1: OcrStream = str; return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
/// <summary>
/// Verifiy the string representation of the parameter
/// </summary>
/// <param name="i">Parameter ID</param>
/// <param name="str">String representation of the parameter</param>
/// <param name="message">In case false is returned this is the error messsage to be displayed</param>
/// <returns>true = parameter OK, false = parameter NOK</returns>
public bool ValidateParam(int i, string str, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
return true;
case 1:
if (!string.IsNullOrEmpty(str)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ProcParams prms)
{
prms.OcrWorkspace = OcrWorkspace;
prms.OcrStream = OcrStream;
}
public IParamsProvider Clone()
{
ProcParams pars = new ProcParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public ProcParams()
{
}
public ProcParams(bool initialize)
{
if (initialize) InitializeAll();
}
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}
@@ -1,16 +1,14 @@
///
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using log4net;
using Common;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using System.IO;
namespace TBF.Rig.DataEntry.StandardCamera
{
@@ -35,30 +33,22 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
const Unit unit = Unit.m3;
// Set to 'true' when the form closes
// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary> Number of text boxes for serial numbers </summary>
readonly Tst mode; /// Start, End or Deferred
readonly Tst mode; /// Start, End or Deferred
public readonly int WaterMetersCount;
readonly IRegReader[] regReaders;
readonly bool[] disabled;
readonly string[] startImages;
readonly string[] endImages;
readonly double refVolume;
readonly double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
readonly double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
readonly OcrVidi ocrVidi;
readonly string ocrMessage;
readonly string streamName;
readonly double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
readonly double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
double denominator; /// derived from PulsesPerLtr, passed to OcrVidi
string format; /// derived from PulsesPerLtr, passed to OcrVidi
// To be retrieved after the form closes
// To be retrieved after the form closes
public double[] WMStartState;
// To be retrieved after the form closes
@@ -67,26 +57,23 @@ namespace TBF.Rig.DataEntry.StandardCamera
// To be retrieved after the form closes
public double[] WMEndState;
const int TextBoxesCount = 24;
string lastImageName;
int lastWmNr1;
Bitmap lastImage; /// non-zoomed image
Bitmap lastImage; /// non-zoomed image
Bitmap zoomedImage;
Thread imageProcessingThread; /// Thread to process images
public delegate void OcrTextObtainedDelegate(int ix, bool isEnd, string text);
OcrTextObtainedDelegate ocrTextObtained;
static int wmNr0b;
static Rotation imageRotation;
static Rotation[] imageRotation;
static bool[] isZoomed;
static Point[] zoomCenterLoc;
///
static TestStartEndForm()
{
wmNr0b = 0;
//imageRotation = new Rotation[TextBoxesCount];
imageRotation = new Rotation[TextBoxesCount];
isZoomed = new bool[TextBoxesCount];
zoomCenterLoc = new Point[TextBoxesCount];
}
@@ -140,8 +127,6 @@ namespace TBF.Rig.DataEntry.StandardCamera
enabledTextBoxes = new List<TextBox>();
imageProcessingThread = null;
completed = false;
StartForceCloseHandler();
}
@@ -150,141 +135,115 @@ namespace TBF.Rig.DataEntry.StandardCamera
/// Constructor to fill in start states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="startImages">Array with paths to start images</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, bool[] disabled)
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] startImages, bool[] disabled)
: this()
{
mode = Tst.Start;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.startImages = startImages;
this.disabled = disabled;
if (startImages == null || startImages.Length != WaterMetersCount)
if (startImages == null || startImages.Length != waterMetersCount)
{
throw new Exception("Invalid 'startImages' argument");
throw (new Exception("Invalid 'startImages' argument"));
}
this.endImages = new string[WaterMetersCount];
WMStartState = new double[WaterMetersCount];
WMStartStateStr = new string[WaterMetersCount];
this.endImages = new string[waterMetersCount];
ConstructorCommon(regReaders);
}
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
Height = 555 + 30 * WaterMetersCount;
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
}
/// <summary>
/// Constructor to fill in end states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="endImages">Array with paths to end images</param>
/// <param name="wmStartState">Array with start states in default volume units (liters)</param>
/// <param name="wmStartStateStr">Information entered on test start</param>
/// <param name="wmStartStateStr">Information entered on test start</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, double[] wmStartState, string[] wmStartStateStr, string[] endImages,
bool[] disabled, double refVolume, double errLimLo, double errLimHi)
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] endImages, double[] wmStartState, string[] wmStartStateStr, bool[] disabled,
double refVolume, double errLimLo, double errLimHi)
: this()
{
mode = Tst.End;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.startImages = startImages;
this.WMStartState = wmStartState;
this.WMStartStateStr = wmStartStateStr;
this.endImages = endImages;
this.disabled = disabled;
if (endImages == null || endImages.Length != waterMetersCount ||
wmStartState == null || wmStartState.Length != waterMetersCount ||
wmStartStateStr == null || wmStartStateStr.Length != waterMetersCount)
{
throw (new Exception("Invalid argument(s)"));
}
this.endImages = endImages;
this.WMStartState = wmStartState;
this.WMStartStateStr = wmStartStateStr;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
if (startImages == null || startImages.Length != WaterMetersCount ||
wmStartState == null || wmStartState.Length != WaterMetersCount ||
wmStartStateStr == null || wmStartStateStr.Length != WaterMetersCount ||
endImages == null || endImages.Length != WaterMetersCount)
{
throw new Exception("Invalid argument(s)");
}
this.startImages = new string[waterMetersCount];
WMEndState = new double[WaterMetersCount];
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
ConstructorCommon(regReaders);
}
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
/// <summary>
/// Constructor for deferred evaluation, to fill in both start- and end-states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="startImages">Array with paths to start images</param>
/// <param name="endImages">Array with paths to end images</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, string[] endImages, bool[] disabled,
double refVolume, double errLimLo, double errLimHi)
Height = 555 + 30 * WaterMetersCount;
WMEndState = new double[waterMetersCount];
}
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] startImages, string[] endImages,
bool[] disabled, double refVolume, double errLimLo, double errLimHi)
: this()
{
mode = Tst.Both;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.startImages = startImages;
this.endImages = endImages;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
if (startImages == null || startImages.Length != waterMetersCount ||
endImages == null || endImages.Length != waterMetersCount)
{
throw new Exception("Invalid argument(s)");
throw (new Exception("Invalid argument(s)"));
}
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
WMEndState = new double[waterMetersCount];
this.startImages = startImages;
this.endImages = endImages;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
ConstructorCommon(regReaders);
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
Height = 555 + 30 * WaterMetersCount;
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
WMEndState = new double[waterMetersCount];
}
void ConstructorCommon(IRegReader[] regReaders)
{
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
int nrLines = (TBF.Data.WMsCount - 1) / TBF.Data.LineSize + 1;
if (nrLines == 1)
{
Width = 1040;
}
}
/// <summary>
/// Make sure the layout of labels/text boxes on the screen
/// corresponds to the layout of watermeters of the test bench.
@@ -333,7 +292,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (wmPos > 0)
{
labels[i].Text = wmPos.ToString();
labels[i].Text = string.Format("{0} {1}", Strings.Water_Meter, wmPos);
switch (mode)
{
@@ -359,11 +318,10 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
else
{
startTextBoxes[i].Enabled = true;
startTextBoxes[i].Text = WMStartStateStr[wmPos - 1];
endTextBoxes[i].Enabled = true;
enabledTextBoxes.Add(startTextBoxes[i]);
enabledTextBoxes.Add(endTextBoxes[i]);
endTextBoxes[i].Enabled = true;
enabledTextBoxes.Add(endTextBoxes[i]);
startTextBoxes[i].Enabled = false;
startTextBoxes[i].Text = WMStartStateStr[wmPos - 1];
}
break;
@@ -385,176 +343,16 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
}
}
if (!string.IsNullOrEmpty(ocrMessage))
{
MessageBox.Show(ocrMessage, Strings.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
int imagesCount = ImagesToProcessCount();
log.WarnFormat("Images to process count = {0}", imagesCount);
///
if (imagesCount > 0 && ocrVidi != null)
{
log.WarnFormat("Starting image processing thread with OcrVidi={0} and OcrStream={1}", ocrVidi, streamName);
/// Delegate for a thread->form communication
ocrTextObtained = new OcrTextObtainedDelegate(OnOcrTextObtained);
/// Show and initalize the progress bar
imageProcessingProgressLabel.Visible = true;
imageProcessingProgressBar.Visible = true;
imageProcessingProgressBar.Minimum = 0;
imageProcessingProgressBar.Value = 0;
imageProcessingProgressBar.Maximum = imagesCount;
/// Start the image processing thread
imageProcessingThread = new Thread(new ThreadStart(ImageProcessingThread));
imageProcessingThread.Start();
}
}
private void TestStartEndForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (imageProcessingThread != null && imageProcessingThread.IsAlive)
{
imageProcessingThread.Join(2000);
}
}
void Localize()
{
Text = (ocrVidi != null)
? string.Format("{0} ({1} / {2})", Strings.Water_Meter_States, ocrVidi, streamName)
: Strings.Water_Meter_States;
startLabel.Text = startLabel2.Text = string.Format("{0} [{1}]", Strings.Start, unit.ToDescription());
endLabel.Text = endLabel2.Text = string.Format("{0} [{1}]", Strings.End, unit.ToDescription());
okButton.Text = Strings.OkBtnText;
Text = Strings.Water_Meter_States;
startLabel.Text = startLabel2.Text = Strings.Start;
endLabel.Text = endLabel2.Text = Strings.End;
okButton.Text = Strings.OkBtnText;
}
int ImagesToProcessCount()
{
int count = 0;
/// Count the images
for (int i = 0; i < WaterMetersCount; i++)
{
if ((mode == Tst.Start || mode == Tst.Both) && startTextBoxes[wm2phys[i + 1]].Enabled &&
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
{
count++;
}
if ((mode == Tst.End || mode == Tst.Both) && endTextBoxes[wm2phys[i + 1]].Enabled &&
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
{
count++;
}
}
return count;
}
void ImageProcessingThread()
{
Thread.Sleep(2000);
bool[] startImgProcessed = new bool[WaterMetersCount];
bool[] endImgProcessed = new bool[WaterMetersCount];
for (int attempt = 1; attempt <= 3; attempt++)
{
for (int i = 0; i < WaterMetersCount; i++)
{
double pulsesPerLtr = (regReaders != null && regReaders.Length > i && regReaders[i] != null) ? regReaders[i].PulsesPerLtr : 1;
GetOcrParameters(pulsesPerLtr, out denominator, out format);
if ((mode == Tst.Start || mode == Tst.Both) && startTextBoxes[wm2phys[i + 1]].Enabled &&
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
{
if (!startImgProcessed[i])
{
try
{
/// Process a start image
var text = ocrVidi.Recognize(streamName, startImages[i], denominator, format); /// OCR
this.Invoke(ocrTextObtained, new object[] { wm2phys[i + 1], false, text });
startImgProcessed[i] = true;
}
catch (Exception)
{
}
}
}
if ((mode == Tst.End || mode == Tst.Both) && endTextBoxes[wm2phys[i + 1]].Enabled &&
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
{
if (!endImgProcessed[i])
{
try
{
/// Process an end image
var text = ocrVidi.Recognize(streamName, endImages[i], denominator, format); /// OCR
this.Invoke(ocrTextObtained, new object[] { wm2phys[i + 1], true, text });
endImgProcessed[i] = true;
}
catch (Exception)
{
}
}
}
}
}
}
void GetOcrParameters(double pulsesPerLtr, out double denominator, out string format)
{
if (pulsesPerLtr == 0.1)
{
denominator = 100;
format = "F2";
}
else if (pulsesPerLtr == 0.01)
{
denominator = 10;
format = "F1";
}
else if (pulsesPerLtr == 10)
{
denominator = 10000;
format = "F4";
}
else // if (pulsesPerLtr == 1)
{
denominator = 1000;
format = "F3";
}
}
public void OnOcrTextObtained(int ix, bool isEnd, string text)
{
if (isEnd)
{
if (ix < endTextBoxes.Length && endTextBoxes[ix].Enabled)
{
endTextBoxes[ix].Text = text;
LoadImage(null, Tst.End, ix);
}
}
else
{
if (ix < startTextBoxes.Length && startTextBoxes[ix].Enabled)
{
startTextBoxes[ix].Text = text;
LoadImage(null, Tst.Start, ix);
}
}
imageProcessingProgressBar.Value++;
}
private void okButton_Click(object sender, EventArgs eArgs)
{
try
@@ -565,28 +363,20 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (wmPos > 0)
{
if (startTextBoxes[i].Enabled && startTextBoxes[i].Text != WMStartStateStr[wmPos - 1])
if (startTextBoxes[i].Enabled)
{
double val;
if (Utils.TryParseUDouble(startTextBoxes[i].Text, out val))
{
WMStartState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
WMStartStateStr[wmPos - 1] = startTextBoxes[i].Text;
}
}
WMStartStateStr[wmPos - 1] = startTextBoxes[i].Text;
WMStartState[wmPos - 1] = Utils.ParseUDouble(startTextBoxes[i].Text) * regReaders[wmPos - 1].LtrsPerPulse;
}
if (endTextBoxes[i].Enabled)
{
double val;
if (Utils.TryParseUDouble(endTextBoxes[i].Text, out val))
{
WMEndState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
}
WMEndState[wmPos - 1] = Utils.ParseUDouble(endTextBoxes[i].Text) * regReaders[wmPos - 1].LtrsPerPulse;
}
}
}
}
catch (Exception e)
catch(Exception e)
{
log.ErrorFormat("Exception: {0}", e.Message);
return;
@@ -688,17 +478,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
try
{
double startV = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text);
double startVolumeL = (unit == Unit.pulse)
? startV * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse
: Units.ConvertFrom(unit, startV);
double endV = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text);
double endVolumeL = (unit == Unit.pulse)
? endV * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse
: Units.ConvertFrom(unit, endV);
double err = 100.0 * (endVolumeL - startVolumeL - refVolume) / refVolume;
double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err);
}
catch
@@ -790,7 +572,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (startTextBoxes[j] == currentTextBox)
{
LoadImage(currentTextBox, Tst.Start, j);
LoadImage(Tst.Start, j);
return;
}
}
@@ -798,7 +580,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (endTextBoxes[j] == currentTextBox)
{
LoadImage(currentTextBox, Tst.End, j);
LoadImage(Tst.End, j);
return;
}
}
@@ -811,103 +593,103 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
private void startTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 0); }
private void startTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 1); }
private void startTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 2); }
private void startTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 3); }
private void startTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 4); }
private void startTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 5); }
private void startTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 6); }
private void startTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 7); }
private void startTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 8); }
private void startTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 9); }
private void startTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 10); }
private void startTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 11); }
private void startTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 12); }
private void startTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 13); }
private void startTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 14); }
private void startTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 15); }
private void startTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 16); }
private void startTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 17); }
private void startTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 18); }
private void startTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 19); }
private void startTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 20); }
private void startTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 21); }
private void startTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 22); }
private void startTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 23); }
private void startTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 0); }
private void startTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 1); }
private void startTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 2); }
private void startTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 3); }
private void startTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 4); }
private void startTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 5); }
private void startTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 6); }
private void startTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 7); }
private void startTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 8); }
private void startTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 9); }
private void startTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 10); }
private void startTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 11); }
private void startTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 12); }
private void startTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 13); }
private void startTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 14); }
private void startTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 15); }
private void startTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 16); }
private void startTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 17); }
private void startTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 18); }
private void startTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 19); }
private void startTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 20); }
private void startTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 21); }
private void startTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 22); }
private void startTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 23); }
private void startTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 0); }
private void startTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 1); }
private void startTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 2); }
private void startTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 3); }
private void startTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 4); }
private void startTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 5); }
private void startTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 6); }
private void startTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 7); }
private void startTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 8); }
private void startTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 9); }
private void startTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 10); }
private void startTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 11); }
private void startTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 12); }
private void startTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 13); }
private void startTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 14); }
private void startTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 15); }
private void startTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 16); }
private void startTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 17); }
private void startTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 18); }
private void startTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 19); }
private void startTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 20); }
private void startTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 21); }
private void startTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 22); }
private void startTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 23); }
private void startTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 0); }
private void startTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 1); }
private void startTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 2); }
private void startTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 3); }
private void startTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 4); }
private void startTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 5); }
private void startTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 6); }
private void startTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 7); }
private void startTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 8); }
private void startTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 9); }
private void startTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 10); }
private void startTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 11); }
private void startTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 12); }
private void startTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 13); }
private void startTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 14); }
private void startTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 15); }
private void startTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 16); }
private void startTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 17); }
private void startTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 18); }
private void startTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 19); }
private void startTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 20); }
private void startTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 21); }
private void startTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 22); }
private void startTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 23); }
private void endTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 0); }
private void endTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 1); }
private void endTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 2); }
private void endTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 3); }
private void endTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 4); }
private void endTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 5); }
private void endTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 6); }
private void endTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 7); }
private void endTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 8); }
private void endTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 9); }
private void endTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 10); }
private void endTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 11); }
private void endTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 12); }
private void endTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 13); }
private void endTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 14); }
private void endTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 15); }
private void endTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 16); }
private void endTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 17); }
private void endTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 18); }
private void endTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 19); }
private void endTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 20); }
private void endTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 21); }
private void endTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 22); }
private void endTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 23); }
private void endTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 0); }
private void endTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 1); }
private void endTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 2); }
private void endTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 3); }
private void endTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 4); }
private void endTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 5); }
private void endTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 6); }
private void endTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 7); }
private void endTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 8); }
private void endTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 9); }
private void endTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 10); }
private void endTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 11); }
private void endTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 12); }
private void endTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 13); }
private void endTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 14); }
private void endTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 15); }
private void endTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 16); }
private void endTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 17); }
private void endTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 18); }
private void endTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 19); }
private void endTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 20); }
private void endTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 21); }
private void endTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 22); }
private void endTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 23); }
private void endTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 0); }
private void endTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 1); }
private void endTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 2); }
private void endTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 3); }
private void endTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 4); }
private void endTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 5); }
private void endTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 6); }
private void endTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 7); }
private void endTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 8); }
private void endTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 9); }
private void endTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 10); }
private void endTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 11); }
private void endTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 12); }
private void endTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 13); }
private void endTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 14); }
private void endTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 15); }
private void endTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 16); }
private void endTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 17); }
private void endTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 18); }
private void endTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 19); }
private void endTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 20); }
private void endTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 21); }
private void endTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 22); }
private void endTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 23); }
private void endTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 0); }
private void endTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 1); }
private void endTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 2); }
private void endTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 3); }
private void endTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 4); }
private void endTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 5); }
private void endTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 6); }
private void endTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 7); }
private void endTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 8); }
private void endTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 9); }
private void endTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 10); }
private void endTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 11); }
private void endTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 12); }
private void endTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 13); }
private void endTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 14); }
private void endTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 15); }
private void endTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 16); }
private void endTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 17); }
private void endTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 18); }
private void endTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 19); }
private void endTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 20); }
private void endTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 21); }
private void endTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 22); }
private void endTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 23); }
/// <summary>
/// Loads appropriate image into pictureBox1.Image
@@ -915,17 +697,17 @@ namespace TBF.Rig.DataEntry.StandardCamera
/// </summary>
/// <param name="startOrEnd">Tst.Start or Tst.End</param>
/// <param name="physPos">0..23</param>
void LoadImage(object sender, Tst startOrEnd, int physPos)
void LoadImage(Tst startOrEnd, int physPos)
{
int wmNr1b = phys2wm[physPos]; /// 0 means no WM
if (wmNr1b <= 0) return;
ShowUnits(startOrEnd, physPos);
wmNr0b = wmNr1b - 1;
int wmNr1b = phys2wm[physPos]; /// 0 means no WM
wmNr0b = Math.Max(0, wmNr1b - 1);
string imageFileName;
if (startOrEnd == Tst.Start && startImages[wmNr0b] != null)
if ((startOrEnd == Tst.Start) && (wmNr1b > 0) && (startImages[wmNr0b] != null))
imageFileName = startImages[wmNr0b];
else if (startOrEnd == Tst.End && endImages[wmNr0b] != null)
else if ((startOrEnd == Tst.End) && (wmNr1b > 0) && (endImages[wmNr0b] != null))
imageFileName = endImages[wmNr0b];
else
imageFileName = string.Empty;
@@ -936,7 +718,6 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
lastImageName = imageFileName;
lastWmNr1 = wmNr1b;
if (string.IsNullOrEmpty(imageFileName) || !File.Exists(imageFileName))
{
@@ -944,31 +725,16 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
else
{
using (Bitmap tempBmp = Image.FromFile(imageFileName) as Bitmap)
{
Rectangle rect;
if (tempBmp.Height < tempBmp.Width)
{
int hght = tempBmp.Height;
int leftMargin = (tempBmp.Width - hght) / 2;
rect = new Rectangle(leftMargin, 0, hght, hght);
}
else
{
int hght = tempBmp.Height;
int wdth = tempBmp.Width;
int margin = (hght - wdth) / 2;
rect = new Rectangle(0, margin, wdth, wdth);
}
//int hght = tempBmp.Height;
//int leftMargin = (tempBmp.Width - hght) / 2;
//lastImage = new Bitmap(tempBmp.Clone(new Rectangle(leftMargin, 0, hght, hght), tempBmp.PixelFormat));
lastImage = new Bitmap(tempBmp.Clone(rect, tempBmp.PixelFormat));
if (isZoomed[wmNr0b])
{
zoomedImage = MakeZoomedImage(lastImage, zoomCenterLoc[wmNr0b]);
}
}
using (Bitmap tempBmp = Image.FromFile(imageFileName) as Bitmap)
{
int hght = tempBmp.Height;
int leftMargin = (tempBmp.Width - hght) / 2;
lastImage = new Bitmap(tempBmp.Clone(new Rectangle(leftMargin, 0, hght, hght), tempBmp.PixelFormat));
if (isZoomed[wmNr0b])
{
zoomedImage = MakeZoomedImage(lastImage, zoomCenterLoc[wmNr0b]);
}
}
}
ShowImage();
@@ -986,7 +752,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (me.Button == MouseButtons.Left && !isZoomed[wmNr0b])
{
switch (imageRotation)
switch (imageRotation[wmNr0b])
{
case Rotation.R0:
zoomCenterLoc[wmNr0b] = me.Location;
@@ -1020,9 +786,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (lastImage == null) return;
if (++imageRotation == Rotation.Count)
if (++imageRotation[wmNr0b] == Rotation.Count)
{
imageRotation = Rotation.R0;
imageRotation[wmNr0b] = Rotation.R0;
}
ShowImage();
}
@@ -1041,17 +807,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
return lastImage.Clone(newRect, oriImage.PixelFormat);
}
///
/// Used by ShowImage()
///
Brush lightBrush = new SolidBrush(Color.LightGreen);
Brush darkBrush = new SolidBrush(Color.Green);
Font largeFont = new Font("arial", 24.0F, FontStyle.Bold); /// normal image
Font smallFont = new Font("arial", 12.0F, FontStyle.Bold); /// zoomed image
/// <summary>
/// Show selected image in the picture box.
/// lastWmNr1, lastImage, zoomedImage, isZoomed and imageRotation are used.
/// lastImage, zoomedImage, isZoomed and imageRotation are used.
/// </summary>
void ShowImage()
{
@@ -1065,37 +823,96 @@ namespace TBF.Rig.DataEntry.StandardCamera
? new Bitmap(zoomedImage.Clone(new Rectangle(0, 0, zoomedImage.Width, zoomedImage.Height), zoomedImage.PixelFormat))
: new Bitmap(lastImage.Clone(new Rectangle(0, 0, lastImage.Width, lastImage.Height), lastImage.PixelFormat));
switch (imageRotation)
switch (imageRotation[wmNr0b])
{
case Rotation.R90: tempBmp.RotateFlip(RotateFlipType.Rotate270FlipNone); break;
case Rotation.R180: tempBmp.RotateFlip(RotateFlipType.Rotate180FlipNone); break;
case Rotation.R270: tempBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); break;
}
/// Write water meter number to the bitmap
using (var grph = Graphics.FromImage(tempBmp))
{
Font font = isZoomed[wmNr0b] ? smallFont : largeFont;
int margin = isZoomed[wmNr0b] ? 1 : 2;
int pixelsCount = 0;
int brightness = 0;
for (int x = margin; x <= 8 * margin; x += margin)
{
for (int y = margin; y <= 8 * margin; y += margin)
{
brightness += (int)tempBmp.GetPixel(x, y).G;
pixelsCount++;
}
}
brightness /= pixelsCount;
Brush brush = (brightness > 160) ? darkBrush : lightBrush;
grph.DrawString(lastWmNr1.ToString(), font, brush, margin, margin);
}
pictureBox1.Image = tempBmp;
}
/// <summary>
/// Updates startLabel.Text, startLabel2.Text, endLabel.Text, endLabel2.Text
/// Appends appropriate units of volume.
/// Handles mouse clicks and Tab-changes inside text boxes.
/// </summary>
/// <param name="startEnd">Tst.Start or Tst.End</param>
/// <param name="physPos">0..24</param>
void ShowUnits(Tst startEnd, int physPos)
{
int wmNr = phys2wm[physPos];
if (wmNr > 0 && startEnd == Tst.Start)
{
if (regReaders[wmNr - 1] != null)
{
if (physPos < 12)
{
startLabel.Text = string.Format("{0} [{1}]", Strings.Start, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
startLabel2.Text = Strings.Start;
}
else
{
startLabel.Text = Strings.Start;
startLabel2.Text = string.Format("{0} [{1}]", Strings.Start, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
}
}
else
{
startLabel.Text = startLabel2.Text = Strings.Start;
}
endLabel.Text = endLabel2.Text = Strings.End;
}
else if (wmNr > 0 && startEnd == Tst.End)
{
startLabel.Text = startLabel2.Text = Strings.Start;
if (regReaders[wmNr - 1] != null)
{
if (physPos < 12)
{
endLabel.Text = string.Format("{0} [{1}]", Strings.End, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
endLabel2.Text = Strings.End;
}
else
{
endLabel.Text = Strings.End;
endLabel2.Text = string.Format("{0} [{1}]", Strings.End, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
}
}
else
{
endLabel.Text = endLabel2.Text = Strings.End;
}
}
else
{
startLabel.Text = startLabel2.Text = Strings.Start;
endLabel.Text = endLabel2.Text = Strings.End;
}
}
///
string GetUnitStr(double pulsesPerLtr)
{
if (pulsesPerLtr == 1 || pulsesPerLtr <= float.Epsilon)
{
return "l";
}
else if (pulsesPerLtr == 0.001)
{
return "m3";
}
else if (pulsesPerLtr == 1000)
{
return "ml";
}
else
{
return string.Format("{0} l", 1 / pulsesPerLtr);
}
}
}
}
File diff suppressed because it is too large Load Diff
-909
View File
@@ -1,909 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class CycleBgEnForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBgEnForm));
/// Arguments
public readonly IList<WaterMeter> WaterMeters;
readonly int lineSize;
readonly Sz sz;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> commonItems;
readonly IList<DEItem> colItems;
readonly bool isEnd;
readonly string formCloseKeys;
/// Derived from arguments in the constructor
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly int commonItemsCount;
/// Size and layout related values
readonly Font font;
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int buttonsWidth;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] commonLabels;
readonly ComboBox[] commonComboBoxes;
readonly Label[] labels; /// Labels for water meter numbers
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
readonly MultiPurposeBtnFunction multiPurposeButtonFn;
bool multiPurposeButtonFlag;
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public CycleBgEnForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="commonItems">Common items displayed in the upper part of the form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="isEnd">true = This form is displayed at the end of cycle</param>
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
: this()
{
/// Arguments
this.WaterMeters = waterMeters;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.commonItems = commonItems;
this.colItems = colItems;
this.isEnd = isEnd;
/// Preserve column items for use in SummaryResults
if (!isEnd)
{
/// cycle beginning
DEItem.ClearSummaryColumns();
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
else
{
/// cycle end
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
commonItemsCount = (commonItems == null) ? 0 : commonItems.Count;
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
///
commonLabels = new Label[commonItemsCount];
commonComboBoxes = new ComboBox[commonItemsCount];
labels = new Label[wmsCount];
comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount];
///
/// Determine the multi purpose button function
///
multiPurposeButton.Visible = false;
multiPurposeButtonFn = MultiPurposeBtnFunction.None;
int buttonsWidth = 350;
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = "Auto s/n";
multiPurposeButtonFn = MultiPurposeBtnFunction.AutoSN;
buttonsWidth += 147;
break;
}
if (colItems[k].Content == Ct.PrintLabel)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = string.Format("{0} ({1}/{2})", Strings.Print, Strings.yes, Strings.no);
multiPurposeButtonFn = MultiPurposeBtnFunction.PrintLabelsOnOff;
multiPurposeButtonFlag = false;
buttonsWidth += 147;
break;
}
}
/// Layout related readonly variables derived from argument 'sz'
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
this.buttonsWidth = buttonsWidth;
hdrHeight = 120;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
this.buttonsWidth = buttonsWidth;
hdrHeight = 140;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
this.buttonsWidth = buttonsWidth;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Group box with common items
///
int groupBoxWidth = 0;
int groupBoxHeight = 0;
if (commonItemsCount > 0)
{
var groupBox = new GroupBox();
int labelsWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width);
var oneLabel = new Label
{
Text = commonItems[ix].Caption,
Font = font,
Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(oneLabelWidth + spacing, meterHeight),
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = groupBox,
};
groupBox.Controls.Add(oneLabel);
labelsWidth = Math.Max(labelsWidth, oneLabelWidth);
}
int combosWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
var cb = new ComboBox
{
Name = string.Format("-1~{0}", ix + 1),
Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(commonItems[ix].Width, meterHeight),
Enabled = (commonItems[ix].Action != Ac.LoadReadOnly),
Font = font,
TabIndex = tabIndex++,
Parent = groupBox,
};
cb.SelectedIndexChanged += new System.EventHandler(comboBox_SelectedIndexChanged);
cb.TextChanged += new System.EventHandler(comboBox_TextChanged);
cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(comboBox_KeyPress);
switch (ix)
{
case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break;
case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break;
case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break;
}
commonComboBoxes[ix] = cb;
groupBox.Controls.Add(cb);
combosWidth = Math.Max(combosWidth, commonItems[ix].Width);
}
///
groupBox.Location = new Point(margin, margin - spacing);
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing;
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
groupBox.Font = font;
groupBox.TabIndex = tabIndex++;
groupBox.Parent = this;
this.Controls.Add(groupBox);
}
///
/// Table
///
int commonCheckBoxLeft = 0;
int commonCheckBoxTop = 0;
int columnsTop = Math.Max(hdrHeight, groupBoxHeight + 2 * margin + spacing);
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var comboBox = new ComboBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
comboBox.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
comboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
if (ci.Content == Ct.PrintLabel)
{
comboBox.Items.Add(Strings.yes);
comboBox.Items.Add(Strings.no);
}
else
{
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
}
left += ci.Width + spacing;
comboBoxes[k, wmPos0] = comboBox;
this.Controls.Add(comboBox);
}
var checkBox = new CheckBox
{
Location = new Point(left, top + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
checkBoxes[wmPos0] = checkBox;
this.Controls.Add(checkBox);
if (commonCheckBoxLeft == 0)
{
commonCheckBoxLeft = left;
commonCheckBoxTop = columnsTop - meterHeight;
}
}
okButton.TabIndex = tabIndex++;
clearButton.TabIndex = tabIndex++;
var commonCheckBox = new CheckBox
{
Location = new Point(commonCheckBoxLeft, commonCheckBoxTop + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
commonCheckBox.CheckedChanged += new System.EventHandler(commonCheckBox_CheckedChanged);
this.Controls.Add(commonCheckBox);
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + buttonsWidth),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
bool activeControlFound = false;
for (int ix = 0; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
ActiveControl = commonComboBoxes[ix];
activeControlFound = true;
break;
}
}
if (!activeControlFound)
{
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
int k, j;
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
ActiveControl = okButton;
}
else
{
ActiveControl = comboBoxes[k, j];
}
}
}
/// <summary>
/// Add combo box items from a history stored in a string array (obtained usually from LocalSettings)
/// </summary>
/// <param name="comboBox">ComboBox to prepare</param>
/// <param name="history">String array with a history</param>
void AddHistoryToCombo(ComboBox comboBox, string[] history)
{
if (history != null)
{
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
}
}
/// <summary>
/// Returns an array of strings from ls.
/// Never returns null, null is converted to new string[0].
/// </summary>
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
/// <param name="k">Column number (0-based)</param>
/// <returns>Array of strings</returns>
string[] GetHistoryFromLS(bool isEnd, int k)
{
if (isEnd)
{
switch (k)
{
case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA;
case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB;
case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC;
case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD;
case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE;
default: return new string[0];
}
}
else
{
switch (k)
{
case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA;
case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB;
case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC;
case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD;
case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE;
default: return new string[0];
}
}
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
clearButton.Text = Strings.ClearBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Common combo boxes
for (int ix = 0; ix < commonItemsCount; ix++)
{
switch (commonItems[ix].Action)
{
default:
case Ac.Clear:
commonComboBoxes[ix].Text = string.Empty;
break;
case Ac.HistoryLast:
commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0)
? commonComboBoxes[ix].Items[0].ToString()
: string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
break;
case Ac.Set:
commonComboBoxes[ix].Text = Strings.yes;
break;
}
}
/// Table
for (int k = 0; k < colItems.Count; k++)
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
break;
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
}
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
}
break;
case Ac.Set:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = (WaterMeters[i] != null && !WaterMeters[i].Disabled) ? Strings.yes : Strings.no;
}
break;
}
}
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = isEnd ? (WaterMeters[i] != null && !WaterMeters[i].Disabled) : false;
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int ix = 0; ix < commonItemsCount; ix++ )
{
DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text);
if (commonItems[ix].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break;
}
}
else
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break;
}
}
}
///
/// Propagate common (batch) values to water meters in case of
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
///
foreach (var wm in WaterMeters)
{
if (wm != null && !wm.Disabled)
{
switch (commonItems[ix].Content)
{
case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break;
case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break;
case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break;
case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break;
}
}
}
}
for (int k = 0; k < colItems.Count; k++)
{
/// Store values to water meters and prepare an array for a history in the LocalSettings
var currentVals = new string[wmsCount];
for (int i = 0; i < wmsCount; i++)
{
DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
currentVals[i] = comboBoxes[k, i].Text;
}
/// Update history
if (colItems[k].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (k)
{
case 0: ls.LastEnColA = currentVals; break;
case 1: ls.LastEnColB = currentVals; break;
case 2: ls.LastEnColC = currentVals; break;
case 3: ls.LastEnColD = currentVals; break;
case 4: ls.LastEnColE = currentVals; break;
}
}
else
{
switch (k)
{
case 0: ls.LastBgColA = currentVals; break;
case 1: ls.LastBgColB = currentVals; break;
case 2: ls.LastBgColC = currentVals; break;
case 3: ls.LastBgColD = currentVals; break;
case 4: ls.LastBgColE = currentVals; break;
}
}
}
}
for (int i = 0; i < wmsCount; i++)
{
if (WaterMeters[i] != null) WaterMeters[i].Disabled = !checkBoxes[i].Checked;
}
}
private void commonCheckBox_CheckedChanged(object sender, EventArgs e)
{
bool state = (sender as CheckBox).Checked;
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = state;
}
}
private void okButton_Click(object sender, EventArgs e)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
InitializeBoxes();
}
private void multiPurposeButton_Click(object sender, EventArgs e)
{
if (multiPurposeButtonFn == MultiPurposeBtnFunction.None) return;
if (multiPurposeButtonFn == MultiPurposeBtnFunction.AutoSN)
{
///
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{
if (checkBoxes[firstIx].Checked) break;
}
if (firstIx == wmsCount)
{
return; /// There is not any enabled water meter
}
char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
///
/// Column with serial numbers found => perform an auto s/n assignment
///
string firstSN = comboBoxes[k, firstIx].Text;
int firstSnNr;
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0)
{
int lastDigitPosPlus1 = startIx + 1;
var listOfDigits = new List<char>(digits);
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1]))
{
lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0)
{
for (int ix = firstIx + 1; ix < wmsCount; ix++)
{
if (checkBoxes[ix].Checked)
{
firstSnNr++;
string newSN = firstSnNr.ToString();
int len = newSN.Length;
if (len <= digitsCount)
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
}
else
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
}
}
}
}
}
}
}
}
if (multiPurposeButtonFn == MultiPurposeBtnFunction.PrintLabelsOnOff)
{
///
/// Find a column with Ct.PrintLabel
///
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.PrintLabel)
{
for (int ix = 0; ix < wmsCount; ix++)
{
if (WaterMeters[ix] != null && !WaterMeters[ix].Disabled)
{
comboBoxes[k, ix].Text = multiPurposeButtonFlag ? Strings.yes : Strings.no;
}
}
}
}
multiPurposeButtonFlag = !multiPurposeButtonFlag;
}
}
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
isHandlersEnabled = false;
if (k >= 0 && colItems[k].Content != Ct.PrintLabel && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
{
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items[0].ToString();
if (!string.IsNullOrEmpty(comboBoxes[k, i].Text)) checkBoxes[i].Checked = true;
}
}
isHandlersEnabled = true;
}
private void comboBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
if (e.KeyChar == '\r')
{
if (k < 0)
{
for (int ix = j; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
commonComboBoxes[ix].Focus();
return;
}
}
/// No next enabled common item found:
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
}
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
comboBoxes[k, j].Focus();
}
}
}
private void comboBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
if (k >= 0) checkBoxes[j].Checked = true;
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="comboBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledCombo(ComboBox[,] comboBoxes, ref int k, ref int i, bool isLrOrder)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == comboBoxes.GetLength(0))
{
k = 0;
if (++i == comboBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == comboBoxes.GetLength(1))
{
i = 0;
if (++k == comboBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!comboBoxes[k, i].Enabled);
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
-86
View File
@@ -1,86 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class CycleBgEnForm
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.multiPurposeButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// clearButton
//
resources.ApplyResources(this.clearButton, "clearButton");
this.clearButton.ForeColor = System.Drawing.Color.Black;
this.clearButton.Name = "clearButton";
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// multiPurposeButton
//
resources.ApplyResources(this.multiPurposeButton, "multiPurposeButton");
this.multiPurposeButton.ForeColor = System.Drawing.Color.Black;
this.multiPurposeButton.Name = "multiPurposeButton";
this.multiPurposeButton.UseVisualStyleBackColor = true;
this.multiPurposeButton.Click += new System.EventHandler(this.multiPurposeButton_Click);
//
// CycleBgEnForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.multiPurposeButton);
this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "CycleBgEnForm";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button multiPurposeButton;
}
}
-246
View File
@@ -1,246 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="okButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>942, 26</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="clearButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="clearButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="clearButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="clearButton.Location" type="System.Drawing.Point, System.Drawing">
<value>795, 26</value>
</data>
<data name="clearButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="clearButton.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="clearButton.Text" xml:space="preserve">
<value>Clear</value>
</data>
<data name="&gt;&gt;clearButton.Name" xml:space="preserve">
<value>clearButton</value>
</data>
<data name="&gt;&gt;clearButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;clearButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="multiPurposeButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="multiPurposeButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="multiPurposeButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="multiPurposeButton.Location" type="System.Drawing.Point, System.Drawing">
<value>648, 26</value>
</data>
<data name="multiPurposeButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="multiPurposeButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="multiPurposeButton.Text" xml:space="preserve">
<value>Multi purpose</value>
</data>
<data name="multiPurposeButton.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Name" xml:space="preserve">
<value>multiPurposeButton</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;multiPurposeButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1094, 561</value>
</data>
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>10000, 10000</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Batch data</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CycleBgEnForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

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