Compare commits

...
Author SHA1 Message Date
Milan Hanajik 4bff6f33de DataEntry.Uni.CycleBgEnForm : 1. autoSNButton --> multiPurposeButton, 2. Initial configuration : Order : Ac.HistoryLast, ver. 2.33.2138 2023-12-12 19:08:09 +01:00
Milan Hanajik e0d10bed71 Bug fixes : 1. UpgradeSelectionDlg (Counter1..5), 2. DataContainer component factories, ver. 2.33.2134 2023-12-01 10:59:15 +01:00
Milan Hanajik a1df68b888 1. PrinterStatus implemented, used by printers, shown in ModelessDlg, 2. 'Simulated' printers, 3. Label.Printer uses wm.PrintLabel. 2023-11-30 17:51:49 +01:00
Milan Hanajik a625e2dfdb bool WaterMeter.PrintLabel (initially set), DataEntry.Uni : 1. "Auto s/n" function, 2. common check box, 3. Ct.PrintLabel (yes/no) 2023-11-28 15:00:48 +01:00
Milan Hanajik 0181294872 ProcedureDlg supports 3 printers. 2023-11-28 14:38:29 +01:00
Milan Hanajik 401828d4c6 Common.Forms.ModelessForm modifications. 2023-11-28 14:27:21 +01:00
Milan Hanajik 2c6e5d3367 Bug fix in Printers.Enhanced.PrinterCfgCtrl. 2023-11-28 14:21:05 +01:00
Milan Hanajik 38983990c2 PL language (Uzytkownici), ver. 2.33.2127 2023-11-09 18:00:52 +01:00
Milan Hanajik e02411d180 ProcedureDlg changes : wider ComboBox-es, PL language, etc., ver. 2.33.2120 2023-11-08 10:06:38 +01:00
Milan Hanajik 69f729b713 ver. 2.33.2113 2023-10-25 11:36:27 +02:00
Milan Hanajik f773e26fa3 SensusOracle.Database.ReadStartInfoFromProcedure( ) bug fix for PT7, ver. 2.33.2112 2023-10-23 14:36:11 +02:00
Milan Hanajik 9fed5148b6 TestWizard improvements 2023-10-23 14:36:11 +02:00
Milan Hanajik ab3a16bdc5 ver. 2.33.2111 2023-10-20 08:53:15 +02:00
Milan Hanajik 6e3f0dad0e iPerlCommunication : simulate iperls 2023-10-19 12:57:21 +02:00
Milan Hanajik ed066a005f MoreWMResultsDlg fixes. 2023-10-19 12:57:21 +02:00
Milan Hanajik d3126bd9ea SendAgain function in PreviousResultsDlg made fool proof for iPERL production, PW protection, etc. 2023-10-19 12:57:20 +02:00
Milan Hanajik 1c638b3f87 Range of q2CorrRL and q2CorrLR limitted to -128 .. +127. 2023-10-19 12:57:20 +02:00
Milan Hanajik f0afcd57a2 Metrology contains links to certificates saved as PDF files, CalibCertificateCtrl, ver. 2.33.2110 2023-10-18 15:32:40 +02:00
Milan Hanajik 769cb230e3 Results.ItemID.cs synchronized with ver. 3 branch. 2023-10-05 12:38:54 +02:00
Milan Hanajik 3c52e54e02 ver. 2.33.2105 2023-09-26 11:04:37 +02:00
Milan Hanajik 068b7fb3a2 Possibility to bypass "production tracing check" for a selected number of cycles, ver. 2.33.2104 2023-09-26 09:31:57 +02:00
Milan Hanajik 2ba6586a0e ver. 2.33.2102 2023-09-25 10:06:36 +02:00
Milan Hanajik fa403a322a TURA_SPECIAL WMsCount = 6, ver. 2.33.2101 2023-09-25 08:54:53 +02:00
Milan Hanajik 30627abc6a iPerlCommunication.OpticalHeadTest rectified. 2023-09-25 08:54:53 +02:00
Milan Hanajik 78772df3a0 Previous results : Possibility to save tracing records into a tracing DB (similarly to saving to Oracle). 2023-08-16 12:13:55 +02:00
Milan Hanajik 426bb0cce9 ProductionTracing : 1. No alternative tracing DB, 2. SaveTracingRecords( ) is public 2023-08-16 12:11:06 +02:00
Milan Hanajik 3da6fcfe73 Q2 correction clean-up, etc. 2023-08-15 17:07:32 +02:00
Milan Hanajik 8f27d1a448 ver. 2.33.2085 2023-08-09 11:39:28 +02:00
Milan Hanajik c5752f21a9 Q2 correction factor calculation bug fix, case when the original factor was not zero and the error target is not zero, ver. 2.33.2084 2023-08-09 11:15:22 +02:00
Milan Hanajik 8c30cb21e2 ver. 2.33.2081 2023-08-08 12:13:39 +02:00
Milan Hanajik 5181f75217 Bug fix in Q2 correction factor calculation when volume = 0, ver. 2.33.2080 2023-08-08 12:08:23 +02:00
Milan Hanajik 7ee41afba2 ver. 2.33.2079 2023-08-08 09:31:44 +02:00
Milan Hanajik 5bb99bbf86 E15 implementation according to MID (for Chennai, Stara Tura) 2023-08-07 16:14:19 +02:00
Milan Hanajik 6fd67cdf08 Q2 correction for standard process and MakeQ2CorrectionFrom(...) modified to satisfy MID, Q2 correction done when OoR. 2023-08-07 12:47:35 +02:00
Milan Hanajik e1bfa71310 iPerlHead.ProcParams.CalibTargetQ2 and WMType_ID removed, clean-up. 2023-08-04 12:34:55 +02:00
Milan Hanajik 2476ed7681 Bug fixes : 1. TestProfileDlg.addButton_Click, 2. TestProfileSelection - conversion to float avoided. 2023-07-14 13:30:51 +02:00
Milan Hanajik e413b55c6a sluprimadev --> deluh1web03 2023-07-12 12:06:02 +02:00
Jan Augustin 7d2da63071 Merge branch 'master-2' of 10.42.130.13:/srv/git/tbf into master-2 2023-07-12 08:46:00 +02:00
Jan Augustin 9aad4a60ab Fixed method DewaRework, add more rfid logs. 2023-07-11 11:30:38 +02:00
Milan Hanajik 6ffbda6e96 ver. 2.33.2070 2023-07-10 13:08:31 +02:00
Milan Hanajik 72a8f1dac6 Correction curve for pressure meters extended for negative pressures, etc., ver. 2.33.2065 2023-06-27 17:52:51 +02:00
Milan Hanajik d2631c8c88 DataEntry.Uni component added, DEUni column items in summary results, ver. 2.33.2064 2023-06-26 15:17:18 +02:00
Milan Hanajik 66b463c468 MainWnd : Procedure selection with filters (profile, DN, Qn, ...) 2023-06-26 14:27:35 +02:00
Milan Hanajik af38dbe81b Clean-up 2023-06-26 14:27:35 +02:00
Milan Hanajik 42010a6c26 Last RFID change reverted. 2023-06-22 14:03:14 +02:00
Milan Hanajik 21d3f5e835 attempt to fix build errors 2023-06-22 14:02:37 +02:00
Milan Hanajik e93aa6a21e Roma200 : Hydraulical scheme updated, ELDE component dated 230613 2023-06-20 15:23:23 +02:00
Milan Hanajik 812ac96284 Bug in water meter chart fixed : Incorrect error limit lines 2023-06-16 15:32:25 +02:00
Milan Hanajik 363f42e75b 1. MainSeqUtils.CreateNewBatchResults( ) : WaterMeterData.ErrLimHi/LoQ initialized properly, 2. comments. 2023-06-16 13:36:15 +02:00
Milan Hanajik 2232c31451 DiverterTest : Delay TimeFlow2Mass (min. 5 s) between tests, UpgradeSlectionDlg changes, ver. 2.33.2061 2023-06-16 12:08:51 +02:00
Milan Hanajik 1c6e3c17fa Merge branch 'master-2' of gitserver:/srv/git/tbf into master-2 2023-06-15 12:03:26 +02:00
Milan Hanajik 4d0c34b544 UI.Procedures.ProceduresCtrl : MoreContent.DEAndSequences added, ver. 2.33.2059 2023-06-15 11:33:50 +02:00
Milan Hanajik 93c2338d6c ver. 2.33.2058 2023-06-13 10:30:36 +02:00
Jan Augustin a455d62e9e RfidCommunicationService.RfidRead method - return type changed to dynamic. 2023-06-09 09:29:57 +02:00
Milan Hanajik aed42818b5 Upgrade from 2.32 to 2.33 takes care for rounding of Volume and TestTime after a conversion to double. 2023-06-09 09:08:58 +02:00
Milan Hanajik 281aa93b4b Merge branch 'master-2-Clean-up-of-MySQL-DB-sessions' into master-2, ver. 2.33.2057
# Conflicts:
#	Config/FluentCommon.cs
#	TBF/Properties/AssemblyInfo.cs
#	TBF/Resources/Strings.resx
#	TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
#	TBF/UI/Procedures/ProcedureDlg.cs
2023-06-07 16:21:54 +02:00
Milan Hanajik 3fee487c5d Access rights clean-up for PL 2023-05-30 11:23:29 +02:00
Milan Hanajik e50c636a34 ver. 2.32.2051 2023-05-22 13:02:59 +02:00
Milan Hanajik 1cbab1acd7 Timeout of all MySQL DB connections is 120 seconds, ver. 2.32.2050 2023-05-22 12:59:47 +02:00
Milan Hanajik 3bc8b55429 Access rights clean-up for PL 2023-05-22 12:59:36 +02:00
Milan Hanajik e6fc3c25d6 StateMachine bug fix : InitializeBoardEtc( ) session argument missing 2023-05-02 16:09:54 +02:00
Milan Hanajik b965541b1c TestWizard.VolumeAndErrorSelection fixed - conversion to float avoided. 2023-04-24 20:02:47 +02:00
Milan Hanajik 02fae9b11e Batch.SaveTime set at the end of a cycle, clean-up 2023-04-24 11:23:57 +02:00
Milan Hanajik 1eda22a391 (1) Initialization of components : Inner exception displayed, (2) Clean-up. 2023-04-24 10:36:51 +02:00
Milan Hanajik 15c916ae66 ver. 2.32.2039 2023-04-20 12:36:32 +02:00
Milan Hanajik 03fb87e6ed ver. 2.32.2038 2023-04-19 12:06:27 +02:00
Milan Hanajik bf67b4a4ec Events DB changes 2023-04-19 12:06:16 +02:00
Milan Hanajik 78d05fb1b9 TBF.DB with 4 static session factories, sessions in UI rewritten, TODO: keep session that loads components open, etc. 2023-04-19 12:06:04 +02:00
Milan Hanajik 0d47578441 Production tracing bug fix : Previous workstep result was not checked, mere existence of a record was sufficient for a WM to pass 2023-04-17 10:26:17 +02:00
Milan Hanajik 07d75b7d00 Bug fix in MakeSimulatedTrivial( ) 2023-04-17 10:26:17 +02:00
Milan Hanajik cc88308513 Production tracing bug fix II. 2023-04-14 12:34:08 +02:00
Milan Hanajik bdf3d155f4 Merge branch 'master-2' of gitserver:/srv/git/tbf into master-2 2023-04-14 09:38:16 +02:00
Jan Augustin fe4531ad4c libRfid1.dll removed 2023-04-14 09:29:56 +02:00
Milan Hanajik 23f9331460 Production tracing bug fix : Previous workstep result was not checked, mere existence of a record was sufficient for a WM to pass 2023-04-13 18:00:37 +02:00
Milan Hanajik 0d6875065c Clean-up 2023-04-12 12:25:36 +02:00
Milan Hanajik b56f712c71 Clean-up 2023-04-11 16:17:12 +02:00
Milan Hanajik 7cc20771fe Statistics.LocalSettings updated. 2023-04-11 16:15:57 +02:00
Milan Hanajik 3efb042d18 Statistics.LocalSettings updated. 2023-04-03 09:56:58 +02:00
Milan Hanajik fba8c52dfb 1. TestWizard.FlowSelection fixed: float avoided, 2. Rounding of test flows after conversion, ver. 2.33.2034 2023-04-02 12:27:38 +02:00
Milan Hanajik aa10ea5c04 float -> double : Qtg, Qfrom, Qto, Volume, TestTime, ver. 2.33.2033 2023-03-31 13:21:38 +02:00
Milan Hanajik f457278342 Batch.SaveTime set at the end of a cycle, clean-up 2023-03-30 16:55:13 +02:00
Milan Hanajik a0c45d2b39 UpgradeSelectionDlg changes : ver. 2.26 -> ver. 2.33 2023-03-29 11:57:50 +02:00
Milan Hanajik 799e5be919 All Output.Printers components : string PrinterName parameter specifies printer to be used. 2023-03-29 10:06:47 +02:00
Milan Hanajik 08c4541914 default_printer added to, Qmax,Qn,Qt,Qmin removed from TBF.Resources.Strings 2023-03-29 10:06:46 +02:00
Milan Hanajik 7b95f5f436 WMChart can plot error limits other then 2% and 5% and qp,qi style hyperbolic error limits, related DB and UI changes, ver. 2.33.2027 2023-03-29 10:06:46 +02:00
Milan Hanajik f0e57554f2 Printing from PreviousResultsDlg, ver. 2.32.2027 2023-03-13 10:14:54 +01:00
Milan Hanajik c8a5640ddc ver. 2.32.2026 2023-03-08 10:35:56 +01:00
Milan Hanajik 1a7a5661c4 iPerlCommunication : Activity 'Q2 corrected from <test> plus' supported, ver. 2.32.2025 2023-03-08 10:01:18 +01:00
Milan Hanajik 94e83ad63a ver. 2.32.2023 2023-03-02 10:42:43 +01:00
Milan Hanajik 5d2008a6dd DataEntry.S620 : Slovak keyboard check. 2023-03-02 10:36:24 +01:00
Milan Hanajik c315c8a42b TestMethods.Message added. 2023-03-02 10:25:33 +01:00
Milan Hanajik aaa78d60db Display batch end time estimate according to a sample batch, ver. 2.32.2022 2023-03-02 10:25:24 +01:00
Milan Hanajik 4b42b5ba7a Procedure number displayed in TBF.UI.ResultsMI.PreviousResultsCtrl, the form is wider, etc. 2023-03-01 11:04:09 +01:00
Milan Hanajik 6e04933eeb Refactorization : Common.Utils.GetParity( ) / GetStopBits( ) / GetHandshake( ) ... 2023-03-01 11:04:09 +01:00
Milan Hanajik f47e7670a3 BatchResultsDlg moved to TBF.UI.ResultsMI 2023-02-27 12:37:41 +01:00
Milan Hanajik 78575e4f6f iPerlCommunications : Modifications for Australia (plus), ver. 2.31.2018 2023-02-24 10:17:24 +01:00
Milan Hanajik b38ee92fe4 ver. 2.31.2017 2023-02-17 11:45:42 +01:00
Milan Hanajik 4ac72c6bbf IperlLogger handles more then 20 tests, previous results open on current screen, etc., ver. 2.31.2016 2023-02-17 09:22:00 +01:00
Milan Hanajik c0e7eab3b2 Order of saving results to MySql DB and to other destinations changed, try-catch for other destinations, ver. 2.31.2014 2023-02-02 11:08:12 +01:00
Milan Hanajik 5081969fdc DataEntry.iPerl.CycleBeginningForm supports up to 10 digit or letter purchase order, ver. 2.31. 2011 2023-01-25 12:11:14 +01:00
Milan Hanajik df386a14f8 SensusOracle.DB : Handling of a crash in transaction.Rollback(), ver. 2.31.2009 2023-01-23 13:10:13 +01:00
Milan Hanajik 2b0ee55901 SensusOracle.Database bug fix : No attempt to read bemerkung from vt_wztyp_sd, ver. 2.31.2007 2023-01-19 08:05:44 +01:00
Milan Hanajik 5b893d69b4 ver. 2.31.2006 2023-01-17 13:00:41 +01:00
Milan Hanajik a50c867b7e SensusOracle.Database uses LUTestData[] based complete test inof-s from test parameters OraId, OraDesignation, etc, ver. 2.31.2003 2023-01-17 12:57:52 +01:00
Milan Hanajik ebcbd47f91 PruefungsNr calculation that uses OraIdRepetMulti / RawDataIdRepetMulti modified, ver. 2.31.2002 2023-01-13 12:33:21 +01:00
Milan Hanajik 310ed6158a ver. 2.31.2001 2023-01-11 14:27:10 +01:00
Milan Hanajik c64e8e773f OraId, OraDesignation, RawDataId ... related : Fixed the case ORACLE_DB is not defined. 2023-01-04 09:03:08 +01:00
Milan Hanajik 56275063f7 Changes for Fuzhou PT300 done in version 2.26.1569 --> 2.26.1998. 2022-12-25 15:42:04 +01:00
Milan Hanajik d7401cfec4 Bug fix : DataEntry.StandardCamera.TestStartEndForm crashed when no RR was defined at certain position 2022-12-21 09:35:36 +01:00
Milan Hanajik 0849467857 IperlHead.DetermineExtraDataFileName( ) fixed, ver. 2.31.1996 2022-12-13 16:33:13 +01:00
Milan Hanajik d83762ddec Refactorization : Common.Utils.GetTestName(...) replaces Results.Utils.GetTestName(...) 2022-12-13 13:16:15 +01:00
Milan Hanajik 4640018e78 FileWriters.IperlLogger rewritten : uses OraId, OraIdRepetMulti, OraDesignation and LUTestData class, BatchResults bug fix 2022-12-13 13:15:33 +01:00
Milan Hanajik 67ebe0718a ProcedureDlg : 1. Qtg is displayed when ORACLE_DB defined, 2. Qtg can be changed when procedure is not protected. 2022-12-13 13:15:23 +01:00
Milan Hanajik b1bebbff50 ORACLE_DB : entities Test and TestData contain OraId, OraIdRepetMulti, OraDesignation, RawDataId, ... ver. 2.31.1994 2022-12-13 13:15:13 +01:00
Milan Hanajik 26126d380b Bug fix : Pruefindex / MaxTestIndex evaluated correctly now. 2022-12-06 10:54:55 +01:00
Milan Hanajik c6a2965faf iPerlCommunication : Milestones reset on start of the session. 2022-11-23 08:12:51 +01:00
Milan Hanajik 77c713425a ver. 2.31.1990 2022-11-21 12:08:48 +01:00
323 changed files with 13214 additions and 6632 deletions
+1
View File
@@ -42,6 +42,7 @@
</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
@@ -0,0 +1,12 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
namespace Common
{
public static class Const
{
public const string MySqlConnectTimeoutSec = "120";
}
}
+1
View File
@@ -12,6 +12,7 @@ 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()
+9 -10
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -49,15 +49,6 @@ 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
@@ -223,6 +214,14 @@ namespace Common
Count,
}
public enum FlowNames
{
QnQtQmin = 0,
Q3Q2Q1 = 1,
QpQi = 2,
Count,
}
public enum ProfileType
{
Q3R,
+7 -4
View File
@@ -1,4 +1,7 @@
using System;
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -53,20 +56,20 @@ namespace Common.Forms
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
void OnUpdateMessage(object sender, MessageEventArgs args)
{
if (args.Message != null) label1.Text = args.Message;
if (args != null && args.Message != null) label1.Text = args.Message;
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public static void CloseForm()
public void CloseForm()
{
if (CloseFormHandler == null) return;
try { CloseFormHandler(null, null); }
catch (Exception) { }
}
static public event EventHandler<EventArgs> CloseFormHandler;
public event EventHandler<EventArgs> CloseFormHandler;
void OnCloseForm(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
+1 -1
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2020-2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
+41
View File
@@ -2,6 +2,7 @@
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
///
using System;
using System.IO.Ports;
namespace Common
{
@@ -20,6 +21,18 @@ 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)
@@ -92,5 +105,33 @@ namespace Common
else return "F5";
}
}
public static Parity GetParity(string str, Parity defaultParity = Parity.None)
{
if (str.Equals(Parity.None.ToString())) return Parity.None;
if (str.Equals(Parity.Even.ToString())) return Parity.Even;
if (str.Equals(Parity.Odd.ToString())) return Parity.Odd;
if (str.Equals(Parity.Mark.ToString())) return Parity.Mark;
if (str.Equals(Parity.Space.ToString())) return Parity.Space;
return defaultParity;
}
public static StopBits GetStopBits(string str, StopBits defaultStopBits = StopBits.One)
{
if (str.Equals(StopBits.None.ToString())) return StopBits.None;
if (str.Equals(StopBits.One.ToString())) return StopBits.One;
if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive;
if (str.Equals(StopBits.Two.ToString())) return StopBits.Two;
return defaultStopBits;
}
public static Handshake GetHandshake(string str, Handshake defaultHandshake = Handshake.None)
{
if (str.Equals(Handshake.None.ToString())) return Handshake.None;
if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend;
if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff;
if (str.Equals(Handshake.RequestToSendXOnXOff.ToString())) return Handshake.RequestToSendXOnXOff;
return defaultHandshake;
}
}
}
+4 -4
View File
@@ -122,7 +122,7 @@ namespace Config.CalendarEvent
}
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime currentDate)
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime dateTimeNow)
{
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 (currentDate >= dt1) || (currentDate >= dt1) || (currentDate >= dt3);
return (dateTimeNow >= dt1) || (dateTimeNow >= dt1) || (dateTimeNow >= dt3);
}
else if (!evnt.TriggerOnExactDayOnly)
{
/// Trigger after event expires
return (currentDate >= evntDT);
return (dateTimeNow >= evntDT);
}
else
{
/// Trigger event on exact date only
return (currentDate >= evntDT) && DayMatchesExactly(evnt, currentDate);
return (dateTimeNow >= evntDT) && DayMatchesExactly(evnt, dateTimeNow);
}
}
+7 -1
View File
@@ -38,12 +38,18 @@ namespace Config
public const int CompoundWMsCount = 3;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif RUM_MOB || TURA_SPECIAL
#elif RUM_MOB
public const int WMsCount = 8;
public const int LineSize = 8;
public const int CompoundWMsCount = 1;
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);
TextColor = unchecked((int)0xFFFFFFFF);
BackColor = unchecked((int)0xFFFF5050); /// (MSB)AARRGGBB(LSB) ... pink
TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
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 float Qn { get; set; } /// - ' ' -
public virtual double Qn { get; set; } /// - ' ' -
public virtual string MClass { get; set; } /// - ' ' -
public virtual string Producer { get; set; } /// - ' ' -
+60 -15
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 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 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 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 string Method { get; set; }
public virtual float ErrLimLo { get; set; } /// in [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
public virtual float ErrLimHi { get; set; } /// in [%] usually > 0, in case of heat meters: -Qn in m3/h
@@ -57,7 +57,14 @@ namespace Config.Entities
public virtual string TransBefore { get; set; }
public virtual string TransBetween { get; set; }
public virtual string TransAfter { get; set; }
#if ORACLE_DB
public virtual int OraId { get; set; }
public virtual int OraIdRepetMulti { get; set; }
public virtual string OraDesignation { get; set; }
public virtual int RawDataId { get; set; }
public virtual int RawDataIdRepetMulti { get; set; }
public virtual string RawDataDesignation { get; set; }
#endif
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
@@ -112,7 +119,15 @@ namespace Config.Entities
TransBefore = string.Empty;
TransBetween = string.Empty;
TransAfter = string.Empty;
}
#if ORACLE_DB
OraId = 0;
OraIdRepetMulti = 0;
OraDesignation = string.Empty;
RawDataId = 0;
RawDataIdRepetMulti = 0;
RawDataDesignation = string.Empty;
#endif
}
public Test(string name, int itemNr, Procedure procedure)
: this()
@@ -192,6 +207,14 @@ namespace Config.Entities
result.TransBefore = TransBefore;
result.TransBetween = TransBetween;
result.TransAfter = TransAfter;
#if ORACLE_DB
result.OraId = OraId;
result.OraIdRepetMulti = OraIdRepetMulti;
result.OraDesignation = OraDesignation;
result.RawDataId = RawDataId;
result.RawDataIdRepetMulti = RawDataIdRepetMulti;
result.RawDataDesignation = RawDataDesignation;
#endif
result.VolumeUnit = VolumeUnit;
result.FlowUnit = FlowUnit;
result.MassUnit = MassUnit;
@@ -242,7 +265,14 @@ namespace Config.Entities
output.WriteLine(TransBetween);
output.WriteLine(Profile);
output.WriteLine(TransAfter);
#if ORACLE_DB
output.WriteLine(OraId);
output.WriteLine(OraIdRepetMulti);
output.WriteLine(OraDesignation);
output.WriteLine(RawDataId);
output.WriteLine(RawDataIdRepetMulti);
output.WriteLine(RawDataDesignation);
#endif
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
}
@@ -262,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 = 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.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.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);
@@ -296,6 +326,14 @@ namespace Config.Entities
: line.Equals(TestProfile.UserDefinedHeatMeter.ToString()) ? TestProfile.UserDefinedHeatMeter
: line.Equals(TestProfile.Protected.ToString()) ? TestProfile.Protected : TestProfile.UserDefined; /// UserDefined is the default
tst.TransAfter = input.ReadLine();
#if ORACLE_DB
tst.OraId = int.Parse(input.ReadLine(), ci);
tst.OraIdRepetMulti = int.Parse(input.ReadLine(), ci);
tst.OraDesignation = input.ReadLine();
tst.RawDataId = int.Parse(input.ReadLine(), ci);
tst.RawDataIdRepetMulti = int.Parse(input.ReadLine(), ci);
tst.RawDataDesignation = input.ReadLine();
#endif
while (true)
{
@@ -355,7 +393,14 @@ namespace Config.Entities
ln = inp.ReadLine(); if (ln != TransBetween) { diff.AppendFormat(fmt, "RelTransBetween", TransBetween, ln); };
ln = inp.ReadLine(); if (ln != Profile.ToString()) { diff.AppendFormat(fmt, "RelTransAfter", Profile, ln); };
ln = inp.ReadLine(); if (ln != TransAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransAfter, ln); };
#if ORACLE_DB
ln = inp.ReadLine(); if (ln != OraId.ToString(ci)) { diff.AppendFormat(fmt, "OraId", OraId.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != OraIdRepetMulti.ToString(ci)) { diff.AppendFormat(fmt, "OraIdRepetMulti", OraIdRepetMulti.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != OraDesignation) { diff.AppendFormat(fmt, "OraDesignation", OraDesignation, ln); };
ln = inp.ReadLine(); if (ln != RawDataId.ToString(ci)) { diff.AppendFormat(fmt, "RawDataId", RawDataId.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != RawDataIdRepetMulti.ToString(ci)){ diff.AppendFormat(fmt, "RawDataIdRepetMulti", RawDataIdRepetMulti.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != RawDataDesignation) { diff.AppendFormat(fmt, "RawDataDesignation", RawDataDesignation, ln); };
#endif
return diff.ToString();
}
-138
View File
@@ -1,148 +1,10 @@
///
/// 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 (trueVolume <= float.Epsilon)
if (-float.Epsilon <= trueVolume && trueVolume <= float.Epsilon)
{
if (measuredVolume <= float.Epsilon)
if (-float.Epsilon <= measuredVolume && measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
+9 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -62,6 +62,14 @@ namespace Config.Mappings
.Column("RelTransBetween");
Map(x => x.TransAfter)
.Column("TransitionAfter");
#if ORACLE_DB
Map(x => x.OraId);
Map(x => x.OraIdRepetMulti);
Map(x => x.OraDesignation);
Map(x => x.RawDataId);
Map(x => x.RawDataIdRepetMulti);
Map(x => x.RawDataDesignation);
#endif
HasMany(x => x.MoreParams)
.Cascade.All();
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("Config")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2018 Sensus Slovensko a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.26.1519.0")]
[assembly: AssemblyFileVersion("2.26.1519.0")]
[assembly: AssemblyVersion("2.31.1990.0")]
[assembly: AssemblyFileVersion("2.31.1990.0")]
+143
View File
@@ -0,0 +1,143 @@
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,6 +66,7 @@
<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
{
DB.DbType = DBType.MySql;
DB.ConnectionString = Program.LocalSettings.ConnectionString;
session = DB.CreateSession();
EViewerDB.DbType = DBType.MySql;
EViewerDB.ConnectionString = Program.LocalSettings.ConnectionString;
session = EViewerDB.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(true);
Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg();
if (dlg.ShowDialog() == DialogResult.OK)
{
if ((new Forms.SettingsDlg()).ShowDialog() == DialogResult.OK)
+7 -155
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -15,156 +15,6 @@ 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>
@@ -180,7 +30,7 @@ namespace Events
DB.BenchName = benchName;
}
/// <summary>
/// <summary>
/// Loads shared data from the database
/// </summary>
public static void LoadSubscribers(ISession session)
@@ -193,6 +43,7 @@ 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)))
@@ -201,7 +52,8 @@ namespace Events
public static void SaveEvent(ISession session, Event evnt, SubscriberGroup groups)
{
if (allSubscribers == null) return;
if (allSubscribers == null) LoadSubscribers(session);
IList<Subscriber> thisEventSubscribers = new List<Subscriber>();
foreach (var s in allSubscribers)
{
@@ -211,10 +63,10 @@ namespace Events
thisEventSubscribers.Add(s);
}
}
evnt.Bench = BenchName;
evnt.Subscribers = thisEventSubscribers;
evnt.Bench = BenchName;
session.SaveOrUpdate(evnt);
session.Flush();
}
}
}
+2 -1
View File
@@ -105,6 +105,7 @@ namespace Results
foreach (var ti in procedure.GetTestInstances())
{
TestData td = TestData.UpdateList(d.TestDataList, new TestData(ti.Test));
if (!d.Batch.Tests.Contains(td)) d.Batch.Tests.Add(td);
/// Create an empty test result and add it to the list
TestRslt tr = new TestRslt(d.Batch, td, ti.Test.Part, ti.Repetition);
@@ -173,7 +174,7 @@ namespace Results
return Batch.GetTestRslt(name, part);
}
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId)
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId = CompoundMeterId.Single)
{
if (Batch.WaterMeters != null && Batch.WaterMeters.Count > wmNr0 && !Batch.WaterMeters[wmNr0].Disabled)
{
+48 -16
View File
@@ -78,11 +78,17 @@ namespace Results
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchemaCreate)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
return cfg.ExposeConfiguration(BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Common.Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
}
@@ -180,29 +186,55 @@ namespace Results
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static void LoadSharedData()
public static void LoadSharedData(ISession session = null)
{
ISession session = DB.CreateSession();
bool openAndCloseSession = (session == null);
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
}
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();
}
}
/// <summary>
/// Loads shared data from the database
/// </summary>
/// <exception>Throws NHibernate exceptions</exception>
public static int GetMaxSavedBatchNr()
public static int GetMaxSavedBatchNr(ISession session = null)
{
ISession session = DB.CreateSession();
IList<Entities.Batch> batches = session.QueryOver<Batch>().List();
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();
}
int maxBatchNr = 0;
foreach (var b in batches)
{
if (b.BatchNr > maxBatchNr) maxBatchNr = b.BatchNr;
}
return maxBatchNr;
}
+2
View File
@@ -40,6 +40,8 @@ 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();
}
+15 -6
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -24,6 +24,8 @@ 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
@@ -39,6 +41,7 @@ namespace Results.Entities
public virtual int Counter10 { get; set; }
public virtual DateTime StartTime { get; set; }
public virtual DateTime EndTime { get; set; }
public virtual DateTime SaveTime { get; set; }
public virtual bool Dirty { get; set; }
public virtual bool RsltsSent { get; set; }
public virtual bool RsltsPrinted { get; set; }
@@ -157,6 +160,7 @@ namespace Results.Entities
Counter10 = oriBatch.Counter10;
StartTime = oriBatch.StartTime;
EndTime = oriBatch.EndTime;
SaveTime = oriBatch.SaveTime;
Dirty = oriBatch.Dirty;
RsltsSent = oriBatch.RsltsSent;
RsltsPrinted = oriBatch.RsltsPrinted;
@@ -321,16 +325,19 @@ namespace Results.Entities
public override string ToString()
{
return string.Format("Batch #{0}, Start:{1}, End:{2}, Procedure:{3}", BatchNr, StartTime, EndTime, ProcedureName);
return string.Format("Batch {0} ({1}s) Start {2}, End {3}, Proc={4}",
BatchNr, (EndTime - StartTime).TotalSeconds, StartTime, EndTime, ProcedureName);
}
public virtual string ToString(int i)
{
return string.Format("Batch: BatchNr={0} ProgramVersion={1} TestBenchId={2} UserName={3} UserNumber={4} ProcedureName={5}{6} ProcRev={7} ProtocolTitle={8} Remark={9} RealDensity={10} AtTemperature={11} Buoyancy={12} StartTime={13} EndTime={14} Dirty={15} RsltsSent={16} RsltsPrinted={17}",
BatchNr, ProgramVersion, TestBenchId, UserName, UserNumber,
return string.Format("Batch {0} ({1}s) ver={2} TestBenchId={3} User={4}/{5} Proc={6}{7} Rev={8} Remark={9} RealDensity={10} AtTemperature={11} Buoyancy={12} StartTime={13} EndTime={14} SaveTime={15} RsltsSent={16} RsltsPrinted={17}",
BatchNr,
(EndTime - StartTime).TotalSeconds,
ProgramVersion, TestBenchId, UserName, UserNumber,
ProcedureName, (IsRemoteProcedure ? "(R)" : ""), ProcedureRevision,
ProtocolTitle, Remark, RealDensity, AtTemperature, Buoyancy,
StartTime, EndTime, Dirty, RsltsSent, RsltsPrinted);
Remark, RealDensity, AtTemperature, Buoyancy,
StartTime, EndTime, SaveTime, RsltsSent, RsltsPrinted);
}
public virtual void WriteBinary(BinaryWriter writer)
@@ -364,6 +371,7 @@ namespace Results.Entities
writer.Write(Counter10);
writer.Write(StartTime.ToString());
writer.Write(EndTime.ToString());
writer.Write(SaveTime.ToString());
writer.Write(Dirty);
writer.Write(RsltsSent);
writer.Write(RsltsPrinted);
@@ -431,6 +439,7 @@ namespace Results.Entities
Counter10 = reader.ReadInt32();
StartTime = DateTime.Parse(reader.ReadString());
EndTime = DateTime.Parse(reader.ReadString());
SaveTime = DateTime.Parse(reader.ReadString());
Dirty = reader.ReadBoolean();
RsltsSent = reader.ReadBoolean();
RsltsPrinted = reader.ReadBoolean();
+55 -3
View File
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Common;
using Config.Entities;
namespace Results.Entities
@@ -31,7 +32,14 @@ namespace Results.Entities
public virtual string TempControl { get; set; }
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool Evaluate { get; set; }
#if ORACLE_DB
public virtual int OraId { get; set; }
public virtual int OraIdRepetMulti { get; set; }
public virtual string OraDesignation { get; set; }
public virtual int RawDataId { get; set; }
public virtual int RawDataIdRepetMulti { get; set; }
public virtual string RawDataDesignation { get; set; }
#endif
/// <summary>
/// Default constructor, safe values
@@ -61,7 +69,15 @@ namespace Results.Entities
TempControl = test.TempControl;
Publish = test.Publish;
Evaluate = test.DoEvaluate;
}
#if ORACLE_DB
OraId = test.OraId;
OraIdRepetMulti = test.OraIdRepetMulti;
OraDesignation = test.OraDesignation;
RawDataId = test.RawDataId;
RawDataIdRepetMulti = test.RawDataIdRepetMulti;
RawDataDesignation = test.RawDataDesignation;
#endif
}
/// <summary>
/// Copy constructor, copies all except of Id
@@ -84,6 +100,14 @@ namespace Results.Entities
TempControl = oriTestData.TempControl;
Publish = oriTestData.Publish;
Evaluate = oriTestData.Evaluate;
#if ORACLE_DB
OraId = oriTestData.OraId;
OraIdRepetMulti = oriTestData.OraIdRepetMulti;
OraDesignation = oriTestData.OraDesignation;
RawDataId = oriTestData.RawDataId;
RawDataIdRepetMulti = oriTestData.RawDataIdRepetMulti;
RawDataDesignation = oriTestData.RawDataDesignation;
#endif
}
@@ -110,7 +134,14 @@ namespace Results.Entities
if (TempControl != td.TempControl) return false;
if (Publish != td.Publish) return false;
if (Evaluate != td.Evaluate) return false;
#if ORACLE_DB
if (OraId != td.OraId) return false;
if (OraIdRepetMulti != td.OraIdRepetMulti) return false;
if (OraDesignation != td.OraDesignation) return false;
if (RawDataId != td.RawDataId) return false;
if (RawDataIdRepetMulti != td.RawDataIdRepetMulti) return false;
if (RawDataDesignation != td.RawDataDesignation) return false;
#endif
return true;
}
@@ -152,6 +183,14 @@ namespace Results.Entities
writer.Write((TempControl != null) ? TempControl : string.Empty);
writer.Write(Publish);
writer.Write(Evaluate);
#if ORACLE_DB
writer.Write(OraId);
writer.Write(OraIdRepetMulti);
writer.Write((OraDesignation != null) ? OraDesignation : string.Empty);
writer.Write(RawDataId);
writer.Write(RawDataIdRepetMulti);
writer.Write((RawDataDesignation != null) ? RawDataDesignation : string.Empty);
#endif
}
public virtual void ReadBinary(BinaryReader reader)
@@ -173,6 +212,19 @@ namespace Results.Entities
TempControl = reader.ReadString();
Publish = reader.ReadSByte();
Evaluate = reader.ReadBoolean();
#if ORACLE_DB
OraId = reader.ReadInt32();
OraIdRepetMulti = reader.ReadInt32();
OraDesignation = reader.ReadString();
RawDataId = reader.ReadInt32();
RawDataIdRepetMulti = reader.ReadInt32();
RawDataDesignation = reader.ReadString();
#endif
}
public override string ToString()
{
return string.Format("{0} (P.{1},{2})", Name, ((Publish)Publish).ToString(), Evaluate ? "E" : "-");
}
}
}
+12 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -147,7 +147,8 @@ namespace Results.Entities
public virtual int Counter5 { get; set; }
/// Wrappers
public virtual string Name() { return Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual string Name() { return Common.Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual string Key() { return string.Format("{0}~{1}~{2}~{3}", TestData.Name, Part, TestData.Repeats, RepetitionNr); } /// Unique key
public virtual int Repeats() { return TestData.Repeats; }
public virtual double Qfrom() { return TestData.Qfrom; }
public virtual double Qto() { return TestData.Qto; }
@@ -164,6 +165,15 @@ namespace Results.Entities
public virtual bool IsDiverter() { return (MethodClass != null) ? ((MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) || MethodClass.Contains("DiverterTest")) : true; }
public virtual bool IsVolumeMethod() { return (MethodClass != null) ? (MethodClass.Contains("TestMethods.FixedStart.") || MethodClass.Contains("TestMethods.FlyingStart.")) : false; }
#if ORACLE_DB
public virtual int OraId() { return TestData.OraId; }
public virtual int OraIdRepetMulti() { return TestData.OraIdRepetMulti; }
public virtual string OraDesignation() { return TestData.OraDesignation; }
public virtual int RawDataId() { return TestData.RawDataId; }
public virtual int RawDataIdRepetMulti() { return TestData.RawDataIdRepetMulti; }
public virtual string RawDataDesignation() { return TestData.RawDataDesignation; }
#endif
public virtual string MethodElde()
{
if (MethodClass == null) return string.Empty;
+24 -56
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -97,12 +97,10 @@ namespace Results.Entities
public virtual int WMTypeRevision { get; set; }
public virtual int Pruefindex { get; set; } /// >=1 ... pruefindex, 0 ... unknown (no reading from DB yet)
public virtual int HydrPruefung { get; set; }
public virtual object RawTestInfos { get; set; } /// Not mapped to DB !!! IList<SensusTestInfo> fetched from Oracle at the beginning of the cycle, not mapped to DB !!!
public virtual object CompleteTestInfos { get; set; } /// Not mapped to DB !!! SensusTestInfo[] obtained as a best match at the beginning of the cycle, not mapped to DB !!!
#endif
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual int SessionId { get; set; } /// Not mapped to DB !!! 1 (regular tracing DB session) or 2 (alternative tracing DB session)
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual bool PrintLabel { get; set; } /// Not mapped to DB !!!
public virtual WaterMeterData WaterMeterData { get; set; }
public virtual Batch Batch { get; set; }
@@ -111,15 +109,23 @@ namespace Results.Entities
///
/// Wrappers
///
public virtual string ProductName() { return WaterMeterData.ProductName; }
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 Producer() { return WaterMeterData.Producer; }
public virtual string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
public virtual string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
public virtual bool NewQnames() { return WaterMeterData.NewQnames; }
public virtual FlowNames Qnames() { return (FlowNames)WaterMeterData.Qnames; }
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; }
@@ -128,8 +134,10 @@ 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; }
public virtual int BatchNr() { return Batch.BatchNr; }
#if ORACLE_DB
public virtual int WMTypeId() { return WaterMeterData.WMTypeId; }
#endif
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; }
@@ -252,7 +260,9 @@ namespace Results.Entities
break;
}
}
#if ORACLE_DB
if (Utils.MaxTestIndex != 0 && (Pruefindex % 100) > Utils.MaxTestIndex) passed = false;
#endif
return passed;
}
@@ -330,7 +340,7 @@ namespace Results.Entities
return GetMeterTestRslt(testName, CompoundMeterId.SingleOrCompound);
}
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId)
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId = CompoundMeterId.Single)
{
if (string.IsNullOrEmpty(testName)) return null;
if (Disabled) return null;
@@ -446,12 +456,10 @@ namespace Results.Entities
WMTypeRevision = 0;
Pruefindex = 0;
HydrPruefung = 0;
RawTestInfos = null;
CompleteTestInfos = null;
#endif
ProcessId = 0;
SessionId = 0;
LastRecordIsNok = false;
PrintLabel = true;
}
@@ -510,12 +518,10 @@ namespace Results.Entities
WMTypeRevision = src.WMTypeRevision;
Pruefindex = src.Pruefindex;
HydrPruefung = src.HydrPruefung;
RawTestInfos = src.RawTestInfos; /// Not mapped to DB
CompleteTestInfos = src.CompleteTestInfos; /// Not mapped to DB
#endif
ProcessId = src.ProcessId; /// Not mapped to DB
SessionId = src.SessionId; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@@ -692,26 +698,10 @@ namespace Results.Entities
writer.Write(WMTypeRevision);
writer.Write(Pruefindex);
writer.Write(HydrPruefung);
/// Write RawTestInfos
IList<Results.Output.SensusTestInfo> rawTestInfos = RawTestInfos as IList<Results.Output.SensusTestInfo>;
writer.Write((rawTestInfos != null) ? rawTestInfos.Count : 0);
if (rawTestInfos != null)
{
for (int i = 0; i < rawTestInfos.Count; i++) rawTestInfos[i].WriteBinary(writer);
}
/// Write CompleteTestInfos
Results.Output.SensusTestInfo[] completeTestInfos = CompleteTestInfos as Results.Output.SensusTestInfo[];
writer.Write((completeTestInfos != null) ? completeTestInfos.Length : 0);
if (completeTestInfos != null)
{
for (int i = 0; i < completeTestInfos.Length; i++) completeTestInfos[i].WriteBinary(writer);
}
#endif
writer.Write(ProcessId);
writer.Write(SessionId);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@@ -788,32 +778,10 @@ namespace Results.Entities
WMTypeRevision = reader.ReadInt32();
Pruefindex = reader.ReadInt32();
HydrPruefung = reader.ReadInt32();
/// Read RawTestInfos
int rawTestInfosCount = reader.ReadInt32();
IList<Results.Output.SensusTestInfo> rawTestInfos = new List<Results.Output.SensusTestInfo>();
for (int i = 0; i < rawTestInfosCount; i++)
{
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
ti.ReadBinary(reader);
rawTestInfos.Add(ti);
}
RawTestInfos = rawTestInfos;
/// Read CompleteTestInfos
int completeTestInfosLen = reader.ReadInt32();
Results.Output.SensusTestInfo[] completeTestInfos = new Results.Output.SensusTestInfo[completeTestInfosLen];
for (int i = 0; i < completeTestInfosLen; i++)
{
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
ti.ReadBinary(reader);
completeTestInfos[i] = ti;
}
CompleteTestInfos = completeTestInfos;
#endif
ProcessId = reader.ReadInt32();
SessionId = reader.ReadInt32();
LastRecordIsNok = reader.ReadBoolean();
PrintLabel = reader.ReadBoolean();
/// Retrieve TestData
if (reader.ReadBoolean())
+16 -5
View File
@@ -17,11 +17,14 @@ 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 bool NewQnames { get; set; } /// Yes = Q3... No = Qn...
public virtual sbyte Qnames { get; set; } /// see Common.Enums.FlowNames
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; }
@@ -66,11 +69,13 @@ namespace Results.Entities
DN = oriWMData.DN;
L = oriWMData.L;
Mounting = oriWMData.Mounting;
NewQnames = oriWMData.NewQnames;
Qnames = oriWMData.Qnames;
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;
@@ -109,11 +114,13 @@ namespace Results.Entities
if (DN != wmd.DN) return false;
if (L != wmd.L) return false;
if (Mounting != wmd.Mounting) return false;
if (NewQnames != wmd.NewQnames) return false;
if (Qnames != wmd.Qnames) 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;
@@ -167,11 +174,13 @@ namespace Results.Entities
writer.Write(DN);
writer.Write(L);
writer.Write((int)Mounting);
writer.Write(NewQnames);
writer.Write((int)Qnames);
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);
@@ -205,11 +214,13 @@ namespace Results.Entities
DN = reader.ReadDouble();
L = reader.ReadDouble();
Mounting = (Mounting)reader.ReadInt32();
NewQnames = reader.ReadBoolean();
Qnames = (sbyte)reader.ReadInt32();
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();
+24 -10
View File
@@ -29,13 +29,15 @@
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.allResultsTabPage = new System.Windows.Forms.TabPage();
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsRowsCtrl();
this.tabControl1.SuspendLayout();
this.allResultsTabPage.SuspendLayout();
this.productionTracingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
this.productionTracingSplitContainer.Panel1.SuspendLayout();
@@ -55,6 +57,17 @@
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);
@@ -113,6 +126,7 @@
//
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);
@@ -120,15 +134,14 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// allResultsTabPage
// oneWMResultsRowsCtrl
//
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;
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;
//
// MoreWMResultsDlg
//
@@ -140,6 +153,7 @@
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();
@@ -153,12 +167,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;
}
}
+61 -57
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -14,6 +14,13 @@ namespace Results.Forms
{
public partial class MoreWMResultsDlg : Form
{
enum Tabs
{
Results = 0,
Graph,
Tracing,
}
public MoreWMResultsDlg(Results.Entities.WaterMeter wm, IList<ReferenceRecord> refRecords)
{
InitializeComponent();
@@ -23,14 +30,15 @@ namespace Results.Forms
ShowAllResults(wm);
ShowChart(wm);
/// Select the initial tab page to be displayed
if (refRecords == null)
{
tabControl1.SelectTab(1);
tabControl1.TabPages.RemoveAt(2);
tabControl1.SelectTab((int)Tabs.Graph);
tabControl1.TabPages.RemoveAt((int)Tabs.Tracing);
}
else
{
tabControl1.SelectTab(2);
tabControl1.SelectTab((int)Tabs.Tracing);
ShowTracingResults(wm, refRecords);
}
}
@@ -39,9 +47,9 @@ namespace Results.Forms
void Localize()
{
Text = Strings.Water_meter_results;
tabControl1.TabPages[0].Text = Strings.All_results;
tabControl1.TabPages[1].Text = Strings.Graphs;
tabControl1.TabPages[2].Text = Strings.Production_tracing_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;
}
@@ -51,67 +59,63 @@ 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}", (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
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
// 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() != Publish.Never &&
// mtr.Publish() != Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.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());
// 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)
{
//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));
tabControl1.TabPages[(int)Tabs.Graph].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
}
+4 -4
View File
@@ -79,18 +79,18 @@ namespace Results.Forms
return;
}
/// Update background color
/// Update background color and caption
string message = string.Empty;
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
bool maxRepeatsExceeded = (Utils.MaxTestIndex != 0 && (wMtr.Pruefindex % 100) > Utils.MaxTestIndex);
UpdateBkColor(wMtr.GetColorOfResults(maxRepeatsExceeded, out message));
tBox.Text = caption = string.Format("{0} ({1}) {2} {3}",
wMtr.WMPosition,
wMtr.Pruefindex == 0 ? "?" : string.Format("{0}x", wMtr.Pruefindex % 100),
(string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr),
message);
#else
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
+12 -9
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
@@ -24,13 +24,16 @@ 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<Results.WMeterRsltItemSpec> items;
IList<WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
@@ -45,7 +48,7 @@ namespace Results.Forms
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
items = new List<WMeterRsltItemSpec>();
columnWidths = new int[0];
}
@@ -62,7 +65,7 @@ namespace Results.Forms
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
public void Update(IList<WMeterRsltItemSpec> items)
{
this.items = items;
@@ -91,21 +94,21 @@ namespace Results.Forms
return;
}
/// Update background color
/// Update background color and caption
string message = string.Empty;
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
bool maxRepeatsExceeded = (Utils.MaxTestIndex != 0 && (wMtr.Pruefindex % 100) > Utils.MaxTestIndex);
UpdateBkColor(wMtr.GetColorOfResults(maxRepeatsExceeded, out message));
tBox.Text = caption = string.Format("{0} ({1}) {2} {3}",
wMtr.WMPosition,
wMtr.Pruefindex == 0 ? "?" : string.Format("{0}x", wMtr.Pruefindex % 100),
(string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr),
message);
#else
UpdateBkColor(wMtr.GetColorOfResults(false, out message));
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
UpdateWMPos(wMtr.WMPosition);
/// Update test results
+5
View File
@@ -343,6 +343,11 @@ namespace Results
X9, /// 291
RadioAddress, /// 292
OriRadioAddress, /// 293
Pls_per_ltr_aux, /// 294 Compound water meter constant (water meter data, not used in calculations)
Pulses_main, /// 295 Compound main meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Pulses_aux, /// 296 Compound aux meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Count,
}
+2 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Results.Entities;
@@ -35,6 +35,7 @@ namespace Results.Mappings
Map(x => x.StartTime);
Map(x => x.EndTime);
Map(x => x.SaveTime);
Map(x => x.Dirty);
Map(x => x.RsltsSent);
Map(x => x.RsltsPrinted);
+10 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Results.Entities;
@@ -24,6 +24,14 @@ namespace Results.Mappings
Map(x => x.ErrLimMargin).Column("Uncertainty");
Map(x => x.Publish);
Map(x => x.Evaluate);
}
#if ORACLE_DB
Map(x => x.OraId);
Map(x => x.OraIdRepetMulti);
Map(x => x.OraDesignation);
Map(x => x.RawDataId);
Map(x => x.RawDataIdRepetMulti);
Map(x => x.RawDataDesignation);
#endif
}
}
}
+3 -3
View File
@@ -18,13 +18,13 @@ namespace Results.Mappings
Map(x => x.L);
Map(x => x.Mounting);
#if MUNICH && LANG_DE
Map(x => x.NewQnames);
#endif
Map(x => x.Qnames);
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.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab1, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
PrintAt(e, Tab3, lineNr * SpacingOne, (wm.Qnames() == FlowNames.Q3Q2Q1) ? "Q3 :" : (wm.Qnames() == FlowNames.QpQi) ? "qp :" : "Qn :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
}
lineNr++;
+108 -15
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019-2022 Sensus Metering Systems
/// Copyright (c) 2019-2023 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -55,6 +55,9 @@ namespace Results.Output
chArea.AxisX.LogarithmBase = 10;
chArea.AxisX.IsLabelAutoFit = true;
Series upperLimit = new Series { Name = Strings.Upper_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red };
List<double> xs = new List<double>() { 0.0001, 0.0002, 0.0005,
0.001, 0.002, 0.005,
0.01, 0.02, 0.05,
@@ -71,6 +74,8 @@ 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])
@@ -88,6 +93,37 @@ 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);
}
}
}
@@ -101,6 +137,36 @@ 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;
}
}
@@ -111,19 +177,20 @@ namespace Results.Output
Legend legend1 = new Legend { Name = "Legend1" };
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);
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 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);
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 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 };
@@ -137,12 +204,38 @@ namespace Results.Output
chart.ChartAreas.Add(chArea);
chart.Legends.Add(legend1);
chart.Series.Add(upperLimit);
chart.Series.Add(lowerLimit);
if (upperLimit.Points.Count > 1) chart.Series.Add(upperLimit);
if (lowerLimit.Points.Count > 1) chart.Series.Add(lowerLimit);
chart.Series.Add(dots);
chart.Series.Add(line);
return chart;
}
static double GetErrorLimit(WaterMeter wm, Unit flowUnit, double x)
{
double flow_m3 = Units.ConvertFrom(flowUnit, x);
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: return Math.Min(3.5, 1.0 + 0.01 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 2: return Math.Min(5.0, 2.0 + 0.02 * wm.WaterMeterData.Q3_Qn / flow_m3);
case 3: return Math.Min(5.0, 3.0 + 0.05 * wm.WaterMeterData.Q3_Qn / flow_m3);
}
}
static double GetQsharp(WaterMeter wm, Unit flowUnit)
{
double qSharp;
switch (Convert.ToInt32(wm.WaterMeterData.Q2_Qt))
{
default:
case 1: qSharp = (0.01 / 2.5) * wm.WaterMeterData.Q3_Qn; break;
case 2: qSharp = (0.02 / 3.0) * wm.WaterMeterData.Q3_Qn; break;
case 3: qSharp = (0.05 / 2.0) * wm.WaterMeterData.Q3_Qn; break;
}
return Units.ConvertTo(flowUnit, qSharp);
}
}
}
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("Results")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2019 Sensus Slovensko, a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko, a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.27.1844.0")]
[assembly: AssemblyFileVersion("2.27.1844.0")]
[assembly: AssemblyVersion("2.31.1990.0")]
[assembly: AssemblyFileVersion("2.31.1990.0")]
-9
View File
@@ -75,12 +75,6 @@
<Compile Include="Entities\WaterMeterData.cs" />
<Compile Include="Entities\WaterMeter.cs" />
<Compile Include="DB.cs" />
<Compile Include="Forms\BatchResultsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ManualEntryConfigCtrl.cs">
<SubType>UserControl</SubType>
@@ -213,9 +207,6 @@
<Folder Include="Output\FileWriters\OneFilePerMeter\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\BatchResultsDlg.resx">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ManualEntryConfigCtrl.resx">
<DependentUpon>ManualEntryConfigCtrl.cs</DependentUpon>
</EmbeddedResource>
+3 -6
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
///
using System;
using System.Text;
@@ -9,12 +9,9 @@ namespace Results
{
public static class Utils
{
public static string GetTestName(string name, int repeats, int repetitionNr)
{
return Common.Utils.GetTestName(name, repeats, repetitionNr);
}
public static int MaxTestIndex = 0;
public static int BenchIdOracle2Asc(int benchIdOracle)
{
switch (benchIdOracle)
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("ResultsBrowser")]
[assembly: AssemblyCopyright("Copyright © 2015 - 2020 Sensus Slovensko a.s.")]
[assembly: AssemblyCopyright("Copyright © 2015 - 2022 Sensus Slovensko a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.26.1577.0")]
[assembly: AssemblyFileVersion("2.26.1577.0")]
[assembly: AssemblyVersion("2.31.1990.0")]
[assembly: AssemblyFileVersion("2.31.1990.0")]
+2
View File
@@ -31,6 +31,8 @@ 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();
+6 -8
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", "WR20", "WR21", "PT7" };
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "WR18", "WR19", "PT7" };
MidNames = new string[] { string.Empty, "I1", "I2", "I3", "I4" }; /// Index is MID-id
#if true
/// Production Stara Tura
@@ -247,16 +247,14 @@ namespace Statistics
ConnectionStrings = new string[]
{
"SERVER=10.42.130.69; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
"SERVER=10.42.129.242; 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.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.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.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.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;",
"SERVER=10.42.130.89; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
};
#else
/// Off-line demo
+4
View File
@@ -133,6 +133,10 @@
</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,6 +13,7 @@ using NHibernate;
using FluentNHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Common;
using Results;
using Results.Entities;
using Statistics.Resources;
@@ -98,6 +99,8 @@ 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)
+20 -1
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
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}
@@ -92,6 +94,8 @@ 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
@@ -386,8 +390,23 @@ 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
+184 -34
View File
@@ -1,11 +1,17 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
/// Copyright (c) 2021-2023 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 Config;
using Users.Entities;
using Events;
using TBF.Resources;
using System.Collections.Generic;
namespace TBF
{
@@ -16,52 +22,196 @@ namespace TBF
///
public static DatabaseSettings CurrentBench;
/// <summary>
/// Session factories for regular sessions.
/// </summary>
public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)DBKind.Count];
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
/// Create a NHibernate session for the given database
public static ISession CreateSession(DBKind database)
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
{
if (database < 0 || database >= DBKind.Count) return null;
int ix = (int)database;
if (SessionFactories[ix] == null)
get
{
SessionFactories[ix] = CreateSessionFactory(database);
return (SharedUsersDBSessionFactory != null)
? new ISessionFactory[] { SharedUsersDBSessionFactory, LocalUsersDBSessionFactory }
: new ISessionFactory[] { LocalUsersDBSessionFactory };
}
}
/// <summary>
/// Create all database session factories
/// </summary>
public static void CreateSessionFactories(DatabaseSettings dbSettings)
{
/// 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);
LocalUsersDBSessionFactory =
CreateSessionFactory(m => m.FluentMappings.AddFromAssemblyOf<Users.Entities.User>(),
dbSettings.ProceduresDBSettings.DbType,
dbSettings.ProceduresDBSettings.ConnectionString);
}
return SessionFactories[ix].OpenSession();
/// 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);
}
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
static ISessionFactory CreateSessionFactory(DBKind database)
public static ISessionFactory CreateSessionFactory(Action<MappingConfiguration> mappings, DBType dbType,
string connectionString, bool createDB = false)
{
DBType dbType;
string connectionString;
switch (database)
try
{
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;
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();
}
}
return Config.FluentCommon.CreateSessionFactory(database, dbType, connectionString, false);
return true;
}
}
}
+21
View File
@@ -231,6 +231,27 @@ 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]
+119 -73
View File
@@ -1,19 +1,19 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 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(true).ShowDialog() == DialogResult.Cancel) ||
(new Users.Forms.LoginDlg().ShowDialog() == DialogResult.Cancel) ||
(new TBF.UI.Settings.BenchesDlg().ShowDialog() == DialogResult.Cancel))
{
return; /// Exit program
@@ -229,6 +229,8 @@ namespace TBF
bool retryLogin = true; /// true = stay in a login loop
do
{
LoadingConfigEnd();
LoginDlgWithBenchSelection loginDlgBench;
if (LocalSettings.LastBenchName != null)
{
@@ -251,10 +253,11 @@ 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);
Users.CurrentUser.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings;
Users.CurrentUser.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings;
LoadingConfigStart();
TBF.DB.CurrentBench = LocalSettings.TestBenches[i].Clone() as DatabaseSettings;
TBF.DB.CreateSessionFactories(LocalSettings.TestBenches[i]);
Users.Entities.User loadedUser = null;
try
@@ -270,11 +273,10 @@ namespace TBF
if (Users.Entities.User.IsPowerUser(loginDlgBench.Alias, loginDlgBench.Password))
{
loadedUser = new Users.Entities.User(loginDlgBench.Alias, 6, true);
authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
if (authorized)
{
Users.CurrentUser.AuthorizedAs = Common.AuthorizedAs.PowerUser;
}
CurrentUser.Change(loadedUser, null);
CurrentUser.LastAuthorization = DateTime.Now;
CurrentUser.AuthorizedAs = Common.AuthorizedAs.PowerUser;
authorized = true;
}
///
@@ -282,42 +284,57 @@ namespace TBF
///
if (!authorized)
{
DBSettings[] dbs = new DBSettings[] { Users.CurrentUser.RemoteUsersDB, Users.CurrentUser.LocalUsersDB };
authorizedAs = Common.AuthorizedAs.RemoteUser; /// Try remote DB first
foreach (var db in dbs)
foreach (var sf in TBF.DB.UserSessionFactories)
{
/// Load and authorise user from the UsersDB database
try
{
if (loginDlgBench.Password == LoginDlgWithBenchSelection.UseTheTagPassword)
if (sf != null)
{
loadedUser = Users.Entities.User.LoadUserByTag(loginDlgBench.Alias, db);
if (loadedUser != null) authorized = loadedUser.AuthorizeTag(loginDlgBench.Alias, reqGrpMembership, null);
}
else
{
switch (loginDlgBench.Method)
var session = sf.OpenSession();
if (loginDlgBench.Password == LoginDlgWithBenchSelection.UseTheTagPassword)
{
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;
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();
}
}
}
catch
{
authorized = false;
@@ -353,7 +370,11 @@ 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.
TBF.DB.CurrentBench = (DatabaseSettings)LocalSettings.TestBenches[i].Clone();
if (TBF.DB.CurrentBench == null)
{
TBF.DB.CurrentBench = LocalSettings.TestBenches[i].Clone() as DatabaseSettings;
TBF.DB.CreateSessionFactories(TBF.DB.CurrentBench);
}
Results.DB.DbType = TBF.DB.CurrentBench.WaterMetersDBSettings.DbType;
Results.DB.ConnectionString = TBF.DB.CurrentBench.WaterMetersDBSettings.ConnectionString;
@@ -364,7 +385,7 @@ namespace TBF
/// Connect to Config database.
/// This triggers an exception in case user is a power user and there is no Config database.
///
ISession session = TBF.DB.CreateSession(DBKind.Config);
var session = TBF.DB.ConfigDBSessionFactory.OpenSession();
if (!string.IsNullOrEmpty(LocalSettings.LastProcedureName))
{
@@ -380,9 +401,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
@@ -393,20 +414,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.
///
Results.DB.LoadSharedData();
int maxBatchNr = Results.DB.GetMaxSavedBatchNr();
var rsltDBSession = TBF.DB.ResultsDBSessionFactory.OpenSession();
Results.DB.LoadSharedData(rsltDBSession);
int maxBatchNr = Results.DB.GetMaxSavedBatchNr(rsltDBSession);
if (!TBF.DB.CurrentBench.IsRealBench || Program.LocalSettings.BatchNr <= maxBatchNr)
{
log.FatalFormat("Max. BatchNr in DB = {0}, LocalSettings.BatchNr = {1}", maxBatchNr, Program.LocalSettings.BatchNr);
@@ -414,17 +435,7 @@ namespace TBF
Program.LocalSettings.Save();
log.FatalFormat("LocalSettings.BatchNr updated to {0}", Program.LocalSettings.BatchNr);
}
///
/// 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
}
if (rsltDBSession != null && rsltDBSession.IsOpen) rsltDBSession.Close();
retryLogin = false;
break;
@@ -460,7 +471,7 @@ namespace TBF
default:
/// Open 'DatabaseSetingsDlg' and retry DB connect on OK
if (new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel ||
if (new Users.Forms.LoginDlg().ShowDialog() == DialogResult.Cancel ||
new TBF.UI.Settings.BenchesDlg().ShowDialog() == DialogResult.Cancel)
{
return; /// Exit program
@@ -482,26 +493,31 @@ namespace TBF
///
if (LocalSettings.LastProcedureName != null)
{
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)
using (var session = TBF.DB.ConfigDBSessionFactory.OpenSession())
{
log.InfoFormat("Pre-selecting the procedure {0}", LocalSettings.LastProcedureName);
SelectedProcedure = listOfProcedures[0];
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();
}
}
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");
Application.Run(MainWnd);
LoadingConfigEnd();
Application.Run(MainWnd);
log.Info("The main window was closed");
}
catch (Exception e)
@@ -536,5 +552,35 @@ namespace TBF
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
log.Fatal("--------------------------------------");
}
}
}
static UI.Shared.ModelessActivityForm form;
static System.Threading.Thread formThread;
static void LoadingConfigStart()
{
form = new UI.Shared.ModelessActivityForm()
{
Message = Strings.Starting_system,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.LightBlue,
};
formThread = new System.Threading.Thread(() => form.ShowDialog());
formThread.Start();
System.Threading.Thread.Sleep(500);
}
static void LoadingConfigEnd()
{
if (form != null && formThread != null)
{
form.CloseForm(null, new EventArgs());
formThread.Join();
}
form = null;
formThread = null;
}
}
}
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("TestBenchFramework")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko, a.s.")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2023 Sensus Slovensko, a.s.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.31.1988.0")]
[assembly: AssemblyFileVersion("2.31.1988.0")]
[assembly: AssemblyVersion("2.33.2138.0")]
[assembly: AssemblyFileVersion("2.33.2138.0")]
+85 -40
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", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
@@ -294,6 +294,15 @@ 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>
@@ -645,6 +654,15 @@ 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>
@@ -1275,6 +1293,15 @@ 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>
@@ -1896,6 +1923,15 @@ 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>
@@ -2256,6 +2292,15 @@ 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>
@@ -3597,6 +3642,15 @@ 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>
@@ -3823,11 +3877,11 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Print again.
/// Looks up a localized string similar to Print.
/// </summary>
internal static string Print_again {
internal static string Print {
get {
return ResourceManager.GetString("Print_again", resourceCulture);
return ResourceManager.GetString("Print", resourceCulture);
}
}
@@ -3885,6 +3939,15 @@ 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>
@@ -4281,33 +4344,6 @@ 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>
@@ -4317,15 +4353,6 @@ 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>
@@ -5100,6 +5127,15 @@ 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>
@@ -6273,6 +6309,15 @@ 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>
+32 -14
View File
@@ -673,10 +673,10 @@
<value>Tiskárna</value>
</data>
<data name="Procedure" xml:space="preserve">
<value>Postup</value>
<value>Procedura</value>
</data>
<data name="Procedures" xml:space="preserve">
<value>Postupy</value>
<value>Procedury</value>
</data>
<data name="Producer" xml:space="preserve">
<value>Výrobce</value>
@@ -688,7 +688,7 @@
<value>Restart programu vyžaduje použít některá nastavení</value>
</data>
<data name="Progress" xml:space="preserve">
<value>V činnosti</value>
<value>Postup</value>
</data>
<data name="Properties" xml:space="preserve">
<value>Vlastnosti</value>
@@ -732,18 +732,9 @@
<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>
@@ -1186,7 +1177,7 @@
<value>Tisk výsledků</value>
</data>
<data name="Procedure_name" xml:space="preserve">
<value>Jméno postupu</value>
<value>Jméno procedury</value>
</data>
<data name="Process" xml:space="preserve">
<value>Proces</value>
@@ -1222,7 +1213,7 @@
<value>Objem</value>
</data>
<data name="PrintBtnText" xml:space="preserve">
<value>Vytisknout</value>
<value>Tisknout</value>
</data>
<data name="Do_you_want_to_save_changes" xml:space="preserve">
<value>Chcete uložit změny?</value>
@@ -1683,4 +1674,31 @@
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Konfigurace testu {0} : chybí {1}</value>
</data>
<data name="Print" xml:space="preserve">
<value>Tisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>předvolená tiskárna</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Zjisti počet cyklů bez kontroly</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Nastav počet cyklů bez kontroly</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Odemknout vypnutí kontroly</value>
</data>
<data name="All_files" xml:space="preserve">
<value>Všechny soubory</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Kalibrační certifikát</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF soubory</value>
</data>
</root>
+2 -14
View File
@@ -1278,8 +1278,8 @@
<data name="Volume" xml:space="preserve">
<value>Volumen</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Druck wiederholen</value>
<data name="Print" xml:space="preserve">
<value>Drucken</value>
</data>
<data name="Show" xml:space="preserve">
<value>Anzeigen</value>
@@ -1545,9 +1545,6 @@
<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>
@@ -1575,12 +1572,6 @@
<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>
@@ -1644,9 +1635,6 @@
<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>
+3 -12
View File
@@ -633,9 +633,6 @@
<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>
@@ -987,12 +984,6 @@
<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>
@@ -1143,9 +1134,6 @@
<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>
@@ -2010,4 +1998,7 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimer</value>
</data>
</root>
+3 -15
View File
@@ -648,9 +648,6 @@
<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>
@@ -1002,12 +999,6 @@
<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>
@@ -1158,9 +1149,6 @@
<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>
@@ -1533,9 +1521,6 @@
<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>
@@ -1779,4 +1764,7 @@
<data name="Start_cycle" xml:space="preserve">
<value>Avviare il ciclo</value>
</data>
<data name="Print" xml:space="preserve">
<value>Stampa</value>
</data>
</root>
+3 -15
View File
@@ -691,9 +691,6 @@
<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>
@@ -1030,12 +1027,6 @@
<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>
@@ -1177,9 +1168,6 @@
<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>
@@ -1543,9 +1531,6 @@
<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>
@@ -1627,4 +1612,7 @@
<data name="Start_cycle" xml:space="preserve">
<value>Start cyklu</value>
</data>
<data name="Print" xml:space="preserve">
<value>Wydruk</value>
</data>
</root>
+29 -14
View File
@@ -643,9 +643,6 @@
<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>
@@ -997,12 +994,6 @@
<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>
@@ -1153,9 +1144,6 @@
<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>
@@ -1531,8 +1519,8 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Print again</value>
<data name="Print" xml:space="preserve">
<value>Print</value>
</data>
<data name="Show" xml:space="preserve">
<value>Show</value>
@@ -2320,4 +2308,31 @@
<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>
+3 -6
View File
@@ -546,12 +546,6 @@
<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>
@@ -831,4 +825,7 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimanta</value>
</data>
</root>
+3 -15
View File
@@ -633,9 +633,6 @@
<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>
@@ -990,12 +987,6 @@
<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>
@@ -1143,9 +1134,6 @@
<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>
@@ -1518,9 +1506,6 @@
<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>
@@ -1599,4 +1584,7 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Print" xml:space="preserve">
<value>Печатать</value>
</data>
</root>
+3 -9
View File
@@ -753,18 +753,9 @@
<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>
@@ -1191,4 +1182,7 @@
<data name="Evaporation" xml:space="preserve">
<value>蒸发</value>
</data>
<data name="Print" xml:space="preserve">
<value>打印机</value>
</data>
</root>
+3 -3
View File
@@ -88,10 +88,10 @@ namespace TBF.Rig.Ambient.Comet
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Common.Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.SetDtrToOne = setDtrCheckBox.Checked;
return flags;
+3 -3
View File
@@ -86,10 +86,10 @@ namespace TBF.Rig.Ambient.Greco
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = Common.Utils.GetHandshake(handshakeComboBox.SelectedItem.ToString());
return flags;
}
+2 -2
View File
@@ -96,9 +96,9 @@ namespace TBF.Rig.Danfoss.VLT2800
config.BusAddress = int.Parse(busAddressTextBox.Text);
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateTextBox.Text);
config.Parity = Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.Parity = Common.Utils.GetParity(parityComboBox.SelectedItem.ToString());
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.StopBits = Common.Utils.GetStopBits(stopBitsComboBox.SelectedItem.ToString());
return flags;
}
+19
View File
@@ -0,0 +1,19 @@
///
/// 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,6 +10,7 @@ using Config;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.BenchInfo.iPerl
{
@@ -56,35 +57,51 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}
}
}
@@ -47,6 +47,7 @@ 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; }
@@ -88,6 +89,7 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
MaxTestIndex = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -349,6 +351,10 @@ 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()
+39 -22
View File
@@ -1,10 +1,11 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Buoyancy
{
@@ -36,35 +37,51 @@ namespace TBF.Rig.DataContainers.Buoyancy
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}
}
}
@@ -27,6 +27,7 @@ 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; }
@@ -50,6 +51,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
Buoyancy = 1.00103;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -112,6 +114,10 @@ namespace TBF.Rig.DataContainers.Buoyancy
void CopyContentTo(ComponentCfg prms)
{
prms.Buoyancy = this.Buoyancy;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+39 -22
View File
@@ -1,10 +1,11 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Density
{
@@ -39,35 +40,51 @@ namespace TBF.Rig.DataContainers.Density
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}
}
}
@@ -28,6 +28,7 @@ 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; }
@@ -52,6 +53,7 @@ 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;
}
@@ -122,6 +124,10 @@ namespace TBF.Rig.DataContainers.Density
{
prms.RealDensity = this.RealDensity;
prms.AtTemperature = this.AtTemperature;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Density
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+39 -22
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using Config.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Evaporation
{
@@ -40,35 +41,51 @@ namespace TBF.Rig.DataContainers.Evaporation
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = myCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = myCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}
}
}
@@ -21,6 +21,7 @@ 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; }
@@ -42,6 +43,7 @@ namespace TBF.Rig.DataContainers.Evaporation
public void InitializeAll()
{
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -16,7 +16,7 @@ namespace TBF.Rig.DataContainers.Evaporation
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+131
View File
@@ -0,0 +1,131 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using Common;
namespace TBF.Rig.DataEntry
{
/// <summary>
/// Action of a DataEntry field
/// </summary>
public enum Ac
{
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
[Description("Last from history")] HistoryLast,
[Description("Load")] Load, /// Load from water meters when the form is open, save on OK
[Description("Load (readonly)")] LoadReadOnly, /// Load from water meters when the form is open, prevent changes, do not save
[Description("Set")] Set, /// Set to 'yes' when the form is open
Count,
}
/// <summary>
/// Content of a DataEntry field
/// </summary>
public enum Ct
{
[Description("None")] None,
[Description("Serial nr.")] SerialNr,
[Description("Serial nr. aux")] SerialNrAux,
[Description("Radio address")] RadioAddress,
[Description("Year of calibration")] YearOfCalibration,
[Description("Start state")] StartState,
[Description("Start state aux")] StartStateAux,
[Description("End state")] EndState,
[Description("End state aux")] EndStateAux,
[Description("Archive path")] ArchivePath,
[Description("WM Order")] WmOrder,
[Description("Batch order")] BatchOrder,
[Description("Batch and WM order")] BatchAndWmOrder,
[Description("WM Remark")] WmRemark,
[Description("Batch remark")] BatchRemark,
[Description("Batch and WM remark")] BatchAndWmRemark,
[Description("Print label")] PrintLabel,
#if ORACLE_DB
[Description("Prefix")] Prefix,
[Description("Suffix")] Suffix,
#endif
Count
}
/// <summary>
/// Function of the multi purpose button
/// </summary>
public enum MultiPurposeBtnFunction
{
None,
AutoSN,
PrintLabelsOnOff,
}
///
/// Identifies image instance
///
public enum Tst
{
Start,
End,
Both,
}
///
/// Image rotation
///
public enum Rotation
{
R0,
R90,
R180,
R270,
Count
}
public class DEItem
{
public readonly Ct Content;
public readonly string Caption;
public readonly Ac Action;
public readonly int Width;
public DEItem(Ct content, string caption, Ac action, int width)
{
Content = content;
Caption = caption;
Action = action;
Width = width;
}
static IList<DEItem> items = new List<DEItem>();
///
public static void ClearItems() { items.Clear(); }
public static void AddItem(DEItem item) { items.Add(item); }
public static void AddItem(Ct content, string caption, Ac action, int width)
{
items.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetItems() { return items; }
static IList<DEItem> columns = new List<DEItem>();
///
public static void ClearColumns() { columns.Clear(); }
public static void AddColumn(DEItem column) { columns.Add(column); }
public static void AddColumn(Ct content, string caption, Ac action, int width)
{
columns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetColumns() { return columns; }
static IList<DEItem> summaryColumns = new List<DEItem>();
///
public static void ClearSummaryColumns() { summaryColumns.Clear(); }
public static void AddSummaryColumn(DEItem column) { summaryColumns.Add(column); }
public static void AddSummaryColumn(Ct content, string caption, Ac action, int width)
{
summaryColumns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetSummaryColumns() { return summaryColumns; }
}
}
+84 -2
View File
@@ -1,13 +1,95 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry
{
public class DEUtils
{
public static string GetContent(Ct content, WaterMeter wm)
{
if (wm == null) return string.Empty;
switch (content)
{
default:
case Ct.None: return string.Empty;
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.StartStateAux: return string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.EndStateAux: return (!wm.Disabled && wm.GetEndStateAux() != null) ? wm.GetEndStateAux() : string.Empty;
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.PrintLabel: return wm.PrintLabel ? Strings.yes : Strings.no;
#if ORACLE_DB
case Ct.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Ct.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
#endif
}
}
public static void PutContent(Ct content, WaterMeter wm, string value)
{
if (wm == null || wm.Disabled) return;
int year;
switch (content)
{
default:
case Ct.None: return;
case Ct.SerialNr: wm.SerialNr = value; return;
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
case Ct.RadioAddress: wm.RadioAddress = value; return;
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
case Ct.StartState: wm.SetStartState(value); return;
case Ct.StartStateAux: return;
case Ct.EndState: wm.EndState = value; return;
case Ct.EndStateAux: wm.SetEndStateAux(value); return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
wm.PurchaseOrder = value;
return;
case Ct.BatchOrder:
case Ct.BatchAndWmOrder:
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
return;
case Ct.WmRemark:
wm.Remark = value;
return;
case Ct.BatchRemark:
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
case Ct.PrintLabel:
wm.PrintLabel = (value == Strings.yes);
return;
#if ORACLE_DB
case Ct.Prefix: wm.Prefix = value; return;
case Ct.Suffix: wm.Suffix = value; return;
#endif
}
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
@@ -488,6 +488,13 @@ namespace TBF.Rig.DataEntry.S620
/// <param name="currentFocusOwner">TextBox control which received the event</param>
private void ProcKeyPress(object sender, KeyPressEventArgs e, ComboBox currentFocusOwner)
{
if (e.KeyChar == 'ľ' || e.KeyChar == 'š' || e.KeyChar == 'č' || e.KeyChar == 'ť' || e.KeyChar == 'ž' || e.KeyChar == 'ý' || e.KeyChar == 'á' || e.KeyChar == 'í' || e.KeyChar == 'é')
{
MessageBox.Show("Zlá klávesnica !!!");
e.Handled = true;
return;
}
if (e.KeyChar == '+')
{
/// Process '+' key ..... Form completed
@@ -859,6 +859,13 @@ namespace TBF.Rig.DataEntry.S620
/// <param name="currentFocusOwner">TextBox control which received the event</param>
private void BodyNoTextBoxKeyPress(object sender, KeyPressEventArgs e, int wmNr0)
{
if (e.KeyChar == 'ľ' || e.KeyChar == 'š' || e.KeyChar == 'č' || e.KeyChar == 'ť' || e.KeyChar == 'ž' || e.KeyChar == 'ý' || e.KeyChar == 'á' || e.KeyChar == 'í' || e.KeyChar == 'é')
{
MessageBox.Show("Zlá klávesnica !!!");
e.Handled = true;
return;
}
if (closeButton != '\0' && e.KeyChar == closeButton)
{
/// Process '+' key ..... Form completed
@@ -467,7 +467,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
for (int i = 0; i < WaterMetersCount; i++)
{
double pulsesPerLtr = (regReaders != null && regReaders.Length > i) ? regReaders[i].PulsesPerLtr : 1;
double pulsesPerLtr = (regReaders != null && regReaders.Length > i && regReaders[i] != null) ? regReaders[i].PulsesPerLtr : 1;
GetOcrParameters(pulsesPerLtr, out denominator, out format);
if ((mode == Tst.Start || mode == Tst.Both) && startTextBoxes[wm2phys[i + 1]].Enabled &&
+909
View File
@@ -0,0 +1,909 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class CycleBgEnForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBgEnForm));
/// Arguments
public readonly IList<WaterMeter> WaterMeters;
readonly int lineSize;
readonly Sz sz;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> commonItems;
readonly IList<DEItem> colItems;
readonly bool isEnd;
readonly string formCloseKeys;
/// Derived from arguments in the constructor
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly int commonItemsCount;
/// Size and layout related values
readonly Font font;
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int buttonsWidth;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] commonLabels;
readonly ComboBox[] commonComboBoxes;
readonly Label[] labels; /// Labels for water meter numbers
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
readonly MultiPurposeBtnFunction multiPurposeButtonFn;
bool multiPurposeButtonFlag;
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public CycleBgEnForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="commonItems">Common items displayed in the upper part of the form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="isEnd">true = This form is displayed at the end of cycle</param>
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
: this()
{
/// Arguments
this.WaterMeters = waterMeters;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.commonItems = commonItems;
this.colItems = colItems;
this.isEnd = isEnd;
/// Preserve column items for use in SummaryResults
if (!isEnd)
{
/// cycle beginning
DEItem.ClearSummaryColumns();
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
else
{
/// cycle end
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
commonItemsCount = (commonItems == null) ? 0 : commonItems.Count;
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
///
commonLabels = new Label[commonItemsCount];
commonComboBoxes = new ComboBox[commonItemsCount];
labels = new Label[wmsCount];
comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount];
///
/// Determine the multi purpose button function
///
multiPurposeButton.Visible = false;
multiPurposeButtonFn = MultiPurposeBtnFunction.None;
int buttonsWidth = 350;
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = "Auto s/n";
multiPurposeButtonFn = MultiPurposeBtnFunction.AutoSN;
buttonsWidth += 147;
break;
}
if (colItems[k].Content == Ct.PrintLabel)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = string.Format("{0} ({1}/{2})", Strings.Print, Strings.yes, Strings.no);
multiPurposeButtonFn = MultiPurposeBtnFunction.PrintLabelsOnOff;
multiPurposeButtonFlag = false;
buttonsWidth += 147;
break;
}
}
/// Layout related readonly variables derived from argument 'sz'
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
this.buttonsWidth = buttonsWidth;
hdrHeight = 120;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
this.buttonsWidth = buttonsWidth;
hdrHeight = 140;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
this.buttonsWidth = buttonsWidth;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Group box with common items
///
int groupBoxWidth = 0;
int groupBoxHeight = 0;
if (commonItemsCount > 0)
{
var groupBox = new GroupBox();
int labelsWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width);
var oneLabel = new Label
{
Text = commonItems[ix].Caption,
Font = font,
Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(oneLabelWidth + spacing, meterHeight),
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = groupBox,
};
groupBox.Controls.Add(oneLabel);
labelsWidth = Math.Max(labelsWidth, oneLabelWidth);
}
int combosWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
var cb = new ComboBox
{
Name = string.Format("-1~{0}", ix + 1),
Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(commonItems[ix].Width, meterHeight),
Enabled = (commonItems[ix].Action != Ac.LoadReadOnly),
Font = font,
TabIndex = tabIndex++,
Parent = groupBox,
};
cb.SelectedIndexChanged += new System.EventHandler(comboBox_SelectedIndexChanged);
cb.TextChanged += new System.EventHandler(comboBox_TextChanged);
cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(comboBox_KeyPress);
switch (ix)
{
case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break;
case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break;
case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break;
}
commonComboBoxes[ix] = cb;
groupBox.Controls.Add(cb);
combosWidth = Math.Max(combosWidth, commonItems[ix].Width);
}
///
groupBox.Location = new Point(margin, margin - spacing);
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing;
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
groupBox.Font = font;
groupBox.TabIndex = tabIndex++;
groupBox.Parent = this;
this.Controls.Add(groupBox);
}
///
/// Table
///
int commonCheckBoxLeft = 0;
int commonCheckBoxTop = 0;
int columnsTop = Math.Max(hdrHeight, groupBoxHeight + 2 * margin + spacing);
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var comboBox = new ComboBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
comboBox.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
comboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
if (ci.Content == Ct.PrintLabel)
{
comboBox.Items.Add(Strings.yes);
comboBox.Items.Add(Strings.no);
}
else
{
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
}
left += ci.Width + spacing;
comboBoxes[k, wmPos0] = comboBox;
this.Controls.Add(comboBox);
}
var checkBox = new CheckBox
{
Location = new Point(left, top + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
checkBoxes[wmPos0] = checkBox;
this.Controls.Add(checkBox);
if (commonCheckBoxLeft == 0)
{
commonCheckBoxLeft = left;
commonCheckBoxTop = columnsTop - meterHeight;
}
}
okButton.TabIndex = tabIndex++;
clearButton.TabIndex = tabIndex++;
var commonCheckBox = new CheckBox
{
Location = new Point(commonCheckBoxLeft, commonCheckBoxTop + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
commonCheckBox.CheckedChanged += new System.EventHandler(commonCheckBox_CheckedChanged);
this.Controls.Add(commonCheckBox);
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + buttonsWidth),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
bool activeControlFound = false;
for (int ix = 0; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
ActiveControl = commonComboBoxes[ix];
activeControlFound = true;
break;
}
}
if (!activeControlFound)
{
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
int k, j;
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
ActiveControl = okButton;
}
else
{
ActiveControl = comboBoxes[k, j];
}
}
}
/// <summary>
/// Add combo box items from a history stored in a string array (obtained usually from LocalSettings)
/// </summary>
/// <param name="comboBox">ComboBox to prepare</param>
/// <param name="history">String array with a history</param>
void AddHistoryToCombo(ComboBox comboBox, string[] history)
{
if (history != null)
{
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
}
}
/// <summary>
/// Returns an array of strings from ls.
/// Never returns null, null is converted to new string[0].
/// </summary>
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
/// <param name="k">Column number (0-based)</param>
/// <returns>Array of strings</returns>
string[] GetHistoryFromLS(bool isEnd, int k)
{
if (isEnd)
{
switch (k)
{
case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA;
case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB;
case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC;
case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD;
case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE;
default: return new string[0];
}
}
else
{
switch (k)
{
case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA;
case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB;
case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC;
case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD;
case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE;
default: return new string[0];
}
}
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
clearButton.Text = Strings.ClearBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Common combo boxes
for (int ix = 0; ix < commonItemsCount; ix++)
{
switch (commonItems[ix].Action)
{
default:
case Ac.Clear:
commonComboBoxes[ix].Text = string.Empty;
break;
case Ac.HistoryLast:
commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0)
? commonComboBoxes[ix].Items[0].ToString()
: string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
break;
case Ac.Set:
commonComboBoxes[ix].Text = Strings.yes;
break;
}
}
/// Table
for (int k = 0; k < colItems.Count; k++)
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
break;
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
}
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
}
break;
case Ac.Set:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = (WaterMeters[i] != null && !WaterMeters[i].Disabled) ? Strings.yes : Strings.no;
}
break;
}
}
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = isEnd ? (WaterMeters[i] != null && !WaterMeters[i].Disabled) : false;
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int ix = 0; ix < commonItemsCount; ix++ )
{
DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text);
if (commonItems[ix].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break;
}
}
else
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break;
}
}
}
///
/// Propagate common (batch) values to water meters in case of
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
///
foreach (var wm in WaterMeters)
{
if (wm != null && !wm.Disabled)
{
switch (commonItems[ix].Content)
{
case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break;
case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break;
case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break;
case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break;
}
}
}
}
for (int k = 0; k < colItems.Count; k++)
{
/// Store values to water meters and prepare an array for a history in the LocalSettings
var currentVals = new string[wmsCount];
for (int i = 0; i < wmsCount; i++)
{
DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
currentVals[i] = comboBoxes[k, i].Text;
}
/// Update history
if (colItems[k].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (k)
{
case 0: ls.LastEnColA = currentVals; break;
case 1: ls.LastEnColB = currentVals; break;
case 2: ls.LastEnColC = currentVals; break;
case 3: ls.LastEnColD = currentVals; break;
case 4: ls.LastEnColE = currentVals; break;
}
}
else
{
switch (k)
{
case 0: ls.LastBgColA = currentVals; break;
case 1: ls.LastBgColB = currentVals; break;
case 2: ls.LastBgColC = currentVals; break;
case 3: ls.LastBgColD = currentVals; break;
case 4: ls.LastBgColE = currentVals; break;
}
}
}
}
for (int i = 0; i < wmsCount; i++)
{
if (WaterMeters[i] != null) WaterMeters[i].Disabled = !checkBoxes[i].Checked;
}
}
private void commonCheckBox_CheckedChanged(object sender, EventArgs e)
{
bool state = (sender as CheckBox).Checked;
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = state;
}
}
private void okButton_Click(object sender, EventArgs e)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
InitializeBoxes();
}
private void multiPurposeButton_Click(object sender, EventArgs e)
{
if (multiPurposeButtonFn == MultiPurposeBtnFunction.None) return;
if (multiPurposeButtonFn == MultiPurposeBtnFunction.AutoSN)
{
///
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{
if (checkBoxes[firstIx].Checked) break;
}
if (firstIx == wmsCount)
{
return; /// There is not any enabled water meter
}
char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
///
/// Column with serial numbers found => perform an auto s/n assignment
///
string firstSN = comboBoxes[k, firstIx].Text;
int firstSnNr;
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0)
{
int lastDigitPosPlus1 = startIx + 1;
var listOfDigits = new List<char>(digits);
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1]))
{
lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0)
{
for (int ix = firstIx + 1; ix < wmsCount; ix++)
{
if (checkBoxes[ix].Checked)
{
firstSnNr++;
string newSN = firstSnNr.ToString();
int len = newSN.Length;
if (len <= digitsCount)
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
}
else
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
}
}
}
}
}
}
}
}
if (multiPurposeButtonFn == MultiPurposeBtnFunction.PrintLabelsOnOff)
{
///
/// Find a column with Ct.PrintLabel
///
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.PrintLabel)
{
for (int ix = 0; ix < wmsCount; ix++)
{
if (WaterMeters[ix] != null && !WaterMeters[ix].Disabled)
{
comboBoxes[k, ix].Text = multiPurposeButtonFlag ? Strings.yes : Strings.no;
}
}
}
}
multiPurposeButtonFlag = !multiPurposeButtonFlag;
}
}
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
isHandlersEnabled = false;
if (k >= 0 && colItems[k].Content != Ct.PrintLabel && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
{
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items[0].ToString();
if (!string.IsNullOrEmpty(comboBoxes[k, i].Text)) checkBoxes[i].Checked = true;
}
}
isHandlersEnabled = true;
}
private void comboBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
if (e.KeyChar == '\r')
{
if (k < 0)
{
for (int ix = j; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
commonComboBoxes[ix].Focus();
return;
}
}
/// No next enabled common item found:
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
}
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
comboBoxes[k, j].Focus();
}
}
}
private void comboBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
if (k >= 0) checkBoxes[j].Checked = true;
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="comboBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledCombo(ComboBox[,] comboBoxes, ref int k, ref int i, bool isLrOrder)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == comboBoxes.GetLength(0))
{
k = 0;
if (++i == comboBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == comboBoxes.GetLength(1))
{
i = 0;
if (++k == comboBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!comboBoxes[k, i].Enabled);
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
+86
View File
@@ -0,0 +1,86 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class CycleBgEnForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.multiPurposeButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// clearButton
//
resources.ApplyResources(this.clearButton, "clearButton");
this.clearButton.ForeColor = System.Drawing.Color.Black;
this.clearButton.Name = "clearButton";
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// multiPurposeButton
//
resources.ApplyResources(this.multiPurposeButton, "multiPurposeButton");
this.multiPurposeButton.ForeColor = System.Drawing.Color.Black;
this.multiPurposeButton.Name = "multiPurposeButton";
this.multiPurposeButton.UseVisualStyleBackColor = true;
this.multiPurposeButton.Click += new System.EventHandler(this.multiPurposeButton_Click);
//
// CycleBgEnForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.multiPurposeButton);
this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "CycleBgEnForm";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button multiPurposeButton;
}
}
+246
View File
@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="okButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>942, 26</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="clearButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="clearButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="clearButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="clearButton.Location" type="System.Drawing.Point, System.Drawing">
<value>795, 26</value>
</data>
<data name="clearButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="clearButton.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="clearButton.Text" xml:space="preserve">
<value>Clear</value>
</data>
<data name="&gt;&gt;clearButton.Name" xml:space="preserve">
<value>clearButton</value>
</data>
<data name="&gt;&gt;clearButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;clearButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="multiPurposeButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="multiPurposeButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="multiPurposeButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="multiPurposeButton.Location" type="System.Drawing.Point, System.Drawing">
<value>648, 26</value>
</data>
<data name="multiPurposeButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="multiPurposeButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="multiPurposeButton.Text" xml:space="preserve">
<value>Multi purpose</value>
</data>
<data name="multiPurposeButton.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Name" xml:space="preserve">
<value>multiPurposeButton</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;multiPurposeButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1094, 561</value>
</data>
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>10000, 10000</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Batch data</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CycleBgEnForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
+20
View File
@@ -0,0 +1,20 @@
///
/// 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
@@ -0,0 +1,305 @@
///
/// 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
@@ -0,0 +1,25 @@
///
/// 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);
}
}
}
@@ -0,0 +1,24 @@
///
/// 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
@@ -0,0 +1,600 @@
///
/// 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
@@ -0,0 +1,114 @@
///
/// 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,5 +1,5 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -193,7 +193,7 @@ namespace TBF.Rig.DataEntry.iPerl
private void okButton_Click(object sender, EventArgs e)
{
if (orderComboBox.Text.Length > 8 ||
if (orderComboBox.Text.Length > 10 ||
(cfg.Orders != Orders.Arbitrary && !orderComboBox.Items.Contains(orderComboBox.Text)))
{
MessageBox.Show(Strings.Invalid_order_number, Strings.Error, MessageBoxButtons.OK,
+2 -2
View File
@@ -120,11 +120,11 @@ namespace TBF.Rig.Elde
public byte[] MeretRS485Address = new byte[4];
#endif
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
#elif CEVAK_200 || DN100 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || SENTEC
#elif CEVAK_200 || DN100 || FUZHOU_150 || IZRAEL_200 || SENTEC
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[6] { 1, 1, 1, 1, 1, 1 };
#elif BERLIN || GELSENWASSER || GENESIS || PETERSBURG_200 || PUCHONG_200 || RUM_MOB || SLM_150
#elif BERLIN || FUZHOU_300 || GELSENWASSER || GENESIS || PETERSBURG_200 || PUCHONG_200 || RUM_MOB || SLM_150
public uint[,] RegValveCalib = new uint[16, 2] { {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500},
{100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500} };
public byte[] MeretRS485Address = new byte[4];
+2 -2
View File
@@ -82,7 +82,7 @@ namespace TBF.Rig.Elde
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
#endif
#if ALZIR_25 || BADGER_STREDNA_TRAT || BAHRAIN_50 || CEVAK_200 || DEWA_300 || FEWA_50 || FUZHOU_100 || FILIPINY_50 || GELSENWASSER || GENESIS || HONGKONG_50 || IZRAEL_25 || IZRAEL_50 || JUZNA_AFRIKA_50 || KEMPNO_50 || KRAKOW_50 || LUXEMBURG_40 || MILWAUKEE || PUCHONG_200 || ROMA_200 || SENTEC || TURA_IPERL_NEW || WARSAW_50 || ZAMBIA || ZODINO
#if ALZIR_25 || BADGER_STREDNA_TRAT || BAHRAIN_50 || CEVAK_200 || DEWA_300 || FEWA_50 || FUZHOU_100 || FUZHOU_300 || FILIPINY_50 || GELSENWASSER || GENESIS || HONGKONG_50 || IZRAEL_25 || IZRAEL_50 || JUZNA_AFRIKA_50 || KEMPNO_50 || KRAKOW_50 || LUXEMBURG_40 || MILWAUKEE || PUCHONG_200 || ROMA_200 || SENTEC || TURA_IPERL_NEW || WARSAW_50 || ZAMBIA || ZODINO
public uint DivTime(int id) { return ctrlBrdComponent.divTime[id]; }
public void SetDivLimit(int divNo, uint limLoPct, uint limHiPct)
{
@@ -115,7 +115,7 @@ namespace TBF.Rig.Elde
}
public float DivSamples(int time, int divIx0)
{
#if FUZHOU_50 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || MUNICH
#if FUZHOU_50 || FUZHOU_150 || IZRAEL_200 || MUNICH
return ctrlBrdComponent.DIVSamples[time, 0];
#else
return ctrlBrdComponent.DIVSamples[time, divIx0];
+1 -1
View File
@@ -56,7 +56,7 @@ namespace TBF.Rig.Elde.CoverTest
{
if (!Users.CurrentUser.IsMemberOf(bypassLevel))
{
if ((new Users.Forms.LoginDlg(bypassLevel, this)).ShowDialog() != DialogResult.OK)
if ((new Users.Forms.LoginDlg(TBF.DB.UserSessionFactories, bypassLevel, this)).ShowDialog() != DialogResult.OK)
{
return;
}
+43 -24
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -9,6 +9,7 @@ using Dirichlet.Numerics;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.Diverter
{
@@ -91,8 +92,10 @@ namespace TBF.Rig.Elde.Diverter
}
else
{
log.ErrorFormat("Unable to set {0} ADC levels: RegValveCalib array size={1}, diverter AdcNr={2}",
Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr);
string message = string.Format("Cannot save calibration: RegValveCalib[] size={1}, ADC#={2}",
Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr);
log.Error(message);
throw new Exception(message);
}
}
@@ -150,35 +153,51 @@ namespace TBF.Rig.Elde.Diverter
///
/// Calendar support
///
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = diverterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = diverterCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}
///
+2
View File
@@ -31,6 +31,7 @@ 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; }
@@ -53,6 +54,7 @@ namespace TBF.Rig.Elde.Diverter
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
+40 -23
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using Config.Entities;
using TBF.Boxes;
using TBF.Resources;
using TBF.UI.Calendar;
namespace TBF.Rig.Elde.FlowMeter
{
@@ -68,7 +69,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));
@@ -86,35 +87,51 @@ namespace TBF.Rig.Elde.FlowMeter
///
/// Calendar support
///
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
public List<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = flowMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
var calEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
DateTime calibDue = flowMeterCfg.CalibValidDate;
if (calibDue > TBF.UI.Constants.MinDate)
{
/// 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))
/// Five weekly notifications
foreach (var days in new int[] { -35, -28, -21, -14 })
{
/// 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));
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))));
}
}
if (DateTime.Now.Date <= calibrationDue.Date)
/// Five daily warnings
foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
/// 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));
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))));
}
}
return calendarEvents;
return calEvents;
}

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