diff --git a/Common/Common.csproj b/Common/Common.csproj index c09591d31..ff7aa24ea 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -42,6 +42,7 @@ + diff --git a/Config/Entities/Enums.cs b/Common/Enums.cs similarity index 81% rename from Config/Entities/Enums.cs rename to Common/Enums.cs index 8d26c9906..76a1de453 100644 --- a/Config/Entities/Enums.cs +++ b/Common/Enums.cs @@ -1,11 +1,11 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2021 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Reflection; -namespace Config.Entities +namespace Common { /// /// Helper class to assign descriptions to enum values @@ -38,6 +38,115 @@ namespace Config.Entities } } + /// + /// Identifies the type of a database + /// + public enum DBType + { + None, /// Database disabled + MySql, /// MySQL database + SQLite, /// SQLite + Count + } + + /// Identifies the database based on the content + public enum DBKind + { + Config, + Results, + RemoteConfig, + Count + } + + public enum ProcedureSelection + { +#if LANG_CS + [Description("Žádné")] None, + [Description("Lokální postupy")] FromLocalDB, + [Description("Postupy ze sdílené databázy")] FromSharedDB, + [Description("Zakázky z Oracle databázy")] OrderNrFromOracleDB, + [Description("Zakázky ze sledovací databázy")] OrderNrFromTracingDB, +#else + [Description("None")] None, + [Description("Local procedures")] FromLocalDB, + [Description("Shared procedures")] FromSharedDB, + [Description("Orders from Oracle DB")] OrderNrFromOracleDB, + [Description("Orders from Tracing DB")] OrderNrFromTracingDB, +#endif + Count + } + + /// + /// Obsolete - replaced by enum ProcedureSelection (above) in 3.1 and newer + /// + public enum RemoteDBUse + { + [Description("Local DB only")] LocalDBOnly, + [Description("Remote DB only")] RemoteDBOnly, + [Description("Both DB-s, local 1st")] BothDBsLocalFirst, + [Description("Both DB-s, remote 1st")] BothDBsRemoteFirst, + Count + } + + /// + /// Obsolete - Contains a procedure name and a database specification (local/remote). + /// + public class ProcedureInfo + { + public readonly string Name; + public readonly bool IsRemote; + + public ProcedureInfo(string name, bool isRemote) + { + Name = name; + IsRemote = isRemote; + } + } + + public enum LoginMethod + { + UserName, /// = alias, abbreviation + FullName, /// = description + Number, + Count + } + + public enum AuthorizedAs + { + PowerUser, + LocalUser, + RemoteUser, + Count + } + + /// + /// GID-s of user groups, each user is member of one or more groups. + /// + public enum GID + { + Testers, + TestingSpecialists, + HeadOfLab, + MaintenanceSpecialists, + Metrologists, + CalibrationSpecialists, + Administrators, /// application / network / database administrator + TraceabilityManagement, + MetrologicalAuthority, + WaterMeterAuthority, + NrOfGroups, /// Number of groups (this is not a GroupID) + None, + } + + public enum MySortOrder + { + None, + Ascending, /// The same like SortOrder.Ascending + Descending, /// The same like SortOrder.Descending + Ascending2, /// Sorts by a surname in ascending order in case or 'Name Surname' column + Descending2, /// Sorts by a surname in descending order in case or 'Name Surname' column + } + /// /// Flags returned by each device configuration control Verify(...) function. /// @@ -52,28 +161,48 @@ namespace Config.Entities InvokeCfgChange = 0x20, /// Invoke CfgChange handler of the component } - public enum RemoteDBUse + /// + /// Event severity + /// + public enum Severity { - [Description("Local DB only")] LocalDBOnly, - [Description("Remote DB only")] RemoteDBOnly, - [Description("Both DB-s, local 1st")] BothDBsLocalFirst, - [Description("Both DB-s, remote 1st")] BothDBsRemoteFirst, + Undefined, + Notification, + Warning, + Error, + FatalError, Count } - /// - /// Contains a procedure name and a database specification (local/remote). - /// - public class ProcedureInfo + public enum EventClass { - public readonly string Name; - public readonly bool IsRemote; + Undefined, + EquipmentHW, + Metrology, + TestingProcess, + BadResults, + ComputerResources, + Network, + Other, + Count + } - public ProcedureInfo(string name, bool isRemote) - { - Name = name; - IsRemote = isRemote; - } + public enum SubscriberGroup : long + { + None = 0, + Metrology = 1, + Maintenance = 2, + Production = 4, + Management = 8, + Finish = 16, + } + + public enum EViewerOption + { + Undefined, + AllEvents, + RecentEvents, + UnreadEvents, } public enum ProcedureState @@ -424,7 +553,7 @@ namespace Config.Entities [Description("Fehler")] FailureDuringOperation, /// Failure during operation -> disabled [Description("Aus")] Off, /// The component is off [Description("Aufzeichnen")] Record, - [Description("Reply")] Reply, + [Description("Abspielen")] Replay, [Description("Simuliert")] Simulate, /// Test bench simulation, this mode does not require any hardware [Description("Geerbt")] Inherit, #elif LANG_FR @@ -435,7 +564,7 @@ namespace Config.Entities [Description("Erreur d'exécution")] FailureDuringOperation, [Description("Éteindre")] Off, [Description("Record")] Record, - [Description("Répondre")] Reply, + [Description("Répondre")] Replay, [Description("Simuler")] Simulate, [Description("Hériter")] Inherit, #else @@ -446,7 +575,7 @@ namespace Config.Entities [Description("Run-time error")] FailureDuringOperation, /// Failure during operation -> disabled [Description("Off")] Off, /// The component is off [Description("Record")] Record, - [Description("Reply")] Reply, + [Description("Replay")] Replay, [Description("Simulate")] Simulate, /// Test bench simulation, this mode does not require any hardware [Description("Inherit")] Inherit, #endif @@ -584,15 +713,15 @@ namespace Config.Entities public enum ErrorFlagMask : long { - E1 = (1L << 0), /// shift = 0, E1 = 1L - E2 = (1L << 1), - E3 = (1L << 2), - E4 = (1L << 3), - E5 = (1L << 4), - E6 = (1L << 5), - E7 = (1L << 6), - E8 = (1L << 7), - E9 = (1L << 8), + E1 = (1L << 0), /// shift = 0, E1 = 1L + E2 = (1L << 1), + E3 = (1L << 2), + E4 = (1L << 3), + E5 = (1L << 4), + E6 = (1L << 5), + E7 = (1L << 6), + E8 = (1L << 7), + E9 = (1L << 8), E10 = (1L << 9), E11 = (1L << 10), E12 = (1L << 11), @@ -648,4 +777,44 @@ namespace Config.Entities E62 = (1L << 61), E63 = (1L << 62), } + + #region iPERL enums + + public enum Side + { +#if LANG_CS + [Description("Levá")] Left, + [Description("Pravá")] Right, +#else + [Description("Left")] Left, + [Description("Right")] Right, +#endif + Count + } + + public enum FlowDir + { + R_L, + L_R, + Count + } + + public enum Counting + { + Arbitrary, + Positive, + Negative, + Count + } + + public enum OptoHeadState + { + Disabled, + OptoAndDirOK, + OptoNok, + DirNok, + Count + } + + #endregion iPERL enums } diff --git a/Config/Config.csproj b/Config/Config.csproj index 0f527134e..a074e9fca 100644 --- a/Config/Config.csproj +++ b/Config/Config.csproj @@ -75,7 +75,6 @@ - @@ -83,7 +82,6 @@ - diff --git a/Config/DatabaseSettings.cs b/Config/DatabaseSettings.cs index 7c813ead1..3db4dbd2d 100644 --- a/Config/DatabaseSettings.cs +++ b/Config/DatabaseSettings.cs @@ -25,10 +25,10 @@ namespace Config { BenchName = String.Empty; /// Empty string (avoid null) IsRealBench = false; - ProceduresDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty); - WaterMetersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty); - EventsDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty); - UsersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty); + ProceduresDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty); + WaterMetersDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty); + EventsDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty); + UsersDBSettings = new Users.DBSettings(Common.DBType.MySql, string.Empty); } public object Clone() diff --git a/Config/Entities/Component.cs b/Config/Entities/Component.cs index 165bd8acb..4846a831a 100644 --- a/Config/Entities/Component.cs +++ b/Config/Entities/Component.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using Common; namespace Config.Entities { @@ -86,7 +87,7 @@ namespace Config.Entities else if (line.Equals(DebugMode.FailureDuringOperation.ToString())) result.Mode = DebugMode.FailureDuringOperation; else if (line.Equals(DebugMode.Off.ToString())) result.Mode = DebugMode.Off; else if (line.Equals(DebugMode.Record.ToString())) result.Mode = DebugMode.Record; - else if (line.Equals(DebugMode.Reply.ToString())) result.Mode = DebugMode.Reply; + else if (line.Equals(DebugMode.Replay.ToString())) result.Mode = DebugMode.Replay; else if (line.Equals(DebugMode.Simulate.ToString())) result.Mode = DebugMode.Simulate; else if (line.Equals(DebugMode.Inherit.ToString())) result.Mode = DebugMode.Inherit; diff --git a/Config/Entities/Group.cs b/Config/Entities/Group.cs index 755e45a18..b68594c1b 100644 --- a/Config/Entities/Group.cs +++ b/Config/Entities/Group.cs @@ -9,7 +9,7 @@ namespace Config.Entities public class Group { public virtual int Id { get; protected set; } - public virtual Users.Entities.GID GID { get; set; } + public virtual Common.GID GID { get; set; } public virtual long AccessFlags { get; set; } /// Bitfield of access flags: bit0 .. bit62 public virtual IList Users { get; set; } /// Group can be a member of a list of users @@ -18,7 +18,7 @@ namespace Config.Entities Users = new List(); } - public Group(Users.Entities.GID gid) + public Group(Common.GID gid) : this() { GID = gid; diff --git a/Config/Entities/IParamsProvider.cs b/Config/Entities/IParamsProvider.cs index 2df3de028..2a92d5421 100644 --- a/Config/Entities/IParamsProvider.cs +++ b/Config/Entities/IParamsProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Xml.Serialization; +using Common; namespace Config.Entities { diff --git a/Config/Entities/IperlEnums.cs b/Config/Entities/IperlEnums.cs deleted file mode 100644 index 3a3bf135b..000000000 --- a/Config/Entities/IperlEnums.cs +++ /dev/null @@ -1,44 +0,0 @@ -/// -/// Copyright (c) 2018 Sensus Slovensko a.s. -/// -using System; - -namespace Config.Entities -{ - - public enum Side - { -#if LANG_CS - [Description("Levá")] Left, - [Description("Pravá")] Right, -#else - [Description("Left")] Left, - [Description("Right")] Right, -#endif - Count - } - - public enum FlowDir - { - R_L, - L_R, - Count - } - - public enum Counting - { - Arbitrary, - Positive, - Negative, - Count - } - - public enum OptoHeadState - { - Disabled, - OptoAndDirOK, - OptoNok, - DirNok, - Count - } -} diff --git a/Config/Entities/PTest.cs b/Config/Entities/PTest.cs index 3a074540e..513fdd201 100644 --- a/Config/Entities/PTest.cs +++ b/Config/Entities/PTest.cs @@ -4,6 +4,7 @@ using System; using System.Globalization; using System.IO; +using Common; namespace Config.Entities { @@ -78,7 +79,7 @@ namespace Config.Entities TempLimHi = 25.0; /// [°C] PressLimLo = 0; /// [bar] PressLimHi = 16.0; /// [bar] - Publish = (sbyte)Config.Entities.Publish.Always; + Publish = (sbyte)Common.Publish.Always; Evaluate = true; E1 = (sbyte)ErrorFlagsMode.On; diff --git a/Config/Entities/Procedure.cs b/Config/Entities/Procedure.cs index 66a7f86cd..1bf4fccf6 100644 --- a/Config/Entities/Procedure.cs +++ b/Config/Entities/Procedure.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using Common; namespace Config.Entities { @@ -78,7 +79,7 @@ namespace Config.Entities CreationTime = DateTime.Now; LastChgUser = CreationUser; LastChgTime = CreationTime; - MetersKind = Entities.MetersKind.Single; + MetersKind = MetersKind.Single; Watermeters = string.Empty; Description = string.Empty; LongDescription = string.Empty; diff --git a/Config/Entities/Profile.cs b/Config/Entities/Profile.cs index cc11fd36e..13672a0b3 100644 --- a/Config/Entities/Profile.cs +++ b/Config/Entities/Profile.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using Common; namespace Config.Entities { diff --git a/Config/Entities/Test.cs b/Config/Entities/Test.cs index f678f1b34..9608390ed 100644 --- a/Config/Entities/Test.cs +++ b/Config/Entities/Test.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using Common; namespace Config.Entities { @@ -25,7 +26,7 @@ namespace Config.Entities 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 TstTime { get; set; } /// Test time (estimate) in [s] + 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 @@ -44,7 +45,7 @@ namespace Config.Entities public virtual int TimeFlow2Mass { get; set; } /// Delay time from the flow stable to the 1st mass measurement in [s] public virtual int TimePump2StartV { get; set; } /// Delay time from the start of the pump to opening the start valve in [s] public virtual int TimeStop2Mass { get; set; } /// Delay time from the test end (diverted) to the 2nd mass measuremen in [s] - public virtual double TolerRed { get; set; } /// = Filter + public virtual double ShortPulses { get; set; } /// = Filter public virtual string RedType { get; set; } public virtual string FeedingPath { get; set; } public virtual string BenchPath { get; set; } @@ -53,9 +54,9 @@ namespace Config.Entities #if HEAT_METERS public virtual string HeatMetersPath { get; set; } #endif - public virtual string RelTransBefore { get; set; } - public virtual string RelTransBetween { get; set; } - public virtual string TransitionAfter { get; set; } + public virtual string TransBefore { get; set; } + public virtual string TransBetween { get; set; } + public virtual string TransAfter { get; set; } public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database @@ -75,7 +76,7 @@ namespace Config.Entities /// Part = 0; Profile = TestProfile.UserDefined; - Publish = (sbyte)Config.Entities.Publish.Always; + Publish = (sbyte)Common.Publish.Always; DoEvaluate = true; Repeats = 1; DoDraining = false; @@ -94,10 +95,10 @@ namespace Config.Entities TimeFlow2Mass = 5; /// [s] time from the flow stable to the 1st mass measurement in [s] TimePump2StartV = 1; /// [s] time from the 1st mass measurement to the test start in [s] TimeStop2Mass = 5; /// [s] between the test end and the final mass measurement - TolerRed = 0; /// = Filter parameter - RelTransBefore = string.Empty; - RelTransBetween = string.Empty; - TransitionAfter = string.Empty; + ShortPulses = 0; /// = Filter parameter + TransBefore = string.Empty; + TransBetween = string.Empty; + TransAfter = string.Empty; } public Test(string name, int itemNr, Procedure procedure) @@ -137,7 +138,7 @@ namespace Config.Entities result.Qfrom = Qfrom; result.Qto = Qto; result.Volume = Volume; - result.TstTime = TstTime; + result.TestTime = TestTime; result.Method = Method; result.ErrLimLo = ErrLimLo; result.ErrLimHi = ErrLimHi; @@ -156,7 +157,7 @@ namespace Config.Entities result.TimeFlow2Mass = TimeFlow2Mass; result.TimePump2StartV = TimePump2StartV; result.TimeStop2Mass = TimeStop2Mass; - result.TolerRed = TolerRed; + result.ShortPulses = ShortPulses; result.RedType = RedType; result.FeedingPath = FeedingPath; result.BenchPath = BenchPath; @@ -165,9 +166,9 @@ namespace Config.Entities #if HEAT_METERS result.HeatMetersPath = HeatMetersPath; #endif - result.RelTransBefore = RelTransBefore; - result.RelTransBetween = RelTransBetween; - result.TransitionAfter = TransitionAfter; + result.TransBefore = TransBefore; + result.TransBetween = TransBetween; + result.TransAfter = TransAfter; foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); } return result; @@ -185,7 +186,7 @@ namespace Config.Entities output.WriteLine(Qfrom.ToString(ci)); output.WriteLine(Qto.ToString(ci)); output.WriteLine(Volume.ToString(ci)); - output.WriteLine(TstTime.ToString(ci)); + output.WriteLine(TestTime.ToString(ci)); output.WriteLine(Method); output.WriteLine(ErrLimLo.ToString(ci)); output.WriteLine(ErrLimHi.ToString(ci)); @@ -208,10 +209,10 @@ namespace Config.Entities output.WriteLine(BenchPath); output.WriteLine(OutputPath); output.WriteLine(MetersPath); - output.WriteLine(RelTransBefore); - output.WriteLine(RelTransBetween); + output.WriteLine(TransBefore); + output.WriteLine(TransBetween); output.WriteLine(Profile); - output.WriteLine(TransitionAfter); + output.WriteLine(TransAfter); foreach (var prms in MoreParams) { prms.Export(output); } output.WriteLine(); @@ -236,7 +237,7 @@ namespace Config.Entities tst.Qfrom = float.Parse(input.ReadLine(), ci); tst.Qto = float.Parse(input.ReadLine(), ci); tst.Volume = float.Parse(input.ReadLine(), ci); - tst.TstTime = 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); @@ -259,13 +260,13 @@ namespace Config.Entities tst.BenchPath = input.ReadLine(); tst.OutputPath = input.ReadLine(); tst.MetersPath = input.ReadLine(); - tst.RelTransBefore = input.ReadLine(); - tst.RelTransBetween = input.ReadLine(); + tst.TransBefore = input.ReadLine(); + tst.TransBetween = input.ReadLine(); string line = input.ReadLine(); tst.Profile = line.Equals(TestProfile.ProtectedHeatMeter.ToString()) ? TestProfile.ProtectedHeatMeter : line.Equals(TestProfile.UserDefinedHeatMeter.ToString()) ? TestProfile.UserDefinedHeatMeter : line.Equals(TestProfile.Protected.ToString()) ? TestProfile.Protected : TestProfile.UserDefined; /// UserDefined is the default - tst.TransitionAfter = input.ReadLine(); + tst.TransAfter = input.ReadLine(); while (true) { @@ -298,7 +299,7 @@ namespace Config.Entities ln = inp.ReadLine(); if (ln != Qfrom.ToString(ci)) { diff.AppendFormat(fmt, "Qfrom", Qfrom.ToString(ci), ln); }; ln = inp.ReadLine(); if (ln != Qto.ToString(ci)) { diff.AppendFormat(fmt, "Qto", Qto.ToString(ci), ln); }; ln = inp.ReadLine(); if (ln != Volume.ToString(ci)) { diff.AppendFormat(fmt, "Volume", Volume.ToString(ci), ln); }; - ln = inp.ReadLine(); if (ln != TstTime.ToString(ci)) { diff.AppendFormat(fmt, "TstTime", TstTime.ToString(ci), ln); }; + ln = inp.ReadLine(); if (ln != TestTime.ToString(ci)) { diff.AppendFormat(fmt, "TstTime", TestTime.ToString(ci), ln); }; ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); }; ln = inp.ReadLine(); if (ln != ErrLimLo.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimLo", ErrLimLo.ToString(ci), ln); }; ln = inp.ReadLine(); if (ln != ErrLimHi.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimHi", ErrLimHi.ToString(ci), ln); }; @@ -321,10 +322,10 @@ namespace Config.Entities ln = inp.ReadLine(); if (ln != BenchPath) { diff.AppendFormat(fmt, "BenchPath", BenchPath, ln); }; ln = inp.ReadLine(); if (ln != OutputPath) { diff.AppendFormat(fmt, "OutputPath", OutputPath, ln); }; ln = inp.ReadLine(); if (ln != MetersPath) { diff.AppendFormat(fmt, "MetersPath", MetersPath, ln); }; - ln = inp.ReadLine(); if (ln != RelTransBefore) { diff.AppendFormat(fmt, "RelTransBefore", RelTransBefore, ln); }; - ln = inp.ReadLine(); if (ln != RelTransBetween) { diff.AppendFormat(fmt, "RelTransBetween", RelTransBetween, ln); }; + ln = inp.ReadLine(); if (ln != TransBefore) { diff.AppendFormat(fmt, "RelTransBefore", TransBefore, ln); }; + ln = inp.ReadLine(); if (ln != TransBetween) { diff.AppendFormat(fmt, "RelTransBetween", TransBetween, ln); }; ln = inp.ReadLine(); if (ln != Profile.ToString()) { diff.AppendFormat(fmt, "RelTransAfter", Profile, ln); }; - ln = inp.ReadLine(); if (ln != TransitionAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransitionAfter, ln); }; + ln = inp.ReadLine(); if (ln != TransAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransAfter, ln); }; return diff.ToString(); } diff --git a/Config/FluentCommon.cs b/Config/FluentCommon.cs index 54e321db1..fb1c82d06 100644 --- a/Config/FluentCommon.cs +++ b/Config/FluentCommon.cs @@ -18,7 +18,7 @@ namespace Config /// NHibernate session factory (to create the database session 'SessionFactory') /// /// A database session - public static ISessionFactory CreateSessionFactory(Users.Entities.DBKind database, Users.Entities.DBType dbType, string connectionString, bool createDB) + public static ISessionFactory CreateSessionFactory(Common.DBKind database, Common.DBType dbType, string connectionString, bool createDB) { try { @@ -27,10 +27,10 @@ namespace Config switch (dbType) { default: - case Users.Entities.DBType.SQLite: + case Common.DBType.SQLite: cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString)); break; - case Users.Entities.DBType.MySql: + case Common.DBType.MySql: cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString)); break; } @@ -38,11 +38,11 @@ namespace Config switch (database) { default: - case Users.Entities.DBKind.Config: - case Users.Entities.DBKind.RemoteConfig: + case Common.DBKind.Config: + case Common.DBKind.RemoteConfig: cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); break; - case Users.Entities.DBKind.Results: + case Common.DBKind.Results: cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); break; } @@ -89,9 +89,9 @@ namespace Config /// DBType.SQLite or DBType.MySql /// Connection string /// true=success, false=error - public static bool CreateEmptyConfigDB(Users.Entities.DBType dbType, string connectionString) + public static bool CreateEmptyConfigDB(Common.DBType dbType, string connectionString) { - ISessionFactory sessionFactory = CreateSessionFactory(Users.Entities.DBKind.Config, dbType, connectionString, true); + ISessionFactory sessionFactory = CreateSessionFactory(Common.DBKind.Config, dbType, connectionString, true); if (sessionFactory == null) return false; /// Populate the database @@ -113,23 +113,23 @@ namespace Config /// /// Prepare all groups, add some of them to admin /// - for (Users.Entities.GID gid = 0; gid < Users.Entities.GID.NrOfGroups; gid++) + for (Common.GID gid = 0; gid < Common.GID.NrOfGroups; gid++) { Config.Entities.Group group = new Config.Entities.Group(gid); switch (gid) { - case Users.Entities.GID.Testers: - case Users.Entities.GID.TestingSpecialists: - case Users.Entities.GID.HeadOfLab: - case Users.Entities.GID.MaintenanceSpecialists: - case Users.Entities.GID.Metrologists: - case Users.Entities.GID.CalibrationSpecialists: - case Users.Entities.GID.Administrators: + 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 Users.Entities.GID.TraceabilityManagement: + case Common.GID.TraceabilityManagement: #elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END - case Users.Entities.GID.MetrologicalAuthority: - case Users.Entities.GID.WaterMeterAuthority: + case Common.GID.MetrologicalAuthority: + case Common.GID.WaterMeterAuthority: #endif admin.AddGroup(group); session.SaveOrUpdate(group); /// Save this group diff --git a/Config/Mappings/TestMap.cs b/Config/Mappings/TestMap.cs index 78956e81f..e48139e66 100644 --- a/Config/Mappings/TestMap.cs +++ b/Config/Mappings/TestMap.cs @@ -22,7 +22,8 @@ namespace Config.Mappings Map(x => x.Qfrom); Map(x => x.Qto); Map(x => x.Volume); - Map(x => x.TstTime); + Map(x => x.TestTime) + .Column("TstTime"); Map(x => x.Repeats); Map(x => x.DoDraining) .Column("Emptying"); @@ -45,7 +46,7 @@ namespace Config.Mappings Map(x => x.ErrLimLo); Map(x => x.ErrLimHi); Map(x => x.Uncertainty); - Map(x => x.TolerRed) + Map(x => x.ShortPulses) .Column("TolerRed"); /// ??? Map(x => x.RedType); Map(x => x.FeedingPath); @@ -55,11 +56,11 @@ namespace Config.Mappings #if HEAT_METERS Map(x => x.HeatMetersPath); #endif - Map(x => x.RelTransBefore) + Map(x => x.TransBefore) .Column("RelTransBefore"); - Map(x => x.RelTransBetween) + Map(x => x.TransBetween) .Column("RelTransBetween"); - Map(x => x.TransitionAfter) + Map(x => x.TransAfter) .Column("TransitionAfter"); HasMany(x => x.MoreParams) diff --git a/Config/Units.cs b/Config/Units.cs index 70f21be2f..2f156c5fd 100644 --- a/Config/Units.cs +++ b/Config/Units.cs @@ -3,6 +3,7 @@ /// using System; using System.Reflection; +using Common; using Config.Entities; namespace Config diff --git a/Config/Utils.cs b/Config/Utils.cs index a5d732007..248fc8092 100644 --- a/Config/Utils.cs +++ b/Config/Utils.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using Common; namespace Config { @@ -147,7 +148,7 @@ namespace Config /// NotSpecified, ColdWater or HotWater /// Default flow when metrologic does not match pattern /// Q1 or Qmin flow in m3/h - public static double GetQ1Qmin(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0) + public static double GetQ1Qmin(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) { if (string.IsNullOrEmpty(metroClass)) return Qdflt; @@ -158,7 +159,7 @@ namespace Config } else { - if (medium == Entities.Medium.HotWater) + if (medium == Medium.HotWater) { switch (metroClass) { @@ -192,7 +193,7 @@ namespace Config /// NotSpecified, ColdWater or HotWater /// Default flow when metrologic does not match pattern /// Q2 or Qt flow in m3/h - public static double GetQ2Qt(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0) + public static double GetQ2Qt(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) { if (string.IsNullOrEmpty(metroClass)) return Qdflt; @@ -202,7 +203,7 @@ namespace Config return 1.6 * Qn / (double)metroClassRatio; } - if (medium == Entities.Medium.HotWater) + if (medium == Medium.HotWater) { switch (metroClass) { @@ -235,7 +236,7 @@ namespace Config /// NotSpecified, ColdWater or HotWater /// Default flow when metrologic does not match pattern /// Q4 or Qmax flow in m3/h - public static double GetQ4Qmax(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0) + public static double GetQ4Qmax(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) { if (string.IsNullOrEmpty(metroClass)) return Qdflt; diff --git a/DeviceTest/DeviceTest.csproj b/DeviceTest/DeviceTest.csproj index 71422376d..2575b3170 100644 --- a/DeviceTest/DeviceTest.csproj +++ b/DeviceTest/DeviceTest.csproj @@ -90,6 +90,10 @@ + + {c8939821-ba5c-4988-a3d0-bf53b74865c7} + Common + {743DF7DB-C7B6-42EB-986D-0F485E5588E4} Config diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs index 572358f1d..f2baca06d 100644 --- a/DeviceTest/DeviceTestDlg.cs +++ b/DeviceTest/DeviceTestDlg.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Text; using System.Threading; +using System.Xml.Serialization; using System.Windows.Forms; +using Common; using TBF.BenchControl; using TBF.BenchControl.Generic; using TBF.UI.Bench.Components; -using System.Xml.Serialization; namespace DeviceTest @@ -109,8 +109,8 @@ namespace DeviceTest config.Name = Program.LocalSettings.ParentName; config.ParentName = string.Empty; config.ItemNr = 0; - config.DebugLevel = Config.Entities.DebugMode.Normal; - config.LogLevel = Config.Entities.LogLevel.Debug; + config.DebugLevel = DebugMode.Normal; + config.LogLevel = LogLevel.Debug; config.Corrections = null; config.Factory = parentFactory; parentCfg = config; @@ -142,8 +142,8 @@ namespace DeviceTest config.Name = Program.LocalSettings.ComponentName; config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.ComponentParentName) ? string.Empty : Program.LocalSettings.ComponentParentName; config.ItemNr = 1; - config.DebugLevel = Config.Entities.DebugMode.Normal; - config.LogLevel = Config.Entities.LogLevel.Debug; + config.DebugLevel = DebugMode.Normal; + config.LogLevel = LogLevel.Debug; config.Corrections = null; config.Factory = component1Factory; component1Cfg = config; @@ -177,8 +177,8 @@ namespace DeviceTest config.Name = Program.LocalSettings.Component2Name; config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component2ParentName) ? string.Empty : Program.LocalSettings.Component2ParentName; config.ItemNr = 2; - config.DebugLevel = Config.Entities.DebugMode.Normal; - config.LogLevel = Config.Entities.LogLevel.Debug; + config.DebugLevel = DebugMode.Normal; + config.LogLevel = LogLevel.Debug; config.Corrections = null; config.Factory = component2Factory; component2Cfg = config; @@ -212,8 +212,8 @@ namespace DeviceTest config.Name = Program.LocalSettings.Component3Name; config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component3ParentName) ? string.Empty : Program.LocalSettings.Component3ParentName; config.ItemNr = 3; - config.DebugLevel = Config.Entities.DebugMode.Normal; - config.LogLevel = Config.Entities.LogLevel.Debug; + config.DebugLevel = DebugMode.Normal; + config.LogLevel = LogLevel.Debug; config.Corrections = null; config.Factory = component3Factory; component3Cfg = config; diff --git a/EventViewer/EventViewerWnd.cs b/EventViewer/EventViewerWnd.cs index 73505a48c..4a354d8f7 100644 --- a/EventViewer/EventViewerWnd.cs +++ b/EventViewer/EventViewerWnd.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Windows.Forms; using NHibernate; +using Common; using Common.UIControls; using Events; using Events.Entities; @@ -210,8 +211,8 @@ namespace EventViewer { lvi.UseItemStyleForSubItems = false; lvi.SubItems.Add(evnt.Severity.ToString()); - lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Utils.GetSeverityColor(evnt.Severity); - lvi.SubItems[lvi.SubItems.Count - 1].ForeColor = Utils.GetSeverityColor(evnt.Severity, true); + lvi.SubItems[lvi.SubItems.Count - 1].BackColor = global::Events.Utils.GetSeverityColor(evnt.Severity); + lvi.SubItems[lvi.SubItems.Count - 1].ForeColor = global::Events.Utils.GetSeverityColor(evnt.Severity, true); } lvi.SubItems.Add(evnt.Message); eventsListView.Items.Add(lvi); @@ -275,7 +276,7 @@ namespace EventViewer private void settingsButton_Click(object sender, EventArgs e) { - //Users.Entities.GID[] groupsWithAccess = new Users.Entities.GID[] { Users.Entities.GID.Administrators }; + //Common.GID[] groupsWithAccess = new Common.GID[] { Common.GID.Administrators }; Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg(true); if (dlg.ShowDialog() == DialogResult.OK) { @@ -290,7 +291,7 @@ namespace EventViewer { try { - Users.GlobalData.RemoteUsersDB = new Users.DBSettings(Users.Entities.DBType.MySql, Program.LocalSettings.UsersDBConnString); + Users.GlobalData.RemoteUsersDB = new Users.DBSettings(Common.DBType.MySql, Program.LocalSettings.UsersDBConnString); Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg(); if (dlg.ShowDialog() == DialogResult.OK) { diff --git a/Events/DB.cs b/Events/DB.cs index 871434943..55bd153fa 100644 --- a/Events/DB.cs +++ b/Events/DB.cs @@ -8,6 +8,7 @@ using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; +using Common; using Events.Entities; namespace Events @@ -34,9 +35,9 @@ namespace Events } /// Database type (MySQL or SQLite) for all sessions - private static Entities.DBType dbType; + private static DBType dbType; /// - public static Entities.DBType DbType + public static DBType DbType { get { return dbType; } set { dbType = value; SessionFactory = null; } @@ -63,10 +64,10 @@ namespace Events switch (dbType) { default: - case Entities.DBType.SQLite: + case DBType.SQLite: cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString)); break; - case Entities.DBType.MySql: + case DBType.MySql: cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString)); break; } diff --git a/Events/Entities/Enums.cs b/Events/Entities/Enums.cs deleted file mode 100644 index b0d388193..000000000 --- a/Events/Entities/Enums.cs +++ /dev/null @@ -1,58 +0,0 @@ -/// -/// Copyright (c) 2020 Sensus Slovensko a.s. -/// -namespace Events.Entities -{ - /// - /// Identifies the type of a database - /// - public enum DBType - { - None, /// Database disabled - MySql, /// MySQL database - SQLite, /// SQLite - Count - } - - - public enum Severity - { - Undefined, - Notification, - Warning, - Error, - FatalError, - Count - } - - public enum EventClass - { - Undefined, - EquipmentHW, - Metrology, - TestingProcess, - BadResults, - ComputerResources, - Network, - Other, - Count - } - - public enum SubscriberGroup : long - { - None = 0, - Metrology = 1, - Maintenance = 2, - Production = 4, - Management = 8, - Finish = 16, - } - - public enum EViewerOption - { - Undefined, - AllEvents, - RecentEvents, - UnreadEvents, - } -} diff --git a/Events/Entities/Event.cs b/Events/Entities/Event.cs index bb8c4d827..47ce4a25c 100644 --- a/Events/Entities/Event.cs +++ b/Events/Entities/Event.cs @@ -3,6 +3,7 @@ /// using System; using System.Collections.Generic; +using Common; namespace Events.Entities { diff --git a/Events/Events.csproj b/Events/Events.csproj index 834daf68b..346e8e7af 100644 --- a/Events/Events.csproj +++ b/Events/Events.csproj @@ -56,7 +56,6 @@ - @@ -67,6 +66,12 @@ + + + {c8939821-ba5c-4988-a3d0-bf53b74865c7} + Common + +