Compare commits

..
Author SHA1 Message Date
Milan Hanajik e81165d210 Reconfigured for iPerl 2023-03-08 10:01:35 +01:00
278 changed files with 5438 additions and 10622 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()
+10 -9
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 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
@@ -214,14 +223,6 @@ namespace Common
Count,
}
public enum FlowNames
{
QnQtQmin = 0,
Q3Q2Q1 = 1,
QpQi = 2,
Count,
}
public enum ProfileType
{
Q3R,
-12
View File
@@ -21,18 +21,6 @@ namespace Common
return (format == "F0") ? value.ToString("F0") : value.ToString(format).TrimEnd(new char[] { '0' });
}
public static FlowNames ProfileType2FlowNames(ProfileType pt)
{
switch (pt)
{
case ProfileType.Q3R: return FlowNames.Q3Q2Q1;
case ProfileType.QnClassColdWater: return FlowNames.QnQtQmin;
case ProfileType.QnClassHotWater: return FlowNames.QnQtQmin;
case ProfileType.QpQi: return FlowNames.QpQi;
default: return FlowNames.Q3Q2Q1;
}
}
public static string SignificantDigitsToFmt(double value, int sigDigits)
{
if (sigDigits == 6)
+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);
}
}
+1 -7
View File
@@ -38,18 +38,12 @@ namespace Config
public const int CompoundWMsCount = 3;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif RUM_MOB
#elif RUM_MOB || TURA_SPECIAL
public const int WMsCount = 8;
public const int LineSize = 8;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_SPECIAL
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif DEWA_300 || FUZHOU_100 || ROMA_200 || LUXEMBURG_40
public const int WMsCount = 10;
public const int LineSize = 10;
+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;
}
+1 -1
View File
@@ -47,7 +47,7 @@ namespace Config.Entities
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
public virtual float DN { get; set; } /// Not mapped to DB, valid in ProceduresCtrl for procedure filtering only
public virtual double Qn { get; set; } /// - ' ' -
public virtual float Qn { get; set; } /// - ' ' -
public virtual string MClass { get; set; } /// - ' ' -
public virtual string Producer { get; set; } /// - ' ' -
+11 -11
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -22,11 +22,11 @@ namespace Config.Entities
public virtual TestProfile Profile { get; set; } /// UserDefined, Protected, UserDefinedHeatMeter, ProtectedHeatMeter
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool DoEvaluate { get; set; }
public virtual double Qtg { get; set; } /// Target water flow [m3/h]
public virtual double Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual double Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual double Volume { get; set; } /// Test volume (target) in [l]
public virtual double TestTime { get; set; } /// Test time (estimate) in [s]
public virtual float Qtg { get; set; } /// Target water flow [m3/h]
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual float Volume { get; set; } /// Test volume (target) in [l]
public virtual float TestTime { get; set; } /// Test time (estimate) in [s]
public virtual string Method { get; set; }
public virtual float ErrLimLo { get; set; } /// in [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
public virtual float ErrLimHi { get; set; } /// in [%] usually > 0, in case of heat meters: -Qn in m3/h
@@ -292,11 +292,11 @@ namespace Config.Entities
tst.Part = int.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.DoEvaluate = bool.Parse(input.ReadLine());
tst.Qtg = double.Parse(input.ReadLine(), ci);
tst.Qfrom = double.Parse(input.ReadLine(), ci);
tst.Qto = double.Parse(input.ReadLine(), ci);
tst.Volume = double.Parse(input.ReadLine(), ci);
tst.TestTime = double.Parse(input.ReadLine(), ci);
tst.Qtg = float.Parse(input.ReadLine(), ci);
tst.Qfrom = float.Parse(input.ReadLine(), ci);
tst.Qto = float.Parse(input.ReadLine(), ci);
tst.Volume = float.Parse(input.ReadLine(), ci);
tst.TestTime = float.Parse(input.ReadLine(), ci);
tst.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);
+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_50 || WARSAW_END
case Common.GID.MetrologicalAuthority:
case Common.GID.WaterMeterAuthority:
#endif
admin.AddGroup(group);
session.SaveOrUpdate(group); /// Save this group
break;
}
}
session.SaveOrUpdate(admin); /// Save user 'admin'
transaction.Commit();
}
}
return true;
}
}
}
+2 -2
View File
@@ -214,9 +214,9 @@ namespace Config
/// </summary>
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
{
if (-float.Epsilon <= trueVolume && trueVolume <= float.Epsilon)
if (trueVolume <= float.Epsilon)
{
if (-float.Epsilon <= measuredVolume && measuredVolume <= float.Epsilon)
if (measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
-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 -1
View File
@@ -174,7 +174,7 @@ namespace Results
return Batch.GetTestRslt(name, part);
}
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId = CompoundMeterId.Single)
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId)
{
if (Batch.WaterMeters != null && Batch.WaterMeters.Count > wmNr0 && !Batch.WaterMeters[wmNr0].Disabled)
{
+16 -48
View File
@@ -78,17 +78,11 @@ namespace Results
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
}
}
@@ -186,55 +180,29 @@ namespace Results
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static void LoadSharedData(ISession session = null)
public static void LoadSharedData()
{
bool openAndCloseSession = (session == null);
ISession session = DB.CreateSession();
try
{
if (openAndCloseSession) session = Results.DB.CreateSession();
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
}
catch (Exception e)
{
log.ErrorFormat("Cannot open results DB: {0}", e.Message);
}
finally
{
if (openAndCloseSession && session != null && session.IsOpen) session.Close();
}
}
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
}
/// <summary>
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static int GetMaxSavedBatchNr(ISession session = null)
public static int GetMaxSavedBatchNr()
{
bool openAndCloseSession = (session == null);
int maxBatchNr = 0;
try
{
if (openAndCloseSession) session = Results.DB.CreateSession();
IList<Entities.Batch> batches = session.QueryOver<Batch>().List();
foreach (var b in batches)
{
if (b.BatchNr > maxBatchNr) maxBatchNr = b.BatchNr;
}
}
catch (Exception e)
{
log.ErrorFormat("Cannot open results DB: {0}", e.Message);
}
finally
{
if (openAndCloseSession && session != null && session.IsOpen) session.Close();
}
ISession session = DB.CreateSession();
IList<Entities.Batch> batches = session.QueryOver<Batch>().List();
int maxBatchNr = 0;
foreach (var b in batches)
{
if (b.BatchNr > maxBatchNr) maxBatchNr = b.BatchNr;
}
return maxBatchNr;
}
-2
View File
@@ -40,8 +40,6 @@ namespace Results
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entities.WaterMeterData>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
+1 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -24,8 +24,6 @@ namespace Results.Entities
public virtual int UserNumber { get; set; }
public virtual string ProcedureName { get; set; }
public virtual bool IsRemoteProcedure { get; set; } /// Stara Tura, not mapped to DB
public virtual string PurchaseOrder { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string Workflow { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
public virtual int ProcedureRevision { get; set; }
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
+1 -1
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;
+10 -15
View File
@@ -99,6 +99,7 @@ namespace Results.Entities
public virtual int HydrPruefung { get; set; }
#endif
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual int SessionId { get; set; } /// Not mapped to DB !!! 1 (regular tracing DB session) or 2 (alternative tracing DB session)
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual WaterMeterData WaterMeterData { get; set; }
@@ -108,23 +109,15 @@ namespace Results.Entities
///
/// Wrappers
///
public virtual string GetEndStateAux() { return Compound() ? EndStateAux : string.Empty; }
public virtual void SetEndStateAux(string s) { if (Compound()) EndStateAux = s; }
public virtual string GetStartState() { return Compound() ? string.Empty : EndStateAux; }
public virtual void SetStartState(string s) { if (!Compound()) EndStateAux = s; }
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string Producer() { return WaterMeterData.Producer; }
public virtual string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
public virtual string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
public virtual FlowNames Qnames() { return (FlowNames)WaterMeterData.Qnames; }
public virtual bool NewQnames() { return WaterMeterData.NewQnames; }
public virtual double Q4_Qmax() { return WaterMeterData.Q4_Qmax; }
public virtual double Q3_Qn() { return WaterMeterData.Q3_Qn; }
public virtual double Q2_Qt() { return WaterMeterData.Q2_Qt; }
public virtual double Q1_Qmin() { return WaterMeterData.Q1_Qmin; }
public virtual double ErrLimHiQ() { return WaterMeterData.ErrLimHiQ; }
public virtual double ErrLimLoQ() { return WaterMeterData.ErrLimLoQ; }
public virtual bool Compound() { return WaterMeterData.Compound; }
public virtual bool HeatMeter() { return WaterMeterData.HeatMeter; }
@@ -133,10 +126,8 @@ namespace Results.Entities
public virtual double Q3_Qn_Aux() { return WaterMeterData.Q3_Qn_Aux; }
public virtual string MetrologicalClassAux() { return WaterMeterData.MetrologicalClassAux; }
public virtual string ApprovalInfoAux() { return WaterMeterData.ApprovalInfoAux; }
#if ORACLE_DB
public virtual int WMTypeId() { return WaterMeterData.WMTypeId; }
#endif
public virtual int BatchNr() { return Batch.BatchNr; }
public virtual int BatchNr() { return Batch.BatchNr; }
public virtual int BenchId() { return Batch.TestBenchId; }
public virtual string ProcedureName() { return Batch.ProcedureName; }
public virtual int ProcedureRevision() { return Batch.ProcedureRevision; }
@@ -339,7 +330,7 @@ namespace Results.Entities
return GetMeterTestRslt(testName, CompoundMeterId.SingleOrCompound);
}
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId = CompoundMeterId.Single)
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId)
{
if (string.IsNullOrEmpty(testName)) return null;
if (Disabled) return null;
@@ -457,6 +448,7 @@ namespace Results.Entities
HydrPruefung = 0;
#endif
ProcessId = 0;
SessionId = 0;
LastRecordIsNok = false;
}
@@ -518,6 +510,7 @@ namespace Results.Entities
HydrPruefung = src.HydrPruefung;
#endif
ProcessId = src.ProcessId; /// Not mapped to DB
SessionId = src.SessionId; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
@@ -697,6 +690,7 @@ namespace Results.Entities
writer.Write(HydrPruefung);
#endif
writer.Write(ProcessId);
writer.Write(SessionId);
writer.Write(LastRecordIsNok);
/// Save WaterMeterData or WaterMeterData.Id
@@ -776,6 +770,7 @@ namespace Results.Entities
HydrPruefung = reader.ReadInt32();
#endif
ProcessId = reader.ReadInt32();
SessionId = reader.ReadInt32();
LastRecordIsNok = reader.ReadBoolean();
/// Retrieve TestData
+5 -16
View File
@@ -17,14 +17,11 @@ namespace Results.Entities
public virtual double DN { get; set; } /// [mm]
public virtual double L { get; set; } /// [mm]
public virtual Mounting Mounting { get; set; } /// H / V / S / F
public virtual sbyte Qnames { get; set; } /// see Common.Enums.FlowNames
public virtual bool NewQnames { get; set; } /// Yes = Q3... No = Qn...
public virtual double Q4_Qmax { get; set; } /// [m3/h]
public virtual double Q3_Qn { get; set; } /// [m3/h]
public virtual double Q2_Qt { get; set; } /// [m3/h]
public virtual double Q1_Qmin { get; set; } /// [m3/h]
public virtual double ErrLimHiQ { get; set; } /// [%]
public virtual double ErrLimLoQ { get; set; } /// [%]
public virtual string MetrologicalClass { get; set; }
public virtual TemperatureClass TemperatureClass { get; set; }
public virtual PressureLossClass PressureLossClass { get; set; }
@@ -69,13 +66,11 @@ namespace Results.Entities
DN = oriWMData.DN;
L = oriWMData.L;
Mounting = oriWMData.Mounting;
Qnames = oriWMData.Qnames;
NewQnames = oriWMData.NewQnames;
Q4_Qmax = oriWMData.Q4_Qmax;
Q3_Qn = oriWMData.Q3_Qn;
Q2_Qt = oriWMData.Q2_Qt;
Q1_Qmin = oriWMData.Q1_Qmin;
ErrLimHiQ = oriWMData.ErrLimHiQ;
ErrLimLoQ = oriWMData.ErrLimLoQ;
MetrologicalClass = oriWMData.MetrologicalClass;
TemperatureClass = oriWMData.TemperatureClass;
PressureLossClass = oriWMData.PressureLossClass;
@@ -114,13 +109,11 @@ namespace Results.Entities
if (DN != wmd.DN) return false;
if (L != wmd.L) return false;
if (Mounting != wmd.Mounting) return false;
if (Qnames != wmd.Qnames) return false;
if (NewQnames != wmd.NewQnames) return false;
if (Q4_Qmax != wmd.Q4_Qmax) return false;
if (Q3_Qn != wmd.Q3_Qn) return false;
if (Q2_Qt != wmd.Q2_Qt) return false;
if (Q1_Qmin != wmd.Q1_Qmin) return false;
if (ErrLimHiQ != wmd.ErrLimHiQ) return false;
if (ErrLimLoQ != wmd.ErrLimLoQ) return false;
if (MetrologicalClass != wmd.MetrologicalClass) return false;
if (TemperatureClass != wmd.TemperatureClass) return false;
if (PressureLossClass != wmd.PressureLossClass) return false;
@@ -174,13 +167,11 @@ namespace Results.Entities
writer.Write(DN);
writer.Write(L);
writer.Write((int)Mounting);
writer.Write((int)Qnames);
writer.Write(NewQnames);
writer.Write(Q4_Qmax);
writer.Write(Q3_Qn);
writer.Write(Q2_Qt);
writer.Write(Q1_Qmin);
writer.Write(ErrLimHiQ);
writer.Write(ErrLimLoQ);
writer.Write((MetrologicalClass != null) ? MetrologicalClass : string.Empty);
writer.Write((int)TemperatureClass);
writer.Write((int)PressureLossClass);
@@ -214,13 +205,11 @@ namespace Results.Entities
DN = reader.ReadDouble();
L = reader.ReadDouble();
Mounting = (Mounting)reader.ReadInt32();
Qnames = (sbyte)reader.ReadInt32();
NewQnames = reader.ReadBoolean();
Q4_Qmax = reader.ReadDouble();
Q3_Qn = reader.ReadDouble();
Q2_Qt = reader.ReadDouble();
Q1_Qmin = reader.ReadDouble();
ErrLimHiQ = reader.ReadDouble();
ErrLimLoQ = reader.ReadDouble();
MetrologicalClass = reader.ReadString();
TemperatureClass = (TemperatureClass)reader.ReadInt32();
PressureLossClass = (PressureLossClass)reader.ReadInt32();
+10 -24
View File
@@ -29,15 +29,13 @@
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.graphsTabPage = new System.Windows.Forms.TabPage();
this.productionTracingTabPage = new System.Windows.Forms.TabPage();
this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer();
this.messageLabel = new System.Windows.Forms.Label();
this.tracingResultsListView = new System.Windows.Forms.ListView();
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsRowsCtrl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.tabControl1.SuspendLayout();
this.allResultsTabPage.SuspendLayout();
this.productionTracingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
this.productionTracingSplitContainer.Panel1.SuspendLayout();
@@ -57,17 +55,6 @@
this.tabControl1.Size = new System.Drawing.Size(1195, 448);
this.tabControl1.TabIndex = 0;
//
// allResultsTabPage
//
this.allResultsTabPage.Controls.Add(this.oneWMResultsCtrl);
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// graphsTabPage
//
this.graphsTabPage.Location = new System.Drawing.Point(4, 22);
@@ -126,7 +113,6 @@
//
this.tracingResultsListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.tracingResultsListView.GridLines = true;
this.tracingResultsListView.HideSelection = false;
this.tracingResultsListView.Location = new System.Drawing.Point(0, 0);
this.tracingResultsListView.Name = "tracingResultsListView";
this.tracingResultsListView.Size = new System.Drawing.Size(1187, 366);
@@ -134,14 +120,15 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// oneWMResultsRowsCtrl
// allResultsTabPage
//
this.oneWMResultsCtrl.Caption = "---";
this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3);
this.oneWMResultsCtrl.Name = "oneWMResultsRowsCtrl";
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
this.oneWMResultsCtrl.TabIndex = 0;
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// MoreWMResultsDlg
//
@@ -153,7 +140,6 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Water meter results";
this.tabControl1.ResumeLayout(false);
this.allResultsTabPage.ResumeLayout(false);
this.productionTracingTabPage.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.PerformLayout();
@@ -167,12 +153,12 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage graphsTabPage;
private System.Windows.Forms.TabPage productionTracingTabPage;
private System.Windows.Forms.SplitContainer productionTracingSplitContainer;
private System.Windows.Forms.Label messageLabel;
private System.Windows.Forms.ListView tracingResultsListView;
private System.Windows.Forms.TabPage allResultsTabPage;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
}
}
+57 -61
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -14,13 +14,6 @@ namespace Results.Forms
{
public partial class MoreWMResultsDlg : Form
{
enum Tabs
{
Results = 0,
Graph,
Tracing,
}
public MoreWMResultsDlg(Results.Entities.WaterMeter wm, IList<ReferenceRecord> refRecords)
{
InitializeComponent();
@@ -30,15 +23,14 @@ namespace Results.Forms
ShowAllResults(wm);
ShowChart(wm);
/// Select the initial tab page to be displayed
if (refRecords == null)
{
tabControl1.SelectTab((int)Tabs.Graph);
tabControl1.TabPages.RemoveAt((int)Tabs.Tracing);
tabControl1.SelectTab(1);
tabControl1.TabPages.RemoveAt(2);
}
else
{
tabControl1.SelectTab((int)Tabs.Tracing);
tabControl1.SelectTab(2);
ShowTracingResults(wm, refRecords);
}
}
@@ -47,9 +39,9 @@ namespace Results.Forms
void Localize()
{
Text = Strings.Water_meter_results;
tabControl1.TabPages[(int)Tabs.Results].Text = Strings.All_results;
tabControl1.TabPages[(int)Tabs.Graph].Text = Strings.Graphs;
tabControl1.TabPages[(int)Tabs.Tracing].Text = Strings.Production_tracing_results;
tabControl1.TabPages[0].Text = Strings.All_results;
tabControl1.TabPages[1].Text = Strings.Graphs;
tabControl1.TabPages[2].Text = Strings.Production_tracing_results;
}
@@ -59,63 +51,67 @@ namespace Results.Forms
/// <param name="wMtr">Water meter entity</param>
void ShowAllResults(Results.Entities.WaterMeter wMtr)
{
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
#if ORACLE_DB
oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", wMtr.SerialNr ?? string.Empty, wMtr.Pruefindex % 100, message);
#else
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", wMtr.SerialNr ?? string.Empty);
#endif
// string message;
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
//#if ORACLE_DB
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
//#else
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
//#endif
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// Header
oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
oneWMResultsCtrl.Columns.Add(str, 100);
i++;
}
// // Header
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
// int i = 1;
// foreach (var str in wMtr.GetAllDecoratedTestNames())
// {
// oneWMResultsCtrl.Columns.Add(str, 100);
// i++;
// }
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Name);
// foreach (var item in items)
// {
// ListViewItem lvi = new ListViewItem(item.Name);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Common.Publish.Never &&
mtr.Publish() != Common.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
// foreach (var mtr in wMtr.MeterTestRslts)
// {
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Publish.Never &&
// mtr.Publish() != Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
// string[] texts = str.Split(new char[] { '|' });
// if (texts.Length == 1)
// {
// lvi.SubItems.Add(str);
// }
// else if (texts.Length == 2)
// {
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
// lvi.UseItemStyleForSubItems = false;
// lvi.SubItems.Add(texts[0]);
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
// }
// else
// {
// lvi.SubItems.Add(string.Empty);
// }
// }
// }
oneWMResultsCtrl.Items.Add(lvi);
}
// oneWMResultsCtrl.Items.Add(lvi);
// }
}
void ShowChart(Results.Entities.WaterMeter wm)
{
tabControl1.TabPages[(int)Tabs.Graph].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
//chart.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yy";
//chart.ChartAreas[0].AxisX.Interval = 1;
//chart.ChartAreas[0].AxisX.IntervalType = ;
tabControl1.TabPages[1].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
}
+4 -7
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
@@ -24,16 +24,13 @@ namespace Results.Forms
}
}
public string Caption { set { caption = value; } get { return caption; } }
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<WMeterRsltItemSpec> items;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
@@ -48,7 +45,7 @@ namespace Results.Forms
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<WMeterRsltItemSpec>();
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
@@ -65,7 +62,7 @@ namespace Results.Forms
}
}
public void Update(IList<WMeterRsltItemSpec> items)
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
-5
View File
@@ -343,11 +343,6 @@ namespace Results
X9, /// 291
RadioAddress, /// 292
OriRadioAddress, /// 293
Pls_per_ltr_aux, /// 294 Compound water meter constant (water meter data, not used in calculations)
Pulses_main, /// 295 Compound main meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Pulses_aux, /// 296 Compound aux meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Count,
}
+1 -1
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;
+3 -3
View File
@@ -18,13 +18,13 @@ namespace Results.Mappings
Map(x => x.L);
Map(x => x.Mounting);
Map(x => x.Qnames);
#if MUNICH && LANG_DE
Map(x => x.NewQnames);
#endif
Map(x => x.Q4_Qmax);
Map(x => x.Q3_Qn);
Map(x => x.Q2_Qt);
Map(x => x.Q1_Qmin);
Map(x => x.ErrLimHiQ);
Map(x => x.ErrLimLoQ);
Map(x => x.MetrologicalClass);
Map(x => x.TemperatureClass);
@@ -526,11 +526,11 @@ namespace Results.Output.Printers.Munich
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab1, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab3, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
}
lineNr++;
+15 -108
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2023 Sensus Metering Systems
/// Copyright (c) 2019-2022 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -55,9 +55,6 @@ namespace Results.Output
chArea.AxisX.LogarithmBase = 10;
chArea.AxisX.IsLabelAutoFit = true;
Series upperLimit = new Series { Name = Strings.Upper_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
List<double> xs = new List<double>() { 0.0001, 0.0002, 0.0005,
0.001, 0.002, 0.005,
0.01, 0.02, 0.05,
@@ -74,8 +71,6 @@ namespace Results.Output
double from = Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin);
double to = Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn);
bool inRange = false;
double qSharp = (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi) ? GetQsharp(wm, flowUnit) : 0;
double lastXs = 0;
for (int i = 0; i < xs.Count - 3; i += 3)
{
if (xs[i] <= from && from < xs[i + 3])
@@ -93,37 +88,6 @@ namespace Results.Output
cl.FromPosition = Math.Log10(xs[j] * spacer);
cl.ToPosition = Math.Log10(xs[j] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi)
{
if (lastXs != 0)
{
double insertedXs = Math.Sqrt(lastXs * xs[j]);
if (lastXs < qSharp && qSharp < insertedXs)
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
double errLim2 = GetErrorLimit(wm, flowUnit, insertedXs);
lowerLimit.Points.AddXY(insertedXs, -errLim2);
upperLimit.Points.AddXY(insertedXs, +errLim2);
if (insertedXs < qSharp && qSharp < xs[j])
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
}
lastXs = xs[j];
double errLim = GetErrorLimit(wm, flowUnit, xs[j]);
lowerLimit.Points.AddXY(xs[j], -errLim);
upperLimit.Points.AddXY(xs[j], +errLim);
}
}
}
@@ -137,36 +101,6 @@ namespace Results.Output
cl.ToPosition = Math.Log10(xs[i + 3] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.QpQi)
{
if (lastXs != 0)
{
double insertedXs = Math.Sqrt(lastXs * xs[i + 3]);
if (lastXs < qSharp && qSharp < insertedXs)
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
double errLim2 = GetErrorLimit(wm, flowUnit, insertedXs);
lowerLimit.Points.AddXY(insertedXs, -errLim2);
upperLimit.Points.AddXY(insertedXs, +errLim2);
if (insertedXs < qSharp && qSharp < xs[i + 3])
{
double errLim3 = GetErrorLimit(wm, flowUnit, qSharp);
lowerLimit.Points.AddXY(qSharp, -errLim3);
upperLimit.Points.AddXY(qSharp, +errLim3);
}
}
double errLim = GetErrorLimit(wm, flowUnit, xs[i + 3]);
lowerLimit.Points.AddXY(xs[i + 3], -errLim);
upperLimit.Points.AddXY(xs[i + 3], +errLim);
}
break;
}
}
@@ -177,20 +111,19 @@ namespace Results.Output
Legend legend1 = new Legend { Name = "Legend1" };
if (wm.WaterMeterData.Qnames == (sbyte)FlowNames.Q3Q2Q1 || wm.WaterMeterData.Qnames == (sbyte)FlowNames.QnQtQmin)
{
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), wm.WaterMeterData.ErrLimLoQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), wm.WaterMeterData.ErrLimLoQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), wm.WaterMeterData.ErrLimHiQ);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), wm.WaterMeterData.ErrLimHiQ);
if (isQ4) upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), wm.WaterMeterData.ErrLimHiQ);
Series upperLimit = new Series { Name = Strings.Upper_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), 5);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 5);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 2);
upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), 2);
if (isQ4) upperLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), 2);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -wm.WaterMeterData.ErrLimLoQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -wm.WaterMeterData.ErrLimLoQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -wm.WaterMeterData.ErrLimHiQ);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -wm.WaterMeterData.ErrLimHiQ);
if (isQ4) lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), -wm.WaterMeterData.ErrLimHiQ);
}
Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -5);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -5);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -2);
lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -2);
if (isQ4) lowerLimit.Points.AddXY(Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), -2);
Series line = new Series { Name = Strings.Relative_error, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.DeepSkyBlue };
Series dots = new Series { Name = Strings.Relative_error + " ", ChartArea = "ChartArea1", ChartType = SeriesChartType.Point, Color = Color.RoyalBlue };
@@ -204,38 +137,12 @@ namespace Results.Output
chart.ChartAreas.Add(chArea);
chart.Legends.Add(legend1);
if (upperLimit.Points.Count > 1) chart.Series.Add(upperLimit);
if (lowerLimit.Points.Count > 1) chart.Series.Add(lowerLimit);
chart.Series.Add(upperLimit);
chart.Series.Add(lowerLimit);
chart.Series.Add(dots);
chart.Series.Add(line);
return chart;
}
static double GetErrorLimit(WaterMeter wm, Unit flowUnit, double x)
{
double flow_m3 = Units.ConvertFrom(flowUnit, x);
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: return Math.Min(3.5, 1.0 + 0.01 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 2: return Math.Min(5.0, 2.0 + 0.02 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 3: return Math.Min(5.0, 3.0 + 0.05 * wm.WaterMeterData.Q3_Qn / flow_m3);
}
}
static double GetQsharp(WaterMeter wm, Unit flowUnit)
{
double qSharp;
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: qSharp = (0.01 / 2.5) * wm.WaterMeterData.Q3_Qn; break;
case 2: qSharp = (0.02 / 3.0) * wm.WaterMeterData.Q3_Qn; break;
case 3: qSharp = (0.05 / 2.0) * wm.WaterMeterData.Q3_Qn; break;
}
return Units.ConvertTo(flowUnit, qSharp);
}
}
}
-2
View File
@@ -31,8 +31,6 @@ namespace ResultsParser
.Database(MySQLConfiguration.Standard.ConnectionString(connStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<WaterMeterData>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory()
.OpenSession();
+8 -6
View File
@@ -239,7 +239,7 @@ namespace Statistics
"SERVER=localhost; DATABASE=genesis-r; UID=root; PASSWORD=; CHARSET=utf8;",
};
#else
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "WR18", "WR19", "PT7" };
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "WR18", "WR19", "WR20", "WR21", "PT7" };
MidNames = new string[] { string.Empty, "I1", "I2", "I3", "I4" }; /// Index is MID-id
#if true
/// Production Stara Tura
@@ -247,14 +247,16 @@ namespace Statistics
ConnectionStrings = new string[]
{
"SERVER=10.42.129.242; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.69; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.129.27; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.0; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.146; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.70; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.52; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.61; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.71; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.165; DATABASE=st-wr18-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.128.159; DATABASE=st-wr19-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.89; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.76; DATABASE=st-wr20-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.156; DATABASE=st-wr21-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.130.131; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
};
#else
/// Off-line demo
-4
View File
@@ -133,10 +133,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\Results\Results.csproj">
<Project>{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}</Project>
<Name>Results</Name>
-3
View File
@@ -13,7 +13,6 @@ using NHibernate;
using FluentNHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Common;
using Results;
using Results.Entities;
using Statistics.Resources;
@@ -99,8 +98,6 @@ namespace Statistics
.Database(MySQLConfiguration.Standard.ConnectionString(connStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Results.Entities.Batch>())
.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
catch (Exception)
+1 -20
View File
@@ -1,8 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}"
ProjectSection(ProjectDependencies) = postProject
{C8939821-BA5C-4988-A3D0-BF53B74865C7} = {C8939821-BA5C-4988-A3D0-BF53B74865C7}
@@ -94,8 +92,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatureVectorCalculator", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsParser", "ResultsParser\ResultsParser.csproj", "{2E08C19B-C0A9-4056-8564-E5B74477959D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sensus.iPerl.RfidCom", "..\iPerlHead\Sensus.iPerl.RfidCom\Sensus.iPerl.RfidCom.csproj", "{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -390,23 +386,8 @@ Global
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7C8EF35-DF72-4DFC-83F7-9641AC1178CF}
EndGlobalSection
EndGlobal
+33 -183
View File
@@ -1,17 +1,11 @@
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Common;
using Events;
using TBF.Resources;
using System.Collections.Generic;
using Config;
using Users.Entities;
namespace TBF
{
@@ -22,196 +16,52 @@ namespace TBF
///
public static DatabaseSettings CurrentBench;
public static ISessionFactory ConfigDBSessionFactory = null; /// Configuration DB session factory (always != null)
public static ISessionFactory SharedDBSessionFactory = null; /// Shared configuration DB session factory or null
public static ISessionFactory ResultsDBSessionFactory = null; /// Results DB session factory (always != null)
public static ISessionFactory EventsDBSessionFactory = null; /// Events DB session factory or null
public static ISessionFactory LocalUsersDBSessionFactory = null; /// Local users DB session factory (always != null)
public static ISessionFactory SharedUsersDBSessionFactory = null; /// Shared users DB session factory or null
public static ISessionFactory[] UserSessionFactories
{
get
{
return (SharedUsersDBSessionFactory != null)
? new ISessionFactory[] { SharedUsersDBSessionFactory, LocalUsersDBSessionFactory }
: new ISessionFactory[] { LocalUsersDBSessionFactory };
}
}
/// <summary>
/// Create all database session factories
/// Session factories for regular sessions.
/// </summary>
public static void CreateSessionFactories(DatabaseSettings dbSettings)
public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)DBKind.Count];
/// Create a NHibernate session for the given database
public static ISession CreateSession(DBKind database)
{
/// Configuration database (local, always non-null)
if (dbSettings.ProceduresDBSettings != null && dbSettings.ProceduresDBSettings.IsValid)
{
ConfigDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
dbSettings.ProceduresDBSettings.DbType,
dbSettings.ProceduresDBSettings.ConnectionString);
if (database < 0 || database >= DBKind.Count) return null;
LocalUsersDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Users.Entities.User>(),
dbSettings.ProceduresDBSettings.DbType,
dbSettings.ProceduresDBSettings.ConnectionString);
int ix = (int)database;
if (SessionFactories[ix] == null)
{
SessionFactories[ix] = CreateSessionFactory(database);
}
/// Shared configuration database (remote)
if (dbSettings.UsersDBSettings != null && dbSettings.UsersDBSettings.IsValid)
{
SharedDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
dbSettings.UsersDBSettings.DbType,
dbSettings.UsersDBSettings.ConnectionString);
SharedUsersDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Users.Entities.User>(),
dbSettings.UsersDBSettings.DbType,
dbSettings.UsersDBSettings.ConnectionString);
}
/// Results database (local, always non-null)
if (dbSettings.WaterMetersDBSettings != null && dbSettings.WaterMetersDBSettings.IsValid)
{
Results.DB.SessionFactory = ResultsDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Results.Entities.Batch>(),
dbSettings.WaterMetersDBSettings.DbType,
dbSettings.WaterMetersDBSettings.ConnectionString);
}
/// Events database (remote or local)
if (dbSettings.EventsDBSettings != null && dbSettings.EventsDBSettings.IsValid)
{
EventsDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Events.Entities.Event>(),
dbSettings.EventsDBSettings.DbType,
dbSettings.EventsDBSettings.ConnectionString);
}
return SessionFactories[ix].OpenSession();
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(Action<MappingConfiguration> mappings, DBType dbType,
string connectionString, bool createDB = false)
static ISessionFactory CreateSessionFactory(DBKind database)
{
try
DBType dbType;
string connectionString;
switch (database)
{
var buildSchema = createDB ? (Action<Configuration>)BuildSchemaCreate : (Action<Configuration>)BuildSchema;
switch (dbType)
{
default:
case DBType.MySql:
return Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(mappings)
.ExposeConfiguration(buildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
case DBType.SQLite:
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.UsingFile(connectionString))
.Mappings(mappings)
.ExposeConfiguration(buildSchema)
.BuildSessionFactory();
}
}
catch (Exception exc)
{
MessageBox.Show(string.Format("{0}: {1}", Strings.Cannot_connect_to_the_database, exc.Message),
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
static void BuildSchema(Configuration config)
{
/// This NHibernate tool takes a configuration (with mapping info in)
/// and exports a database schema from it
new SchemaExport(config).SetOutputFile("db_schema");
}
static void BuildSchemaCreate(Configuration config)
{
/// This NHibernate tool takes a configuration (with mapping info in)
/// and exports a database schema from it
new SchemaExport(config).Create(true, true);
}
/// <summary>
/// Create an empty users database.
/// Database contains only the user 'admin' and the control board component 'CB'.
/// </summary>
/// <param name="dbType">DBType.SQLite or DBType.MySql</param>
/// <param name="connectionString">Connection string</param>
/// <returns>true=success, false=error</returns>
public static bool CreateEmptyConfigDB(Common.DBType dbType, string connectionString)
{
ISessionFactory sessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Config.Entities.Procedure>(),
dbType, connectionString, true);
if (sessionFactory == null) return false;
/// Populate the database
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
///
/// Create user 'admin'
///
var admin = new Config.Entities.User
{
UserName = Config.Data.AdminUsername,
FullName = Strings.Administrator,
LastPwChange = DateTime.Now
};
admin.SetPassword(Config.Data.AdminPassword);
///
/// Prepare all groups, add some of them to admin
///
for (Common.GID gid = 0; gid < Common.GID.NrOfGroups; gid++)
{
Config.Entities.Group group = new Config.Entities.Group(gid);
switch (gid)
{
case Common.GID.Testers:
case Common.GID.TestingSpecialists:
case Common.GID.HeadOfLab:
case Common.GID.MaintenanceSpecialists:
case Common.GID.Metrologists:
case Common.GID.CalibrationSpecialists:
case Common.GID.Administrators:
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
case Common.GID.TraceabilityManagement:
#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END
case Common.GID.MetrologicalAuthority:
case Common.GID.WaterMeterAuthority:
#endif
admin.AddGroup(group);
session.SaveOrUpdate(group); /// Save this group
break;
}
}
session.SaveOrUpdate(admin); /// Save user 'admin'
transaction.Commit();
}
default:
case DBKind.Config:
dbType = CurrentBench.ProceduresDBSettings.DbType;
connectionString = CurrentBench.ProceduresDBSettings.ConnectionString;
break;
case DBKind.Results:
dbType = CurrentBench.WaterMetersDBSettings.DbType;
connectionString = CurrentBench.WaterMetersDBSettings.ConnectionString;
break;
case DBKind.RemoteConfig:
dbType = CurrentBench.UsersDBSettings.DbType;
connectionString = CurrentBench.UsersDBSettings.ConnectionString;
break;
}
return true;
return Config.FluentCommon.CreateSessionFactory(database, dbType, connectionString, false);
}
}
}
-21
View File
@@ -231,27 +231,6 @@ namespace TBF
public string LastText3;
public string LastRemark;
/// DataEntry.Uni history
public string[] LastBgComm1;
public string[] LastBgComm2;
public string[] LastBgComm3;
///
public string[] LastBgColA;
public string[] LastBgColB;
public string[] LastBgColC;
public string[] LastBgColD;
public string[] LastBgColE;
///
public string[] LastEnComm1;
public string[] LastEnComm2;
public string[] LastEnComm3;
///
public string[] LastEnColA;
public string[] LastEnColB;
public string[] LastEnColC;
public string[] LastEnColD;
public string[] LastEnColE;
/// Purchase order history
public string[] PurchaseOrderHistory;
[XmlIgnore]
+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;
}
}
}
}
}
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.33.2110.0")]
[assembly: AssemblyFileVersion("2.33.2110.0")]
[assembly: AssemblyVersion("2.32.2025.0")]
[assembly: AssemblyFileVersion("2.32.2025.0")]
+40 -85
View File
@@ -19,7 +19,7 @@ namespace TBF.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
@@ -294,15 +294,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to All files.
/// </summary>
internal static string All_files {
get {
return ResourceManager.GetString("All_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All tests must be completed.
/// </summary>
@@ -654,15 +645,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate.
/// </summary>
internal static string Calibration_certificate {
get {
return ResourceManager.GetString("Calibration_certificate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate validity expired.
/// </summary>
@@ -1293,15 +1275,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to default printer.
/// </summary>
internal static string default_printer {
get {
return ResourceManager.GetString("default_printer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Default units.
/// </summary>
@@ -1923,15 +1896,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>
@@ -2292,15 +2256,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Get number of cycles to bypass.
/// </summary>
internal static string Get_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Get_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Grab.
/// </summary>
@@ -3642,15 +3597,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to PDF files.
/// </summary>
internal static string PDF_files {
get {
return ResourceManager.GetString("PDF_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PID.
/// </summary>
@@ -3877,11 +3823,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);
}
}
@@ -3939,15 +3885,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>
@@ -4344,6 +4281,33 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Qmax [m3/h].
/// </summary>
internal static string Qmax {
get {
return ResourceManager.GetString("Qmax", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qmin [m3/h].
/// </summary>
internal static string Qmin {
get {
return ResourceManager.GetString("Qmin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qn [m3/h].
/// </summary>
internal static string Qn {
get {
return ResourceManager.GetString("Qn", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Qrise.
/// </summary>
@@ -4353,6 +4317,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Qt [m3/h].
/// </summary>
internal static string Qt {
get {
return ResourceManager.GetString("Qt", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Question.
/// </summary>
@@ -5127,15 +5100,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Set number of cycles to bypass.
/// </summary>
internal static string Set_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Set_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set route.
/// </summary>
@@ -6309,15 +6273,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Unlock a bypass.
/// </summary>
internal static string Unlock_bypass {
get {
return ResourceManager.GetString("Unlock_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unlock.
/// </summary>
+11 -29
View File
@@ -673,7 +673,7 @@
<value>Tiskárna</value>
</data>
<data name="Procedure" xml:space="preserve">
<value>Procedura</value>
<value>Prodedura</value>
</data>
<data name="Procedures" xml:space="preserve">
<value>Procedury</value>
@@ -732,9 +732,18 @@
<data name="Qfall" xml:space="preserve">
<value>Qfall</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Qrise</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>Otázka</value>
</data>
@@ -1177,7 +1186,7 @@
<value>Tisk výsledků</value>
</data>
<data name="Procedure_name" xml:space="preserve">
<value>Jméno procedury</value>
<value>Jméno postupu</value>
</data>
<data name="Process" xml:space="preserve">
<value>Proces</value>
@@ -1674,31 +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>
<data name="default_printer" xml:space="preserve">
<value>předvolená tiskárna</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Zjisti počet cyklů bez kontroly</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Nastav počet cyklů bez kontroly</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Odemknout vypnutí kontroly</value>
</data>
<data name="All_files" xml:space="preserve">
<value>Všechny soubory</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Kalibrační certifikát</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF soubory</value>
</data>
</root>
+14 -2
View File
@@ -1278,8 +1278,8 @@
<data name="Volume" xml:space="preserve">
<value>Volumen</value>
</data>
<data name="Print" xml:space="preserve">
<value>Drucken</value>
<data name="Print_again" xml:space="preserve">
<value>Druck wiederholen</value>
</data>
<data name="Show" xml:space="preserve">
<value>Anzeigen</value>
@@ -1545,6 +1545,9 @@
<data name="Invalid_username_or_password" xml:space="preserve">
<value>Ungültiger Benutzername oder Passwort </value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_Meter_States" xml:space="preserve">
<value>WZ-Stand</value>
</data>
@@ -1572,6 +1575,12 @@
<data name="Main_" xml:space="preserve">
<value>Hauptzähler</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Wasser</value>
</data>
@@ -1635,6 +1644,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Ungültige Einstellung. Bitte um Korrektur!</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax [m3/h]</value>
</data>
<data name="L" xml:space="preserve">
<value>Länge</value>
</data>
+12 -3
View File
@@ -633,6 +633,9 @@
<data name="Producer" xml:space="preserve">
<value>Producteur</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Compteurs eau</value>
</data>
@@ -984,6 +987,12 @@
<data name="Main_" xml:space="preserve">
<value>Principale</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Eau</value>
</data>
@@ -1134,6 +1143,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Informations d'étalonnage non valides. Corrigez le s'il vous plaît.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificat</value>
</data>
@@ -1998,7 +2010,4 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimer</value>
</data>
</root>
+15 -3
View File
@@ -648,6 +648,9 @@
<data name="Producer" xml:space="preserve">
<value>produttore</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>contatori acqua</value>
</data>
@@ -999,6 +1002,12 @@
<data name="Main_" xml:space="preserve">
<value>principale:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Q minimo</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Water" xml:space="preserve">
<value>acqua</value>
</data>
@@ -1149,6 +1158,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Informazioni di calibrazione non valida. Prego correggere</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Q massimo</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificato</value>
</data>
@@ -1521,6 +1533,9 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>stampa ancora</value>
</data>
<data name="Show" xml:space="preserve">
<value>mostrare</value>
</data>
@@ -1764,7 +1779,4 @@
<data name="Start_cycle" xml:space="preserve">
<value>Avviare il ciclo</value>
</data>
<data name="Print" xml:space="preserve">
<value>Stampa</value>
</data>
</root>
+15 -3
View File
@@ -691,6 +691,9 @@
<data name="Qfall" xml:space="preserve">
<value>Qopad</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Qwzras</value>
</data>
@@ -1027,6 +1030,12 @@
<data name="Main_" xml:space="preserve">
<value>Główny:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Water" xml:space="preserve">
<value>Woda</value>
</data>
@@ -1168,6 +1177,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Nieprawidłowa nivormacje o kalibracji. Proszę poprawić.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certyfikat</value>
</data>
@@ -1531,6 +1543,9 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Wydrukuj jeszcze raz</value>
</data>
<data name="Show" xml:space="preserve">
<value>Pokaż</value>
</data>
@@ -1612,7 +1627,4 @@
<data name="Start_cycle" xml:space="preserve">
<value>Start cyklu</value>
</data>
<data name="Print" xml:space="preserve">
<value>Wydruk</value>
</data>
</root>
+14 -29
View File
@@ -643,6 +643,9 @@
<data name="Producer" xml:space="preserve">
<value>Producer</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn [m3/h]</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Water meters</value>
</data>
@@ -994,6 +997,12 @@
<data name="Main_" xml:space="preserve">
<value>Main:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin [m3/h]</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt [m3/h]</value>
</data>
<data name="Water" xml:space="preserve">
<value>Water</value>
</data>
@@ -1144,6 +1153,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Invalid calibration information. Correct it please.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax [m3/h]</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Certificate</value>
</data>
@@ -1519,8 +1531,8 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print" xml:space="preserve">
<value>Print</value>
<data name="Print_again" xml:space="preserve">
<value>Print again</value>
</data>
<data name="Show" xml:space="preserve">
<value>Show</value>
@@ -2308,31 +2320,4 @@
<data name="no_profile" xml:space="preserve">
<value>no profile</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Printer selection</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>default printer</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Get number of cycles to bypass</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Set number of cycles to bypass</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Unlock a bypass</value>
</data>
<data name="Error_reading_configuration_database" xml:space="preserve">
<value>Error reading configuration database</value>
</data>
<data name="All_files" xml:space="preserve">
<value>All files</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Calibration certificate</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF files</value>
</data>
</root>
+6 -3
View File
@@ -546,6 +546,12 @@
<data name="Q_to_lph" xml:space="preserve">
<value>Q pana la [l/h]</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>Intrebare</value>
</data>
@@ -825,7 +831,4 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimanta</value>
</data>
</root>
+15 -3
View File
@@ -633,6 +633,9 @@
<data name="Producer" xml:space="preserve">
<value>Производитель</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Water_meters" xml:space="preserve">
<value>Счетчики воды</value>
</data>
@@ -987,6 +990,12 @@
<data name="Main_" xml:space="preserve">
<value>Главн:</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="cold" xml:space="preserve">
<value>холодный</value>
</data>
@@ -1134,6 +1143,9 @@
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Неверная информация калибровки. Исправьте это, пожалуйста.</value>
</data>
<data name="Qmax" xml:space="preserve">
<value>Qmax</value>
</data>
<data name="Certificate" xml:space="preserve">
<value>Сертификат</value>
</data>
@@ -1506,6 +1518,9 @@
<data name="P_delta" xml:space="preserve">
<value>P дельта</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Печатать снова</value>
</data>
<data name="Show" xml:space="preserve">
<value>Показать</value>
</data>
@@ -1584,7 +1599,4 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Print" xml:space="preserve">
<value>Печатать</value>
</data>
</root>
+9 -3
View File
@@ -753,9 +753,18 @@
<data name="Qfall" xml:space="preserve">
<value>Q下降</value>
</data>
<data name="Qmin" xml:space="preserve">
<value>Qmin</value>
</data>
<data name="Qn" xml:space="preserve">
<value>Qn</value>
</data>
<data name="Qrise" xml:space="preserve">
<value>Q上升</value>
</data>
<data name="Qt" xml:space="preserve">
<value>Qt</value>
</data>
<data name="Question" xml:space="preserve">
<value>问题</value>
</data>
@@ -1182,7 +1191,4 @@
<data name="Evaporation" xml:space="preserve">
<value>蒸发</value>
</data>
<data name="Print" xml:space="preserve">
<value>打印机</value>
</data>
</root>
-19
View File
@@ -1,19 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
namespace TBF.Rig
{
public class DataChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public object Data;
public DataChangeArgs(CfgChangeCmd command, object data)
{
Command = command;
Data = data;
}
}
}
@@ -10,7 +10,6 @@ using Config;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.BenchInfo.iPerl
{
@@ -57,51 +56,35 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -47,7 +47,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -89,7 +88,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
MaxTestIndex = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -351,10 +349,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
prms.LenghtUnit = this.LenghtUnit;
prms.Side = this.Side;
prms.MaxTestIndex = this.MaxTestIndex;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
+22 -39
View File
@@ -1,11 +1,10 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Buoyancy
{
@@ -37,51 +36,35 @@ namespace TBF.Rig.DataContainers.Buoyancy
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -27,7 +27,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -51,7 +50,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
Buoyancy = 1.00103;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -114,10 +112,6 @@ namespace TBF.Rig.DataContainers.Buoyancy
void CopyContentTo(ComponentCfg prms)
{
prms.Buoyancy = this.Buoyancy;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
+22 -39
View File
@@ -1,11 +1,10 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Density
{
@@ -40,51 +39,35 @@ namespace TBF.Rig.DataContainers.Density
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -28,7 +28,6 @@ namespace TBF.Rig.DataContainers.Density
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -53,7 +52,6 @@ namespace TBF.Rig.DataContainers.Density
AtTemperature = 20.0; /// °C
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -124,10 +122,6 @@ namespace TBF.Rig.DataContainers.Density
{
prms.RealDensity = this.RealDensity;
prms.AtTemperature = this.AtTemperature;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,7 +7,6 @@ using log4net;
using Config.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Evaporation
{
@@ -41,51 +40,35 @@ namespace TBF.Rig.DataContainers.Evaporation
}
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
if (DateTime.Now.Date <= calibrationDue.Date)
{
if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
{
/// Weekly reminders (last 5 weeks)
calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
calibDue.Date.AddDays(days),
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
/// Calibration due date
if (calibDue.Date >= DateTime.Now.Date)
{
calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
Name,
string.Format(Strings.Calibration_due_date_is_0,
calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calEvents;
return calendarEvents;
}
}
}
@@ -21,7 +21,6 @@ namespace TBF.Rig.DataContainers.Evaporation
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -43,7 +42,6 @@ namespace TBF.Rig.DataContainers.Evaporation
public void InitializeAll()
{
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
-95
View File
@@ -1,95 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using Common;
namespace TBF.Rig.DataEntry
{
///
/// Ac = Action
///
public enum Ac
{
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
[Description("Last from history")] HistoryLast,
[Description("Load")] Load, /// Load from water meters when the form is open, save on OK
[Description("Load (readonly)")] LoadReadOnly, /// Load from water meters when the form is open, prevent changes, do not save
Count,
}
///
/// Ct = Content
///
public enum Ct
{
[Description("None")] None,
[Description("Serial nr.")] SerialNr,
[Description("Serial nr. aux")] SerialNrAux,
[Description("Radio address")] RadioAddress,
[Description("Year of calibration")] YearOfCalibration,
[Description("Start state")] StartState,
[Description("End state")] EndState,
[Description("Archive path")] ArchivePath,
[Description("WM Order")] WmOrder,
[Description("Batch order")] BatchOrder,
[Description("Batch and WM order")] BatchAndWmOrder,
[Description("WM Remark")] WmRemark,
[Description("Batch remark")] BatchRemark,
[Description("Batch and WM remark")] BatchAndWmRemark,
#if ORACLE_DB
[Description("Prefix")] Prefix,
[Description("Suffix")] Suffix,
#endif
Count
}
public class DEItem
{
public readonly Ct Content;
public readonly string Caption;
public readonly Ac Action;
public readonly int Width;
public DEItem(Ct content, string caption, Ac action, int width)
{
Content = content;
Caption = caption;
Action = action;
Width = width;
}
static IList<DEItem> items = new List<DEItem>();
///
public static void ClearItems() { items.Clear(); }
public static void AddItem(DEItem item) { items.Add(item); }
public static void AddItem(Ct content, string caption, Ac action, int width)
{
items.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetItems() { return items; }
static IList<DEItem> columns = new List<DEItem>();
///
public static void ClearColumns() { columns.Clear(); }
public static void AddColumn(DEItem column) { columns.Add(column); }
public static void AddColumn(Ct content, string caption, Ac action, int width)
{
columns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetColumns() { return columns; }
static IList<DEItem> summaryColumns = new List<DEItem>();
///
public static void ClearSummaryColumns() { summaryColumns.Clear(); }
public static void AddSummaryColumn(DEItem column) { summaryColumns.Add(column); }
public static void AddSummaryColumn(Ct content, string caption, Ac action, int width)
{
summaryColumns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetSummaryColumns() { return summaryColumns; }
}
}
+2 -74
View File
@@ -1,85 +1,13 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Results.Entities;
namespace TBF.Rig.DataEntry
{
public class DEUtils
{
public static string GetContent(Ct content, WaterMeter wm)
{
if (wm == null) return string.Empty;
switch (content)
{
default:
case Ct.None: return string.Empty;
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
#if ORACLE_DB
case Ct.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Ct.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
#endif
}
}
public static void PutContent(Ct content, WaterMeter wm, string value)
{
if (wm == null || wm.Disabled) return;
int year;
switch (content)
{
default:
case Ct.None: return;
case Ct.SerialNr: wm.SerialNr = value; return;
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
case Ct.RadioAddress: wm.RadioAddress = value; return;
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
case Ct.StartState: wm.SetStartState(value); return;
case Ct.EndState: wm.EndState = value; return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
wm.PurchaseOrder = value;
return;
case Ct.BatchOrder:
case Ct.BatchAndWmOrder:
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
return;
case Ct.WmRemark:
wm.Remark = value;
return;
case Ct.BatchRemark:
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
#if ORACLE_DB
case Ct.Prefix: wm.Prefix = value; return;
case Ct.Suffix: wm.Suffix = value; return;
#endif
}
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
-736
View File
@@ -1,736 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class CycleBgEnForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBgEnForm));
/// Arguments
public readonly IList<WaterMeter> WaterMeters;
readonly int lineSize;
readonly Sz sz;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> commonItems;
readonly IList<DEItem> colItems;
readonly bool isEnd;
readonly string formCloseKeys;
/// Derived from arguments in the constructor
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly int commonItemsCount;
/// Size and layout related values
readonly Font font;
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int buttonsWidth;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] commonLabels;
readonly ComboBox[] commonComboBoxes;
readonly Label[] labels; /// Labels for water meter numbers
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public CycleBgEnForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="commonItems">Common items displayed in the upper part of the form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="isEnd">true = This form is displayed at the end of cycle</param>
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
: this()
{
/// Arguments
this.WaterMeters = waterMeters;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.commonItems = commonItems;
this.colItems = colItems;
this.isEnd = isEnd;
/// Preserve column items for use in SummaryResults
if (!isEnd)
{
/// cycle beginning
DEItem.ClearSummaryColumns();
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
else
{
/// cycle end
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
commonItemsCount = (commonItems == null) ? 0 : commonItems.Count;
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
///
commonLabels = new Label[commonItemsCount];
commonComboBoxes = new ComboBox[commonItemsCount];
labels = new Label[wmsCount];
comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount];
/// Layout related readonly variables derived from argument 'sz'
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
buttonsWidth = 350;
hdrHeight = 120;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
buttonsWidth = 350;
hdrHeight = 140;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
buttonsWidth = 350;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Group box with common items
///
int groupBoxWidth = 0;
int groupBoxHeight = 0;
if (commonItemsCount > 0)
{
var groupBox = new GroupBox();
int labelsWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width);
var oneLabel = new Label
{
Text = commonItems[ix].Caption,
Font = font,
Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(oneLabelWidth + spacing, meterHeight),
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = groupBox,
};
groupBox.Controls.Add(oneLabel);
labelsWidth = Math.Max(labelsWidth, oneLabelWidth);
}
int combosWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
var cb = new ComboBox
{
Name = string.Format("-1~{0}", ix + 1),
Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(commonItems[ix].Width, meterHeight),
Enabled = (commonItems[ix].Action != Ac.LoadReadOnly),
Font = font,
TabIndex = tabIndex++,
Parent = groupBox,
};
cb.SelectedIndexChanged += new System.EventHandler(comboBox_SelectedIndexChanged);
cb.TextChanged += new System.EventHandler(comboBox_TextChanged);
cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(comboBox_KeyPress);
switch (ix)
{
case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break;
case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break;
case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break;
}
commonComboBoxes[ix] = cb;
groupBox.Controls.Add(cb);
combosWidth = Math.Max(combosWidth, commonItems[ix].Width);
}
///
groupBox.Location = new Point(margin, margin - spacing);
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing;
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
groupBox.Font = font;
groupBox.TabIndex = tabIndex++;
groupBox.Parent = this;
this.Controls.Add(groupBox);
}
///
/// Table
///
int columnsTop = Math.Max(hdrHeight, groupBoxHeight + 2 * margin + spacing);
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var comboBox = new ComboBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
comboBox.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
comboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
left += ci.Width + spacing;
comboBoxes[k, wmPos0] = comboBox;
this.Controls.Add(comboBox);
}
var checkBox = new CheckBox
{
Location = new Point(left, top + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
checkBoxes[wmPos0] = checkBox;
this.Controls.Add(checkBox);
}
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + buttonsWidth),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
bool activeControlFound = false;
for (int ix = 0; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
ActiveControl = commonComboBoxes[ix];
activeControlFound = true;
break;
}
}
if (!activeControlFound)
{
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
int k, j;
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
ActiveControl = okButton;
}
else
{
ActiveControl = comboBoxes[k, j];
}
}
}
/// <summary>
/// Add combo box items from a history stored in a string array (obtained usually from LocalSettings)
/// </summary>
/// <param name="comboBox">ComboBox to prepare</param>
/// <param name="history">String array with a history</param>
void AddHistoryToCombo(ComboBox comboBox, string[] history)
{
if (history != null)
{
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
}
}
/// <summary>
/// Returns an array of strings from ls.
/// Never returns null, null is converted to new string[0].
/// </summary>
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
/// <param name="k">Column number (0-based)</param>
/// <returns>Array of strings</returns>
string[] GetHistoryFromLS(bool isEnd, int k)
{
if (isEnd)
{
switch (k)
{
case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA;
case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB;
case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC;
case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD;
case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE;
default: return new string[0];
}
}
else
{
switch (k)
{
case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA;
case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB;
case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC;
case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD;
case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE;
default: return new string[0];
}
}
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
clearButton.Text = Strings.ClearBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Common combo boxes
for (int ix = 0; ix < commonItemsCount; ix++)
{
switch (commonItems[ix].Action)
{
default:
case Ac.Clear:
commonComboBoxes[ix].Text = string.Empty;
break;
case Ac.HistoryLast:
commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0)
? commonComboBoxes[ix].Items[0].ToString()
: string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
break;
}
}
/// Table
for (int k = 0; k < colItems.Count; k++)
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
break;
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
}
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
}
break;
}
}
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = isEnd ? (WaterMeters[i] != null && !WaterMeters[i].Disabled) : false;
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int ix = 0; ix < commonItemsCount; ix++ )
{
DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text);
if (commonItems[ix].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break;
}
}
else
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break;
}
}
}
///
/// Propagate common (batch) values to water meters in case of
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
///
foreach (var wm in WaterMeters)
{
if (wm != null && !wm.Disabled)
{
switch (commonItems[ix].Content)
{
case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break;
case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break;
case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break;
case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break;
}
}
}
}
for (int k = 0; k < colItems.Count; k++)
{
/// Store values to water meters and prepare an array for a history in the LocalSettings
var currentVals = new string[wmsCount];
for (int i = 0; i < wmsCount; i++)
{
DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
currentVals[i] = comboBoxes[k, i].Text;
}
/// Update history
if (colItems[k].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (k)
{
case 0: ls.LastEnColA = currentVals; break;
case 1: ls.LastEnColB = currentVals; break;
case 2: ls.LastEnColC = currentVals; break;
case 3: ls.LastEnColD = currentVals; break;
case 4: ls.LastEnColE = currentVals; break;
}
}
else
{
switch (k)
{
case 0: ls.LastBgColA = currentVals; break;
case 1: ls.LastBgColB = currentVals; break;
case 2: ls.LastBgColC = currentVals; break;
case 3: ls.LastBgColD = currentVals; break;
case 4: ls.LastBgColE = currentVals; break;
}
}
}
}
for (int i = 0; i < wmsCount; i++)
{
if (WaterMeters[i] != null) WaterMeters[i].Disabled = !checkBoxes[i].Checked;
}
}
private void clearButton_Click(object sender, EventArgs e)
{
InitializeBoxes();
}
private void okButton_Click(object sender, EventArgs e)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
isHandlersEnabled = false;
if (k >= 0 && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
{
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items[0].ToString();
if (!string.IsNullOrEmpty(comboBoxes[k, i].Text)) checkBoxes[i].Checked = true;
}
}
isHandlersEnabled = true;
}
private void comboBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
if (e.KeyChar == '\r')
{
if (k < 0)
{
for (int ix = j; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
commonComboBoxes[ix].Focus();
return;
}
}
/// No next enabled common item found:
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
}
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
comboBoxes[k, j].Focus();
}
}
}
private void comboBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
if (k >= 0) checkBoxes[j].Checked = true;
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="comboBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledCombo(ComboBox[,] comboBoxes, ref int k, ref int i, bool isLrOrder)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == comboBoxes.GetLength(0))
{
k = 0;
if (++i == comboBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == comboBoxes.GetLength(1))
{
i = 0;
if (++k == comboBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!comboBoxes[k, i].Enabled);
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
-75
View File
@@ -1,75 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class CycleBgEnForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// clearButton
//
resources.ApplyResources(this.clearButton, "clearButton");
this.clearButton.ForeColor = System.Drawing.Color.Black;
this.clearButton.Name = "clearButton";
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// CycleBgEnForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "CycleBgEnForm";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton;
}
}
-210
View File
@@ -1,210 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="okButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>942, 26</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="clearButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="clearButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="clearButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="clearButton.Location" type="System.Drawing.Point, System.Drawing">
<value>795, 26</value>
</data>
<data name="clearButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="clearButton.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="clearButton.Text" xml:space="preserve">
<value>Clear</value>
</data>
<data name="&gt;&gt;clearButton.Name" xml:space="preserve">
<value>clearButton</value>
</data>
<data name="&gt;&gt;clearButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;clearButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1094, 561</value>
</data>
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>10000, 10000</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Batch data</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CycleBgEnForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
-20
View File
@@ -1,20 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using TBF.Rig.GenericDevices;
namespace TBF.Rig.DataEntry.Uni
{
public class EntryForm : EntryFormNoStartEnd, IHasWMStatesForm
{
public EntryForm()
: base()
{
}
public EntryForm(Generic.IComponentCfg cfg)
: base(cfg)
{
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,305 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.DataEntry.Uni
{
public class EntryFormNoStartEnd : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm
{
private static readonly ILog log = LogManager.GetLogger(typeof(EntryFormNoStartEnd));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
public bool UsesCameras() { return false; }
readonly EntryFormCfg myCfg;
IRegReader[] regReaders;
/// <summary>
/// Properties set by the Begin, End and WMStates form
/// </summary>
bool[] disabled; /// This array is shared between forms
string[] wmCycleEndState;
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
double[] wmStartState;
public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; }
double[] wmEndState;
public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; }
string[] wmStartStateStr;
System.Windows.Forms.Form modelessDlg;
public bool Completed { get { return (modelessDlg is IHasCompleted) ? (modelessDlg as IHasCompleted).Completed : true; } }
Common.Unit volumeUnit;
double refVolume;
double errLimLo;
double errLimHi;
bool resultSaved; /// Set in Run() when results are saved
IList<Results.Entities.WaterMeter> waterMeters; /// Reference to ...ProcessData.BatchRslts.WaterMeters[]
public enum CurrentOp
{
None,
ShowFormAtCycleBeginning,
ShowFormAtCycleEnd,
EnterTestStartStates,
EnterTestEndStates,
}
CurrentOp currentOp;
public EntryFormNoStartEnd() { }
public EntryFormNoStartEnd(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as EntryFormCfg;
}
public override void Initialize()
{
disabled = new bool[TBF.Data.WMsCount];
wmStartState = new double[TBF.Data.WMsCount];
wmStartStateStr = new string[TBF.Data.WMsCount];
wmEndState = new double[TBF.Data.WMsCount];
wmCycleEndState = new string[TBF.Data.WMsCount];
volumeUnit = (TBF.Rig.Sequences.ProcessData.BenchInfo != null) ? TBF.Rig.Sequences.ProcessData.BenchInfo.VolumeUnit : Common.Unit.l;
currentOp = CurrentOp.None;
log.FatalFormat("{0} initialized: {1}", Name, this);
}
/// <returns>Reference to the operation</returns>
public IOperation ShowCycleBeginFormOp()
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleBeginning;
waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowCycleEndFormOp()
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleEnd;
waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowTestStartFormOp(IRegReader[] regReaders)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.EnterTestStartStates;
this.waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
this.regReaders = regReaders;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowTestEndFormOp(IRegReader[] regReaders, double refVolume, double errLimLo, double errLimHi)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.EnterTestEndStates;
this.waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
this.regReaders = regReaders;
this.refVolume = refVolume;
this.errLimLo = errLimLo;
this.errLimHi = errLimHi;
return this;
}
public IOperation ShowAdvancedTestStartFormOp(IRegReader[] regReaders, IList<Results.Entities.WaterMeter> waterMeters, bool isCondOp = false)
{
return null;
}
delegate void EntryFormDlgt(EntryFormNoStartEnd myRef);
///
void OpenBeginningDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearItems();
for (int i = 0; i < myCfg.GetBgItemsCount(); i++)
{
if (myCfg.BgItemContent[i] != Ct.None)
{
DEItem.AddItem(myCfg.BgItemContent[i], myCfg.BgItemCaption[i], myCfg.BgItemAction[i], myCfg.BgItemWidth[i]);
}
}
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetBgColumnsCount(); i++)
{
if (myCfg.BgColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.BgColumnContent[i], myCfg.BgColumnCaption[i], myCfg.BgColumnAction[i], myCfg.BgColumnWidth[i]);
}
}
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.BgTitle, myCfg.BgSize, myCfg.BgIsLrOrder, myCfg.BgFormCloseKeys,
DEItem.GetItems(), DEItem.GetColumns(), false);
modelessDlg.Show();
}
///
void OpenEndDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearItems();
for (int i = 0; i < myCfg.GetEnItemsCount(); i++)
{
if (myCfg.EnItemContent[i] != Ct.None)
{
DEItem.AddItem(myCfg.EnItemContent[i], myCfg.EnItemCaption[i], myCfg.EnItemAction[i], myCfg.EnItemWidth[i]);
}
}
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetEnColumnsCount(); i++)
{
if (myCfg.EnColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.EnColumnContent[i], myCfg.EnColumnCaption[i], myCfg.EnColumnAction[i], myCfg.EnColumnWidth[i]);
}
}
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.EnTitle, myCfg.EnSize, myCfg.EnIsLrOrder, myCfg.EnFormCloseKeys,
DEItem.GetItems(), DEItem.GetColumns(), true);
modelessDlg.Show();
}
///
void OpenTestStartStatesDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetTestColumnsCount(); i++)
{
if (myCfg.TestColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.TestColumnContent[i], myCfg.TestColumnCaption[i], myCfg.TestColumnAction[i], myCfg.TestColumnWidth[i]);
}
}
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
volumeUnit);
modelessDlg.Show();
}
///
void OpenTestEndStatesDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetTestColumnsCount(); i++)
{
if (myCfg.TestColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.TestColumnContent[i], myCfg.TestColumnCaption[i], myCfg.TestColumnAction[i], myCfg.TestColumnWidth[i]);
}
}
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
volumeUnit, wmStartStateStr, refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
/// <summary>Start this operation</summary>
public void Start()
{
resultSaved = false;
switch (currentOp)
{
case CurrentOp.ShowFormAtCycleBeginning:
if (myCfg.BgShowForm)
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
}
break;
case CurrentOp.ShowFormAtCycleEnd:
if (myCfg.EnShowForm)
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this);
}
break;
case CurrentOp.EnterTestStartStates:
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestStartStatesDlg), this);
break;
case CurrentOp.EnterTestEndStates:
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestEndStatesDlg), this);
break;
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
{
return Event.ModelessFormIsOpen;
}
if (!resultSaved) /// This is to save the result only once
{
if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestStartStates)
{
/// Fixed start test - start
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
if (dlg != null)
{
volumeUnit = dlg.VolumeUnit;
for (int i = 0; i < waterMeters.Count; i++)
{
if (!((i < waterMeters.Count && waterMeters[i].Disabled) || (i < regReaders.Length && regReaders[i] == null)))
{
wmStartState[i] = dlg.WMStartState[i];
wmStartStateStr[i] = dlg.WMStartStateStr[i];
}
}
}
}
else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestEndStates)
{
/// Fixed start test - end
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
if (dlg != null)
{
volumeUnit = dlg.VolumeUnit;
for (int i = 0; i < waterMeters.Count; i++)
{
if (!((i < waterMeters.Count && waterMeters[i].Disabled) || (i < regReaders.Length && regReaders[i] == null)))
{
wmEndState[i] = dlg.WMEndState[i];
}
}
}
}
resultSaved = true;
modelessDlg = null;
}
return Event.ModelessFormClosed; /// Form closed
}
/// <summary>Stop this operation</summary>
public void Stop()
{
if (modelessDlg is IHasCompleted)
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
currentOp = CurrentOp.None;
}
}
}
-25
View File
@@ -1,25 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.Uni
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new EntryFormNoStartEnd(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryForm(cfg); }
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8)); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(EntryFormCfg.Serializer, component, this);
}
}
}
@@ -1,24 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.Uni
{
public class FactoryNoStartEnd : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8) + "-NoStartEnd"; } }
public IComponent DummyComponent() { return new EntryFormNoStartEnd(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryFormNoStartEnd(cfg); }
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8) + "-NoStartEnd"); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(EntryFormCfg.Serializer, component, this);
}
}
}
-600
View File
@@ -1,600 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Common;
using Results.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
/// Arguments
public readonly IList<WaterMeter> waterMeters;
readonly IRegReader[] regReaders;
readonly int lineSize;
readonly Sz sz;
readonly bool isStartBoxAlwaysEn;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> colItems;
readonly string formCloseKeys;
public readonly string[] WMStartStateStr;
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
/// Derived from arguments in the constructor
readonly bool isEnd;
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly bool fixedErrorLimits; /// false in case of calculated error limits
/// To be retrieved after the form closes
public double[] WMStartState;
public double[] WMEndState;
public Unit VolumeUnit;
int startStateColumn;
int endStateColumn;
/// Size and layout related values
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] labels; /// Labels for water meter numbers
readonly TextBox[,] textBoxes; /// Text boxes for values in columns
readonly Label[] exclamations;
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public TestStartEndForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="regReaders">Array of register readers</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="initialVolumeUnit">Volume unit preset initially</param>
/// <param name="wmStartStateStr">Information entered on test start</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(IList<WaterMeter> waterMeters, IRegReader[] regReaders, int lineSize, string title, Sz sz,
bool isStartBoxAlwaysEn, bool isLrOrder, string formCloseKeys, IList<DEItem> colItems,
Unit initialVolumeUnit, string[] wmStartStateStr = null,
double refVolume = 0, double errLimLo = 0, double errLimHi = 0)
: this()
{
this.waterMeters = waterMeters;
this.regReaders = regReaders;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isStartBoxAlwaysEn = isStartBoxAlwaysEn;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.colItems = colItems;
this.VolumeUnit = initialVolumeUnit;
this.WMStartStateStr = wmStartStateStr;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
if (waterMeters == null || regReaders == null ||
(wmStartStateStr != null && wmStartStateStr.Length != waterMeters.Count))
{
throw new Exception("Invalid argument");
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
isEnd = (wmStartStateStr != null);
wmsCount = waterMeters.Count;
if (WMStartStateStr == null) WMStartStateStr = new string[wmsCount];
fixedErrorLimits = (errLimHi > errLimLo);
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = waterMeters.FirstOrDefault(x => (x != null && !x.Disabled));
WMStartState = new double[wmsCount];
WMEndState = new double[wmsCount];
///
unitComboBox.Text = VolumeUnit.ToDescription();
labels = new Label[wmsCount];
textBoxes = new TextBox[colItems.Count, wmsCount];
exclamations = new Label[wmsCount];
/// Layout related readonly variables derived from argument 'sz'
Font font;
Font exclamationFont;
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
//exclamationFont = new Font("Verdana", 24F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(238)));
exclamationFont = new Font("Verdana", 18, FontStyle.Bold);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
hdrHeight = 160;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
exclamationFont = new Font("Verdana", 20, FontStyle.Bold);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
hdrHeight = 160;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
exclamationFont = new Font("Verdana", 24, FontStyle.Bold);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Table
///
int columnsTop = hdrHeight;
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var textBox = new TextBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
textBox.TextChanged += new System.EventHandler(textBox_TextChanged);
textBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox_KeyPress);
textBox.MouseClick += new System.Windows.Forms.MouseEventHandler(textBox_MouseClick);
left += ci.Width + spacing;
textBoxes[k, wmPos0] = textBox;
this.Controls.Add(textBox);
}
var exclamation = new Label
{
AutoSize = true,
Font = exclamationFont,
ForeColor = System.Drawing.Color.Red,
Location = new Point(left, top),
Parent = this,
TabIndex = tabIndex++,
Text = "!",
Visible = false,
};
exclamations[wmPos0] = exclamation;
this.Controls.Add(exclamation);
}
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), 1300),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Table
startStateColumn = -1;
endStateColumn = -1;
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.StartState)
{
startStateColumn = k;
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = (!isEnd || waterMeters[i] == null
|| waterMeters[i].Disabled
|| i >= regReaders.Length
|| regReaders[i] == null
|| string.IsNullOrEmpty(WMStartStateStr[i])) ? string.Empty : WMStartStateStr[i];
textBoxes[k, i].Enabled = (isStartBoxAlwaysEn || !isEnd) && waterMeters[i] != null && !waterMeters[i].Disabled
&& i < regReaders.Length && regReaders[i] != null;
}
}
else if (colItems[k].Content == Ct.EndState)
{
endStateColumn = k;
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = string.Empty;
textBoxes[k, i].Enabled = isEnd && waterMeters[i] != null && !waterMeters[i].Disabled
&& i < regReaders.Length && regReaders[i] != null;
}
}
else
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++) textBoxes[k, i].Text = string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, waterMeters[i]);
}
break;
}
}
}
if (isEnd && isStartBoxAlwaysEn)
{
int k = 0;
int j = 0;
if (!FindNextEnabledTextBox(textBoxes, ref k, ref j, isLrOrder, true))
{
ActiveControl = textBoxes[k, j];
}
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int k = 0; k < colItems.Count; k++)
{
for (int i = 0; i < wmsCount; i++)
{
if (colItems[k].Content == Ct.StartState)
{
/// Water meter start state
double startVol;
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out startVol))
{
WMStartStateStr[i] = textBoxes[k, i].Text;
WMStartState[i] = Units.ConvertFrom(VolumeUnit, startVol);
}
}
else if (colItems[k].Content == Ct.EndState)
{
/// Water meter end state
double endVol;
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out endVol))
{
WMEndState[i] = Units.ConvertFrom(VolumeUnit, endVol);
}
}
else
{
/// Other value - store values to a water meter structure
DEUtils.PutContent(colItems[k].Content, waterMeters[i], textBoxes[k, i].Text);
}
}
}
}
private void okButton_Click(object sender, EventArgs eArgs)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void unitComboBox_TextChanged(object sender, EventArgs e)
{
unitComboBox_SelectedIndexChanged(sender, e);
}
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
var newUnit = Units.FromDescription(unitComboBox.Text);
if (Units.IsVolume(newUnit))
{
VolumeUnit = newUnit;
if (!isHandlersEnabled) return;
/// Update exclamation marks
if (isEnd && startStateColumn >= 0 && endStateColumn >= 0)
{
for (int i = 0; i < wmsCount; i++)
{
double startVol, endVol;
if (Utils.TryParseUDouble(textBoxes[startStateColumn, i].Text, out startVol) &&
Utils.TryParseUDouble(textBoxes[endStateColumn, i].Text, out endVol))
{
double startState = Units.ConvertFrom(VolumeUnit, startVol);
double endState = Units.ConvertFrom(VolumeUnit, endVol);
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
}
else
{
exclamations[i].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, i].Text);
}
}
largeTextBox.Text = string.Empty;
largeExclamationLabel.Visible = false;
}
}
}
private void textBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as TextBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
if (!string.IsNullOrEmpty(formCloseKeys))
{
/// Close the form if any 'close form key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
}
if (e.KeyChar == '\r')
{
/// Change focus
if (FindNextEnabledTextBox(textBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
textBoxes[k, j].Focus();
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
largeExclamationLabel.Visible = false;
}
}
}
/// Handle mouse clicks so that the large text box and the large exclamation mark are updated
private void textBox_MouseClick(object sndr, MouseEventArgs e)
{
textBox_TextChanged(sndr, e);
}
private void textBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as TextBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
if (isEnd && (k == startStateColumn || k == endStateColumn))
{
double startVol, endVol;
if (startStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumn, j].Text, out startVol) &&
endStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumn, j].Text, out endVol))
{
double startState = Units.ConvertFrom(VolumeUnit, startVol);
double endState = Units.ConvertFrom(VolumeUnit, endVol);
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
largeExclamationLabel.Visible =
exclamations[j].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
}
else
{
largeExclamationLabel.Visible =
exclamations[j].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, j].Text);
}
}
else
{
largeExclamationLabel.Visible = false;
}
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="textBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledTextBox(TextBox[,] textBoxes, ref int k, ref int i, bool isLrOrder, bool skipStartColumn = false)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == textBoxes.GetLength(0))
{
k = 0;
if (++i == textBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == textBoxes.GetLength(1))
{
i = 0;
if (++k == textBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!textBoxes[k, i].Enabled || (skipStartColumn && k == startStateColumn));
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
-114
View File
@@ -1,114 +0,0 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class TestStartEndForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.okButton = new System.Windows.Forms.Button();
this.largeTextBox = new System.Windows.Forms.TextBox();
this.largeExclamationLabel = new System.Windows.Forms.Label();
this.unitComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Location = new System.Drawing.Point(1120, 29);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(123, 63);
this.okButton.TabIndex = 100;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// largeTextBox
//
this.largeTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.largeTextBox.Location = new System.Drawing.Point(35, 29);
this.largeTextBox.Name = "largeTextBox";
this.largeTextBox.Size = new System.Drawing.Size(849, 80);
this.largeTextBox.TabIndex = 101;
//
// largeExclamationLabel
//
this.largeExclamationLabel.AutoSize = true;
this.largeExclamationLabel.Font = new System.Drawing.Font("Verdana", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.largeExclamationLabel.ForeColor = System.Drawing.Color.Red;
this.largeExclamationLabel.Location = new System.Drawing.Point(890, 28);
this.largeExclamationLabel.Name = "largeExclamationLabel";
this.largeExclamationLabel.Size = new System.Drawing.Size(59, 78);
this.largeExclamationLabel.TabIndex = 102;
this.largeExclamationLabel.Text = "!";
this.largeExclamationLabel.Visible = false;
//
// unitComboBox
//
this.unitComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.unitComboBox.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.unitComboBox.FormattingEnabled = true;
this.unitComboBox.Location = new System.Drawing.Point(962, 46);
this.unitComboBox.Name = "unitComboBox";
this.unitComboBox.Size = new System.Drawing.Size(123, 31);
this.unitComboBox.TabIndex = 103;
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
this.unitComboBox.TextChanged += new System.EventHandler(this.unitComboBox_TextChanged);
//
// TestStartEndForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.ClientSize = new System.Drawing.Size(1284, 676);
this.Controls.Add(this.unitComboBox);
this.Controls.Add(this.largeExclamationLabel);
this.Controls.Add(this.largeTextBox);
this.Controls.Add(this.okButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "TestStartEndForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "End States";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.TextBox largeTextBox;
private System.Windows.Forms.Label largeExclamationLabel;
private System.Windows.Forms.ComboBox unitComboBox;
}
}
+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;
}
+22 -39
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 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
{
@@ -153,51 +152,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;
}
///
-2
View File
@@ -31,7 +31,6 @@ namespace TBF.Rig.Elde.Diverter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -54,7 +53,6 @@ namespace TBF.Rig.Elde.Diverter
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
+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;
}
-34
View File
@@ -54,12 +54,6 @@ namespace TBF.Rig.Elde.FlowMeter
public string CalibCertificate3;
public string CalibCertificate4;
public string CalibCertificate5;
public string CertPath;
public string CertPath1;
public string CertPath2;
public string CertPath3;
public string CertPath4;
public string CertPath5;
public DateTime CalibDate;
public DateTime CalibDate1;
public DateTime CalibDate2;
@@ -172,34 +166,6 @@ namespace TBF.Rig.Elde.FlowMeter
}
}
public string GetCertPath(int rangeIx1)
{
switch (rangeIx1)
{
default:
case 0: return CertPath;
case 1: return CertPath1;
case 2: return CertPath2;
case 3: return CertPath3;
case 4: return CertPath4;
case 5: return CertPath5;
}
}
public void SetCertPath(int rangeIx1, string certificate)
{
switch (rangeIx1)
{
default:
case 0: CertPath = certificate; return;
case 1: CertPath1 = certificate; return;
case 2: CertPath2 = certificate; return;
case 3: CertPath3 = certificate; return;
case 4: CertPath4 = certificate; return;
case 5: CertPath5 = certificate; return;
}
}
public DateTime GetCalibDate(int rangeIx1)
{
switch (rangeIx1)
+2 -35
View File
@@ -1,8 +1,9 @@
///
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.Rig.Generic;
@@ -54,12 +55,6 @@ namespace TBF.Rig.Elde.FlowMeterDewa
public string CalibCertificate3;
public string CalibCertificate4;
public string CalibCertificate5;
public string CertPath;
public string CertPath1;
public string CertPath2;
public string CertPath3;
public string CertPath4;
public string CertPath5;
public DateTime CalibDate;
public DateTime CalibDate1;
public DateTime CalibDate2;
@@ -172,34 +167,6 @@ namespace TBF.Rig.Elde.FlowMeterDewa
}
}
public string GetCertPath(int rangeIx1)
{
switch (rangeIx1)
{
default:
case 0: return CertPath;
case 1: return CertPath1;
case 2: return CertPath2;
case 3: return CertPath3;
case 4: return CertPath4;
case 5: return CertPath5;
}
}
public void SetCertPath(int rangeIx1, string certificate)
{
switch (rangeIx1)
{
default:
case 0: CertPath = certificate; return;
case 1: CertPath1 = certificate; return;
case 2: CertPath2 = certificate; return;
case 3: CertPath3 = certificate; return;
case 4: CertPath4 = certificate; return;
case 5: CertPath5 = certificate; return;
}
}
public DateTime GetCalibDate(int rangeIx1)
{
switch (rangeIx1)
+1 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
+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;
}
@@ -26,7 +26,6 @@ namespace TBF.Rig.Elde.PressureMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -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;
}
@@ -29,7 +29,6 @@ namespace TBF.Rig.Elde.PressureMeterInternal
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
+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()
-2
View File
@@ -29,7 +29,6 @@ namespace TBF.Rig.Elde.TempMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -52,7 +51,6 @@ namespace TBF.Rig.Elde.TempMeter
DefaultTemperature = 20.0;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
+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;
}
@@ -29,7 +29,6 @@ namespace TBF.Rig.Elde.TempMeterInternal
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -52,7 +51,6 @@ namespace TBF.Rig.Elde.TempMeterInternal
A5 = 0;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
+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;
}
@@ -44,7 +44,6 @@ namespace TBF.Rig.Elde.TempMeterMeret
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -70,7 +69,6 @@ namespace TBF.Rig.Elde.TempMeterMeret
MeretIdx0 = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -174,10 +172,6 @@ namespace TBF.Rig.Elde.TempMeterMeret
prms.TempIdx0 = this.TempIdx0;
prms.ModbusAddress = this.ModbusAddress;
prms.MeretIdx0 = this.MeretIdx0;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
+1 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
namespace TBF.Rig
{
@@ -31,8 +31,6 @@ namespace TBF.Rig
GetAdc, /// Get regul.valve or diverter ADC
GetAdc1, /// Get regul.valve or diverter ADC feedback value #1
GetAdc2, /// Get regul.valve or diverter ADC feedback value #2
SetData, /// Generic set
GetData, /// Generic get
}
public enum ValveCategory
+4 -5
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Metering Systems
///
using System;
using TBF.Rig.Generic;
@@ -11,9 +11,8 @@ namespace TBF.Rig.GenericDevices
///
/// Parameters displayed in Metrology tab page
///
string CalibCertificateNr { get; set; } /// Calibration certificate ID
string CertPath { get; set; } /// Path to a calibration certificate PDF document
DateTime CalibDate { get; set; } /// Date of calibration
DateTime CalibValidDate { get; set; } /// Calibration is valid until (date)
string CalibCertificateNr { get; set; } /// calibration certificate number
DateTime CalibDate { get; set; } /// date of calibration
DateTime CalibValidDate { get; set; } /// calibration valid until (date)
}
}
+3 -5
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 TBF.Rig.Generic;
@@ -20,13 +20,11 @@ namespace TBF.Rig.GenericDevices
double GetPressHi(int rangeIx1);
string GetCalibCertificate(int rangeIx1); /// Get calibration certificate number
string GetCertPath(int rangeIx1); /// Get path to a calibration certificate PDF document
DateTime GetCalibDate(int rangeIx1); /// Get the date of calibration
DateTime GetCalibValidDate(int rangeIx1); /// Get calibration valid until (date)
void SetCalibCertificate(int rangeIx1, string certificate); /// Set calibration certificate number
void SetCertPath(int rangeIx1, string certPath); /// Set path to a calibration certificate PDF document
void SetCalibDate(int rangeIx1, DateTime date); /// Set the date of calibration
void SetCalibValidDate(int rangeIx1, DateTime date); /// Set calibration valid until (date)
void SetCalibDate(int rangeIx1, DateTime date); /// Get the date of calibration
void SetCalibValidDate(int rangeIx1, DateTime date); /// Get calibration valid until (date)
}
}
+1 -1
View File
@@ -8,6 +8,6 @@ namespace TBF.Rig.GenericDevices
{
interface IHasCalendarEvents
{
List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents();
IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents();
}
}
+7 -9
View File
@@ -1,8 +1,8 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using Common;
using TBF.Rig.Generic;
using Common;
namespace TBF.Rig.GenericDevices
{
@@ -17,13 +17,11 @@ namespace TBF.Rig.GenericDevices
float L { get; } /// building length [mm]
Mounting Mounting { get; } /// mounting H / V
FlowNames Qnames { get; } /// true = Q3... false = Qn...
double Q4_Qmax { get; } /// [m3/h]
double Q3_Qn { get; } /// [m3/h]
double Q2_Qt { get; } /// [m3/h]
double Q1_Qmin { get; } /// [m3/h]
double ErrLimHiQ { get; } /// [%]
double ErrLimLoQ { get; } /// [%]
bool NewQnames { get; } /// true = Q3... false = Qn...
float Q4_Qmax { get; } /// [m3/h]
float Q3_Qn { get; } /// [m3/h]
float Q2_Qt { get; } /// [m3/h]
float Q1_Qmin { get; } /// [m3/h]
string MetrologicalClass { get; } /// R<Q3/Q1>
TemperatureClass TemperatureClass { get; } /// T30, T50, T70, ...
+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 -7
View File
@@ -1,10 +1,13 @@
///
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
/// Copyright (c) 2018-2021 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Hart.Nivotrack
@@ -35,7 +38,6 @@ namespace TBF.Rig.Hart.Nivotrack
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -61,7 +63,6 @@ namespace TBF.Rig.Hart.Nivotrack
Par2 = 8;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -178,10 +179,6 @@ namespace TBF.Rig.Hart.Nivotrack
prms.Address = this.Address;
prms.Par1 = this.Par1;
prms.Par2 = this.Par2;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
+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()
+2 -2
View File
@@ -1,8 +1,9 @@
///
/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
/// Copyright (c) 2016-2021 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.Rig.Generic;
@@ -36,7 +37,6 @@ namespace TBF.Rig.Keithley.TempMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
+50 -18
View File
@@ -1,7 +1,8 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
@@ -47,20 +48,56 @@ namespace TBF.Rig.MettlerToledo.Multi
public StopBits StopBits;
public Handshake Handshake;
/// Buoyancy related serialized parameters displayed in Metrology tab page
public float BuoyancyTemp { get; set; }
public float BuoyancyPress { get; set; }
public float BuoyancyHumi { get; set; }
public float WeightStandardDensity { get; set; }
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
///
/// Buoyancy related serialized parameters - Displayed in Metrology tab page
///
float buoyancyTemp;
float buoyancyPress;
float buoyancyHumi;
float weightStandardDensity;
string calibCertificateNr;
DateTime calibDate;
DateTime calibValidDate;
///
public float BuoyancyTemp
{
get { return buoyancyTemp; }
set { buoyancyTemp = value; }
}
public float BuoyancyPress
{
get { return buoyancyPress; }
set { buoyancyPress = value; }
}
public float BuoyancyHumi
{
get { return buoyancyHumi; }
set { buoyancyHumi = value; }
}
public float WeightStandardDensity
{
get { return weightStandardDensity; }
set { weightStandardDensity = value; }
}
public string CalibCertificateNr
{
get { return calibCertificateNr; }
set { calibCertificateNr = value; }
}
public DateTime CalibDate
{
get { return calibDate; }
set { calibDate = value; }
}
public DateTime CalibValidDate
{
get { return calibValidDate; }
set { calibValidDate = value; }
}
/// Private parameterless constructor invoked by all other (public) constructors
BalanceCfg()
BalanceCfg()
{
Name = "Balance";
ParentName = string.Empty;
@@ -82,11 +119,6 @@ namespace TBF.Rig.MettlerToledo.Multi
BuoyancyTemp = 20.0f;
BuoyancyPress = 1.0f;
BuoyancyHumi = 40.0f;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
public BalanceCfg(IComponentFactory factory)
+2 -3
View File
@@ -1,7 +1,8 @@
///
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
@@ -51,7 +52,6 @@ namespace TBF.Rig.MettlerToledo.Standard
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -88,7 +88,6 @@ namespace TBF.Rig.MettlerToledo.Standard
BuoyancyHumi = 40.0f;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}

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