Compare commits

..
228 changed files with 4719 additions and 7773 deletions
-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 -19
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
@@ -295,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
}
@@ -333,7 +329,6 @@ namespace Common
[Description("")] NotSpecified,
[Description("U0")] U0, /// ?
[Description("D0")] D0, /// ?
///
Count
}
+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("")]
-29
View File
@@ -2,7 +2,6 @@
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
///
using System;
using System.IO.Ports;
namespace Common
{
@@ -93,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
@@ -26,7 +26,7 @@ namespace Config
public const int CompoundWMsCount = 0;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 1;
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50 || TURA_SPECIAL
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
@@ -38,7 +38,7 @@ namespace Config
public const int CompoundWMsCount = 3;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif RUM_MOB || TURA_SPECIAL
#elif RUM_MOB
public const int WMsCount = 8;
public const int LineSize = 8;
public const int CompoundWMsCount = 1;
+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 -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)
{
+5 -50
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -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();
}
@@ -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;
}
}
}
-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
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);
+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 -13
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;
@@ -39,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; }
@@ -158,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;
@@ -323,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)
@@ -369,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);
@@ -437,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;
+46 -4
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,6 +97,8 @@ 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)
@@ -250,9 +252,7 @@ namespace Results.Entities
break;
}
}
#if ORACLE_DB
if (Utils.MaxTestIndex != 0 && (Pruefindex % 100) > Utils.MaxTestIndex) passed = false;
#endif
return passed;
}
@@ -446,6 +446,8 @@ namespace Results.Entities
WMTypeRevision = 0;
Pruefindex = 0;
HydrPruefung = 0;
RawTestInfos = null;
CompleteTestInfos = null;
#endif
ProcessId = 0;
SessionId = 0;
@@ -508,6 +510,8 @@ 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
@@ -688,6 +692,22 @@ 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);
@@ -768,6 +788,28 @@ 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();
@@ -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]);
}
+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
+5 -5
View File
@@ -91,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
+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
@@ -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")]
+9
View File
@@ -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
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)
-7
View File
@@ -8,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
+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);
}
}
}
+75 -121
View File
@@ -1,19 +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 NHibernate;
namespace TBF
{
@@ -214,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
@@ -229,8 +229,6 @@ namespace TBF
bool retryLogin = true; /// true = stay in a login loop
do
{
LoadingConfigEnd();
LoginDlgWithBenchSelection loginDlgBench;
if (LocalSettings.LastBenchName != null)
{
@@ -253,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
@@ -273,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;
}
}
///
@@ -284,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;
@@ -370,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;
@@ -385,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))
{
@@ -401,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
@@ -414,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);
@@ -435,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;
@@ -471,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
@@ -493,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)
@@ -552,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.32.2050.0")]
[assembly: AssemblyFileVersion("2.32.2050.0")]
[assembly: AssemblyVersion("2.30.1991.0")]
[assembly: AssemblyFileVersion("2.30.1991.0")]
+4 -49
View File
@@ -357,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>
@@ -673,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 {
@@ -1896,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>
@@ -3282,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>
@@ -3832,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);
}
}
@@ -3894,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>
@@ -5451,15 +5415,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string String1 {
get {
return ResourceManager.GetString("String1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sun.
/// </summary>
+3 -9
View File
@@ -673,10 +673,10 @@
<value>Tiskárna</value>
</data>
<data name="Procedure" xml:space="preserve">
<value>Prodedura</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>
@@ -1683,10 +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>Vytisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
</data>
</root>
+2 -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>
-3
View File
@@ -2010,7 +2010,4 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimer</value>
</data>
</root>
+3 -3
View File
@@ -1533,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>
@@ -1776,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>
+4 -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>
@@ -1543,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>
@@ -1624,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>
+3 -15
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>
@@ -1531,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>
@@ -2314,16 +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="Error_reading_configuration_database" xml:space="preserve">
<value>Error reading configuration database</value>
</data>
</root>
-3
View File
@@ -831,7 +831,4 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimanta</value>
</data>
</root>
+3 -3
View File
@@ -1518,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>
@@ -1596,7 +1599,4 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Print" xml:space="preserve">
<value>Печатать</value>
</data>
</root>
-3
View File
@@ -1191,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;
}
@@ -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;
}
}
}
+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;
}
}
}
+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;
}
}
}
+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;
}
}
}
@@ -488,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
@@ -859,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
@@ -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;
@@ -193,7 +193,7 @@ namespace TBF.Rig.DataEntry.iPerl
private void okButton_Click(object sender, EventArgs e)
{
if (orderComboBox.Text.Length > 10 ||
if (orderComboBox.Text.Length > 8 ||
(cfg.Orders != Orders.Arbitrary && !orderComboBox.Items.Contains(orderComboBox.Text)))
{
MessageBox.Show(Strings.Invalid_order_number, Strings.Error, MessageBoxButtons.OK,
+2 -2
View File
@@ -120,11 +120,11 @@ namespace TBF.Rig.Elde
public byte[] MeretRS485Address = new byte[4];
#endif
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
#elif CEVAK_200 || DN100 || FUZHOU_150 || IZRAEL_200 || SENTEC
#elif CEVAK_200 || DN100 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || SENTEC
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[6] { 1, 1, 1, 1, 1, 1 };
#elif BERLIN || FUZHOU_300 || GELSENWASSER || GENESIS || PETERSBURG_200 || PUCHONG_200 || RUM_MOB || SLM_150
#elif BERLIN || GELSENWASSER || GENESIS || PETERSBURG_200 || PUCHONG_200 || RUM_MOB || SLM_150
public uint[,] RegValveCalib = new uint[16, 2] { {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500},
{100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500} };
public byte[] MeretRS485Address = new byte[4];
+2 -2
View File
@@ -82,7 +82,7 @@ namespace TBF.Rig.Elde
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
#endif
#if ALZIR_25 || BADGER_STREDNA_TRAT || BAHRAIN_50 || CEVAK_200 || DEWA_300 || FEWA_50 || FUZHOU_100 || FUZHOU_300 || FILIPINY_50 || GELSENWASSER || GENESIS || HONGKONG_50 || IZRAEL_25 || IZRAEL_50 || JUZNA_AFRIKA_50 || KEMPNO_50 || KRAKOW_50 || LUXEMBURG_40 || MILWAUKEE || PUCHONG_200 || ROMA_200 || SENTEC || TURA_IPERL_NEW || WARSAW_50 || ZAMBIA || ZODINO
#if ALZIR_25 || BADGER_STREDNA_TRAT || BAHRAIN_50 || CEVAK_200 || DEWA_300 || FEWA_50 || FUZHOU_100 || FILIPINY_50 || GELSENWASSER || GENESIS || HONGKONG_50 || IZRAEL_25 || IZRAEL_50 || JUZNA_AFRIKA_50 || KEMPNO_50 || KRAKOW_50 || LUXEMBURG_40 || MILWAUKEE || PUCHONG_200 || ROMA_200 || SENTEC || TURA_IPERL_NEW || WARSAW_50 || ZAMBIA || ZODINO
public uint DivTime(int id) { return ctrlBrdComponent.divTime[id]; }
public void SetDivLimit(int divNo, uint limLoPct, uint limHiPct)
{
@@ -115,7 +115,7 @@ namespace TBF.Rig.Elde
}
public float DivSamples(int time, int divIx0)
{
#if FUZHOU_50 || FUZHOU_150 || IZRAEL_200 || MUNICH
#if FUZHOU_50 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || MUNICH
return ctrlBrdComponent.DIVSamples[time, 0];
#else
return ctrlBrdComponent.DIVSamples[time, divIx0];
+1 -1
View File
@@ -56,7 +56,7 @@ namespace TBF.Rig.Elde.CoverTest
{
if (!Users.CurrentUser.IsMemberOf(bypassLevel))
{
if ((new Users.Forms.LoginDlg(TBF.DB.UserSessionFactories, bypassLevel, this)).ShowDialog() != DialogResult.OK)
if ((new Users.Forms.LoginDlg(bypassLevel, this)).ShowDialog() != DialogResult.OK)
{
return;
}
+24 -43
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -9,7 +9,6 @@ using Dirichlet.Numerics;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.Diverter
{
@@ -92,10 +91,8 @@ namespace TBF.Rig.Elde.Diverter
}
else
{
string message = string.Format("Cannot save calibration: RegValveCalib[] size={1}, ADC#={2}",
Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr);
log.Error(message);
throw new Exception(message);
log.ErrorFormat("Unable to set {0} ADC levels: RegValveCalib array size={1}, diverter AdcNr={2}",
Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr);
}
}
@@ -153,51 +150,35 @@ namespace TBF.Rig.Elde.Diverter
///
/// Calendar support
///
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = diverterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = diverterCfg.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;
}
///
+23 -40
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,7 +7,6 @@ using log4net;
using Config.Entities;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.FlowMeter
{
@@ -69,7 +68,7 @@ namespace TBF.Rig.Elde.FlowMeter
{
for (int r = 0; r <= 5; r++)
{
if (RangeEnabled(r) && flowMeterCfg.GetCalibValidDate(r) > DateTime.MinValue
if (RangeEnabled(r) && flowMeterCfg.GetCalibValidDate(r) != DateTime.MinValue
&& flowMeterCfg.GetCalibValidDate(r).Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}/r{1}: {2}", Name, r, Strings.Calibration_certificate_validity_expired));
@@ -87,51 +86,35 @@ namespace TBF.Rig.Elde.FlowMeter
///
/// Calendar support
///
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = flowMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = flowMeterCfg.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;
}
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,7 +7,6 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.PressureMeter
{
@@ -56,51 +55,35 @@ namespace TBF.Rig.Elde.PressureMeter
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = pressureMeterCfg.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;
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
///
using System;
@@ -8,7 +8,6 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.PressureMeterInternal
{
@@ -50,51 +49,35 @@ namespace TBF.Rig.Elde.PressureMeterInternal
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = pressureMeterCfg.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;
}
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,7 +8,6 @@ using Common;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeter
{
@@ -53,51 +52,35 @@ namespace TBF.Rig.Elde.TempMeter
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = tempMtrCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = tempMtrCfg.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;
}
public double ReadTemperature()
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -7,7 +7,6 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeterInternal
{
@@ -47,51 +46,35 @@ namespace TBF.Rig.Elde.TempMeterInternal
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = tempMtrCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = tempMtrCfg.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;
}
+22 -39
View File
@@ -1,12 +1,11 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeterMeret
{
@@ -40,51 +39,35 @@ namespace TBF.Rig.Elde.TempMeterMeret
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = tempMtrCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = tempMtrCfg.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;
}
+18 -12
View File
@@ -14,7 +14,8 @@ namespace TBF.Rig
public float Qto;
public string Selector;
public IValve Pump; /// pump to use with this path or null
public IList<RegValvePosition> RegVPositions;
public IList<IRegValve> RegulValves;
public IList<float> RegulValvesPct;
public IList<IValve> ValvesOpen; /// a list of valves to open or null
public IList<IValve> ValvesClose; /// a list of valves to close or null
@@ -23,9 +24,10 @@ namespace TBF.Rig
{
ItemNr = itemNr;
Name = name;
RegVPositions = new List<RegValvePosition>();
ValvesOpen = new List<IValve>();
ValvesClose = new List<IValve>();
RegulValves = new List<IRegValve>();
RegulValvesPct = new List<float>();
}
/// Constructor from data entity
@@ -38,22 +40,29 @@ namespace TBF.Rig
Pump = TbfComponents.FindComponent(entity.Pump, components) as IValve;
///
/// Feeding regulation valves and their positions
/// Feeding regulation valve components
///
RegVPositions.Clear();
foreach (var cmpnt in components)
{
IRegValve rv = cmpnt as IRegValve;
if (rv != null && rv.Category == TBF.Rig.ValveCategory.Feeding && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
IRegValve regValve = cmpnt as IRegValve;
if (regValve != null && regValve.Category == TBF.Rig.ValveCategory.Feeding)
{
RegVPositions.Add(new RegValvePosition(rv));
RegulValves.Add(regValve);
}
}
TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct);
///
/// Regular valves to open
/// Feeding regulation valve precentages
///
string[] rvPosStr = (entity.RegulValvesPct != null) ? entity.RegulValvesPct.Split(new char[] { ';' }) : new string[0];
for (int i = 0; i < RegulValves.Count; i++)
{
string str = (i < rvPosStr.Length) ? rvPosStr[i] : "---";
float pct;
if (!Utils.TryParseUFloat(str, out pct) || pct > 100.0f || str == "---") pct = 0;
RegulValvesPct.Add(pct);
}
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
ValvesOpen = new List<IValve>();
foreach (var vName in vOpen)
@@ -62,9 +71,6 @@ namespace TBF.Rig
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
}
///
/// Regular valves to close
///
string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
ValvesClose = new List<IValve>();
foreach (var vName in vClose)
+1 -1
View File
@@ -8,6 +8,6 @@ namespace TBF.Rig.GenericDevices
{
interface IHasCalendarEvents
{
List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents();
IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents();
}
}
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -10,7 +10,6 @@ using TBF.Rig.GenericDevices;
using TBF.Boxes;
using TBF.Rig.Hart.Common;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Hart.Nivotrack
{
@@ -78,51 +77,35 @@ namespace TBF.Rig.Hart.Nivotrack
///
/// Calendar support
///
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = nivotrackCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = nivotrackCfg.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;
}
+4 -1
View File
@@ -1,7 +1,10 @@
///
/// Copyright (c) 2013-2015 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBF.Rig
{
@@ -88,10 +88,10 @@ namespace TBF.Rig.Keithley.Multimeter_2010_RS232
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;
}
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
/// Copyright (c) 2016-2020 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -8,7 +8,6 @@ using log4net;
using TBF.Boxes;
using TBF.Rig.Keithley.Multimeter_2010_RS232;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Keithley.TempMeter
{
@@ -50,51 +49,35 @@ namespace TBF.Rig.Keithley.TempMeter
///
/// Calendar support
///
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = tempMtrCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = tempMtrCfg.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;
}
public double ReadTemperature()
@@ -200,10 +200,10 @@ namespace TBF.Rig.MettlerToledo.Multi
{
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;
@@ -214,10 +214,10 @@ namespace TBF.Rig.MettlerToledo.Standard
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;
}
+23 -40
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -12,7 +12,6 @@ using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.MettlerToledo.Standard
{
@@ -112,7 +111,7 @@ namespace TBF.Rig.MettlerToledo.Standard
Balances[nextBalanceIdx - 1] = this;
}
if (balanceCfg.CalibValidDate > DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
if (balanceCfg.CalibValidDate != DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired));
}
@@ -138,51 +137,35 @@ namespace TBF.Rig.MettlerToledo.Standard
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = balanceCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = balanceCfg.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;
}
+4 -3
View File
@@ -5,6 +5,7 @@ using System;
using System.Windows.Forms;
using System.IO.Ports;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
@@ -87,10 +88,10 @@ namespace TBF.Rig.Modbus.Common
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = global::Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = global::Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = global::Common.Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
return flags;
}
+1 -1
View File
@@ -251,7 +251,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
if (scpThread != null && scpThread.IsAlive) scpThread.Join(50);
if (scpThread != null) scpThread.Join(50);
if (rtpListenerThread != null) rtpListenerThread.Join(50);
if (msrmntListenerThread != null) msrmntListenerThread.Join(50);
+54 -63
View File
@@ -1,13 +1,11 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using log4net;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Criterion;
using Common;
@@ -37,7 +35,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
public const string WorkstepName = "Test_bench";
public const int WorkstepRsltOK = 0;
MonitoringCfg tracingCfg;
string workplace
@@ -119,42 +116,39 @@ namespace TBF.Rig.Output.DB.ProductionTracing
if (tracingCfg.DebugLevel == DebugMode.Normal)
{
/// Session factory is used to create database sessions
sessionFactory = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildSessionFactory();
/// Session factory 2 is used to create the 2nd database sessions
if (!string.IsNullOrEmpty(tracingCfg.ConnStr2))
{
sessionFactory2 = Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr2))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
sessionFactory2 = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr2))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildSessionFactory();
}
/// Register this test bench in the tracing DB for approx. 2 weeks
var session = sessionFactory.OpenSession();
#if !DEBUG
/// Only a release version registers a workplace
TracingDB.DB.RegisterWorkplace(session,
workplace,
Users.CurrentUser.UserName(),
(ipAddress != null) ? ipAddress.ToString() : "1.2.3.4",
"<multiple>",
WorkstepName,
DateTime.Now + new TimeSpan(15, 0, 0, 0));
session.Flush();
#endif
session.Close();
ISession session = sessionFactory.OpenSession();
#if !DEBUG
/// Only a release version registers a workplace
TracingDB.DB.RegisterWorkplace(session,
workplace,
Users.CurrentUser.UserName(),
(ipAddress != null) ? ipAddress.ToString() : "1.2.3.4",
"<multiple>",
WorkstepName,
DateTime.Now + new TimeSpan(15, 0, 0, 0));
#endif
session.Flush();
session.Close();
TracingDB.DB.SessionFactory = sessionFactory;
if (session != null) session.Dispose();
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
@@ -280,12 +274,11 @@ namespace TBF.Rig.Output.DB.ProductionTracing
opCompleted = true;
if (SaveTracingRecords(batch) != Retv.OK) anyError = true;
if (TBF.DB.EventsDBSessionFactory != null && anyError)
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
NHibernate.ISession session = null;
try
{
session = TBF.DB.EventsDBSessionFactory.OpenSession();
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -297,22 +290,17 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
finally
{
if (session != null && session.IsOpen) session.Close();
}
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
}
else
{
if (TBF.DB.EventsDBSessionFactory != null && anyError)
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
NHibernate.ISession session = null;
try
{
session = TBF.DB.EventsDBSessionFactory.OpenSession();
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -324,10 +312,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
finally
{
if (session != null && session.IsOpen) session.Close();
}
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
@@ -410,24 +394,22 @@ namespace TBF.Rig.Output.DB.ProductionTracing
Workstep workstep = null;
ProjectionList projections = Projections.ProjectionList();
projections.Add(Projections.Property(() => refRecord.Id)); /// rcrd[0] = reference record ID
projections.Add(Projections.Property(() => workstep.Id)); /// rcrd[1] = workstep ID
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rcrd[2] = process ID
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rcrd[3] = reference record time stamp
projections.Add(Projections.Property(() => refRecord.Result)); /// rcrd[4] = result: =0...OK, >0...error code
projections.Add(Projections.Property(() => refRecord.Id)); /// rslt[0] = reference record ID
projections.Add(Projections.Property(() => workstep.Id)); /// rslt[1] = workstep ID
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rslt[2] = process ID
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rslt[3] = reference record time stamp
///
/// Get all reference records with Code == SerialNr from all worksteps different from 'Test_bench'
///
IList<object[]> records = session.QueryOver<ReferenceRecord>(() => refRecord)
IList<object[]> results = session.QueryOver<ReferenceRecord>(() => refRecord)
.Where(rr => (rr.Code == wm.SerialNr))
.OrderBy(rr => rr.TimeStamp).Asc
.JoinQueryOver<Workstep>(rr => rr.Workstep, () => workstep)
.And(ws => (ws.Name != WorkstepName))
.Select(projections)
.List<object[]>();
if (records.Count == 0)
if (results.Count == 0)
{
/// No records found
wm.ProcessId = 0;
@@ -440,18 +422,27 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
/// Get processId of the last record
///
int lastProcessId = (int)records[records.Count - 1][2];
DateTime lastTimeStamp = (DateTime)records[records.Count - 1][3];
if (lastProcessId == 0) return Retv.Error; /// This should never happen
int processId = 0;
DateTime lastTimeStamp = DateTime.MinValue;
foreach (var rslt in results)
{
if (DateTime.Compare((DateTime)rslt[3], lastTimeStamp) > 0)
{
lastTimeStamp = (DateTime)rslt[3];
processId = (int)rslt[2];
}
}
if (processId == 0) return Retv.Error; /// This should never happen
if ((currentProcess == null) || (currentProcess.Id != lastProcessId))
if ((currentProcess == null) || (currentProcess.Id != processId))
{
///
/// Process changed ==> update currentProcess / currentWorkstep / verifiedWorkstep / verifiedPart / verifyReferencePart
///
var processes = session.QueryOver<Process>()
.Where(p => (p.Id == lastProcessId))
.Where(p => (p.Id == processId))
.List();
if (processes.Count != 1) return Retv.Error;
@@ -481,13 +472,13 @@ namespace TBF.Rig.Output.DB.ProductionTracing
wm.ProcessId = currentProcess.Id;
wm.SessionId = sessionId;
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
foreach (var rcrd in records)
foreach (var rslt in results)
{
if ((verifiedWorkstep.Id == (int)rcrd[1]) && (lastProcessId == (int)rcrd[2]))
if ((verifiedWorkstep.Id == (int)rslt[1]) && (processId == (int)rslt[2]))
{
/// This record fits verification requirements.
/// As records are ordered by time, the result of the last one determines the verification result.
wm.LastRecordIsNok = ((int)rcrd[4] != WorkstepRsltOK);
/// This record fits verification requirements
wm.LastRecordIsNok = false; /// OK
break;
}
}
@@ -200,7 +200,7 @@ namespace TBF.Rig.Output.DB.SaveDiverterCorrections
ITransaction transaction = null;
try
{
var session = TBF.DB.ConfigDBSessionFactory.OpenSession();
ISession session = TBF.DB.CreateSession(Common.DBKind.Config);
transaction = session.BeginTransaction();
for (int div = 1; div <= myCfg.DivertersCount(); div++)
@@ -207,7 +207,7 @@ namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
ITransaction transaction = null;
try
{
var session = TBF.DB.ConfigDBSessionFactory.OpenSession();
ISession session = TBF.DB.CreateSession(Common.DBKind.Config);
transaction = session.BeginTransaction();
for (int fmtr = 1; fmtr <= myCfg.FlowmetersCount(); fmtr++)
+144 -103
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -41,6 +41,17 @@ namespace TBF.Rig.Output.DB.SensusOracle
Count
}
/// <summary>
/// Test/Q designation mode for IperlLogger and IperlHead opto data files
/// </summary>
public enum DesigMode
{
Auto,
Based_on_procedure,
As_specified,
Count
}
public class Database : ComponentBase, IOperation, GenericDevices.IResultsWriter, GenericDevices.IStartInfoReader, Generic.IDevice
{
@@ -57,6 +68,8 @@ namespace TBF.Rig.Output.DB.SensusOracle
public bool SaveResults { get { return (dbCfg == null || dbCfg.ProcParams == null) ? false : dbCfg.ProcParams.SaveResults; } }
public bool ReadStartInfo { get { return (dbCfg == null || dbCfg.ProcParams == null) ? true : dbCfg.ProcParams.ReadStartInfo; } }
public bool StartInfoIsRequired { get { return (dbCfg == null || dbCfg.ProcParams == null) ? false : dbCfg.ProcParams.StartInfoIsRequired; } }
public DesigMode DesigMode { get { return (dbCfg == null || dbCfg.ProcParams == null) ? DesigMode.Auto : dbCfg.ProcParams.DesigMode; } }
public LogType DesigType { get { return (dbCfg == null || dbCfg.ProcParams == null) ? LogType.Just_Q3Q2Q1 : dbCfg.ProcParams.DesigType; } }
enum OpState
{
@@ -111,7 +124,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
int wmTypeRevision;
string procedureSignature;
IList<SensusTestInfo> oracleTestInfo; /// Raw incomplete test info from Oracle DB (or null)
LUTestData[] completeTestInfo; /// Complete test info obtained from the procedure
SensusTestInfo[] completeTestInfo; /// Complete TBF test info obtained as the best match (never null when oracleTestInfo != null)
public Database() {}
@@ -179,7 +192,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
/// <param name="wmTypeId">Water meter type Id</param>
/// <param name="wmTypeRevision">Water meter type revision</param>
/// <returns>SensusTestInfos array</returns>
public IList<SensusTestInfo> GetOracleTestInfo(OracleConnection conn, int wmTypeId, out int wmTypeRevision, out string wzTyp, out string metrolKlasse, out string zulasszeichen, out string materialNr, out double q3, out DateTime timeStamp)
public IList<SensusTestInfo> GetOracleTestInfo(OracleConnection conn, int wmTypeId, out int wmTypeRevision, out string wzTyp, out string metrolKlasse, out string zulasszeichen, out string materialNr, out double q3, out DateTime timeStamp, out string remark)
{
///
/// Read 'incomplete' TestInfo from Oracle database containing only flowId-s ad qBezeichnung-s
@@ -196,8 +209,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
materialNr = string.Empty;
q3 = 0;
timeStamp = DateTime.MinValue;
remark = string.Empty;
OracleCommand cmd = new OracleCommand("SELECT rev_wztyp, wztyp, metrolklasse, zulasszeichen, materialnr, qmax, aenderungsdatum " +
OracleCommand cmd = new OracleCommand("SELECT rev_wztyp, wztyp, metrolklasse, zulasszeichen, materialnr, qmax, aenderungsdatum, bemerkung " +
"FROM vt_wztyp_sd " +
"WHERE anbid=:1 AND id_wztyp=:2 AND aktiv=:3", conn);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_Producer });
@@ -214,6 +228,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
materialNr = dr.GetString(4);
q3 = dr.GetDouble(5);
timeStamp = dr.GetDateTime(6);
remark = dr.GetString(7);
}
dr.Close();
@@ -336,6 +351,15 @@ namespace TBF.Rig.Output.DB.SensusOracle
#endif
}
if (DesigMode == DesigMode.Based_on_procedure && StateMachine.Procedure != null)
{
Sequences.ProcessData.CompleteTestInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
}
else if (DesigMode == DesigMode.As_specified && DesigType >= 0 && DesigType < LogType.Count)
{
Sequences.ProcessData.CompleteTestInfos = SensusTestInfo.GetTestInfos(DesigType);
}
opCompleted = true;
}
@@ -357,12 +381,11 @@ namespace TBF.Rig.Output.DB.SensusOracle
opCompleted = true;
}
if (TBF.DB.EventsDBSessionFactory != null && anyError)
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
NHibernate.ISession session = null;
try
{
session = TBF.DB.EventsDBSessionFactory.OpenSession();
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -374,10 +397,6 @@ namespace TBF.Rig.Output.DB.SensusOracle
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
finally
{
if (session != null && session.IsOpen) session.Close();
}
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
@@ -410,7 +429,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
catch (Exception exc)
{
log.ErrorFormat("Reading StartInfo from ORACLE DB failed, error={é}", exc.Message);
log.ErrorFormat("Reading from ORACLE DB failed, batch={0}, error={1}", batch.BatchNr, exc.Message);
conn.Close();
return Retv.Error;
@@ -432,6 +451,67 @@ namespace TBF.Rig.Output.DB.SensusOracle
try
{
/// Prepare a procedure signature to distinguish between different procedures with the same wmTypeId
IList<string> wmTestNames = new List<string>();
StringBuilder procedureSignatureSB = new StringBuilder();
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (mtr.Evaluate())
{
wmTestNames.Add(mtr.Name());
procedureSignatureSB.Append(mtr.Name());
procedureSignatureSB.Append("~");
}
}
if (oracleTestInfo == null || (wmTypeId == 0) || (wmTypeId != wm.WaterMeterData.WMTypeId) || (procedureSignature != procedureSignatureSB.ToString()))
{
///
/// Currnet test info. is not walid => Get a new one from Oracle and SensusTestInfo table
///
int wmTR;
string wzTypStr;
string metroKlasse;
string zulasszeichen;
string materialNr;
double q3 = 0;
DateTime timeStamp;
string remark;
IList<SensusTestInfo> rti = GetOracleTestInfo(conn, wm.WaterMeterData.WMTypeId, out wmTR, out wzTypStr, out metroKlasse, out zulasszeichen, out materialNr, out q3, out timeStamp, out remark);
if (rti != null)
{
/// All 5 updated together
wmTypeId = wm.WaterMeterData.WMTypeId;
wmTypeRevision = wmTR;
procedureSignature = procedureSignatureSB.ToString();
oracleTestInfo = rti;
string tInfoName;
completeTestInfo = SensusTestInfo.GetBestMatch(rti, wmTestNames, out tInfoName);
///
log.WarnFormat("Selected test info : {0}", tInfoName);
foreach (var cti in completeTestInfo)
{
log.WarnFormat("Selected test info : ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4} PrfNrOpto={5} QBzOpto={6} PrfNrLog={7} QBzLog={8} Range={9}", wmTypeId, wmTypeRevision,
cti.TestName, cti.PruefungsNrDB, cti.QBezeichnungDB, cti.PruefungsNrOpto, cti.QBezeichnungOpto, cti.PruefungsNrLog, cti.QBezeichnungLog, cti.Range);
}
}
else
{
return Retv.Error;
}
}
/// Write the test info. to WaterMeter entity
wm.RawTestInfos = oracleTestInfo;
wm.CompleteTestInfos = completeTestInfo;
wm.WMTypeRevision = wmTypeRevision;
/// Write the test info. to ProcessData
Sequences.ProcessData.RawTestInfos = oracleTestInfo;
Sequences.ProcessData.CompleteTestInfos = completeTestInfo;
OracleCommand cmd;
OracleDataReader dr;
@@ -533,9 +613,6 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
dr.Close();
#if TURA_SPECIAL
/// TODO: Check after modifications in completeTestInfo due to OraId, OraDesignation, etc.
///
/// Read data from VT_PRUEFREIHE_IST_PD
///
@@ -559,7 +636,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
string baseTestName = null;
foreach (var ti in completeTestInfo)
{
if (ti.Id == testId)
if (ti.PruefungsNrDB == testId)
{
int ix = ti.TestName.LastIndexOf(" (");
baseTestName = (ix < 0) ? ti.TestName : ti.TestName.Substring(0, ix);
@@ -582,7 +659,6 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
}
dr.Close();
#endif
///
/// Copy acquired data to WaterMeter object
@@ -629,10 +705,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
public Retv WriteResultsToDB(OracleConnection conn, Results.Entities.Batch bat, WMKind wmKind, bool safeMode)
public Retv WriteResultsToDB(OracleConnection conn, Results.Entities.Batch batch, WMKind wmKind, bool safeMode)
{
OracleTransaction transaction;
bool savedOK = false;
try
{
@@ -641,15 +716,16 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
catch (Exception exc)
{
log.ErrorFormat("Results of batch {0} not written to ORACLE DB (phase 1): {1}", bat.BatchNr, exc.Message);
log.ErrorFormat("Results of batch {0} not written to ORACLE DB (phase 1): {1}",
batch.BatchNr, exc.Message);
conn.Close();
return Retv.Error;
}
try
{
SaveBatchData(conn, bat);
foreach (var wMtr in bat.WaterMeters)
SaveBatchData(conn, batch);
foreach (var wMtr in batch.WaterMeters)
{
if (wmKind == WMKind.iPERL)
{
@@ -666,34 +742,18 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
transaction.Commit();
savedOK = true;
conn.Close();
log.ErrorFormat("Results of batch {0} correctly written to ORACLE DB", bat.BatchNr);
log.ErrorFormat("Results of batch {0} correctly written to ORACLE DB", batch.BatchNr);
return Retv.OK;
}
catch (Exception exc)
{
savedOK = false;
log.ErrorFormat("Results of batch {0} not written to ORACLE DB: {1}", bat.BatchNr, exc.Message);
transaction.Rollback();
conn.Close();
log.ErrorFormat("Results of batch {0} not written to ORACLE DB: {1}", batch.BatchNr, exc.Message);
return Retv.Error;
}
if (!savedOK)
{
try
{
transaction.Rollback();
conn.Close();
}
catch (Exception exc)
{
log.ErrorFormat("Even transaction.Rollback() failed: {0}", exc.Message);
}
return Retv.Error;
}
return Retv.OK;
}
}
/// <summary>
///
@@ -747,20 +807,22 @@ namespace TBF.Rig.Output.DB.SensusOracle
/// <summary>
/// Save common batch data
/// </summary>
/// <param name="bat">Batch</param>
void SaveBatchData(OracleConnection conn, Results.Entities.Batch bat)
/// <param name="b">Batch</param>
void SaveBatchData(OracleConnection conn, Results.Entities.Batch b)
{
IList<string> wmTestNames = new List<string>();
StringBuilder procedureSignatureSB = new StringBuilder();
foreach (var tr in bat.RegularTestRslts())
foreach (var tr in b.RegularTestRslts())
{
if (tr.Evaluate())
{
wmTestNames.Add(tr.Name());
procedureSignatureSB.Append(tr.Name());
procedureSignatureSB.Append("~");
}
}
if ((oracleTestInfo == null) || (wmTypeId != bat.WaterMeters[0].WaterMeterData.WMTypeId) || (wmTypeRevision == 0) || (procedureSignature != procedureSignatureSB.ToString()))
if ((oracleTestInfo == null) || (wmTypeId != b.WaterMeters[0].WaterMeterData.WMTypeId) || (wmTypeRevision == 0) || (procedureSignature != procedureSignatureSB.ToString()))
{
int wmTR = 0;
string wzTypStr;
@@ -769,54 +831,33 @@ namespace TBF.Rig.Output.DB.SensusOracle
string materialNr;
double q3 = 0;
DateTime timeStamp;
IList<SensusTestInfo> ti = GetOracleTestInfo(conn, bat.WaterMeters[0].WaterMeterData.WMTypeId, out wmTR, out wzTypStr, out metroKlasse, out zulasszeichen, out materialNr, out q3, out timeStamp);
string remark;
IList<SensusTestInfo> ti = GetOracleTestInfo(conn, b.WaterMeters[0].WaterMeterData.WMTypeId, out wmTR, out wzTypStr, out metroKlasse, out zulasszeichen, out materialNr, out q3, out timeStamp, out remark);
if (ti != null)
{
/// All 5 updated together
wmTypeId = bat.WaterMeters[0].WaterMeterData.WMTypeId;
wmTypeId = b.WaterMeters[0].WaterMeterData.WMTypeId;
wmTypeRevision = wmTR;
procedureSignature = procedureSignatureSB.ToString();
oracleTestInfo = ti;
completeTestInfo = SensusTestInfo.GetBestMatch(oracleTestInfo, wmTestNames);
foreach (var cti in completeTestInfo)
{
log.WarnFormat("Selected test info : ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4} PrfNrOpto={5} QBzOpto={6} PrfNrLog={7} QBzLog={8} Range={9}", wmTypeId, wmTypeRevision,
cti.TestName, cti.PruefungsNrDB, cti.QBezeichnungDB, cti.PruefungsNrOpto, cti.QBezeichnungOpto, cti.PruefungsNrLog, cti.QBezeichnungLog, cti.Range);
}
}
else
{
throw new Exception(string.Format("Cannot save batch {0} to Oracle, missing entry in VT_WZTYP_SD", bat.BatchNr));
throw new Exception("No matching test infos found");
}
}
if (oracleTestInfo == null || wmTypeId == 0 || wmTypeRevision == 0)
if (oracleTestInfo == null || completeTestInfo == null || wmTypeId == 0 || wmTypeRevision == 0)
{
throw new Exception(string.Format("Cannot save batch {0} to Oracle, missing entry in VT_WZTYP_SD", bat.BatchNr));
}
///
/// Select or create appropriate test infos
///
IList<LUTestData> testsToSave = new List<LUTestData>();
int maxPruefungsNr = 0;
double totalTestTime = 0;
foreach (var td in bat.Tests)
{
for (int repNr = 1; repNr <= td.Repeats; repNr++)
{
int testId = td.OraId + (td.Repeats - repNr) * td.OraIdRepetMulti;
if (testId != 0)
{
testsToSave.Add(new LUTestData(td, repNr));
if (Math.Abs(testId) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testId);
totalTestTime += td.TargetTime;
}
}
}
LUTestData[] testsToSaveArr = testsToSave.ToArray();
Array.Sort(testsToSaveArr, new LUTestDataComparer());
completeTestInfo = testsToSaveArr;
foreach (var cti in completeTestInfo)
{
log.WarnFormat("Selected test info : ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4}",
wmTypeId, wmTypeRevision, cti.TestName, cti.Id, cti.Designation);
throw new Exception("No matching test infos found");
}
@@ -829,13 +870,13 @@ namespace TBF.Rig.Output.DB.SensusOracle
"VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17)", conn);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_Producer });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.TestBenchGroupId + bat.TestBenchId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = bat.BatchNr });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = bat.WaterMeters[0].WaterMeterData.WMTypeId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.TestBenchGroupId + b.TestBenchId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = b.BatchNr });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = b.WaterMeters[0].WaterMeterData.WMTypeId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wmTypeRevision });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 1 });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.TimeStamp, Value = bat.StartTime });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.TimeStamp, Value = bat.EndTime });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.TimeStamp, Value = b.StartTime });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.TimeStamp, Value = b.EndTime });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = string.Empty });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 0 });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 0 });
@@ -844,23 +885,23 @@ namespace TBF.Rig.Output.DB.SensusOracle
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 0 }); /// TODO: DruckBeiAbpressen
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 0 });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 0 }); /// TODO: SpuelDurchflussIst
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = string.Format("TBF v.{0}", bat.ProgramVersion) });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = string.Format("TBF v.{0}", b.ProgramVersion) });
cmd.ExecuteNonQuery(); /// Returns nr. of updated rows
log.InfoFormat("VT_PRUEFREIHE_PD inserted, BatchNr={0}, TypeId={1}, TypeRev={2}, Start={3}", bat.BatchNr, bat.WaterMeters[0].WaterMeterData.WMTypeId, wmTypeRevision, bat.StartTime);
log.InfoFormat("VT_PRUEFREIHE_PD inserted, BatchNr={0}, TypeId={1}, TypeRev={2}, Start={3}", b.BatchNr, b.WaterMeters[0].WaterMeterData.WMTypeId, wmTypeRevision, b.StartTime);
}
else
{
log.WarnFormat("SIM: VT_PRUEFREIHE_PD inserted, BatchNr={0}, TypeId={1}, TypeRev={2}, Start={3}", bat.BatchNr, bat.WaterMeters[0].WaterMeterData.WMTypeId, wmTypeRevision, bat.StartTime);
log.WarnFormat("SIM: VT_PRUEFREIHE_PD inserted, BatchNr={0}, TypeId={1}, TypeRev={2}, Start={3}", b.BatchNr, b.WaterMeters[0].WaterMeterData.WMTypeId, wmTypeRevision, b.StartTime);
}
foreach (var testInfo in completeTestInfo)
{
if ((testInfo.Id != 0) && (-20 <= testInfo.Id) && (testInfo.Id <= 20)) /// LU PruefungsNr-s are between -20 and 20
if ((testInfo.PruefungsNrDB != 0) && (-20 <= testInfo.PruefungsNrDB) && (testInfo.PruefungsNrDB <= 20)) /// LU PruefungsNr-s are between -20 and 20
{
Results.Entities.TestRslt tr = bat.GetTestRslt(testInfo.TestName, 0);
Results.Entities.TestRslt tr = b.GetTestRslt(testInfo.TestName, 0);
if (tr == null) tr = bat.GetTestRslt(testInfo.TestName, 1); /// TODO: Remove this workaround for large watermeters with multiple parts at Q3
if (tr == null) tr = b.GetTestRslt(testInfo.TestName, 1); /// TODO: Remove this workaround for large watermeters with multiple parts at Q3
if (tr == null) continue;
double Q_ist = (tr.VolumeMaster != 0) ? (tr.FlowVolume * tr.VolumeCTV / tr.VolumeMaster) : (double)tr.FlowVolume;
@@ -906,9 +947,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
"VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23)", conn);
OracleParameter parm;
parm = new OracleParameter("ANBID", OracleDbType.Int32); parm.Value = Anbid_Producer; cmd2.Parameters.Add(parm); ///:1
parm = new OracleParameter("ID_Pruefstand", OracleDbType.Int32); parm.Value = dbCfg.TestBenchGroupId + bat.TestBenchId; cmd2.Parameters.Add(parm); ///:2
parm = new OracleParameter("ID_WzPruefreihe", OracleDbType.Int32); parm.Value = bat.BatchNr; cmd2.Parameters.Add(parm); ///:3
parm = new OracleParameter("PruefungsNr", OracleDbType.Int32); parm.Value = testInfo.Id; cmd2.Parameters.Add(parm); ///:4
parm = new OracleParameter("ID_Pruefstand", OracleDbType.Int32); parm.Value = dbCfg.TestBenchGroupId + b.TestBenchId; cmd2.Parameters.Add(parm); ///:2
parm = new OracleParameter("ID_WzPruefreihe", OracleDbType.Int32); parm.Value = b.BatchNr; cmd2.Parameters.Add(parm); ///:3
parm = new OracleParameter("PruefungsNr", OracleDbType.Int32); parm.Value = testInfo.PruefungsNrDB; cmd2.Parameters.Add(parm); ///:4
///
parm = new OracleParameter("PVOL", OracleDbType.Double); parm.Value = Units.ConvertTo(Unit.l, tr.VolumeCTV); cmd2.Parameters.Add(parm); ///:5
parm = new OracleParameter("PMasse", OracleDbType.Double); parm.Value = Units.ConvertTo(Unit.kg, tr.MassEnd - tr.MassStart); cmd2.Parameters.Add(parm); ///:6
@@ -934,17 +975,17 @@ namespace TBF.Rig.Output.DB.SensusOracle
parm = new OracleParameter("EndGewicht", OracleDbType.Double); parm.Value = Units.ConvertTo(Unit.kg, tr.MassEnd); cmd2.Parameters.Add(parm); ///:23
///
cmd2.ExecuteNonQuery(); /// Returns nr. of updated rows
log.InfoFormat("VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)", Anbid_Producer, dbCfg.TestBenchGroupId + bat.TestBenchId, bat.BatchNr, testInfo.Id, Q_ist);
log.InfoFormat("VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)", Anbid_Producer, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, testInfo.PruefungsNrDB, Q_ist);
#endif
}
else
{
log.WarnFormat("SIM: VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)", Anbid_Producer, dbCfg.TestBenchGroupId + bat.TestBenchId, bat.BatchNr, testInfo.Id, Q_ist);
log.WarnFormat("SIM: VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)", Anbid_Producer, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, testInfo.PruefungsNrDB, Q_ist);
}
}
}
log.InfoFormat("Batch data saved, batchNr={0}", bat.BatchNr);
log.InfoFormat("Batch data saved, batchNr={0}", b.BatchNr);
}
@@ -1079,7 +1120,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
foreach (var testInfo in completeTestInfo)
{
if ((testInfo.Id != 0) && (-20 <= testInfo.Id) && (testInfo.Id <= 20)) /// LU PruefungsNr-s are nonzero and between -20 and 20
if ((testInfo.PruefungsNrDB != 0) && (-20 <= testInfo.PruefungsNrDB) && (testInfo.PruefungsNrDB <= 20)) /// LU PruefungsNr-s are nonzero and between -20 and 20
{
Results.Entities.TestData tData = wm.GetTestData(testInfo.TestName);
Results.Entities.MeterTestRslt mtr;
@@ -1115,7 +1156,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
mtr.Error = Formulas.ErrorFromVolumes(mtr.VolumeMeter, mtr.VolumeRef);
}
SaveMeterTestResult(conn, mtr, testInfo.Id, max_Pruefindex, wmTypeRevision);
SaveMeterTestResult(conn, mtr, testInfo.PruefungsNrDB, max_Pruefindex, wmTypeRevision);
}
}
@@ -1312,7 +1353,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
foreach (var testInfo in completeTestInfo)
{
if ((testInfo.Id != 0) && (-20 <= testInfo.Id) && (testInfo.Id <= 20)) /// LU PruefungsNr-s are nonzero and between -20 and 20
if ((testInfo.PruefungsNrDB != 0) && (-20 <= testInfo.PruefungsNrDB) && (testInfo.PruefungsNrDB <= 20)) /// LU PruefungsNr-s are nonzero and between -20 and 20
{
Results.Entities.TestData tData = wm.GetTestData(testInfo.TestName);
Results.Entities.MeterTestRslt mtr;
@@ -1348,7 +1389,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
mtr.Error = Formulas.ErrorFromVolumes(mtr.VolumeMeter, mtr.VolumeRef);
}
SaveMeterTestResult(conn, mtr, testInfo.Id, max_Pruefindex, wmTypeRevision);
SaveMeterTestResult(conn, mtr, testInfo.PruefungsNrDB, max_Pruefindex, wmTypeRevision);
}
}
}

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