Compare commits

..
Author SHA1 Message Date
Jan Augustin 6cb4b2bba8 Null exception fix - save again results to Oracle database. 2024-11-06 06:57:37 +01:00
Jan Augustin 56c2aeb647 New ControlComponent3U.dll for Fuzhou150 2024-10-10 09:31:19 +02:00
Jan Augustin a4d7dccde9 System.NullReferenceException fix. 2024-09-26 09:31:14 +02:00
Jan Augustin 74655e976f System.NullReferenceException fix. 2024-07-30 09:44:27 +02:00
Jan Augustin 7486b2a490 Improve NFC communication (also updated NfcS5_DLL project) 2024-07-25 12:08:15 +02:00
Jan Augustin 6e62be6e6c IperlHead component test optimization 2024-07-10 08:02:37 +02:00
Jan Augustin 6c7dbfa5a0 Add test tab to iPerlHead component configuration 2024-06-27 10:02:25 +02:00
Jan Augustin c77fd822a6 Bug fixes.
Oracle DB: In the vt_zaehler_pindex_pd.korrimprate should be new CalibFactor, not OrigCalibFactor (Joern Goegge)
2024-03-28 08:53:39 +01:00
Jan Augustin 60f30d65fd NFC communication debugging 2024-03-13 10:47:30 +01:00
Jan Augustin 704232d231 Splitted Q3 test (part 1,2) for Suez procedures causes problem with unique indexes in oracle tables vt_pruefdurchfluss_pd, vt_zaehler_pindex_pd 2024-03-12 09:17:07 +01:00
Jan Augustin 79c5c022ea NFC S5 support 2024-02-28 12:42:37 +01:00
Jan Augustin 5bea046c01 PowerUser name fix. 2024-02-28 12:18:25 +01:00
Milan Hanajik 6226a2812b 1. State.RunOperations() is try-catch protected (Event.Crashed), 2. Saving and printing results modified, ver. 2.33.2140 2024-01-04 12:50:02 +01:00
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
Milan Hanajik 604120e2b8 Test profile includes test method, ver. 2.31.1988 2022-11-18 13:35:43 +01:00
Milan Hanajik d29d8be81a FixedStartMassCollection : Flow adjustment during measurement, ver. 2.30.1987 2022-11-18 12:34:31 +01:00
Milan Hanajik 6a374c5af0 Approval by legalizator only when !string.IsNullOrEmpty(AltProcName), legalizator full name used in reports, ver. 2.30.1986 2022-11-18 11:55:23 +01:00
Milan Hanajik a14e21eb57 Profile import fixed. 2022-11-18 10:52:36 +01:00
Milan Hanajik 100a357fc1 MainSeq: Approval by legalizator, ver. 2.30.1984 2022-11-18 10:52:36 +01:00
Milan Hanajik 75fcffc9c3 Create from profile button in ProceduresDlg enabled again, etc, ver. 2.30.1983 2022-11-18 10:52:36 +01:00
Milan Hanajik 8d6d0c011b Procedures : Selection via profiles, More column can display profile, ver. 2.30.1982 2022-11-16 06:50:18 +01:00
Milan Hanajik be8f6814c8 Power user password changes. 2022-11-14 07:09:39 +01:00
Milan Hanajik 75766938be FixedStartMassCollection : Diverter to tank after start valve is closed, 'Winiki lub E' support MeterTestRslt, ver. 2.30.1980 2022-11-10 15:39:12 +01:00
Milan Hanajik 08b3ab45ba Browsing previous results : SerialNr can be used as search criterion, ver. 2.30.1978 2022-11-09 11:22:39 +01:00
Milan Hanajik 0539844d85 RegValvePosition class with RV/position pair, FeedingPath RV positions used in sequences, ver. 2.30.1976 2022-11-04 12:23:22 +01:00
Milan Hanajik da7ac83c75 Bug fix : Prevent crash in certain cases when using MakeSimulated( ). 2022-11-04 12:23:22 +01:00
Milan Hanajik 01f0c03f62 Bug fix : Prevent crash in certain cases when using MakeSimulated( ). 2022-11-02 08:57:57 +01:00
Milan Hanajik 9ac1b0b6fa Project dependencies fixed 2022-10-19 08:18:29 +02:00
Milan Hanajik 685d57db8b Clean-up 2022-10-10 08:12:49 +02:00
Milan Hanajik 7de5551c24 IperLogger.ProcParams (DesigMode, DesigType), etc. 2022-10-04 11:31:58 +02:00
Milan Hanajik 36c52e5d7e DataEntry.StandardCamera changes - OCR as for Hong Kong, ver. 2.30.1971 2022-10-04 11:29:45 +02:00
Milan Hanajik 9f6bfc6410 1 Common.Enums.Mounting.HV added, 2 iPerlCommunicationForm bug fix, ver. 2.30.1966 2022-09-26 17:09:30 +02:00
Milan Hanajik 81498a6db4 LiveStream : New default values for OverlayLeft/Top/Width/Height test parameters. 2022-09-26 09:47:58 +02:00
Milan Hanajik a595b6cd8d TURA_SPECIAL : WMsCount = LineSize = 8, ver. 2.30.1962 2022-09-19 09:25:45 +02:00
Milan Hanajik 668d68a80c ver. 2.30.1960 2022-09-14 08:34:27 +02:00
Milan Hanajik 61ea3ef86b Renaming transition sequences enhanced, ver. 2.30.1959 2022-09-08 12:46:03 +02:00
Milan Hanajik a7118935ca iPerlCommunication : Sequence conditions 2022-09-08 12:45:54 +02:00
Milan Hanajik b044b00571 Start/EndTestingSealedMeter activity for iPerlCommunicationForm. 2022-09-06 21:20:49 +02:00
Milan Hanajik 0e77a31a0f Remote database exception logging, ver. 2.30.1956 2022-09-06 13:44:48 +02:00
Milan Hanajik 2183d1c452 Components with proc. params. in 'More" tab in ProcedureDlg are determined automatically, ver. 2.30.1955 2022-09-04 21:01:39 +02:00
Milan Hanajik be97777159 1 CLP1611.Camera scp file upload disabled, 2 LiveStream method displays an overlay (test param.) in the image stream. 2022-08-30 14:58:27 +02:00
Milan Hanajik 4781acf3e2 Camera.CLP1611.GrabImagesOp does not delete and overwrite images in simulation mode. 2022-08-30 14:58:27 +02:00
Milan Hanajik 207d4be3d6 Batch nr. is displayed in MainWnd 2022-08-30 14:58:26 +02:00
Milan 92b2f55871 Clean-up 2022-08-30 14:58:26 +02:00
Milan Hanajik 0fd0c44c18 Better on-screen error message when a path is missing in a test. 2022-08-30 14:58:26 +02:00
Milan Hanajik 5629b94e47 All projects targer .Net Framework 4.7.2 2022-07-28 12:45:00 +02:00
Milan Hanajik 3bff80f64b Selectors are used in TestWizard in FlowSelection and TestProfileSelection, Map(x => x.selectors) in all paths, ver. 2.30.1930 2022-07-01 11:59:34 +02:00
Milan Hanajik b3df3307a0 When using 'Create from Profile' the generated tests can be renamed, order of profilesin ComboBox. 2022-06-30 17:48:17 +02:00
Milan Hanajik 1f12464218 TBF.UI.Procedures.Formulas static class, refactorization. 2022-06-28 12:26:01 +02:00
Milan Hanajik b17282f826 UI.Procedures.TestWizard.TestProfileSelection : Q1/2/3/4/min/t/n/max/p/i are not case sensitive, ver. 2.29.1929 2022-06-28 11:10:06 +02:00
Milan Hanajik ae348d13fd Custom units in MetrologyDlg tabs : Bug fixes : 1. Test after adding a value, 2. test of FlowMeter+rangeIx, ver. 2.29.1927 2022-06-23 15:30:51 +02:00
Milan Hanajik e7ab26669e Custom units in MetrologyDlg tabs Balance, FlowMeter, PressMeter and TempMeter, ver. 2.29.1926 2022-06-22 13:52:13 +02:00
427 changed files with 19999 additions and 9677 deletions
+22
View File
@@ -54,6 +54,28 @@ Users/bin/
Users/obj/
UserManagement/bin/
UserManagement/obj/
DataMatrix4Net/bin/
DataMatrix4Net/obj/
GenericTest/bin/
GenericTest/obj/
LabelPrinting/bin/
LabelPrinting/obj/
OrderManagement/bin/
OrderManagement/obj/
ProductionTracing/bin/
ProductionTracing/obj/
RecordProcessing/bin/
RecordProcessing/obj/
S640TestApp/bin/
S640TestApp/obj/
SchematicDrawing/bin/
SchematicDrawing/obj/
SharedDatabase/bin/
SharedDatabase/obj/
WorkflowConfigurator/bin/
WorkflowConfigurator/obj/
Workplace/bin/
Workplace/obj/
.vs/
*.suo
*.bak
+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()
+27 -14
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;
@@ -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
@@ -103,6 +94,17 @@ namespace Common
}
}
/// <summary>
/// Test designation mode for IperlLogger and IperlHead opto data files
/// </summary>
public enum DesigMode
{
Auto,
Based_on_procedure,
As_specified,
Count
}
public enum LoginMethod
{
UserName, /// = alias, abbreviation
@@ -212,6 +214,14 @@ namespace Common
Count,
}
public enum FlowNames
{
QnQtQmin = 0,
Q3Q2Q1 = 1,
QpQi = 2,
Count,
}
public enum ProfileType
{
Q3R,
@@ -293,11 +303,13 @@ namespace Common
[Description("V")] V, /// vertical
[Description("STR")] S, /// standrohre
[Description("F")] F, /// fall
[Description("H/V")] HV, /// horizontal / vertical
#else
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("S")] S, /// steig
[Description("F")] F, /// fall
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("S")] S, /// steig
[Description("F")] F, /// fall
[Description("H/V")] HV, /// horizontal / vertical
#endif
Count
}
@@ -329,6 +341,7 @@ namespace Common
[Description("")] NotSpecified,
[Description("U0")] U0, /// ?
[Description("D0")] D0, /// ?
///
Count
}
+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;
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Common
public interface IMeasurementCorrection
{
int RangeIx { get; set; }
float Measurement { get; set; }
float Correction { get; set; }
double Measurement { get; set; }
double Correction { get; set; }
}
}
+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("")]
+92 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
///
using System;
using System.IO.Ports;
@@ -15,6 +15,97 @@ namespace Common
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
}
public static string ToNiceString(double value, int sigDigits)
{
string format = SignificantDigitsToFmt(value, sigDigits);
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)
{
if (value >= 99999.5 || value < -99999.5) return "F0";
else if (value >= 9999.95 || value < -9999.95) return "F1";
else if (value >= 999.995 || value < -999.995) return "F2";
else if (value >= 99.9995 || value < -99.9995) return "F3";
else if (value >= 9.99995 || value < -9.99995) return "F4";
else if (value >= 0.999995 || value < -0.999995) return "F5";
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
else return "F10";
}
else if (sigDigits == 5)
{
if (value >= 9999.5 || value < -9999.5) return "F0";
else if (value >= 999.95 || value < -999.95) return "F1";
else if (value >= 99.995 || value < -99.995) return "F2";
else if (value >= 9.9995 || value < -9.9995) return "F3";
else if (value >= 0.99995 || value < -0.99995) return "F4";
else if (value >= 0.099995 || value < -0.099995) return "F5";
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
else return "F9";
}
else if (sigDigits == 4)
{
if (value >= 999.5 || value < -999.5) return "F0";
else if (value >= 99.95 || value < -99.95) return "F1";
else if (value >= 9.995 || value < -9.995) return "F2";
else if (value >= 0.9995 || value < -0.9995) return "F3";
else if (value >= 0.09995 || value < -0.09995) return "F4";
else if (value >= 0.009995 || value < -0.009995) return "F5";
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
else return "F8";
}
else if (sigDigits == 3)
{
if (value >= 99.5 || value < -99.5) return "F0";
else if (value >= 9.95 || value < -9.95) return "F1";
else if (value >= 0.995 || value < -0.995) return "F2";
else if (value >= 0.0995 || value < -0.0995) return "F3";
else if (value >= 0.00995 || value < -0.00995) return "F4";
else if (value >= 0.000995 || value < -0.000995) return "F5";
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
else return "F7";
}
else if (sigDigits == 2)
{
if (value >= 9.5 || value < -9.5) return "F0";
else if (value >= 0.95 || value < -0.95) return "F1";
else if (value >= 0.095 || value < -0.095) return "F2";
else if (value >= 0.0095 || value < -0.0095) return "F3";
else if (value >= 0.00095 || value < -0.00095) return "F4";
else if (value >= 0.000095 || value < -0.000095) return "F5";
else return "F6";
}
else /// if (sigDigits == 1)
{
if (value >= 0.95 || value < -0.95) return "F0";
else if (value >= 0.095 || value < -0.095) return "F1";
else if (value >= 0.0095 || value < -0.0095) return "F2";
else if (value >= 0.00095 || value < -0.00095) return "F3";
else if (value >= 0.000095 || value < -0.000095) return "F4";
else return "F5";
}
}
public static Parity GetParity(string str, Parity defaultParity = Parity.None)
{
if (str.Equals(Parity.None.ToString())) return Parity.None;
+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);
}
}
+2 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE;DEBUG;MUNICH</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -30,7 +30,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE;MUNICH</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+7 -1
View File
@@ -26,7 +26,7 @@ namespace Config
public const int CompoundWMsCount = 0;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 1;
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50 || TURA_SPECIAL
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
@@ -44,6 +44,12 @@ namespace Config
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;
}
+13 -4
View File
@@ -1,17 +1,17 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class MeasurementCorrection : Common.IMeasurementCorrection
public class MeasurementCorrection : Common.IMeasurementCorrection, IComparable<MeasurementCorrection>
{
public virtual int Id { get; protected set; }
public virtual int RangeIx { get; set; } /// 0..5
public virtual float Measurement { get; set; }
public virtual float Correction { get; set; }
public virtual double Measurement { get; set; }
public virtual double Correction { get; set; }
public MeasurementCorrection()
{
@@ -23,6 +23,10 @@ namespace Config.Entities
RangeIx = rangeIx;
}
public virtual int CompareTo(MeasurementCorrection other)
{
return (Measurement > other.Measurement) ? 1 : ((Measurement == other.Measurement) ? 0 : -1);
}
/// <summary>
/// Calculates corrected value from a list of corrections by interpolation.
@@ -76,5 +80,10 @@ namespace Config.Entities
/// rawValue is above the highest value in the correction table
return corrections[corrections.Count - 1].Correction;
}
public override string ToString()
{
return string.Format("{0} {1} ({2})", Measurement, Correction, RangeIx);
}
}
}
+27 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
@@ -27,6 +27,7 @@ namespace Config.Entities
public virtual double PressLimHi { get; set; } /// [bar] max. water pressure
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool Evaluate { get; set; }
public virtual string Method { get; set; } /// Test method (component name)
public virtual sbyte E1 { get; set; } ///
public virtual sbyte E2 { get; set; } ///
@@ -81,6 +82,7 @@ namespace Config.Entities
PressLimHi = 16.0; /// [bar]
Publish = (sbyte)Common.Publish.Always;
Evaluate = true;
Method = string.Empty;
E1 = (sbyte)ErrorFlagsMode.On;
E2 = (sbyte)ErrorFlagsMode.On;
@@ -140,6 +142,7 @@ namespace Config.Entities
result.PressLimHi = PressLimHi;
result.Publish = Publish;
result.Evaluate = Evaluate;
result.Method = Method;
result.E1 = E1;
result.E2 = E2;
@@ -193,6 +196,7 @@ namespace Config.Entities
output.WriteLine(PressLimHi.ToString(ci));
output.WriteLine(Publish.ToString());
output.WriteLine(Evaluate.ToString());
output.WriteLine(Method);
output.WriteLine(E1.ToString());
output.WriteLine(E2.ToString());
@@ -247,10 +251,29 @@ namespace Config.Entities
tst.ErrLimHi = double.Parse(input.ReadLine(), ci);
tst.TempLimLo = double.Parse(input.ReadLine(), ci);
tst.TempLimHi = double.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine());
tst.PressLimLo = double.Parse(input.ReadLine(), ci);
tst.PressLimHi = double.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.Evaluate = bool.Parse(input.ReadLine());
tst.Method = input.ReadLine();
/// TODO (E1 .. E21)
tst.E1 = sbyte.Parse(input.ReadLine(), ci);
tst.E2 = sbyte.Parse(input.ReadLine(), ci);
tst.E3 = sbyte.Parse(input.ReadLine(), ci);
tst.E4 = sbyte.Parse(input.ReadLine(), ci);
tst.E5 = sbyte.Parse(input.ReadLine(), ci);
tst.E6 = sbyte.Parse(input.ReadLine(), ci);
tst.E7 = sbyte.Parse(input.ReadLine(), ci);
tst.E8 = sbyte.Parse(input.ReadLine(), ci);
tst.E9 = sbyte.Parse(input.ReadLine(), ci);
tst.E10 = sbyte.Parse(input.ReadLine(), ci);
tst.E11 = sbyte.Parse(input.ReadLine(), ci);
tst.E12 = sbyte.Parse(input.ReadLine(), ci);
tst.E13 = sbyte.Parse(input.ReadLine(), ci);
tst.E14 = sbyte.Parse(input.ReadLine(), ci);
tst.E15 = sbyte.Parse(input.ReadLine(), ci);
tst.E16 = sbyte.Parse(input.ReadLine(), ci);
tst.E21 = sbyte.Parse(input.ReadLine(), ci);
tst.Delta_Q_pct = double.Parse(input.ReadLine(), ci);
tst.Delta_T = double.Parse(input.ReadLine(), ci);
@@ -293,6 +316,7 @@ namespace Config.Entities
ln = inp.ReadLine(); if (ln != PressLimHi.ToString(ci)) { diff.AppendFormat(fmt, "Pressure_max", PressLimHi.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Publish.ToString()) { diff.AppendFormat(fmt, "Publish", Publish.ToString(), ln); };
ln = inp.ReadLine(); if (ln != Evaluate.ToString()) { diff.AppendFormat(fmt, "Evaluate", Evaluate.ToString(), ln); };
ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); };
ln = inp.ReadLine(); if (ln != E1.ToString()) { diff.AppendFormat(fmt, "E1", E1.ToString(), ln); };
ln = inp.ReadLine(); if (ln != E2.ToString()) { diff.AppendFormat(fmt, "E2", E2.ToString(), ln); };
+1 -1
View File
@@ -47,7 +47,7 @@ namespace Config.Entities
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
public virtual float DN { get; set; } /// Not mapped to DB, valid in ProceduresCtrl for procedure filtering only
public virtual float Qn { get; set; } /// - ' ' -
public virtual double Qn { get; set; } /// - ' ' -
public virtual string MClass { get; set; } /// - ' ' -
public virtual string Producer { get; set; } /// - ' ' -
+4 -1
View File
@@ -78,6 +78,8 @@ namespace Config.Entities
output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(LastChgUser);
output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(((sbyte)ProfileType).ToString());
output.WriteLine(((sbyte)ErrorLimitType).ToString());
foreach (var test in Tests) { test.Export(output); }
output.WriteLine();
@@ -96,7 +98,8 @@ namespace Config.Entities
result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.LastChgUser = input.ReadLine();
result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
string line = input.ReadLine();
result.ProfileType = (ProfileType)sbyte.Parse(input.ReadLine());
result.ErrorLimitType = (ErrorLimitType)sbyte.Parse(input.ReadLine());
while (true)
{
+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_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;
+3 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,7 +15,8 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.TempMtrUp).Column("TempIn");
Map(x => x.Selector);
Map(x => x.TempMtrUp).Column("TempIn");
Map(x => x.TempMtrDown).Column("TempOut");
Map(x => x.PressMtrUp).Column("PressIn");
Map(x => x.PressMtrDown).Column("PressOut");
+3 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,7 +15,8 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Pump);
Map(x => x.Selector);
Map(x => x.Pump);
Map(x => x.RegulValvesPct);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
+3 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
@@ -15,7 +15,8 @@ namespace Config.Mappings
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.RegulValve);
Map(x => x.Selector);
Map(x => x.RegulValve);
Map(x => x.FlowMeter);
Map(x => x.PidCoef);
Map(x => x.StartValve);
+1
View File
@@ -24,6 +24,7 @@ namespace Config.Mappings
Map(x => x.PressLimHi);
Map(x => x.Publish);
Map(x => x.Evaluate);
Map(x => x.Method);
Map(x => x.E1);
Map(x => x.E2);
Map(x => x.E3);
+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")]
+1 -190
View File
@@ -1,90 +1,15 @@
///
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
namespace Config
{
public static class Utils
{
public static string SignificantDigitsToFmt(double value, int sigDigits)
{
if (sigDigits == 6)
{
if (value >= 99999.5 || value < -99999.5) return "F0";
else if (value >= 9999.95 || value < -9999.95) return "F1";
else if (value >= 999.995 || value < -999.995) return "F2";
else if (value >= 99.9995 || value < -99.9995) return "F3";
else if (value >= 9.99995 || value < -9.99995) return "F4";
else if (value >= 0.999995 || value < -0.999995) return "F5";
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
else return "F10";
}
else if (sigDigits == 5)
{
if (value >= 9999.5 || value < -9999.5) return "F0";
else if (value >= 999.95 || value < -999.95) return "F1";
else if (value >= 99.995 || value < -99.995) return "F2";
else if (value >= 9.9995 || value < -9.9995) return "F3";
else if (value >= 0.99995 || value < -0.99995) return "F4";
else if (value >= 0.099995 || value < -0.099995) return "F5";
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
else return "F9";
}
else if (sigDigits == 4)
{
if (value >= 999.5 || value < -999.5) return "F0";
else if (value >= 99.95 || value < -99.95) return "F1";
else if (value >= 9.995 || value < -9.995) return "F2";
else if (value >= 0.9995 || value < -0.9995) return "F3";
else if (value >= 0.09995 || value < -0.09995) return "F4";
else if (value >= 0.009995 || value < -0.009995) return "F5";
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
else return "F8";
}
else if (sigDigits == 3)
{
if (value >= 99.5 || value < -99.5) return "F0";
else if (value >= 9.95 || value < -9.95) return "F1";
else if (value >= 0.995 || value < -0.995) return "F2";
else if (value >= 0.0995 || value < -0.0995) return "F3";
else if (value >= 0.00995 || value < -0.00995) return "F4";
else if (value >= 0.000995 || value < -0.000995) return "F5";
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
else return "F7";
}
else if (sigDigits == 2)
{
if (value >= 9.5 || value < -9.5) return "F0";
else if (value >= 0.95 || value < -0.95) return "F1";
else if (value >= 0.095 || value < -0.095) return "F2";
else if (value >= 0.0095 || value < -0.0095) return "F3";
else if (value >= 0.00095 || value < -0.00095) return "F4";
else if (value >= 0.000095 || value < -0.000095) return "F5";
else return "F6";
}
else /// if (sigDigits == 1)
{
if (value >= 0.95 || value < -0.95) return "F0";
else if (value >= 0.095 || value < -0.095) return "F1";
else if (value >= 0.0095 || value < -0.0095) return "F2";
else if (value >= 0.00095 || value < -0.00095) return "F3";
else if (value >= 0.000095 || value < -0.000095) return "F4";
else return "F5";
}
}
/// <summary>
/// Extract and return a DB server from a MySQL connection string.
/// </summary>
@@ -139,119 +64,5 @@ namespace Config
/// pattern NOT found
return string.Empty;
}
/// <summary>
/// Get either Q1 or Qmin flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q1 or Qmin flow in m3/h</returns>
public static double GetQ1Qmin(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
int metroClassRatio;
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
{
return Qn / (double)metroClassRatio;
}
else
{
if (medium == Medium.HotWater)
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.04 * Qn);
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.02 * Qn);
case "D": return (Qn < 15) ? (0.01 * Qn) : Qdflt;
default: break;
}
}
else
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.03 * Qn);
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.006 * Qn);
default: break;
}
}
}
return Qdflt;
}
/// <summary>
/// Get either Q2 or Qt flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q2 or Qt flow in m3/h</returns>
public static double GetQ2Qt(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
int metroClassRatio;
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
{
return 1.6 * Qn / (double)metroClassRatio;
}
if (medium == Medium.HotWater)
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.2 * Qn);
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.15 * Qn);
case "C": return (Qn < 15) ? (0.06 * Qn) : (0.1 * Qn);
case "D": return (Qn < 15) ? (0.015 * Qn) : Qdflt;
default: break;
}
}
else
{
switch (metroClass)
{
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.3 * Qn);
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.2 * Qn);
case "C": return (Qn < 15) ? (0.015 * Qn) : (0.015 * Qn);
default: break;
}
}
return Qdflt;
}
/// <summary>
/// Get either Q4 or Qmax flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q4 or Qmax flow in m3/h</returns>
public static double GetQ4Qmax(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0)
{
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
switch (metroClass[0])
{
case 'A':
case 'B':
case 'C':
case 'D':
return 2 * Qn;
case 'R':
return 1.25 * Qn;
default:
return Qdflt;
}
}
}
}
+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();
}
}
}
+3 -1
View File
@@ -35,7 +35,7 @@
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<OldToolsVersion>2.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
@@ -76,6 +76,7 @@
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
@@ -99,6 +100,7 @@
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
+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();
+7
View File
@@ -106,6 +106,13 @@ namespace Results.Entities
public virtual bool IsDataStream() { return (RegReaderType == (int)RegisterReaderType.DataStream); }
public virtual bool IsManual() { return (RegReaderType == (int)RegisterReaderType.Manual); }
public virtual string PassedOrErrorFlagsStr()
{
string eFlags = Utils.ErrorFlagsStr(ErrorIndicators);
var str = string.IsNullOrEmpty(eFlags) ? PassedColorStr(null) : eFlags;
return str;
}
public virtual string PassedColorStr(string yesNoFormatOrEmpty)
{
if (string.IsNullOrEmpty(yesNoFormatOrEmpty))
+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")]
+2 -11
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
@@ -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)
+9 -8
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -331,11 +331,12 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(ItemID.ThreeState, "Three state result", Quantity.Enumerated, ItemCategory.MeterResult, (w, t, u, f, p) => FormatThreeState(f, w.ThreeStateFromTests())));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Scale, "Scale", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Scale()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Diverter, "Diverter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Diverter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RegValve, "Reg. valve", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RegValve()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Scale, "Scale", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Scale()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Diverter, "Diverter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Diverter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RegValve, "Reg. valve", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RegValve()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult,(w, t, u, f, p) => (w.GetMeterTestRslt(t) != null) ? FormatStr(f, w.GetMeterTestRslt(t).PassedOrErrorFlagsStr())
: FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
///
/// Water meter info
@@ -677,7 +678,7 @@ namespace Results
int significantDigits;
if (int.TryParse(precision.Substring(1), out significantDigits))
{
precision = Config.Utils.SignificantDigitsToFmt(val, significantDigits);
precision = Common.Utils.SignificantDigitsToFmt(val, significantDigits);
}
}
@@ -715,7 +716,7 @@ namespace Results
int significantDigits;
if (int.TryParse(precision.Substring(1), out significantDigits))
{
precision = Config.Utils.SignificantDigitsToFmt(val1, significantDigits);
precision = Common.Utils.SignificantDigitsToFmt(val1, significantDigits);
}
}
+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 -2
View File
@@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -32,7 +32,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL_NEW;IPERL;ORACLE_DB</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+2 -2
View File
@@ -15,8 +15,6 @@ namespace ResultsParser
{
class Program
{
static ISessionFactory sessionFactory;
static void Main(string[] args)
{
Console.WriteLine("Bench: [WR15]");
@@ -33,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>
+4 -1
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;
@@ -40,7 +41,7 @@ namespace Statistics
MidOrWaterMetersCtrl ctrl = new MidOrWaterMetersCtrl();
ctrl.MidId = midId;
ctrl.Parent = this;
ctrl.ParentDlg = this;
ctrl.Dock = DockStyle.Fill;
tp.Controls.Add(ctrl);
@@ -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)
@@ -14,7 +14,7 @@ namespace Statistics.UserControls
public partial class MidOrWaterMetersCtrl : UserControl
{
public int MidId; /// 1-based MID Id.
public StatisticsDlg Parent;
public StatisticsDlg ParentDlg;
public bool IsFlowEnabled(int i)
@@ -82,7 +82,7 @@ namespace Statistics.UserControls
public IList<TestRslt> UpdateRequest(int benchId)
{
return Parent.UpdateRequest(benchId, MidId);
return ParentDlg.UpdateRequest(benchId, MidId);
}
+41 -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}
@@ -8,11 +10,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8
{0C0A1F4D-1363-4544-A7C5-196C76D26CCA} = {0C0A1F4D-1363-4544-A7C5-196C76D26CCA}
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE} = {46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}
{5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0} = {5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0}
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Results", "Results\Results.csproj", "{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}"
ProjectSection(ProjectDependencies) = postProject
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Config", "Config\Config.csproj", "{743DF7DB-C7B6-42EB-986D-0F485E5588E4}"
ProjectSection(ProjectDependencies) = postProject
{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} = {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsBrowser", "ResultsBrowser\ResultsBrowser.csproj", "{07BA543A-54CA-4A59-9AD9-DDE7038E1BF9}"
ProjectSection(ProjectDependencies) = postProject
@@ -85,6 +94,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatureVectorCalculator", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsParser", "ResultsParser\ResultsParser.csproj", "{2E08C19B-C0A9-4056-8564-E5B74477959D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sensus.iPerl.RfidCom", "..\iPerlHead\Sensus.iPerl.RfidCom\Sensus.iPerl.RfidCom.csproj", "{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NfcS5_DLL", "..\NfcS5_DLL\NfcS5_DLL.csproj", "{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -379,8 +392,35 @@ Global
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2E08C19B-C0A9-4056-8564-E5B74477959D}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Debug|x86.Build.0 = Debug|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.ActiveCfg = Release|Any CPU
{A3E14180-7F00-42E5-94A9-8DB62EAD6EE8}.Release|x86.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|x86.ActiveCfg = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Debug|x86.Build.0 = Debug|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Any CPU.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|x86.ActiveCfg = Release|Any CPU
{34F6AA20-3BEC-44B4-9D18-DC66BAB79A83}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7C8EF35-DF72-4DFC-83F7-9641AC1178CF}
EndGlobalSection
EndGlobal
+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]
+130 -76
View File
@@ -1,19 +1,20 @@
///
/// 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;
using System.Threading;
namespace TBF
{
@@ -69,7 +70,9 @@ namespace TBF
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
/// Program version string
System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
@@ -144,7 +147,7 @@ namespace TBF
IEnumerable<string> files = Directory.EnumerateFiles(TempImagesDir); /// TODO: Implement recursive directory delete
foreach (var file in files) File.Delete(file);
}
catch (Exception e)
catch (Exception)
{
MessageBox.Show("Error creating a local application data directory and preparing an initial configuration", "Fatal error");
return; /// Fatal error
@@ -214,7 +217,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 +232,8 @@ namespace TBF
bool retryLogin = true; /// true = stay in a login loop
do
{
LoadingConfigEnd();
LoginDlgWithBenchSelection loginDlgBench;
if (LocalSettings.LastBenchName != null)
{
@@ -251,10 +256,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 +276,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 +287,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 +373,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 +388,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 +404,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 +417,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 +438,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 +474,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 +496,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)
@@ -520,7 +539,12 @@ namespace TBF
log.Info("Exiting application.");
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
private static void Form1_UIThreadException(object sender, ThreadExceptionEventArgs e)
{
LogException(log, "Unhandled thread exception", (Exception)e.Exception);
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
LogException(log, "Unhandled exception", (Exception)args.ExceptionObject);
}
@@ -536,5 +560,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.28.1933.0")]
[assembly: AssemblyFileVersion("2.28.1933.0")]
[assembly: AssemblyVersion("2.33.2140.0")]
[assembly: AssemblyFileVersion("2.33.2140.0")]
+122 -41
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>
@@ -357,6 +366,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to any profile.
/// </summary>
internal static string any_profile {
get {
return ResourceManager.GetString("any_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Approval.
/// </summary>
@@ -636,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>
@@ -664,7 +691,7 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Calibration Specialist.
/// Looks up a localized string similar to Legalizator.
/// </summary>
internal static string Calibration_Specialist {
get {
@@ -1266,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>
@@ -1887,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>
@@ -1896,6 +1941,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Error when saving and printing results.
/// </summary>
internal static string Error_when_saving_and_printing_results {
get {
return ResourceManager.GetString("Error_when_saving_and_printing_results", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error while creating the database. Reason: .
/// </summary>
@@ -2247,6 +2301,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>
@@ -3264,6 +3327,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to no profile.
/// </summary>
internal static string no_profile {
get {
return ResourceManager.GetString("no_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No results to print.
/// </summary>
@@ -3579,6 +3651,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>
@@ -3805,11 +3886,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);
}
}
@@ -3867,6 +3948,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>
@@ -4263,33 +4353,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>
@@ -4299,15 +4362,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>
@@ -5082,6 +5136,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>
@@ -5739,6 +5802,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Test {0} config. error : {1} is missing.
/// </summary>
internal static string Test_0_config_error_1_is_missing {
get {
return ResourceManager.GetString("Test_0_config_error_1_is_missing", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test bench.
/// </summary>
@@ -6246,6 +6318,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>
+38 -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>
@@ -1680,4 +1671,37 @@
<data name="Delay" xml:space="preserve">
<value>Zpoždění</value>
</data>
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Konfigurace testu {0} : chybí {1}</value>
</data>
<data name="Print" xml:space="preserve">
<value>Tisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>předvolená tiskárna</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Zjisti počet cyklů bez kontroly</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Nastav počet cyklů bez kontroly</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Odemknout vypnutí kontroly</value>
</data>
<data name="All_files" xml:space="preserve">
<value>Všechny soubory</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Kalibrační certifikát</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF soubory</value>
</data>
<data name="Error_when_saving_and_printing_results" xml:space="preserve">
<value>Chyba při ukládání a tisknutí výsledků</value>
</data>
</root>
+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>
+5 -16
View File
@@ -199,7 +199,8 @@
<value>Parametry stanowiska</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Specjalistyczna kalibracja</value>
<value>Legalizator</value>
<comment>Specjalistyczna kalibracja</comment>
</data>
<data name="Camera_error" xml:space="preserve">
<value>Błąd kamery</value>
@@ -690,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>
@@ -1029,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>
@@ -1176,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>
@@ -1542,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>
@@ -1626,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>
+42 -15
View File
@@ -424,7 +424,7 @@
<value>Administrator</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Calibration Specialist</value>
<value>Legalizator</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Head of Lab</value>
@@ -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>
@@ -2311,4 +2299,43 @@
<data name="Delay" xml:space="preserve">
<value>Delay</value>
</data>
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Test {0} config. error : {1} is missing</value>
</data>
<data name="any_profile" xml:space="preserve">
<value>any profile</value>
</data>
<data name="no_profile" xml:space="preserve">
<value>no profile</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Printer selection</value>
</data>
<data name="default_printer" xml:space="preserve">
<value>default printer</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Get number of cycles to bypass</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Set number of cycles to bypass</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Unlock a bypass</value>
</data>
<data name="Error_reading_configuration_database" xml:space="preserve">
<value>Error reading configuration database</value>
</data>
<data name="All_files" xml:space="preserve">
<value>All files</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Calibration certificate</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF files</value>
</data>
<data name="Error_when_saving_and_printing_results" xml:space="preserve">
<value>Error when saving and printing results</value>
</data>
</root>
+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>
+2 -2
View File
@@ -134,7 +134,7 @@ namespace TBF.Rig
{
if (GetRuntimeProcParamsProvider() == null)
{
/// Component has no test parametes
/// Component has no procedure parameters
return null;
}
@@ -195,7 +195,7 @@ namespace TBF.Rig
{
if (GetRuntimeTestParamsProvider() == null)
{
/// Component has no test parametes
/// Component has no test parameters
return null;
}
+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
+84 -26
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -16,8 +16,24 @@ namespace TBF.Rig.DataEntry.StandardCamera
private static readonly ILog log = LogManager.GetLogger(typeof(EntryForm));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
const string DfltOcrWorkspaceFolder = "C:\\TBF\\OCR\\";
const string DfltOcrWorkspaceExt = ".vrws";
static Dictionary<string, OcrVidi> ocrDictionary = new Dictionary<string, OcrVidi>();
readonly EntryFormCfg entryFormCfg;
public string OcrWorkspace
{
get { return (entryFormCfg != null && entryFormCfg.ProcParams != null) ? entryFormCfg.ProcParams.OcrWorkspace : string.Empty; }
}
public string OcrStream
{
get { return (entryFormCfg != null && entryFormCfg.ProcParams != null) ? entryFormCfg.ProcParams.OcrStream : string.Empty; }
}
IRegReader[] regReaders;
@@ -28,26 +44,13 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (entryFormCfg.DebugLevel == DebugMode.Simulate)
{
startImages = new string[] { "C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg" };
startImages = new string[] { "C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg",
"C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg", "C:\\TBF\\Images\\Test\\Image3.jpg",
"C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg", "C:\\TBF\\Images\\Test\\Image1.jpg",
"C:\\TBF\\Images\\Test\\Image2.jpg", "C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg",
"C:\\TBF\\Images\\Test\\Image5.jpg", "C:\\TBF\\Images\\Test\\Image1.jpg", "C:\\TBF\\Images\\Test\\Image2.jpg",
"C:\\TBF\\Images\\Test\\Image3.jpg", "C:\\TBF\\Images\\Test\\Image4.jpg", "C:\\TBF\\Images\\Test\\Image5.jpg" };
}
else
{
@@ -110,7 +113,6 @@ namespace TBF.Rig.DataEntry.StandardCamera
CurrentOp currentOp;
public EntryForm() { }
public EntryForm(Generic.IComponentCfg cfg)
@@ -213,21 +215,75 @@ namespace TBF.Rig.DataEntry.StandardCamera
///
void OpenTestStartStatesDlg(EntryForm myRef)
{
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, startImages, disabled);
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, disabled);
modelessDlg.Show();
}
///
void OpenTestEndStatesDlg(EntryForm myRef)
{
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, endImages, wmStartState, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi);
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, wmStartState, wmStartStateStr, endImages, disabled,
refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
///
void OpenDeferredTestEvalDlg(EntryForm myRef)
{
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, startImages, endImages, disabled, refVolume, errLimLo, errLimHi);
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
startImages, endImages, disabled,
refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
///
OcrVidi GetOcr(string ocrWorkspace, out string message)
{
message = string.Empty;
if (string.IsNullOrEmpty(ocrWorkspace)) return null; /// No OCR was configured
string fullPath = (ocrWorkspace.Contains("\\") || ocrWorkspace.Contains("/"))
? ocrWorkspace.Replace('/', '\\')
: System.IO.Path.Combine(DfltOcrWorkspaceFolder, ocrWorkspace);
if (!fullPath.Contains(".")) fullPath = fullPath + DfltOcrWorkspaceExt;
OcrVidi ocrVidi;
if (ocrDictionary.TryGetValue(fullPath, out ocrVidi))
{
log.InfoFormat("existing OcrVidi({0}) was retrieved from dictionary", fullPath);
return ocrVidi;
}
try
{
ocrVidi = new OcrVidi(fullPath);
ocrDictionary.Add(fullPath, ocrVidi);
log.WarnFormat("new OcrVidi({0}) was added to dictionary", fullPath);
return ocrVidi;
}
catch (Exception e)
{
if (e.InnerException != null)
{
log.ErrorFormat("new OcrVidi({0}) thrown {1}: {2} / {3}",
fullPath, e.GetType().ToString(), e.Message,e.InnerException.Message);
}
else
{
log.ErrorFormat("new OcrVidi({0}) thrown {1}: {2}",
fullPath, e.GetType().ToString(), e.Message);
}
log.ErrorFormat("Stack trace:\r\n{0}", e.StackTrace);
message = string.Format("Cannot load OCR workspace:\r\n{0}\r\nOCR workspace file is {1}", e.Message, fullPath);
return null;
}
}
/// <summary>Start this operation</summary>
public void Start()
@@ -349,7 +405,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
for (int i = 0; i < dlg.WaterMetersCount; i++)
{
wmEndState[i] = dlg.WMEndState[i];
wmStartState[i] = dlg.WMStartState[i];
wmStartStateStr[i] = dlg.WMStartStateStr[i];
wmEndState[i] = dlg.WMEndState[i];
}
}
}
@@ -1,9 +1,10 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.StandardCamera
@@ -27,9 +28,18 @@ namespace TBF.Rig.DataEntry.StandardCamera
public string ProtocolTitle3;
public string ProtocolTitle4;
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public ProcParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
EntryFormCfg()
{
ProcParams = new ProcParams(true);
Name = "DataEntry-for-Camera";
ParentName = string.Empty;
HideOrder = false;
@@ -0,0 +1,97 @@
using System.Collections.Generic;
#if OCR
using ViDi2;
#endif
namespace TBF.Rig.DataEntry.StandardCamera
{
public class OcrVidi
{
#if OCR
/// Static variable: OCR ViDi control can only have one instance
static ViDi2.Runtime.IControl control;
readonly IWorkspace workspace;
#endif
readonly string ocrWorkspaceFile;
/// <summary>
/// Create OcrVidi wrapper class
/// </summary>
/// <param name="ocrWorkspaceFile">Cognex runtime workspace file (vrws)</param>
public OcrVidi(string ocrWorkspaceFile)
{
this.ocrWorkspaceFile = ocrWorkspaceFile;
#if OCR
if (control == null)
{
/// Create and initialize the main control
control = new ViDi2.Runtime.Local.Control(GpuMode.NoSupport);
control.InitializeComputeDevices(GpuMode.NoSupport, new List<int>() { }); /// Initializes all CUDA devices
}
/// Open a runtime workspace from file
workspace = control.Workspaces.Add(string.Format("ws{0}", control.Workspaces.Count + 1), ocrWorkspaceFile);
#endif
}
public string Recognize(string streamName, string imagePath, double denominator = 1000, string format = "F3")
{
#if OCR
IStream stream;
try { stream = workspace.Streams[streamName]; }
catch (Exception) { return string.Empty; }
if (stream == null) return string.Empty;
string findedText = string.Empty; /// Hladane cislo - stav vodomera - string
double findedValue = 0; /// Hladane cislo - stav vodomera
bool finded = false; /// Ci sme nasli hodnotu
// load an image from file
using (IImage image = new ViDi2.Local.LibraryImage(imagePath)) //disposing the image when we do not need it anymore
{
// allocates a sample with the image
using (ISample sample = stream.CreateSample(image))
{
ITool tool = stream.Tools["Read"];
// process image with the blue read tool
sample.Process(tool);
IBlueMarking blueReadMarking = sample.Markings[tool.Name] as IBlueMarking;
foreach (IBlueView view in blueReadMarking.Views)
{
foreach (IMatch match in view.Matches)
{
//System.Console.WriteLine($"This model says \" {(match as IReadModelMatch).FeatureString} \" with a score of {match.Score}");
string word = (match as IReadModelMatch).FeatureString;
if (word.Length >= 7 && word.Length <= 8 // hladane cislo ma od 7 do 8 znakov
&& double.TryParse(word,out findedValue)) // a ak najdeny text je cislo
{
findedValue /= denominator; // Convert to m3, red digits are fractions of m3
finded = true;
break;
}
}
if (finded) break;
}
}
}
if (finded)
{
findedText = findedValue.ToString(format);
}
return findedText;
#else
return null;
#endif
}
public override string ToString()
{
return ocrWorkspaceFile;
}
}
}
@@ -0,0 +1,132 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System.IO;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.StandardCamera
{
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public string OcrWorkspace; /// Path to a Cognex workspace file
public string OcrStream; /// Cognex workspace stream name
public override void InitializeAll()
{
OcrWorkspace = string.Empty;
OcrStream = "default";
}
string[] paramNames = new string[]
{
"OCR workspace file",
"OCR stream",
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return OcrWorkspace;
case 1: return OcrStream;
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string str)
{
switch (i)
{
case 0: OcrWorkspace = str; return CfgUpdateFlags.None;
case 1: OcrStream = str; return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
/// <summary>
/// Verifiy the string representation of the parameter
/// </summary>
/// <param name="i">Parameter ID</param>
/// <param name="str">String representation of the parameter</param>
/// <param name="message">In case false is returned this is the error messsage to be displayed</param>
/// <returns>true = parameter OK, false = parameter NOK</returns>
public bool ValidateParam(int i, string str, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
return true;
case 1:
if (!string.IsNullOrEmpty(str)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ProcParams prms)
{
prms.OcrWorkspace = OcrWorkspace;
prms.OcrStream = OcrStream;
}
public IParamsProvider Clone()
{
ProcParams pars = new ProcParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public ProcParams()
{
}
public ProcParams(bool initialize)
{
if (initialize) InitializeAll();
}
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}
@@ -1,14 +1,16 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using log4net;
using Common;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using System.IO;
namespace TBF.Rig.DataEntry.StandardCamera
{
@@ -33,22 +35,30 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
// Set to 'true' when the form closes
const Unit unit = Unit.m3;
// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary> Number of text boxes for serial numbers </summary>
readonly Tst mode; /// Start, End or Deferred
readonly Tst mode; /// Start, End or Deferred
public readonly int WaterMetersCount;
readonly IRegReader[] regReaders;
readonly bool[] disabled;
readonly string[] startImages;
readonly string[] endImages;
readonly double refVolume;
readonly double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
readonly double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
readonly double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
readonly double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
readonly OcrVidi ocrVidi;
readonly string ocrMessage;
readonly string streamName;
// To be retrieved after the form closes
double denominator; /// derived from PulsesPerLtr, passed to OcrVidi
string format; /// derived from PulsesPerLtr, passed to OcrVidi
// To be retrieved after the form closes
public double[] WMStartState;
// To be retrieved after the form closes
@@ -57,23 +67,26 @@ namespace TBF.Rig.DataEntry.StandardCamera
// To be retrieved after the form closes
public double[] WMEndState;
const int TextBoxesCount = 24;
string lastImageName;
Bitmap lastImage; /// non-zoomed image
int lastWmNr1;
Bitmap lastImage; /// non-zoomed image
Bitmap zoomedImage;
Thread imageProcessingThread; /// Thread to process images
public delegate void OcrTextObtainedDelegate(int ix, bool isEnd, string text);
OcrTextObtainedDelegate ocrTextObtained;
static int wmNr0b;
static Rotation[] imageRotation;
static Rotation imageRotation;
static bool[] isZoomed;
static Point[] zoomCenterLoc;
///
static TestStartEndForm()
{
wmNr0b = 0;
imageRotation = new Rotation[TextBoxesCount];
//imageRotation = new Rotation[TextBoxesCount];
isZoomed = new bool[TextBoxesCount];
zoomCenterLoc = new Point[TextBoxesCount];
}
@@ -127,6 +140,8 @@ namespace TBF.Rig.DataEntry.StandardCamera
enabledTextBoxes = new List<TextBox>();
imageProcessingThread = null;
completed = false;
StartForceCloseHandler();
}
@@ -135,115 +150,141 @@ namespace TBF.Rig.DataEntry.StandardCamera
/// Constructor to fill in start states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] startImages, bool[] disabled)
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="startImages">Array with paths to start images</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, bool[] disabled)
: this()
{
mode = Tst.Start;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.startImages = startImages;
this.disabled = disabled;
if (startImages == null || startImages.Length != waterMetersCount)
if (startImages == null || startImages.Length != WaterMetersCount)
{
throw (new Exception("Invalid 'startImages' argument"));
throw new Exception("Invalid 'startImages' argument");
}
this.endImages = new string[waterMetersCount];
this.endImages = new string[WaterMetersCount];
WMStartState = new double[WaterMetersCount];
WMStartStateStr = new string[WaterMetersCount];
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
Height = 555 + 30 * WaterMetersCount;
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
}
ConstructorCommon(regReaders);
}
/// <summary>
/// Constructor to fill in end states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="wmStartStateStr">Information entered on test start</param>
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="endImages">Array with paths to end images</param>
/// <param name="wmStartState">Array with start states in default volume units (liters)</param>
/// <param name="wmStartStateStr">Information entered on test start</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] endImages, double[] wmStartState, string[] wmStartStateStr, bool[] disabled,
double refVolume, double errLimLo, double errLimHi)
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, double[] wmStartState, string[] wmStartStateStr, string[] endImages,
bool[] disabled, double refVolume, double errLimLo, double errLimHi)
: this()
{
mode = Tst.End;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
if (endImages == null || endImages.Length != waterMetersCount ||
wmStartState == null || wmStartState.Length != waterMetersCount ||
wmStartStateStr == null || wmStartStateStr.Length != waterMetersCount)
{
throw (new Exception("Invalid argument(s)"));
}
this.endImages = endImages;
this.WMStartState = wmStartState;
this.WMStartStateStr = wmStartStateStr;
this.disabled = disabled;
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.startImages = startImages;
this.WMStartState = wmStartState;
this.WMStartStateStr = wmStartStateStr;
this.endImages = endImages;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
this.startImages = new string[waterMetersCount];
if (startImages == null || startImages.Length != WaterMetersCount ||
wmStartState == null || wmStartState.Length != WaterMetersCount ||
wmStartStateStr == null || wmStartStateStr.Length != WaterMetersCount ||
endImages == null || endImages.Length != WaterMetersCount)
{
throw new Exception("Invalid argument(s)");
}
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
WMEndState = new double[WaterMetersCount];
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
ConstructorCommon(regReaders);
}
Height = 555 + 30 * WaterMetersCount;
WMEndState = new double[waterMetersCount];
}
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] startImages, string[] endImages,
bool[] disabled, double refVolume, double errLimLo, double errLimHi)
/// <summary>
/// Constructor for deferred evaluation, to fill in both start- and end-states
/// </summary>
/// <param name="waterMetersCount">Number of water meters</param>
/// <param name="regReaders">Array with register reader components</param>
/// <param name="ocrVidi">Cognex wrapper object performing OCR or null</param>
/// <param name="startImages">Array with paths to start images</param>
/// <param name="endImages">Array with paths to end images</param>
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, OcrVidi ocrVidi, string ocrMessage, string streamName,
string[] startImages, string[] endImages, bool[] disabled,
double refVolume, double errLimLo, double errLimHi)
: this()
{
mode = Tst.Both;
this.regReaders = regReaders;
this.WaterMetersCount = Math.Min(waterMetersCount, regReaders.Length);
this.ocrVidi = ocrVidi;
this.ocrMessage = ocrMessage;
this.streamName = streamName;
this.startImages = startImages;
this.endImages = endImages;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
if (startImages == null || startImages.Length != waterMetersCount ||
endImages == null || endImages.Length != waterMetersCount)
{
throw (new Exception("Invalid argument(s)"));
throw new Exception("Invalid argument(s)");
}
this.startImages = startImages;
this.endImages = endImages;
this.disabled = disabled;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
WMEndState = new double[waterMetersCount];
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
Height = 555 + 30 * WaterMetersCount;
WMStartState = new double[waterMetersCount];
WMStartStateStr = new string[waterMetersCount];
WMEndState = new double[waterMetersCount];
ConstructorCommon(regReaders);
}
void ConstructorCommon(IRegReader[] regReaders)
{
/// For large benches with WaterMetersCount LE 6 is TBF.Data.LineSize==1 (compound meters)
int lineSize = (WaterMetersCount <= 6) ? WaterMetersCount : TBF.Data.LineSize;
DeterminePhysPosWMPos(TextBoxesCount, WaterMetersCount, lineSize, out phys2wm, out wm2phys);
int nrLines = (TBF.Data.WMsCount - 1) / TBF.Data.LineSize + 1;
if (nrLines == 1)
{
Width = 1040;
}
}
/// <summary>
/// Make sure the layout of labels/text boxes on the screen
/// corresponds to the layout of watermeters of the test bench.
@@ -292,7 +333,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (wmPos > 0)
{
labels[i].Text = string.Format("{0} {1}", Strings.Water_Meter, wmPos);
labels[i].Text = wmPos.ToString();
switch (mode)
{
@@ -318,10 +359,11 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
else
{
endTextBoxes[i].Enabled = true;
enabledTextBoxes.Add(endTextBoxes[i]);
startTextBoxes[i].Enabled = false;
startTextBoxes[i].Text = WMStartStateStr[wmPos - 1];
startTextBoxes[i].Enabled = true;
startTextBoxes[i].Text = WMStartStateStr[wmPos - 1];
endTextBoxes[i].Enabled = true;
enabledTextBoxes.Add(startTextBoxes[i]);
enabledTextBoxes.Add(endTextBoxes[i]);
}
break;
@@ -343,16 +385,176 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
}
}
if (!string.IsNullOrEmpty(ocrMessage))
{
MessageBox.Show(ocrMessage, Strings.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
int imagesCount = ImagesToProcessCount();
log.WarnFormat("Images to process count = {0}", imagesCount);
///
if (imagesCount > 0 && ocrVidi != null)
{
log.WarnFormat("Starting image processing thread with OcrVidi={0} and OcrStream={1}", ocrVidi, streamName);
/// Delegate for a thread->form communication
ocrTextObtained = new OcrTextObtainedDelegate(OnOcrTextObtained);
/// Show and initalize the progress bar
imageProcessingProgressLabel.Visible = true;
imageProcessingProgressBar.Visible = true;
imageProcessingProgressBar.Minimum = 0;
imageProcessingProgressBar.Value = 0;
imageProcessingProgressBar.Maximum = imagesCount;
/// Start the image processing thread
imageProcessingThread = new Thread(new ThreadStart(ImageProcessingThread));
imageProcessingThread.Start();
}
}
private void TestStartEndForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (imageProcessingThread != null && imageProcessingThread.IsAlive)
{
imageProcessingThread.Join(2000);
}
}
void Localize()
{
Text = Strings.Water_Meter_States;
startLabel.Text = startLabel2.Text = Strings.Start;
endLabel.Text = endLabel2.Text = Strings.End;
okButton.Text = Strings.OkBtnText;
Text = (ocrVidi != null)
? string.Format("{0} ({1} / {2})", Strings.Water_Meter_States, ocrVidi, streamName)
: Strings.Water_Meter_States;
startLabel.Text = startLabel2.Text = string.Format("{0} [{1}]", Strings.Start, unit.ToDescription());
endLabel.Text = endLabel2.Text = string.Format("{0} [{1}]", Strings.End, unit.ToDescription());
okButton.Text = Strings.OkBtnText;
}
int ImagesToProcessCount()
{
int count = 0;
/// Count the images
for (int i = 0; i < WaterMetersCount; i++)
{
if ((mode == Tst.Start || mode == Tst.Both) && startTextBoxes[wm2phys[i + 1]].Enabled &&
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
{
count++;
}
if ((mode == Tst.End || mode == Tst.Both) && endTextBoxes[wm2phys[i + 1]].Enabled &&
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
{
count++;
}
}
return count;
}
void ImageProcessingThread()
{
Thread.Sleep(2000);
bool[] startImgProcessed = new bool[WaterMetersCount];
bool[] endImgProcessed = new bool[WaterMetersCount];
for (int attempt = 1; attempt <= 3; attempt++)
{
for (int i = 0; i < WaterMetersCount; i++)
{
double pulsesPerLtr = (regReaders != null && regReaders.Length > i && regReaders[i] != null) ? regReaders[i].PulsesPerLtr : 1;
GetOcrParameters(pulsesPerLtr, out denominator, out format);
if ((mode == Tst.Start || mode == Tst.Both) && startTextBoxes[wm2phys[i + 1]].Enabled &&
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
{
if (!startImgProcessed[i])
{
try
{
/// Process a start image
var text = ocrVidi.Recognize(streamName, startImages[i], denominator, format); /// OCR
this.Invoke(ocrTextObtained, new object[] { wm2phys[i + 1], false, text });
startImgProcessed[i] = true;
}
catch (Exception)
{
}
}
}
if ((mode == Tst.End || mode == Tst.Both) && endTextBoxes[wm2phys[i + 1]].Enabled &&
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
{
if (!endImgProcessed[i])
{
try
{
/// Process an end image
var text = ocrVidi.Recognize(streamName, endImages[i], denominator, format); /// OCR
this.Invoke(ocrTextObtained, new object[] { wm2phys[i + 1], true, text });
endImgProcessed[i] = true;
}
catch (Exception)
{
}
}
}
}
}
}
void GetOcrParameters(double pulsesPerLtr, out double denominator, out string format)
{
if (pulsesPerLtr == 0.1)
{
denominator = 100;
format = "F2";
}
else if (pulsesPerLtr == 0.01)
{
denominator = 10;
format = "F1";
}
else if (pulsesPerLtr == 10)
{
denominator = 10000;
format = "F4";
}
else // if (pulsesPerLtr == 1)
{
denominator = 1000;
format = "F3";
}
}
public void OnOcrTextObtained(int ix, bool isEnd, string text)
{
if (isEnd)
{
if (ix < endTextBoxes.Length && endTextBoxes[ix].Enabled)
{
endTextBoxes[ix].Text = text;
LoadImage(null, Tst.End, ix);
}
}
else
{
if (ix < startTextBoxes.Length && startTextBoxes[ix].Enabled)
{
startTextBoxes[ix].Text = text;
LoadImage(null, Tst.Start, ix);
}
}
imageProcessingProgressBar.Value++;
}
private void okButton_Click(object sender, EventArgs eArgs)
{
try
@@ -363,20 +565,28 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (wmPos > 0)
{
if (startTextBoxes[i].Enabled)
if (startTextBoxes[i].Enabled && startTextBoxes[i].Text != WMStartStateStr[wmPos - 1])
{
WMStartStateStr[wmPos - 1] = startTextBoxes[i].Text;
WMStartState[wmPos - 1] = Utils.ParseUDouble(startTextBoxes[i].Text) * regReaders[wmPos - 1].LtrsPerPulse;
}
double val;
if (Utils.TryParseUDouble(startTextBoxes[i].Text, out val))
{
WMStartState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
WMStartStateStr[wmPos - 1] = startTextBoxes[i].Text;
}
}
if (endTextBoxes[i].Enabled)
{
WMEndState[wmPos - 1] = Utils.ParseUDouble(endTextBoxes[i].Text) * regReaders[wmPos - 1].LtrsPerPulse;
double val;
if (Utils.TryParseUDouble(endTextBoxes[i].Text, out val))
{
WMEndState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
}
}
}
}
}
catch(Exception e)
catch (Exception e)
{
log.ErrorFormat("Exception: {0}", e.Message);
return;
@@ -478,9 +688,17 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
try
{
double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume;
double startV = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text);
double startVolumeL = (unit == Unit.pulse)
? startV * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse
: Units.ConvertFrom(unit, startV);
double endV = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text);
double endVolumeL = (unit == Unit.pulse)
? endV * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse
: Units.ConvertFrom(unit, endV);
double err = 100.0 * (endVolumeL - startVolumeL - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err);
}
catch
@@ -572,7 +790,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (startTextBoxes[j] == currentTextBox)
{
LoadImage(Tst.Start, j);
LoadImage(currentTextBox, Tst.Start, j);
return;
}
}
@@ -580,7 +798,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (endTextBoxes[j] == currentTextBox)
{
LoadImage(Tst.End, j);
LoadImage(currentTextBox, Tst.End, j);
return;
}
}
@@ -593,103 +811,103 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
private void startTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 0); }
private void startTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 1); }
private void startTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 2); }
private void startTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 3); }
private void startTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 4); }
private void startTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 5); }
private void startTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 6); }
private void startTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 7); }
private void startTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 8); }
private void startTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 9); }
private void startTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 10); }
private void startTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 11); }
private void startTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 12); }
private void startTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 13); }
private void startTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 14); }
private void startTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 15); }
private void startTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 16); }
private void startTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 17); }
private void startTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 18); }
private void startTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 19); }
private void startTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 20); }
private void startTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 21); }
private void startTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 22); }
private void startTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.Start, 23); }
private void startTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 0); }
private void startTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 1); }
private void startTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 2); }
private void startTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 3); }
private void startTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 4); }
private void startTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 5); }
private void startTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 6); }
private void startTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 7); }
private void startTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 8); }
private void startTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 9); }
private void startTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 10); }
private void startTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 11); }
private void startTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 12); }
private void startTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 13); }
private void startTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 14); }
private void startTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 15); }
private void startTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 16); }
private void startTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 17); }
private void startTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 18); }
private void startTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 19); }
private void startTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 20); }
private void startTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 21); }
private void startTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 22); }
private void startTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.Start, 23); }
private void startTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 0); }
private void startTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 1); }
private void startTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 2); }
private void startTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 3); }
private void startTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 4); }
private void startTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 5); }
private void startTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 6); }
private void startTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 7); }
private void startTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 8); }
private void startTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 9); }
private void startTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 10); }
private void startTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 11); }
private void startTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 12); }
private void startTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 13); }
private void startTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 14); }
private void startTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 15); }
private void startTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 16); }
private void startTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 17); }
private void startTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 18); }
private void startTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 19); }
private void startTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 20); }
private void startTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 21); }
private void startTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 22); }
private void startTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.Start, 23); }
private void startTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 0); }
private void startTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 1); }
private void startTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 2); }
private void startTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 3); }
private void startTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 4); }
private void startTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 5); }
private void startTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 6); }
private void startTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 7); }
private void startTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 8); }
private void startTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 9); }
private void startTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 10); }
private void startTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 11); }
private void startTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 12); }
private void startTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 13); }
private void startTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 14); }
private void startTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 15); }
private void startTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 16); }
private void startTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 17); }
private void startTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 18); }
private void startTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 19); }
private void startTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 20); }
private void startTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 21); }
private void startTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 22); }
private void startTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.Start, 23); }
private void endTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 0); }
private void endTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 1); }
private void endTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 2); }
private void endTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 3); }
private void endTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 4); }
private void endTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 5); }
private void endTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 6); }
private void endTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 7); }
private void endTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 8); }
private void endTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 9); }
private void endTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 10); }
private void endTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 11); }
private void endTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 12); }
private void endTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 13); }
private void endTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 14); }
private void endTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 15); }
private void endTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 16); }
private void endTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 17); }
private void endTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 18); }
private void endTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 19); }
private void endTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 20); }
private void endTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 21); }
private void endTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 22); }
private void endTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(Tst.End, 23); }
private void endTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 0); }
private void endTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 1); }
private void endTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 2); }
private void endTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 3); }
private void endTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 4); }
private void endTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 5); }
private void endTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 6); }
private void endTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 7); }
private void endTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 8); }
private void endTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 9); }
private void endTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 10); }
private void endTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 11); }
private void endTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 12); }
private void endTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 13); }
private void endTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 14); }
private void endTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 15); }
private void endTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 16); }
private void endTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 17); }
private void endTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 18); }
private void endTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 19); }
private void endTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 20); }
private void endTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 21); }
private void endTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 22); }
private void endTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(Tst.End, 23); }
private void endTextBox1_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 0); }
private void endTextBox2_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 1); }
private void endTextBox3_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 2); }
private void endTextBox4_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 3); }
private void endTextBox5_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 4); }
private void endTextBox6_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 5); }
private void endTextBox7_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 6); }
private void endTextBox8_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 7); }
private void endTextBox9_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 8); }
private void endTextBox10_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 9); }
private void endTextBox11_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 10); }
private void endTextBox12_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 11); }
private void endTextBox13_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 12); }
private void endTextBox14_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 13); }
private void endTextBox15_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 14); }
private void endTextBox16_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 15); }
private void endTextBox17_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 16); }
private void endTextBox18_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 17); }
private void endTextBox19_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 18); }
private void endTextBox20_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 19); }
private void endTextBox21_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 20); }
private void endTextBox22_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 21); }
private void endTextBox24_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 22); }
private void endTextBox23_AcceptsTabChanged(object sender, EventArgs e) { LoadImage(sender, Tst.End, 23); }
private void endTextBox1_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 0); }
private void endTextBox2_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 1); }
private void endTextBox3_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 2); }
private void endTextBox4_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 3); }
private void endTextBox5_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 4); }
private void endTextBox6_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 5); }
private void endTextBox7_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 6); }
private void endTextBox8_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 7); }
private void endTextBox9_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 8); }
private void endTextBox10_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 9); }
private void endTextBox11_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 10); }
private void endTextBox12_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 11); }
private void endTextBox13_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 12); }
private void endTextBox14_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 13); }
private void endTextBox15_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 14); }
private void endTextBox16_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 15); }
private void endTextBox17_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 16); }
private void endTextBox18_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 17); }
private void endTextBox19_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 18); }
private void endTextBox20_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 19); }
private void endTextBox21_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 20); }
private void endTextBox22_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 21); }
private void endTextBox23_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 22); }
private void endTextBox24_MouseDown(object sender, MouseEventArgs e) { LoadImage(sender, Tst.End, 23); }
/// <summary>
/// Loads appropriate image into pictureBox1.Image
@@ -697,17 +915,17 @@ namespace TBF.Rig.DataEntry.StandardCamera
/// </summary>
/// <param name="startOrEnd">Tst.Start or Tst.End</param>
/// <param name="physPos">0..23</param>
void LoadImage(Tst startOrEnd, int physPos)
void LoadImage(object sender, Tst startOrEnd, int physPos)
{
ShowUnits(startOrEnd, physPos);
int wmNr1b = phys2wm[physPos]; /// 0 means no WM
wmNr0b = Math.Max(0, wmNr1b - 1);
if (wmNr1b <= 0) return;
wmNr0b = wmNr1b - 1;
string imageFileName;
if ((startOrEnd == Tst.Start) && (wmNr1b > 0) && (startImages[wmNr0b] != null))
if (startOrEnd == Tst.Start && startImages[wmNr0b] != null)
imageFileName = startImages[wmNr0b];
else if ((startOrEnd == Tst.End) && (wmNr1b > 0) && (endImages[wmNr0b] != null))
else if (startOrEnd == Tst.End && endImages[wmNr0b] != null)
imageFileName = endImages[wmNr0b];
else
imageFileName = string.Empty;
@@ -718,6 +936,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
lastImageName = imageFileName;
lastWmNr1 = wmNr1b;
if (string.IsNullOrEmpty(imageFileName) || !File.Exists(imageFileName))
{
@@ -725,16 +944,31 @@ namespace TBF.Rig.DataEntry.StandardCamera
}
else
{
using (Bitmap tempBmp = Image.FromFile(imageFileName) as Bitmap)
{
int hght = tempBmp.Height;
int leftMargin = (tempBmp.Width - hght) / 2;
lastImage = new Bitmap(tempBmp.Clone(new Rectangle(leftMargin, 0, hght, hght), tempBmp.PixelFormat));
if (isZoomed[wmNr0b])
{
zoomedImage = MakeZoomedImage(lastImage, zoomCenterLoc[wmNr0b]);
}
}
using (Bitmap tempBmp = Image.FromFile(imageFileName) as Bitmap)
{
Rectangle rect;
if (tempBmp.Height < tempBmp.Width)
{
int hght = tempBmp.Height;
int leftMargin = (tempBmp.Width - hght) / 2;
rect = new Rectangle(leftMargin, 0, hght, hght);
}
else
{
int hght = tempBmp.Height;
int wdth = tempBmp.Width;
int margin = (hght - wdth) / 2;
rect = new Rectangle(0, margin, wdth, wdth);
}
//int hght = tempBmp.Height;
//int leftMargin = (tempBmp.Width - hght) / 2;
//lastImage = new Bitmap(tempBmp.Clone(new Rectangle(leftMargin, 0, hght, hght), tempBmp.PixelFormat));
lastImage = new Bitmap(tempBmp.Clone(rect, tempBmp.PixelFormat));
if (isZoomed[wmNr0b])
{
zoomedImage = MakeZoomedImage(lastImage, zoomCenterLoc[wmNr0b]);
}
}
}
ShowImage();
@@ -752,7 +986,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (me.Button == MouseButtons.Left && !isZoomed[wmNr0b])
{
switch (imageRotation[wmNr0b])
switch (imageRotation)
{
case Rotation.R0:
zoomCenterLoc[wmNr0b] = me.Location;
@@ -786,9 +1020,9 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
if (lastImage == null) return;
if (++imageRotation[wmNr0b] == Rotation.Count)
if (++imageRotation == Rotation.Count)
{
imageRotation[wmNr0b] = Rotation.R0;
imageRotation = Rotation.R0;
}
ShowImage();
}
@@ -807,9 +1041,17 @@ namespace TBF.Rig.DataEntry.StandardCamera
return lastImage.Clone(newRect, oriImage.PixelFormat);
}
///
/// Used by ShowImage()
///
Brush lightBrush = new SolidBrush(Color.LightGreen);
Brush darkBrush = new SolidBrush(Color.Green);
Font largeFont = new Font("arial", 24.0F, FontStyle.Bold); /// normal image
Font smallFont = new Font("arial", 12.0F, FontStyle.Bold); /// zoomed image
/// <summary>
/// Show selected image in the picture box.
/// lastImage, zoomedImage, isZoomed and imageRotation are used.
/// lastWmNr1, lastImage, zoomedImage, isZoomed and imageRotation are used.
/// </summary>
void ShowImage()
{
@@ -823,96 +1065,37 @@ namespace TBF.Rig.DataEntry.StandardCamera
? new Bitmap(zoomedImage.Clone(new Rectangle(0, 0, zoomedImage.Width, zoomedImage.Height), zoomedImage.PixelFormat))
: new Bitmap(lastImage.Clone(new Rectangle(0, 0, lastImage.Width, lastImage.Height), lastImage.PixelFormat));
switch (imageRotation[wmNr0b])
switch (imageRotation)
{
case Rotation.R90: tempBmp.RotateFlip(RotateFlipType.Rotate270FlipNone); break;
case Rotation.R180: tempBmp.RotateFlip(RotateFlipType.Rotate180FlipNone); break;
case Rotation.R270: tempBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); break;
}
/// Write water meter number to the bitmap
using (var grph = Graphics.FromImage(tempBmp))
{
Font font = isZoomed[wmNr0b] ? smallFont : largeFont;
int margin = isZoomed[wmNr0b] ? 1 : 2;
int pixelsCount = 0;
int brightness = 0;
for (int x = margin; x <= 8 * margin; x += margin)
{
for (int y = margin; y <= 8 * margin; y += margin)
{
brightness += (int)tempBmp.GetPixel(x, y).G;
pixelsCount++;
}
}
brightness /= pixelsCount;
Brush brush = (brightness > 160) ? darkBrush : lightBrush;
grph.DrawString(lastWmNr1.ToString(), font, brush, margin, margin);
}
pictureBox1.Image = tempBmp;
}
/// <summary>
/// Updates startLabel.Text, startLabel2.Text, endLabel.Text, endLabel2.Text
/// Appends appropriate units of volume.
/// Handles mouse clicks and Tab-changes inside text boxes.
/// </summary>
/// <param name="startEnd">Tst.Start or Tst.End</param>
/// <param name="physPos">0..24</param>
void ShowUnits(Tst startEnd, int physPos)
{
int wmNr = phys2wm[physPos];
if (wmNr > 0 && startEnd == Tst.Start)
{
if (regReaders[wmNr - 1] != null)
{
if (physPos < 12)
{
startLabel.Text = string.Format("{0} [{1}]", Strings.Start, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
startLabel2.Text = Strings.Start;
}
else
{
startLabel.Text = Strings.Start;
startLabel2.Text = string.Format("{0} [{1}]", Strings.Start, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
}
}
else
{
startLabel.Text = startLabel2.Text = Strings.Start;
}
endLabel.Text = endLabel2.Text = Strings.End;
}
else if (wmNr > 0 && startEnd == Tst.End)
{
startLabel.Text = startLabel2.Text = Strings.Start;
if (regReaders[wmNr - 1] != null)
{
if (physPos < 12)
{
endLabel.Text = string.Format("{0} [{1}]", Strings.End, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
endLabel2.Text = Strings.End;
}
else
{
endLabel.Text = Strings.End;
endLabel2.Text = string.Format("{0} [{1}]", Strings.End, GetUnitStr(regReaders[wmNr - 1].PulsesPerLtr));
}
}
else
{
endLabel.Text = endLabel2.Text = Strings.End;
}
}
else
{
startLabel.Text = startLabel2.Text = Strings.Start;
endLabel.Text = endLabel2.Text = Strings.End;
}
}
///
string GetUnitStr(double pulsesPerLtr)
{
if (pulsesPerLtr == 1 || pulsesPerLtr <= float.Epsilon)
{
return "l";
}
else if (pulsesPerLtr == 0.001)
{
return "m3";
}
else if (pulsesPerLtr == 1000)
{
return "ml";
}
else
{
return string.Format("{0} l", 1 / pulsesPerLtr);
}
}
}
}

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