From e252e551973c7e8f8ef431e0b61a36c037d11439 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 5 Jun 2019 16:02:36 +0200 Subject: [PATCH] (1) Results.Output.Printers.WMChart added, (2) Results.Forms.MoreWMResultsDlg added, (3) Output.Printers.OnePerMeter can print graphs, ver. 2.18.1249 --- Results/Entities/WaterMeter.cs | 96 ++++++++++ Results/Forms/BatchResultsDlg.cs | 129 +++---------- Results/Forms/MoreWMResultsDlg.Designer.cs | 177 ++++++++++++++++++ Results/Forms/MoreWMResultsDlg.cs | 150 +++++++++++++++ Results/Forms/MoreWMResultsDlg.resx | 120 ++++++++++++ .../OnePerMeter/OnePerMeterPrintDocument.cs | 6 + .../OnePerMeter/OnePerMeterPrinterCfg.cs | 8 +- Results/Output/{Printers => }/Table.cs | 22 +-- Results/Output/WMChart.cs | 116 ++++++++++++ Results/Properties/AssemblyInfo.cs | 4 +- Results/Resources/Strings.Designer.cs | 72 +++++++ Results/Resources/Strings.cs.resx | 30 +++ Results/Resources/Strings.resx | 24 +++ Results/Results.csproj | 13 +- Results/WMeterRsltItemSpec.cs | 4 +- .../Output/Printers/OnePerMeter/Printer.cs | 16 +- .../Output/Printers/OnePerMeter/PrinterCfg.cs | 10 +- .../OnePerMeter/PrinterCfgCtrl.Designer.cs | 132 ++++++++----- .../Printers/OnePerMeter/PrinterCfgCtrl.cs | 53 +++++- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/Resources/Strings.Designer.cs | 9 + TBF/Resources/Strings.cs.resx | 3 + TBF/Resources/Strings.resx | 3 + TBF/Screens/ResultsTabPageCtrl.cs | 135 +++---------- 24 files changed, 1043 insertions(+), 293 deletions(-) create mode 100644 Results/Forms/MoreWMResultsDlg.Designer.cs create mode 100644 Results/Forms/MoreWMResultsDlg.cs create mode 100644 Results/Forms/MoreWMResultsDlg.resx rename Results/Output/{Printers => }/Table.cs (94%) create mode 100644 Results/Output/WMChart.cs diff --git a/Results/Entities/WaterMeter.cs b/Results/Entities/WaterMeter.cs index 3a6a40c20..59a3c25fe 100644 --- a/Results/Entities/WaterMeter.cs +++ b/Results/Entities/WaterMeter.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Text; using Config.Entities; +using Results.Resources; namespace Results.Entities { @@ -444,5 +445,100 @@ namespace Results.Entities sb.AppendFormat(" test start: {0} {1} batch={2}", StartTime().ToShortDateString(), StartTime().ToShortTimeString(), BatchNr()); return sb.ToString(); } + + + /// + /// Get decorated test names for a specified watermeter + /// + /// Watermeter results entity + /// A list of strings + public virtual IList GetAllDecoratedTestNames() + { + IList testNames = new List(); + + if (MeterTestRslts != null) + { + foreach (var mtr in MeterTestRslts) + { + if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound || mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) + && mtr.TestDone + && (mtr.Publish() != Config.Entities.Publish.Never) + && (mtr.Publish() != Config.Entities.Publish.Internal)) + { + testNames.Add(mtr.Name()); + } + } + } + + return testNames; + } + + + static readonly System.Drawing.Color NotCompletedColor = System.Drawing.Color.White; + static readonly System.Drawing.Color OkColor = System.Drawing.Color.LightGreen; + static readonly System.Drawing.Color NokColor = System.Drawing.Color.LightPink; + static readonly System.Drawing.Color RejectColor = System.Drawing.Color.Magenta; + static readonly System.Drawing.Color ProductionTracing = System.Drawing.Color.RoyalBlue; + static readonly System.Drawing.Color WrongDirection = System.Drawing.Color.Gold; + static readonly System.Drawing.Color WrongQ2FactorsColor = System.Drawing.Color.Red; + + /// + /// Get color for highlighting results and an apporpriate text message. + /// + /// Water meter results entity + /// Appropriate message + /// Color for results + public virtual System.Drawing.Color GetColorOfResults(bool maxRepeatsExceeded, out string message) + { + bool wmtrCompleted = CompletedFromTests(); + bool wmtrPassed = PassedFromTests(); + + if ((ErrorFlags & (int)ErrorFlagMask.E28) != 0) + { + message = Strings.Previous_step_is_missing_or_NOK; + return ProductionTracing; + } + else if ((ErrorFlags & (int)ErrorFlagMask.E27) != 0) + { + message = Strings.Wrong_iPerl_counting_direction; + return WrongDirection; + } + else if ((ErrorFlags & (int)ErrorFlagMask.E26) != 0) + { + message = Strings.Invalid_Q2_correction_factors; + return WrongQ2FactorsColor; + } + else if ((ErrorFlags & (int)ErrorFlagMask.E25) != 0) + { + message = Strings.Test_repetition_count_exceeded_upper_limit; + return RejectColor; + } + else if (wmtrPassed) + { + /// Water meter passed (therefore is was also completed) + message = Strings.Passed; + return OkColor; + } + else if (wmtrCompleted) + { + /// Water meter was completed but did not pass => Failed + if (maxRepeatsExceeded) + { + message = Strings.Test_repetition_count_exceeded_upper_limit; + return RejectColor; + } + else + { + message = Strings.Failed; + return NokColor; + } + } + else + { + /// Water meter was not completed yet => did not pass, did not fail + message = Strings.Test_in_progress; + return NotCompletedColor; + } + } } } diff --git a/Results/Forms/BatchResultsDlg.cs b/Results/Forms/BatchResultsDlg.cs index 3686604d9..1bb6158f5 100644 --- a/Results/Forms/BatchResultsDlg.cs +++ b/Results/Forms/BatchResultsDlg.cs @@ -19,15 +19,6 @@ namespace Results.Forms static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsDlg)); - static readonly Color NotCompletedColor = Color.White; - static readonly Color OkColor = Color.LightGreen; - static readonly Color NokColor = Color.LightPink; - static readonly Color RejectColor = Color.Magenta; - static readonly Color ProductionTracing = Color.RoyalBlue; - static readonly Color WrongDirection = Color.Gold; - static readonly Color WrongQ2FactorsColor = Color.Red; - - DateTime lastRedraw; DateTime lastSizeChange; bool loaded; @@ -174,19 +165,17 @@ namespace Results.Forms first = false; } -#if TURA_IPERL || TURA_SPECIAL lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args) - { - if (InvokeRequired) { - Invoke(new EventHandler(OnDoubleClick), sender, args); - } - else - { - OnDoubleClick(sender, args); - } - }; -#endif + if (InvokeRequired) + { + Invoke(new EventHandler(OnDoubleClick), sender, args); + } + else + { + OnDoubleClick(sender, args); + } + }; } } } @@ -213,81 +202,10 @@ namespace Results.Forms { return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm); } - OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm) { return GetListView(Color.White, wm); } - - - /// - /// Get decorated test names for a specified watermeter - /// - /// Watermeter results entity - /// A list of strings - IList GetAllDecoratedTestNames(Results.Entities.WaterMeter wMtr) + /// + OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm) { - IList testNames = new List(); - - foreach (var mtr in wMtr.MeterTestRslts) - { - if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound || mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) - && mtr.TestDone - && (mtr.Publish() != Config.Entities.Publish.Never) - && (mtr.Publish() != Config.Entities.Publish.Internal)) - { - testNames.Add(mtr.Name()); - } - } - - return testNames; - } - - /// - /// Get color for highlighting results and an apporpriate text message. - /// - /// Water meter results entity - /// Appropriate message - /// Color for results - Color GetColorOfResults(Results.Entities.WaterMeter wMtr, out string message) - { - bool wmtrCompleted = wMtr.CompletedFromTests(); - bool wmtrPassed = wMtr.PassedFromTests(); - - if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E28) != 0) - { - message = Strings.Previous_step_is_missing_or_NOK; - return ProductionTracing; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E27) != 0) - { - message = Strings.Wrong_iPerl_counting_direction; - return WrongDirection; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E26) != 0) - { - message = Strings.Invalid_Q2_correction_factors; - return WrongQ2FactorsColor; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E25) != 0) - { - message = Strings.Test_repetition_count_exceeded_upper_limit; - return RejectColor; - } - else if (wmtrPassed) - { - /// Water meter passed (therefore is was also completed) - message = Strings.Passed; - return OkColor; - } - else if (wmtrCompleted) - { - /// Water meter was completed but did not pass => Failed - message = Strings.Failed; - return NokColor; - } - else - { - /// Water meter was not completed yet => did not pass, did not fail - message = Strings.Test_in_progress; - return NotCompletedColor; - } + return GetListView(Color.White, wm); } @@ -301,7 +219,7 @@ namespace Results.Forms metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single); string message = string.Empty; - Color commonBackColor = GetColorOfResults(wMtr, out message); + Color commonBackColor = wMtr.GetColorOfResults(false, out message); OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); #if ORACLE_DB lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message); @@ -323,7 +241,7 @@ namespace Results.Forms } - IList testNames = GetAllDecoratedTestNames(wMtr); + IList testNames = wMtr.GetAllDecoratedTestNames(); int ix = 0; foreach (var mtr in wMtr.MeterTestRslts) { @@ -373,7 +291,7 @@ namespace Results.Forms metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single); string message; - Color commonBackColor = GetColorOfResults(wMtr, out message); + Color commonBackColor = wMtr.GetColorOfResults(false, out message); OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); #if ORACLE_DB lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message); @@ -388,7 +306,7 @@ namespace Results.Forms // Header lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40); int i = 1; - foreach (var str in GetAllDecoratedTestNames(wMtr)) + foreach (var str in wMtr.GetAllDecoratedTestNames()) { lview.Columns.Add(str, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70); i++; @@ -433,22 +351,21 @@ namespace Results.Forms void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args) { - Results.Entities.WaterMeter wm = args.WM; - - if (wm == null || wm.Disabled || string.IsNullOrEmpty(wm.SerialNr)) + if ( args.WM == null || args.WM.Disabled) { - MessageBox.Show("No water meter or missing S/N"); + MessageBox.Show(Strings.No_water_meter); + return; } - else if (TracingDB.DB.SessionFactory == null) + else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr)) { - MessageBox.Show("No access to tracing database"); + new Results.Forms.MoreWMResultsDlg( args.WM, null).ShowDialog(); } else { using (ISession session = TracingDB.DB.SessionFactory.OpenSession()) { IList refRecords = session.QueryOver() - .Where(x => (x.Code == wm.SerialNr)) + .Where(x => (x.Code == args.WM.SerialNr)) .OrderBy(x => x.TimeStamp).Desc .List(); for (int i = 0; i < refRecords.Count; i++) @@ -474,7 +391,7 @@ namespace Results.Forms } } - new Results.Forms.TracingResultsDlg(refRecords).ShowDialog(); + new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog(); } } } diff --git a/Results/Forms/MoreWMResultsDlg.Designer.cs b/Results/Forms/MoreWMResultsDlg.Designer.cs new file mode 100644 index 000000000..1dcf645fc --- /dev/null +++ b/Results/Forms/MoreWMResultsDlg.Designer.cs @@ -0,0 +1,177 @@ +namespace Results.Forms +{ + partial class MoreWMResultsDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.allResultsTabPage = new System.Windows.Forms.TabPage(); + this.graphsTabPage = new System.Windows.Forms.TabPage(); + this.productionTracingTabPage = new System.Windows.Forms.TabPage(); + this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer(); + this.messageLabel = new System.Windows.Forms.Label(); + this.tracingResultsListView = new System.Windows.Forms.ListView(); + this.oneWMResultsCtrl = new Results.Forms.OneWMResultsCtrl(); + this.tabControl1.SuspendLayout(); + this.allResultsTabPage.SuspendLayout(); + this.productionTracingTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit(); + this.productionTracingSplitContainer.Panel1.SuspendLayout(); + this.productionTracingSplitContainer.Panel2.SuspendLayout(); + this.productionTracingSplitContainer.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.allResultsTabPage); + this.tabControl1.Controls.Add(this.graphsTabPage); + this.tabControl1.Controls.Add(this.productionTracingTabPage); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + 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); + this.graphsTabPage.Name = "graphsTabPage"; + this.graphsTabPage.Padding = new System.Windows.Forms.Padding(3); + this.graphsTabPage.Size = new System.Drawing.Size(1187, 422); + this.graphsTabPage.TabIndex = 1; + this.graphsTabPage.Text = "Graphs"; + this.graphsTabPage.UseVisualStyleBackColor = true; + // + // productionTracingTabPage + // + this.productionTracingTabPage.Controls.Add(this.productionTracingSplitContainer); + this.productionTracingTabPage.Location = new System.Drawing.Point(4, 22); + this.productionTracingTabPage.Name = "productionTracingTabPage"; + this.productionTracingTabPage.Size = new System.Drawing.Size(1187, 422); + this.productionTracingTabPage.TabIndex = 2; + this.productionTracingTabPage.Text = "Production tracing"; + this.productionTracingTabPage.UseVisualStyleBackColor = true; + // + // productionTracingSplitContainer + // + this.productionTracingSplitContainer.BackColor = System.Drawing.SystemColors.Control; + this.productionTracingSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.productionTracingSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.productionTracingSplitContainer.IsSplitterFixed = true; + this.productionTracingSplitContainer.Location = new System.Drawing.Point(0, 0); + this.productionTracingSplitContainer.Name = "productionTracingSplitContainer"; + this.productionTracingSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // productionTracingSplitContainer.Panel1 + // + this.productionTracingSplitContainer.Panel1.Controls.Add(this.messageLabel); + this.productionTracingSplitContainer.Panel1MinSize = 55; + // + // productionTracingSplitContainer.Panel2 + // + this.productionTracingSplitContainer.Panel2.Controls.Add(this.tracingResultsListView); + this.productionTracingSplitContainer.Panel2MinSize = 60; + this.productionTracingSplitContainer.Size = new System.Drawing.Size(1187, 422); + this.productionTracingSplitContainer.SplitterDistance = 55; + this.productionTracingSplitContainer.SplitterWidth = 1; + this.productionTracingSplitContainer.TabIndex = 0; + // + // messageLabel + // + this.messageLabel.AutoSize = true; + this.messageLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.messageLabel.Location = new System.Drawing.Point(12, 9); + this.messageLabel.Name = "messageLabel"; + this.messageLabel.Size = new System.Drawing.Size(152, 37); + this.messageLabel.TabIndex = 1; + this.messageLabel.Text = "Message"; + // + // tracingResultsListView + // + this.tracingResultsListView.Dock = System.Windows.Forms.DockStyle.Fill; + this.tracingResultsListView.GridLines = true; + this.tracingResultsListView.Location = new System.Drawing.Point(0, 0); + this.tracingResultsListView.Name = "tracingResultsListView"; + this.tracingResultsListView.Size = new System.Drawing.Size(1187, 366); + this.tracingResultsListView.TabIndex = 0; + this.tracingResultsListView.UseCompatibleStateImageBehavior = false; + this.tracingResultsListView.View = System.Windows.Forms.View.Details; + // + // oneWMResultsCtrl + // + this.oneWMResultsCtrl.Caption = ""; + this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; + this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3); + this.oneWMResultsCtrl.Name = "oneWMResultsCtrl"; + this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416); + this.oneWMResultsCtrl.TabIndex = 0; + // + // MoreWMResultsDlg + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1195, 448); + this.Controls.Add(this.tabControl1); + this.Name = "MoreWMResultsDlg"; + 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(); + this.productionTracingSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).EndInit(); + this.productionTracingSplitContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage allResultsTabPage; + private OneWMResultsCtrl 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; + } +} \ No newline at end of file diff --git a/Results/Forms/MoreWMResultsDlg.cs b/Results/Forms/MoreWMResultsDlg.cs new file mode 100644 index 000000000..ba7dcde8e --- /dev/null +++ b/Results/Forms/MoreWMResultsDlg.cs @@ -0,0 +1,150 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using TracingDB.Entities; +using Results.Resources; +using Config.Entities; +using System.Drawing; +using System.Windows.Forms.DataVisualization.Charting; + +namespace Results.Forms +{ + public partial class MoreWMResultsDlg : Form + { + public MoreWMResultsDlg(Results.Entities.WaterMeter wm, IList refRecords) + { + InitializeComponent(); + + Localize(); + + ShowAllResults(wm); + ShowChart(wm); + + if (refRecords == null) + { + tabControl1.SelectTab(1); + tabControl1.TabPages[2].Hide(); + } + else + { + tabControl1.SelectTab(2); + ShowTracingResults(wm, refRecords); + } + } + + + 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; + } + + + /// + /// Display all results for this water meter in the 1st tab page + /// + /// Water meter entity + 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 + + IList 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++; + } + + 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() != Config.Entities.Publish.Never && + mtr.Publish() != Config.Entities.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); + } + } + } + + 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)); + } + + + /// + /// Display tracing results in the 3rd tab page + /// + /// Water meter entity + /// ReferenceRecord-s from tracing DB + void ShowTracingResults(Results.Entities.WaterMeter wm, IList refRecords) + { + tracingResultsListView.Columns.Add(Strings.Date_and_time, 110); + tracingResultsListView.Columns.Add(Strings.Step, 100); + tracingResultsListView.Columns.Add(Strings.Workplace, 100); + tracingResultsListView.Columns.Add(Strings.Name, 100); + tracingResultsListView.Columns.Add(Strings.Result, 70); + tracingResultsListView.Columns.Add(Strings.Part, 90); + tracingResultsListView.Columns.Add(Strings.Code, 150); + tracingResultsListView.Columns.Add(Strings.Workflow, 450); + + foreach (var rr in refRecords) + { + tracingResultsListView.Items.Add(new ListViewItem(new string[] + { + rr.TimeStamp.ToString("dd.MM.yyyy HH:mm"), + rr.Workstep.Name, + rr.Workplace, + rr.UserName, + rr.Result == 0 ? "OK" : "NOK", + rr.Workstep.ReferencePart.Name, + rr.Code, + rr.Process.Name, + })); + } + } + } +} diff --git a/Results/Forms/MoreWMResultsDlg.resx b/Results/Forms/MoreWMResultsDlg.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/Results/Forms/MoreWMResultsDlg.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs index 773e4f519..f4b6fbdf3 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs @@ -152,6 +152,12 @@ namespace Results.Output.Printers.OnePerMeter } } + if ((cfg.GraphHgh != 0) && (cfg.GraphWid != 0)) + { + Rectangle pos = new Rectangle(cfg.GraphLeft, cfg.GraphTop, cfg.GraphWid, cfg.GraphHgh); + WMChart.GetChart(wm).Printing.PrintPaint(e.Graphics, pos); + } + float tableTop = cfg.TopMargin; if (pageNr == 1) diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs index 94700e6a7..748c68033 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2019 Sensus Slovensko a.s. /// namespace Results.Output.Printers.OnePerMeter @@ -45,10 +45,14 @@ namespace Results.Output.Printers.OnePerMeter public string[] BelowItems3; public string Footer; public bool TestsAreRows; - public string ImgFullPathName; + public int GraphLeft; + public int GraphTop; + public int GraphWid; + public int GraphHgh; public int ImgLeft; public int ImgTop; public int ImgWid; public int ImgHgh; + public string ImgFullPathName; } } diff --git a/Results/Output/Printers/Table.cs b/Results/Output/Table.cs similarity index 94% rename from Results/Output/Printers/Table.cs rename to Results/Output/Table.cs index 17c1419b2..f5fd7776d 100644 --- a/Results/Output/Printers/Table.cs +++ b/Results/Output/Table.cs @@ -7,7 +7,7 @@ using System.Drawing; using System.Drawing.Printing; using Config.Entities; -namespace Results.Output.Printers +namespace Results.Output { public enum TableLines { @@ -94,7 +94,7 @@ namespace Results.Output.Printers else { bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount); - SizeF size = PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); + SizeF size = Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width; if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height; } @@ -157,7 +157,7 @@ namespace Results.Output.Printers { /// In not a separator line bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount); - SizeF size = PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); + SizeF size = Printers.PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); if ((Style.ColumnWidths != null) && (Style.ColumnWidths.Length > colIx)) { size.Width = Style.ColumnWidths[colIx]; /// Override measurement if column width is defined @@ -244,14 +244,14 @@ namespace Results.Output.Printers for (int colIndex = 0; colIndex < tblColumnsCount; colIndex++) { bool isHeader = (colIndex < Style.LeftHeadersCount) || (rowIndex < Style.TopHeadersCount); - PrintersCommon.PrintAt(e, oneTableRow[colIndex], - isHeader ? Style.HeaderFont : Style.Font, - columnPos[colIndex], - rowPos[rowIndex], - columnWidth[colIndex], - rowHeight[rowIndex], - horizAlignment[colIndex], - vertAlignment[colIndex]); + Printers.PrintersCommon.PrintAt(e, oneTableRow[colIndex], + isHeader ? Style.HeaderFont : Style.Font, + columnPos[colIndex], + rowPos[rowIndex], + columnWidth[colIndex], + rowHeight[rowIndex], + horizAlignment[colIndex], + vertAlignment[colIndex]); } } } diff --git a/Results/Output/WMChart.cs b/Results/Output/WMChart.cs new file mode 100644 index 000000000..26ce4419a --- /dev/null +++ b/Results/Output/WMChart.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms.DataVisualization.Charting; +using Config.Entities; +using Results.Entities; +using Results.Resources; + +namespace Results.Output +{ + public class WMChart + { + public static Chart GetChart(WaterMeter wm) + { + return GetChart(wm, Config.Unit.lph, false); + } + + public static Chart GetChart(WaterMeter wm, Config.Unit flowUnit, bool isQ4) + { + IList unsortedPoints = new List(); + foreach (var mtr in wm.MeterTestRslts) + { + if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0)) + { + double flow = Config.Units.ConvertTo(flowUnit, mtr.TestRslt.VolumeCTV / mtr.TestTime * 3.6 * mtr.PulsesMaster / mtr.TestRslt.PulsesMaster); + if (flow > 0) + { + unsortedPoints.Add(new PointF((float)flow, (float)mtr.Error)); + } + } + } + IEnumerable sortedPoints = unsortedPoints.OrderBy(x => x.X); + + Chart chart = new Chart + { + Name = "chart", + Text = "chart", + Dock = System.Windows.Forms.DockStyle.Fill, + TabIndex = 0, + Size = new System.Drawing.Size(5, 5), + Location = new System.Drawing.Point(3, 3), + }; + + ChartArea chArea = new ChartArea { Name = "ChartArea1" }; + chArea.AxisX.Title = Strings.Flow; + chArea.AxisX.IsLogarithmic = true; + chArea.AxisX.LogarithmBase = 10; + chArea.AxisX.IsLabelAutoFit = false; + + List xs = new List() { 0.0001, 0.0002, 0.0005, + 0.001, 0.002, 0.005, + 0.01, 0.02, 0.05, + 0.1, 0.2, 0.5, + 1, 2, 5, + 10, 20, 50, + 100, 200, 500, + 1000, 2000, 5000, + 10000, 20000, 50000, + 100000, 200000, 500000, + 1000000, 2000000, 5000000 }; + double spacer = 0.8; + double from = Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin); + double to = Config.Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn); + for (int i = 1; i < xs.Count - 1; i++) + { + if ((xs[i + 1] > from) && (xs[i - 1] < to)) + { + CustomLabel cl = new CustomLabel(); + cl.Text = string.Format("{0} {1}", xs[i], flowUnit.ToDescription()); + cl.FromPosition = Math.Log10(xs[i] * spacer); + cl.ToPosition = Math.Log10(xs[i] / spacer); + chArea.AxisX.CustomLabels.Add(cl); + } + } + + chArea.AxisY.Title = Strings.Relative_error; + chArea.AxisY.Interval = 3; + chArea.AxisY.LabelStyle.Format = "{#} %"; + + 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(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), 5); + upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 5); + upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), 2); + upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), 2); + if (isQ4) upperLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), 2); + + Series lowerLimit = new Series { Name = Strings.Lower_limit, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.Red }; + lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin), -5); + lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -5); + lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q2_Qt), -2); + lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q3_Qn), -2); + if (isQ4) lowerLimit.Points.AddXY(Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q4_Qmax), -2); + + Series line = new Series { Name = Strings.Relative_error, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.DeepSkyBlue }; + Series dots = new Series { Name = Strings.Relative_error + " ", ChartArea = "ChartArea1", ChartType = SeriesChartType.Point, Color = Color.RoyalBlue }; + foreach (var point in sortedPoints) + { + line.Points.AddXY(point.X, point.Y); + dots.Points.AddXY(point.X, point.Y); + } + + chart.ChartAreas.Add(chArea); + chart.Legends.Add(legend1); + chart.Series.Add(upperLimit); + chart.Series.Add(lowerLimit); + chart.Series.Add(dots); + chart.Series.Add(line); + + return chart; + } + } +} diff --git a/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index a3f10f3ac..b5fba20ed 100644 --- a/Results/Properties/AssemblyInfo.cs +++ b/Results/Properties/AssemblyInfo.cs @@ -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.18.1241.0")] -[assembly: AssemblyFileVersion("2.18.1241.0")] +[assembly: AssemblyVersion("2.18.1249.0")] +[assembly: AssemblyFileVersion("2.18.1249.0")] diff --git a/Results/Resources/Strings.Designer.cs b/Results/Resources/Strings.Designer.cs index 95dd5f6fc..112ee6011 100644 --- a/Results/Resources/Strings.Designer.cs +++ b/Results/Resources/Strings.Designer.cs @@ -87,6 +87,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to All results. + /// + internal static string All_results { + get { + return ResourceManager.GetString("All_results", resourceCulture); + } + } + /// /// Looks up a localized string similar to Approval. /// @@ -465,6 +474,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Graphs. + /// + internal static string Graphs { + get { + return ResourceManager.GetString("Graphs", resourceCulture); + } + } + /// /// Looks up a localized string similar to H amb. /// @@ -510,6 +528,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Lower limit. + /// + internal static string Lower_limit { + get { + return ResourceManager.GetString("Lower_limit", resourceCulture); + } + } + /// /// Looks up a localized string similar to main. /// @@ -564,6 +591,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to No water meter. + /// + internal static string No_water_meter { + get { + return ResourceManager.GetString("No_water_meter", resourceCulture); + } + } + /// /// Looks up a localized string similar to OK. /// @@ -861,6 +897,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Relative error. + /// + internal static string Relative_error { + get { + return ResourceManager.GetString("Relative_error", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remark. /// @@ -951,6 +996,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Serial number is missing. + /// + internal static string Serial_number_is_missing { + get { + return ResourceManager.GetString("Serial_number_is_missing", resourceCulture); + } + } + /// /// Looks up a localized string similar to Single. /// @@ -1851,6 +1905,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Upper limit. + /// + internal static string Upper_limit { + get { + return ResourceManager.GetString("Upper_limit", resourceCulture); + } + } + /// /// Looks up a localized string similar to User. /// @@ -2013,6 +2076,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Water meter results. + /// + internal static string Water_meter_results { + get { + return ResourceManager.GetString("Water_meter_results", resourceCulture); + } + } + /// /// Looks up a localized string similar to Width. /// diff --git a/Results/Resources/Strings.cs.resx b/Results/Resources/Strings.cs.resx index 90b99f139..03d3edcc1 100644 --- a/Results/Resources/Strings.cs.resx +++ b/Results/Resources/Strings.cs.resx @@ -303,4 +303,34 @@ Součástka + + Všechny výsledky + + + Grafy + + + Žádný vodoměr + + + Chybí sériové číslo + + + Chyba + + + Dolní hranice + + + Horní hranice + + + Výsledky vodoměru + + + Relativní chyba + + + Průtok + \ No newline at end of file diff --git a/Results/Resources/Strings.resx b/Results/Resources/Strings.resx index ec4db417d..0d085eb63 100644 --- a/Results/Resources/Strings.resx +++ b/Results/Resources/Strings.resx @@ -792,4 +792,28 @@ Part + + All results + + + Graphs + + + No water meter + + + Serial number is missing + + + Lower limit + + + Upper limit + + + Water meter results + + + Relative error + \ No newline at end of file diff --git a/Results/Results.csproj b/Results/Results.csproj index fa8c9c43c..e76f173ff 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -51,6 +51,7 @@ + @@ -80,6 +81,12 @@ + + Form + + + MoreWMResultsDlg.cs + UserControl @@ -131,11 +138,12 @@ Component - Component + + True @@ -176,6 +184,9 @@ ListViewEx.cs + + MoreWMResultsDlg.cs + OneWMResultsCtrl.cs diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 08e853e9e..926a43a10 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -211,13 +211,13 @@ namespace Results AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_from, string.Format("{0} {1}", Strings.VName_Flow, Strings.from), Quantity.Flow, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).Qfrom()))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_to, string.Format("{0} {1}", Strings.VName_Flow, Strings.to), Quantity.Flow, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).Qto()))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow, string.Format("{0} v r", Strings.VName_Flow), Strings.Tooltip_Q_v_r, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowVolume))); - AllItems.Add(new WMeterRsltItemSpec(ItemID.Qc, string.Format("Qc"), "Calculated water meter flow", Quantity.Flow, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).VolumeCTV / w.GetMeterTestRslt(t).TestTime * 3.6 * w.GetMeterTestRslt(t).PulsesMaster / w.GetTestRslt(t).PulsesMaster))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_mean, string.Format("{0} rim ()", Strings.VName_Flow), Strings.Tooltip_Q_rim, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMean))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_min, string.Format("{0} ref min ()", Strings.VName_Flow), Strings.Tooltip_Q_min, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMin))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_max, string.Format("{0} ref max ()", Strings.VName_Flow), Strings.Tooltip_Q_max, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMax))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_start, string.Format("{0} ref start ()",Strings.VName_Flow),Strings.Tooltip_Q_start, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowStart))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_end, string.Format("{0} ref end ()", Strings.VName_Flow), Strings.Tooltip_Q_end, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowEnd))); - AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow_ctv, string.Format("{0} ctv ()", Strings.VName_Flow), "CTV of the flow (mean val.)",Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", (w.GetTestRslt(t).TestTime == 0) ? 0 : 3.6 * w.GetTestRslt(t).VolumeCTV / w.GetTestRslt(t).TestTime))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Qc, string.Format("Qc"), "Calculated water meter flow", Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V5", (w.GetMeterTestRslt(t).TestTime == 0 || w.GetTestRslt(t).PulsesMaster == 0) ? 0 : w.GetTestRslt(t).VolumeCTV / w.GetMeterTestRslt(t).TestTime * 3.6 * w.GetMeterTestRslt(t).PulsesMaster / w.GetTestRslt(t).PulsesMaster))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow_ctv, string.Format("{0} ctv ()", Strings.VName_Flow), "CTV of the flow (mean val.)", Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V5", (w.GetMeterTestRslt(t).TestTime == 0 || w.GetTestRslt(t).PulsesMaster == 0) ? 0 : w.GetTestRslt(t).VolumeCTV / w.GetMeterTestRslt(t).TestTime * 3.6 * w.GetMeterTestRslt(t).PulsesMaster / w.GetTestRslt(t).PulsesMaster))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow_ctv_min, string.Format("{0} ctv min ()", Strings.VName_Flow), "Min. CTV of the flow", Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", (w.GetTestRslt(t).VolumeMaster == 0) ? 0 : w.GetTestRslt(t).VolumeCTV * w.GetTestRslt(t).FlowMin / w.GetTestRslt(t).VolumeMaster))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow_ctv_max, string.Format("{0} ctv max ()", Strings.VName_Flow), "Max. CTV of the flow", Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", (w.GetTestRslt(t).VolumeMaster == 0) ? 0 : w.GetTestRslt(t).VolumeCTV * w.GetTestRslt(t).FlowMax / w.GetTestRslt(t).VolumeMaster))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow_ctv_start, string.Format("{0} ctv start ()", Strings.VName_Flow), "Start flow CTV", Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", (w.GetTestRslt(t).VolumeMaster == 0) ? 0 : w.GetTestRslt(t).VolumeCTV * w.GetTestRslt(t).FlowStart / w.GetTestRslt(t).VolumeMaster))); diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs index 096ff6a5a..1bbee3050 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2019 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -111,12 +111,16 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter printerCfg.BelowItems3 = newCfg.BelowItems3; printerCfg.Footer = newCfg.Footer; printerCfg.TestsAreRows = newCfg.TestsAreRows; - printerCfg.DocName = newCfg.DocName; - printerCfg.ImgName = newCfg.ImgName; + printerCfg.GraphLeft = newCfg.GraphLeft; + printerCfg.GraphTop = newCfg.GraphTop; + printerCfg.GraphWid = newCfg.GraphWid; + printerCfg.GraphHgh = newCfg.GraphHgh; printerCfg.ImgLeft = newCfg.ImgLeft; printerCfg.ImgTop = newCfg.ImgTop; printerCfg.ImgWid = newCfg.ImgWid; printerCfg.ImgHgh = newCfg.ImgHgh; + printerCfg.ImgName = newCfg.ImgName; + printerCfg.DocName = newCfg.DocName; ApplyConfig(); } @@ -224,11 +228,15 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter BelowItems3 = printerCfg.BelowItems3, Footer = printerCfg.Footer, TestsAreRows = printerCfg.TestsAreRows, - ImgFullPathName = (wm.ArchivePath != null) ? System.IO.Path.Combine(wm.ArchivePath, printerCfg.ImgName) : null, + GraphLeft = printerCfg.GraphLeft, + GraphTop = printerCfg.GraphTop, + GraphWid = printerCfg.GraphWid, + GraphHgh = printerCfg.GraphHgh, ImgLeft = printerCfg.ImgLeft, ImgTop = printerCfg.ImgTop, ImgWid = printerCfg.ImgWid, ImgHgh = printerCfg.ImgHgh, + ImgFullPathName = (wm.ArchivePath != null) ? System.IO.Path.Combine(wm.ArchivePath, printerCfg.ImgName) : null, }; new Results.Output.Printers.OnePerMeter.OnePerMeterPrintDocument(batch, cfg, wm, documentName).Print(); diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs index 896e8fa69..ea2ac7723 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2019 Sensus Slovensko a.s. /// using System.Xml.Serialization; using Config.Entities; @@ -59,12 +59,16 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter public string Footer; public bool TestsAreRows; /// true = Tests are rows - public string DocName; - public string ImgName; + public int GraphLeft; + public int GraphTop; + public int GraphWid; + public int GraphHgh; public int ImgLeft; public int ImgTop; public int ImgWid; public int ImgHgh; + public string ImgName; + public string DocName; [XmlIgnore] public Config.Entities.MetersKind MetersKind; diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs index a3362bfff..0de3b1e0b 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs @@ -75,7 +75,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.footerFontFamilyComboBox = new System.Windows.Forms.ComboBox(); this.footerFontLabel = new System.Windows.Forms.Label(); this.imageNameTextBox = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); this.imageLeftTextBox = new System.Windows.Forms.TextBox(); this.imageTopTextBox = new System.Windows.Forms.TextBox(); this.imageWidthTextBox = new System.Windows.Forms.TextBox(); @@ -103,6 +102,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.belowItems2Button = new System.Windows.Forms.Button(); this.belowItems1Button = new System.Windows.Forms.Button(); this.table1FormComboBox = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.graphHeightTextBox = new System.Windows.Forms.TextBox(); + this.graphWidthTextBox = new System.Windows.Forms.TextBox(); + this.graphTopTextBox = new System.Windows.Forms.TextBox(); + this.graphLeftTextBox = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // nameTextBox @@ -214,9 +218,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // footerButton // this.footerButton.Enabled = false; - this.footerButton.Location = new System.Drawing.Point(287, 303); + this.footerButton.Location = new System.Drawing.Point(291, 285); this.footerButton.Name = "footerButton"; - this.footerButton.Size = new System.Drawing.Size(100, 23); + this.footerButton.Size = new System.Drawing.Size(100, 20); this.footerButton.TabIndex = 41; this.footerButton.Text = "Footer"; this.footerButton.UseVisualStyleBackColor = true; @@ -225,9 +229,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // headerButton // this.headerButton.Enabled = false; - this.headerButton.Location = new System.Drawing.Point(287, 193); + this.headerButton.Location = new System.Drawing.Point(291, 190); this.headerButton.Name = "headerButton"; - this.headerButton.Size = new System.Drawing.Size(100, 23); + this.headerButton.Size = new System.Drawing.Size(100, 20); this.headerButton.TabIndex = 37; this.headerButton.Text = "Title"; this.headerButton.UseVisualStyleBackColor = true; @@ -236,9 +240,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // testItemsButton // this.testItemsButton.Enabled = false; - this.testItemsButton.Location = new System.Drawing.Point(287, 237); + this.testItemsButton.Location = new System.Drawing.Point(291, 228); this.testItemsButton.Name = "testItemsButton"; - this.testItemsButton.Size = new System.Drawing.Size(100, 23); + this.testItemsButton.Size = new System.Drawing.Size(100, 20); this.testItemsButton.TabIndex = 39; this.testItemsButton.Text = "1st table"; this.testItemsButton.UseVisualStyleBackColor = true; @@ -405,9 +409,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // testItems2Button // this.testItems2Button.Enabled = false; - this.testItems2Button.Location = new System.Drawing.Point(287, 259); + this.testItems2Button.Location = new System.Drawing.Point(291, 247); this.testItems2Button.Name = "testItems2Button"; - this.testItems2Button.Size = new System.Drawing.Size(100, 23); + this.testItems2Button.Size = new System.Drawing.Size(100, 20); this.testItems2Button.TabIndex = 40; this.testItems2Button.Text = "2nd table"; this.testItems2Button.UseVisualStyleBackColor = true; @@ -507,24 +511,15 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // imageNameTextBox // this.imageNameTextBox.Enabled = false; - this.imageNameTextBox.Location = new System.Drawing.Point(143, 304); + this.imageNameTextBox.Location = new System.Drawing.Point(287, 306); this.imageNameTextBox.Name = "imageNameTextBox"; this.imageNameTextBox.Size = new System.Drawing.Size(135, 20); this.imageNameTextBox.TabIndex = 44; // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(57, 307); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(87, 13); - this.label3.TabIndex = 45; - this.label3.Text = "Image file name :"; - // // imageLeftTextBox // this.imageLeftTextBox.Enabled = false; - this.imageLeftTextBox.Location = new System.Drawing.Point(143, 282); + this.imageLeftTextBox.Location = new System.Drawing.Point(141, 306); this.imageLeftTextBox.Name = "imageLeftTextBox"; this.imageLeftTextBox.Size = new System.Drawing.Size(33, 20); this.imageLeftTextBox.TabIndex = 46; @@ -532,7 +527,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // imageTopTextBox // this.imageTopTextBox.Enabled = false; - this.imageTopTextBox.Location = new System.Drawing.Point(179, 282); + this.imageTopTextBox.Location = new System.Drawing.Point(177, 306); this.imageTopTextBox.Name = "imageTopTextBox"; this.imageTopTextBox.Size = new System.Drawing.Size(31, 20); this.imageTopTextBox.TabIndex = 47; @@ -540,7 +535,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // imageWidthTextBox // this.imageWidthTextBox.Enabled = false; - this.imageWidthTextBox.Location = new System.Drawing.Point(213, 282); + this.imageWidthTextBox.Location = new System.Drawing.Point(211, 306); this.imageWidthTextBox.Name = "imageWidthTextBox"; this.imageWidthTextBox.Size = new System.Drawing.Size(31, 20); this.imageWidthTextBox.TabIndex = 48; @@ -548,7 +543,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // imageHeightTextBox // this.imageHeightTextBox.Enabled = false; - this.imageHeightTextBox.Location = new System.Drawing.Point(247, 282); + this.imageHeightTextBox.Location = new System.Drawing.Point(245, 306); this.imageHeightTextBox.Name = "imageHeightTextBox"; this.imageHeightTextBox.Size = new System.Drawing.Size(31, 20); this.imageHeightTextBox.TabIndex = 49; @@ -556,20 +551,20 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(41, 285); + this.label4.Location = new System.Drawing.Point(17, 309); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(103, 13); + this.label4.Size = new System.Drawing.Size(115, 13); this.label4.TabIndex = 50; - this.label4.Text = "Image left/top/w/h :"; + this.label4.Text = "Image left/top/w/h/file"; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(109, 266); + this.label8.Location = new System.Drawing.Point(55, 269); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(172, 13); + this.label8.Size = new System.Drawing.Size(224, 13); this.label8.TabIndex = 57; - this.label8.Text = "Image coordinates are in 0.254 mm"; + this.label8.Text = "Graph and image coordinates are in 0.254 mm"; // // label6 // @@ -634,9 +629,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // commonItems3Button // this.commonItems3Button.Enabled = false; - this.commonItems3Button.Location = new System.Drawing.Point(393, 215); + this.commonItems3Button.Location = new System.Drawing.Point(397, 209); this.commonItems3Button.Name = "commonItems3Button"; - this.commonItems3Button.Size = new System.Drawing.Size(47, 23); + this.commonItems3Button.Size = new System.Drawing.Size(47, 20); this.commonItems3Button.TabIndex = 65; this.commonItems3Button.Text = "Col. 3"; this.commonItems3Button.UseVisualStyleBackColor = true; @@ -645,9 +640,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // commonItems2Button // this.commonItems2Button.Enabled = false; - this.commonItems2Button.Location = new System.Drawing.Point(340, 215); + this.commonItems2Button.Location = new System.Drawing.Point(344, 209); this.commonItems2Button.Name = "commonItems2Button"; - this.commonItems2Button.Size = new System.Drawing.Size(47, 23); + this.commonItems2Button.Size = new System.Drawing.Size(47, 20); this.commonItems2Button.TabIndex = 64; this.commonItems2Button.Text = "Col. 2"; this.commonItems2Button.UseVisualStyleBackColor = true; @@ -656,9 +651,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // commonItems1Button // this.commonItems1Button.Enabled = false; - this.commonItems1Button.Location = new System.Drawing.Point(287, 215); + this.commonItems1Button.Location = new System.Drawing.Point(291, 209); this.commonItems1Button.Name = "commonItems1Button"; - this.commonItems1Button.Size = new System.Drawing.Size(47, 23); + this.commonItems1Button.Size = new System.Drawing.Size(47, 20); this.commonItems1Button.TabIndex = 63; this.commonItems1Button.Text = "Col. 1"; this.commonItems1Button.UseVisualStyleBackColor = true; @@ -727,9 +722,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // belowItems3Button // this.belowItems3Button.Enabled = false; - this.belowItems3Button.Location = new System.Drawing.Point(393, 281); + this.belowItems3Button.Location = new System.Drawing.Point(397, 266); this.belowItems3Button.Name = "belowItems3Button"; - this.belowItems3Button.Size = new System.Drawing.Size(47, 23); + this.belowItems3Button.Size = new System.Drawing.Size(47, 20); this.belowItems3Button.TabIndex = 77; this.belowItems3Button.Text = "Col. 3"; this.belowItems3Button.UseVisualStyleBackColor = true; @@ -738,9 +733,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // belowItems2Button // this.belowItems2Button.Enabled = false; - this.belowItems2Button.Location = new System.Drawing.Point(340, 281); + this.belowItems2Button.Location = new System.Drawing.Point(344, 266); this.belowItems2Button.Name = "belowItems2Button"; - this.belowItems2Button.Size = new System.Drawing.Size(47, 23); + this.belowItems2Button.Size = new System.Drawing.Size(47, 20); this.belowItems2Button.TabIndex = 76; this.belowItems2Button.Text = "Col. 2"; this.belowItems2Button.UseVisualStyleBackColor = true; @@ -749,9 +744,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // belowItems1Button // this.belowItems1Button.Enabled = false; - this.belowItems1Button.Location = new System.Drawing.Point(287, 281); + this.belowItems1Button.Location = new System.Drawing.Point(291, 266); this.belowItems1Button.Name = "belowItems1Button"; - this.belowItems1Button.Size = new System.Drawing.Size(47, 23); + this.belowItems1Button.Size = new System.Drawing.Size(47, 20); this.belowItems1Button.TabIndex = 75; this.belowItems1Button.Text = "Col. 1"; this.belowItems1Button.UseVisualStyleBackColor = true; @@ -761,15 +756,61 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // this.table1FormComboBox.Enabled = false; this.table1FormComboBox.FormattingEnabled = true; - this.table1FormComboBox.Location = new System.Drawing.Point(388, 249); + this.table1FormComboBox.Location = new System.Drawing.Point(392, 237); this.table1FormComboBox.Name = "table1FormComboBox"; this.table1FormComboBox.Size = new System.Drawing.Size(64, 21); this.table1FormComboBox.TabIndex = 78; // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(17, 288); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(97, 13); + this.label3.TabIndex = 83; + this.label3.Text = "Graph left/top/w/h"; + // + // graphHeightTextBox + // + this.graphHeightTextBox.Enabled = false; + this.graphHeightTextBox.Location = new System.Drawing.Point(245, 285); + this.graphHeightTextBox.Name = "graphHeightTextBox"; + this.graphHeightTextBox.Size = new System.Drawing.Size(31, 20); + this.graphHeightTextBox.TabIndex = 82; + // + // graphWidthTextBox + // + this.graphWidthTextBox.Enabled = false; + this.graphWidthTextBox.Location = new System.Drawing.Point(211, 285); + this.graphWidthTextBox.Name = "graphWidthTextBox"; + this.graphWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.graphWidthTextBox.TabIndex = 81; + // + // graphTopTextBox + // + this.graphTopTextBox.Enabled = false; + this.graphTopTextBox.Location = new System.Drawing.Point(177, 285); + this.graphTopTextBox.Name = "graphTopTextBox"; + this.graphTopTextBox.Size = new System.Drawing.Size(31, 20); + this.graphTopTextBox.TabIndex = 80; + // + // graphLeftTextBox + // + this.graphLeftTextBox.Enabled = false; + this.graphLeftTextBox.Location = new System.Drawing.Point(141, 285); + this.graphLeftTextBox.Name = "graphLeftTextBox"; + this.graphLeftTextBox.Size = new System.Drawing.Size(33, 20); + this.graphLeftTextBox.TabIndex = 79; + // // PrinterCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label3); + this.Controls.Add(this.graphHeightTextBox); + this.Controls.Add(this.graphWidthTextBox); + this.Controls.Add(this.graphTopTextBox); + this.Controls.Add(this.graphLeftTextBox); this.Controls.Add(this.table1FormComboBox); this.Controls.Add(this.belowItems3Button); this.Controls.Add(this.belowItems2Button); @@ -797,7 +838,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.Controls.Add(this.imageWidthTextBox); this.Controls.Add(this.imageTopTextBox); this.Controls.Add(this.imageLeftTextBox); - this.Controls.Add(this.label3); this.Controls.Add(this.imageNameTextBox); this.Controls.Add(this.footerItalicCheckBox); this.Controls.Add(this.footerBoldCheckBox); @@ -896,7 +936,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter private System.Windows.Forms.ComboBox footerFontFamilyComboBox; private System.Windows.Forms.Label footerFontLabel; private System.Windows.Forms.TextBox imageNameTextBox; - private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox imageLeftTextBox; private System.Windows.Forms.TextBox imageTopTextBox; private System.Windows.Forms.TextBox imageWidthTextBox; @@ -924,5 +963,10 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter private System.Windows.Forms.Button belowItems2Button; private System.Windows.Forms.Button belowItems1Button; private System.Windows.Forms.ComboBox table1FormComboBox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox graphHeightTextBox; + private System.Windows.Forms.TextBox graphWidthTextBox; + private System.Windows.Forms.TextBox graphTopTextBox; + private System.Windows.Forms.TextBox graphLeftTextBox; } } diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs index 5d5666527..ea0358581 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2019 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -138,12 +138,17 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter cultureComboBox.Text = config.Culture.ToString(); - docNameTextBox.Text = config.DocName; - imageNameTextBox.Text = config.ImgName; + graphLeftTextBox.Text = config.GraphLeft.ToString(); + graphTopTextBox.Text = config.GraphTop.ToString(); + graphWidthTextBox.Text = config.GraphWid.ToString(); + graphHeightTextBox.Text = config.GraphHgh.ToString(); + imageLeftTextBox.Text = config.ImgLeft.ToString(); imageTopTextBox.Text = config.ImgTop.ToString(); imageWidthTextBox.Text = config.ImgWid.ToString(); imageHeightTextBox.Text = config.ImgHgh.ToString(); + imageNameTextBox.Text = config.ImgName; + docNameTextBox.Text = config.DocName; table1FormComboBox.Text = config.Form.ToString(); } @@ -192,12 +197,16 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter belowItems2Button.Enabled = true; belowItems3Button.Enabled = true; footerButton.Enabled = true; - docNameTextBox.Enabled = true; - imageNameTextBox.Enabled = true; + graphLeftTextBox.Enabled = true; + graphTopTextBox.Enabled = true; + graphWidthTextBox.Enabled = true; + graphHeightTextBox.Enabled = true; imageLeftTextBox.Enabled = true; imageTopTextBox.Enabled = true; imageWidthTextBox.Enabled = true; imageHeightTextBox.Enabled = true; + imageNameTextBox.Enabled = true; + docNameTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -304,24 +313,42 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter } + if (!int.TryParse(graphLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) + { + message += Environment.NewLine + "Graph left' should be between 0 and 1100"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(graphTopTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) + { + message += Environment.NewLine + "Graph top' should be between 0 and 1100"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(graphWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) + { + message += Environment.NewLine + "Graph width' should be between 0 and 1100"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(graphHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) + { + message += Environment.NewLine + "Graph height' should be between 0 and 1100"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(imageLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image left' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } - if (!int.TryParse(imageTopTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image top' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } - if (!int.TryParse(imageWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image width' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } - if (!int.TryParse(imageHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image height' should be between 0 and 1100"; @@ -431,12 +458,18 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter } } - flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - flags |= UpdateDifferent(ref config.ImgName, imageNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.GraphLeft, graphLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.GraphTop, graphTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.GraphWid, graphWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.GraphHgh, graphHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.ImgLeft, imageLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgTop, imageTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgWid, imageWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgHgh, imageHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.ImgName, imageNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + + flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) { diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 3aec60b4d..fff87704b 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.1245.0")] -[assembly: AssemblyFileVersion("2.18.1245.0")] +[assembly: AssemblyVersion("2.18.1249.0")] +[assembly: AssemblyFileVersion("2.18.1249.0")] diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 98a7c7b8c..eed790cd5 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2778,6 +2778,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to No water meter. + /// + internal static string No_water_meter { + get { + return ResourceManager.GetString("No_water_meter", resourceCulture); + } + } + /// /// Looks up a localized string similar to No test bench in the program configuration.. /// diff --git a/TBF/Resources/Strings.cs.resx b/TBF/Resources/Strings.cs.resx index 10c27beda..054dc46d0 100644 --- a/TBF/Resources/Strings.cs.resx +++ b/TBF/Resources/Strings.cs.resx @@ -1440,4 +1440,7 @@ Vypařování + + Žádný vodoměr + \ No newline at end of file diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 2723e9e73..040f315a6 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2002,4 +2002,7 @@ Missing a pressure meter + + No water meter + \ No newline at end of file diff --git a/TBF/Screens/ResultsTabPageCtrl.cs b/TBF/Screens/ResultsTabPageCtrl.cs index 6f53b655a..36b373317 100644 --- a/TBF/Screens/ResultsTabPageCtrl.cs +++ b/TBF/Screens/ResultsTabPageCtrl.cs @@ -311,7 +311,6 @@ namespace TBF.Screens first = false; } -#if TURA_IPERL || TURA_SPECIAL lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args) { if (InvokeRequired) @@ -323,7 +322,6 @@ namespace TBF.Screens OnDoubleClick(sender, args); } }; -#endif } } } @@ -350,93 +348,10 @@ namespace TBF.Screens { return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm); } - OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm) { return GetListView(Color.White, wm); } - - - /// - /// Get decorated test names for a specified watermeter - /// - /// Watermeter results entity - /// A list of strings - IList GetAllDecoratedTestNames(Results.Entities.WaterMeter wMtr) - { - IList testNames = new List(); - - foreach (var mtr in wMtr.MeterTestRslts) - { - if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound || mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) - && mtr.TestDone - && (mtr.Publish() != Config.Entities.Publish.Never) - && (mtr.Publish() != Config.Entities.Publish.Internal)) - { - testNames.Add(mtr.Name()); - } - } - - return testNames; - } - - /// - /// Get color for highlighting results and an apporpriate text message. - /// - /// Water meter results entity - /// Appropriate message - /// Color for results - Color GetColorOfResults(Results.Entities.WaterMeter wMtr, out string message) + /// + OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm) { - bool wmtrCompleted = wMtr.CompletedFromTests(); - bool wmtrPassed = wMtr.PassedFromTests(); - - if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E28) != 0) - { - message = Strings.Previous_step_is_missing_or_NOK; - return ProductionTracing; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E27) != 0) - { - message = Strings.Wrong_iPerl_counting_direction; - return WrongDirection; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E26) != 0) - { - message = Strings.Invalid_Q2_correction_factors; - return WrongQ2FactorsColor; - } - else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E25) != 0) - { - message = Strings.Test_repetition_count_exceeded_upper_limit; - return RejectColor; - } - else if (wmtrPassed) - { - /// Water meter passed (therefore is was also completed) - message = Strings.Passed; - return OkColor; - } - else if (wmtrCompleted) - { - /// Water meter was completed but did not pass => Failed -#if ORACLE_DB - if ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) && - (wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex) - { - /// Proefindex reached the limit => Proefindex would be above this limit next time => Reject - message = Strings.Test_repetition_count_exceeded_upper_limit; - return RejectColor; - } - else -#endif - { - message = Strings.Failed; - return NokColor; - } - } - else - { - /// Water meter was not completed yet => did not pass, did not fail - message = Strings.Test_in_progress; - return NotCompletedColor; - } + return GetListView(Color.White, wm); } @@ -450,15 +365,19 @@ namespace TBF.Screens metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single); string message = string.Empty; - Color commonBackColor = GetColorOfResults(wMtr, out message); - OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); #if ORACLE_DB + bool maxRepeatsExceeded = ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) && + (wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex); + Color commonBackColor = wMtr.GetColorOfResults(maxRepeatsExceeded, out message); + OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message); #else + Color commonBackColor = wMtr.GetColorOfResults(false, out message); + OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr); #endif - IList items = GetRsltItems(metersKind); + IList items = GetRsltItems(metersKind); if (items == null || items.Count == 0) return lview; @@ -473,7 +392,7 @@ namespace TBF.Screens } - IList testNames = GetAllDecoratedTestNames(wMtr); + IList testNames = wMtr.GetAllDecoratedTestNames(); int ix = 0; foreach (var mtr in wMtr.MeterTestRslts) { @@ -528,11 +447,15 @@ namespace TBF.Screens metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single); string message; - Color commonBackColor = GetColorOfResults(wMtr, out message); - OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); #if ORACLE_DB + bool maxRepeatsExceeded = ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) && + (wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex); + Color commonBackColor = wMtr.GetColorOfResults(maxRepeatsExceeded, out message); + OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message); #else + Color commonBackColor = wMtr.GetColorOfResults(false, out message); + OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr); lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr); #endif @@ -544,7 +467,7 @@ namespace TBF.Screens TBF.LocalSettings ls = Program.LocalSettings; lview.Columns.Add(printedWMNr.ToString(), (ls.RsltsClmnCount > 0) ? ls.RsltsClmnWidths[0] : 40); int i = 1; - foreach (var str in GetAllDecoratedTestNames(wMtr)) + foreach (var str in wMtr.GetAllDecoratedTestNames()) { lview.Columns.Add(str, (ls.RsltsClmnCount > i) ? ls.RsltsClmnWidths[i] : 70); i++; @@ -615,24 +538,24 @@ namespace TBF.Screens void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args) { - Results.Entities.WaterMeter wm = args.WM; - - if (wm == null || wm.Disabled || string.IsNullOrEmpty(wm.SerialNr)) + if (args.WM == null || args.WM.Disabled) { - MessageBox.Show("No water meter or missing S/N"); + MessageBox.Show(Strings.No_water_meter); + return; } - else if (TracingDB.DB.SessionFactory == null) + else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr)) { - MessageBox.Show("No access to tracing database"); + new Results.Forms.MoreWMResultsDlg(args.WM, null).ShowDialog(); } else { + IList refRecords = null; using (ISession session = TracingDB.DB.SessionFactory.OpenSession()) { - IList refRecords = session.QueryOver() - .Where(x => (x.Code == wm.SerialNr)) - .OrderBy(x => x.TimeStamp).Desc - .List(); + refRecords = session.QueryOver() + .Where(x => (x.Code == args.WM.SerialNr)) + .OrderBy(x => x.TimeStamp).Desc + .List(); for (int i = 0; i < refRecords.Count; i++) { ReferenceRecord refR = refRecords[i]; @@ -656,7 +579,7 @@ namespace TBF.Screens } } - new Results.Forms.TracingResultsDlg(refRecords).ShowDialog(); + new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog(); } } }