diff --git a/Config/Properties/AssemblyInfo.cs b/Config/Properties/AssemblyInfo.cs
index b00234fd5..67d1db97e 100644
--- a/Config/Properties/AssemblyInfo.cs
+++ b/Config/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.0.162.0")]
-[assembly: AssemblyFileVersion("2.0.162.0")]
+[assembly: AssemblyVersion("2.0.163.0")]
+[assembly: AssemblyFileVersion("2.0.163.0")]
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs
new file mode 100644
index 000000000..90c220395
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs
@@ -0,0 +1,323 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.IO;
+using Config.Entities;
+using TBF.Resources;
+
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ public class PrintLabelDocument : PrintDocument
+ {
+ const string FontFamilyName = "Arial"; //"Times New Roman";
+ const int topMrgn = 100;
+
+ const int SpacingOne = 18;
+ const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
+ const int TitleX = 100;
+ readonly int TitleY; /// Depends on the size of the header
+ readonly int HdrTop; /// = TitleY + 60
+ readonly int BodyTop; /// = HdrTop + 160
+
+ readonly int paperWidth;
+ readonly int paperHeight;
+ readonly string templateFile;
+
+ ///
+ /// Property variable for the Font the user wishes to use
+ ///
+ Font font;
+ Font boldFont;
+ Font titleFont;
+
+ ///
+ /// Data to print
+ ///
+ readonly GenericDevices.IBenchInfo benchId;
+ readonly Procedure procedure;
+ readonly IList unsortedResults;
+ readonly bool combined;
+ readonly DateTime dateTime;
+
+ ///
+ /// Items to print
+ ///
+ readonly IList resultItems;
+
+ ///
+ /// Layout and status
+ ///
+ int nrWMsOnFirstPage;
+ int nrWMsOnNextPage;
+ int nextWMNr; /// nr. of watermeter to be printed as the first one on the next page
+ int nrPages;
+ int pageNr; /// Page number to be printed at the bottom of the page
+
+
+ ///
+ /// Constructor
+ ///
+ /// Text to be printed
+ public PrintLabelDocument(GenericDevices.IBenchInfo benchId,
+ Procedure procedure,
+ IList unsortedResults,
+ PageOrientation pageOrientation,
+ int paperWidth,
+ int paperHeight,
+ string templateFile)
+ {
+ this.benchId = benchId;
+ this.procedure = procedure;
+ this.unsortedResults = unsortedResults;
+ this.paperWidth = paperWidth;
+ this.paperHeight = paperHeight;
+ this.templateFile = templateFile;
+
+ DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
+
+ TitleY = topMrgn; /// Depends on the size of the header
+ HdrTop = TitleY + 60;
+ BodyTop = HdrTop + 160;
+
+ dateTime = DateTime.Now;
+
+
+ if ((unsortedResults != null) && (unsortedResults.Count != 0) && (unsortedResults[0].MetersKind == MetersKind.Single))
+ {
+ resultItems = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
+ combined = false;
+ }
+ else
+ {
+ resultItems = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
+ combined = true;
+ }
+
+
+ /// Set print area size and margins (in dots using 80 dpi)
+ int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
+ int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
+ int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
+ int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
+
+ /// Check if the user selected to print in Landscape mode
+ /// if they did then we need to swap height/width parameters
+ if (DefaultPageSettings.Landscape)
+ {
+ int tmp = printHeight;
+ printHeight = printWidth;
+ printWidth = tmp;
+ }
+
+ /// One watermeter per label/page
+ nrWMsOnFirstPage = 1;
+ nrWMsOnNextPage = 1;
+ nrPages = (combined ? Config.Data.CompoundWMsCount : Config.Data.WMsCount);
+
+ pageNr = 1;
+ nextWMNr = 0;
+ }
+
+ ///
+ /// Override the default onbeginPrint method of the PrintDocument Object
+ ///
+ ///
+ ///
+ protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
+ {
+ base.OnBeginPrint(e);
+
+ if (font == null) { font = new Font(FontFamilyName, 10, FontStyle.Regular); }
+ if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
+ if (titleFont == null) { titleFont = new Font(FontFamilyName, 18, FontStyle.Bold); }
+ }
+
+ ///
+ /// Override the default OnPrintPage method of the PrintDocument.
+ ///
+ ///
+ /// This provides the print logic for our document
+ protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
+ {
+ /// Run base code
+ base.OnPrintPage(e);
+
+ if (File.Exists(templateFile))
+ {
+ Image img = Image.FromFile(templateFile);
+ e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, paperWidth, paperHeight));
+ }
+
+ /// Set print area size and margins (in dots using 80 dpi)
+ int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
+ int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
+ int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
+ int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
+
+ /// Check if the user selected to print in Landscape mode
+ /// if they did then we need to swap height/width parameters
+ if (base.DefaultPageSettings.Landscape)
+ {
+ int tmp = printHeight;
+ printHeight = printWidth;
+ printWidth = tmp;
+ }
+
+ int x = leftMargin;
+ int y = topMargin;
+
+ /// Use the StringFormat class for the text layout of our document
+ StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
+
+
+ ///--------
+ /// Body
+ ///--------
+
+ /// This variable represents the top coordinate of the area where WM results are printed
+ /// and it is updated (increased by) the value returned by PrintXyzWM() - the section size.
+ int nextWmTop = (pageNr == 1) ? BodyTop : TitleY;
+
+ int nrWMsOnPage = (pageNr == 1) ? nrWMsOnFirstPage : nrWMsOnNextPage;
+
+ if (combined)
+ {
+ PrintCombinedWM(e, nextWMNr + 1);
+ nextWMNr += nrWMsOnPage;
+ e.HasMorePages = (nextWMNr < Config.Data.CompoundWMsCount);
+ }
+ else
+ {
+ if (!unsortedResults[0].Meters[nextWMNr].Disabled) PrintSingleWM(e, nextWMNr);
+ nextWMNr += nrWMsOnPage;
+ e.HasMorePages = (nextWMNr < Config.Data.WMsCount);
+ }
+ }
+
+
+ ///
+ /// Print one water meter results
+ ///
+ /// Water meter number (0-based)
+ void PrintSingleWM(System.Drawing.Printing.PrintPageEventArgs e, int wmNr)
+ {
+ /// Serial number
+ if (!string.IsNullOrEmpty(unsortedResults[0].Meters[wmNr].SerialNr))
+ {
+ PrintAt(e, 20, 60, unsortedResults[0].Meters[wmNr].SerialNr);
+ }
+
+ /// Watermeter type
+ PrintAt(e, 20, 72, unsortedResults[0].ProtocolTitle);
+
+ /// Date
+ string dateTimeStr = string.Format("{0}/{1}/{2}", dateTime.Day.ToString("D2"), dateTime.Month.ToString("D2"), (dateTime.Year % 100).ToString("D2"));
+ PrintAt(e, 135, 72, dateTimeStr);
+
+ IList results = Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr+1, combined));
+
+ for (int printPosition = 1; printPosition <= 3; printPosition++)
+ {
+ for (int r = 0; r < results.Count; r++)
+ {
+ if (results[r] != null && (r + 1) == printPosition)
+ {
+ if (resultItems.Count > 0)
+ {
+ string text = resultItems[0].Print(results[r].Meters[wmNr]);
+
+ string[] texts = text.Split(new char[] { '|' });
+
+ if (texts.Length == 2)
+ {
+ Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
+ text = texts[0];
+ /// TODO: How to print colors?
+ }
+
+ PrintAt(e, 78, 6 + 14 * printPosition, string.Format("{0}%", text));
+ }
+ }
+ }
+ }
+ }
+
+
+ ///
+ /// Print one combined water meter results
+ ///
+ /// Water meter number (1-based)
+ /// Top coordinate of watermeter data
+ /// The height of the printed section
+ void PrintCombinedWM(System.Drawing.Printing.PrintPageEventArgs e, int wmNr1)
+ {
+ /// Serial number
+ if (!string.IsNullOrEmpty(unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr))
+ {
+ PrintAt(e, 20, 60, unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr);
+ }
+
+ /// Watermeter type
+ PrintAt(e, 20, 72, unsortedResults[0].ProtocolTitle);
+
+ /// Date
+ string dateTimeStr = string.Format("{0}/{1}/{2}", dateTime.Day.ToString("D2"), dateTime.Month.ToString("D2"), (dateTime.Year % 100).ToString("D2"));
+ PrintAt(e, 135, 72, dateTimeStr);
+
+ IList results = Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr1, combined));
+
+ for (int printPosition = 1; printPosition <= 3; printPosition++)
+ {
+ for (int r = 0; r < results.Count; r++)
+ {
+ if (results[r] != null && (r + 1) == printPosition)
+ {
+ if (resultItems.Count > 0)
+ {
+ string text = resultItems[0].PrintCombined(results[r].Meters[2 * wmNr1 - 2],
+ results[r].Meters[2 * wmNr1 - 1],
+ results[r].CombinedMeters[wmNr1 - 1]);
+ string[] texts = text.Split(new char[] { '|' });
+
+ if (texts.Length == 2)
+ {
+ Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
+ text = texts[0];
+ /// TODO: How to print colors?
+ }
+
+ PrintAt(e, 78, 6 + 14 * printPosition, string.Format("{0}%", text));
+ }
+ }
+ }
+ }
+ }
+
+
+ void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
+ {
+ PrintAt(e, p.X, p.Y, text);
+ }
+
+ void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
+ {
+ RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
+ e.Graphics.DrawString(text, this.font, Brushes.Black, printArea);
+ }
+
+ void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
+ {
+ PrintBoldAt(e, p.X, p.Y, text);
+ }
+
+ void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
+ {
+ RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
+ e.Graphics.DrawString(text, this.boldFont, Brushes.Black, printArea);
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/Printer.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/Printer.cs
new file mode 100644
index 000000000..dada017e8
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/Printer.cs
@@ -0,0 +1,90 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Printing;
+using log4net;
+using Config.Entities;
+using TBF.BenchControl;
+
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
+ public override string ToString() { return string.Format("LabelPrinter({0})", Cfg.ToString(1)); }
+
+ readonly PrinterCfg printerCfg;
+
+ public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
+
+ ///
+ /// Data to print
+ ///
+ GenericDevices.IBenchInfo benchId;
+ Procedure procedure;
+ IList unsortedResults;
+
+ public Printer()
+ {
+ }
+
+ public Printer(PrinterCfg cfg)
+ : base(cfg)
+ {
+ printerCfg = cfg;
+ log.Debug(this.ToString());
+ }
+
+ ///
+ /// Prints the test cycle results, Events: Event.ResultsPrinted
+ ///
+ /// Bench ID
+ /// This parameter is unused
+ /// Procedure to print the results of
+ /// Results to print
+ /// This parameter is unused
+ /// Reference to the operation
+ public IOperation PrintResultsOp(GenericDevices.IBenchInfo benchId,
+ IList waterMeters,
+ Procedure procedure,
+ IList unsortedResults,
+ string title)
+ {
+ if ((procedure == null) || (unsortedResults == null) || (unsortedResults.Count < 1))
+ {
+ return null;
+ }
+
+ this.benchId = benchId;
+ this.procedure = procedure;
+ this.unsortedResults = unsortedResults;
+
+ return this;
+ }
+
+ /// Start this operation
+ public void Start()
+ {
+ new PrintLabelDocument(benchId, procedure, unsortedResults,
+ printerCfg.PageOrientation,
+ printerCfg.PaperWidth,
+ printerCfg.PaperHeight,
+ printerCfg.TemplateFile).Print();
+ }
+
+ /// Run this operation
+ /// Event.ResultsPrinted
+ public Event Run()
+ {
+ return Event.ResultsPrinted;
+ }
+
+ /// Stop this operation
+ public void Stop()
+ {
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfg.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfg.cs
new file mode 100644
index 000000000..1aed448c0
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfg.cs
@@ -0,0 +1,57 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml.Serialization;
+using Config.Entities;
+using TBF.BenchControl.Generic;
+
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
+ {
+ public IComponent GetComponent(IList components) { return new Printer(this); }
+ public IComponentCfgCtrl GetControl() { return new PrinterCfgCtrl(); }
+
+ ///
+ /// Serialized parameters
+ ///
+ public PageOrientation PageOrientation;
+ public int PaperWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count
+ public int PaperHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count
+ public string TemplateFile; /// Full path to a 'png' file
+ public bool SupressPrinting; /// true = Bypass printing
+
+ /// Private parameterless constructor invoked by all other (public) constructors
+ PrinterCfg()
+ {
+ Name = "LabelPrinter";
+ ParentName = string.Empty;
+ PageOrientation = PageOrientation.Portrait;
+ PaperWidth = 827; /// A4 width
+ PaperHeight = 1169; /// A4 height
+ TemplateFile = "C:\\TBF\\Templates\\Label.png";
+ SupressPrinting = false;
+ }
+
+ public PrinterCfg(IComponentFactory factory)
+ : this()
+ {
+ this.Factory = factory;
+ }
+
+ public string ToString(int i)
+ {
+ return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, SupressPrinting={5}",
+ Name,
+ PageOrientation,
+ PaperWidth,
+ PaperHeight,
+ TemplateFile,
+ SupressPrinting ? "yes" : "no"
+ );
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.Designer.cs
new file mode 100644
index 000000000..5e2786370
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.Designer.cs
@@ -0,0 +1,193 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ partial class PrinterCfgCtrl
+ {
+ ///
+ /// 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 Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.nameTextBox = new System.Windows.Forms.TextBox();
+ this.nameLabel = new System.Windows.Forms.Label();
+ this.classNameLabel = new System.Windows.Forms.Label();
+ this.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
+ this.orientationLabel = new System.Windows.Forms.Label();
+ this.orientationComboBox = new System.Windows.Forms.ComboBox();
+ this.templateTextBox = new System.Windows.Forms.TextBox();
+ this.templateLabel = new System.Windows.Forms.Label();
+ this.paperWidthTextBox = new System.Windows.Forms.TextBox();
+ this.paperWidthLabel = new System.Windows.Forms.Label();
+ this.paperHeightTextBox = new System.Windows.Forms.TextBox();
+ this.paperHeightLabel = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // nameTextBox
+ //
+ this.nameTextBox.Enabled = false;
+ this.nameTextBox.Location = new System.Drawing.Point(98, 30);
+ this.nameTextBox.Name = "nameTextBox";
+ this.nameTextBox.Size = new System.Drawing.Size(130, 20);
+ this.nameTextBox.TabIndex = 2;
+ //
+ // nameLabel
+ //
+ this.nameLabel.AutoSize = true;
+ this.nameLabel.Location = new System.Drawing.Point(8, 33);
+ this.nameLabel.Name = "nameLabel";
+ this.nameLabel.Size = new System.Drawing.Size(35, 13);
+ this.nameLabel.TabIndex = 1;
+ this.nameLabel.Text = "Name";
+ //
+ // classNameLabel
+ //
+ this.classNameLabel.AutoSize = true;
+ this.classNameLabel.Location = new System.Drawing.Point(95, 6);
+ this.classNameLabel.Name = "classNameLabel";
+ this.classNameLabel.Size = new System.Drawing.Size(83, 13);
+ this.classNameLabel.TabIndex = 0;
+ this.classNameLabel.Text = "ComonentName";
+ //
+ // supressPrintingCheckBox
+ //
+ this.supressPrintingCheckBox.AutoSize = true;
+ this.supressPrintingCheckBox.Enabled = false;
+ this.supressPrintingCheckBox.Location = new System.Drawing.Point(98, 164);
+ this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
+ this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
+ this.supressPrintingCheckBox.TabIndex = 11;
+ this.supressPrintingCheckBox.Text = "Supress printing";
+ this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
+ //
+ // orientationLabel
+ //
+ this.orientationLabel.AutoSize = true;
+ this.orientationLabel.Location = new System.Drawing.Point(8, 59);
+ this.orientationLabel.Name = "orientationLabel";
+ this.orientationLabel.Size = new System.Drawing.Size(84, 13);
+ this.orientationLabel.TabIndex = 3;
+ this.orientationLabel.Text = "Page orientation";
+ //
+ // orientationComboBox
+ //
+ this.orientationComboBox.Enabled = false;
+ this.orientationComboBox.FormattingEnabled = true;
+ this.orientationComboBox.Location = new System.Drawing.Point(98, 56);
+ this.orientationComboBox.Name = "orientationComboBox";
+ this.orientationComboBox.Size = new System.Drawing.Size(130, 21);
+ this.orientationComboBox.TabIndex = 4;
+ //
+ // templateTextBox
+ //
+ this.templateTextBox.Enabled = false;
+ this.templateTextBox.Location = new System.Drawing.Point(98, 135);
+ this.templateTextBox.Name = "templateTextBox";
+ this.templateTextBox.Size = new System.Drawing.Size(187, 20);
+ this.templateTextBox.TabIndex = 10;
+ //
+ // templateLabel
+ //
+ this.templateLabel.AutoSize = true;
+ this.templateLabel.Location = new System.Drawing.Point(8, 138);
+ this.templateLabel.Name = "templateLabel";
+ this.templateLabel.Size = new System.Drawing.Size(67, 13);
+ this.templateLabel.TabIndex = 9;
+ this.templateLabel.Text = "Template file";
+ //
+ // paperWidthTextBox
+ //
+ this.paperWidthTextBox.Enabled = false;
+ this.paperWidthTextBox.Location = new System.Drawing.Point(98, 83);
+ this.paperWidthTextBox.Name = "paperWidthTextBox";
+ this.paperWidthTextBox.Size = new System.Drawing.Size(51, 20);
+ this.paperWidthTextBox.TabIndex = 6;
+ //
+ // paperWidthLabel
+ //
+ this.paperWidthLabel.AutoSize = true;
+ this.paperWidthLabel.Location = new System.Drawing.Point(8, 86);
+ this.paperWidthLabel.Name = "paperWidthLabel";
+ this.paperWidthLabel.Size = new System.Drawing.Size(63, 13);
+ this.paperWidthLabel.TabIndex = 5;
+ this.paperWidthLabel.Text = "Paper width";
+ //
+ // paperHeightTextBox
+ //
+ this.paperHeightTextBox.Enabled = false;
+ this.paperHeightTextBox.Location = new System.Drawing.Point(98, 109);
+ this.paperHeightTextBox.Name = "paperHeightTextBox";
+ this.paperHeightTextBox.Size = new System.Drawing.Size(51, 20);
+ this.paperHeightTextBox.TabIndex = 8;
+ //
+ // paperHeightLabel
+ //
+ this.paperHeightLabel.AutoSize = true;
+ this.paperHeightLabel.Location = new System.Drawing.Point(8, 112);
+ this.paperHeightLabel.Name = "paperHeightLabel";
+ this.paperHeightLabel.Size = new System.Drawing.Size(67, 13);
+ this.paperHeightLabel.TabIndex = 7;
+ this.paperHeightLabel.Text = "Paper height";
+ //
+ // PrinterCfgCtrl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.paperHeightTextBox);
+ this.Controls.Add(this.paperHeightLabel);
+ this.Controls.Add(this.paperWidthTextBox);
+ this.Controls.Add(this.paperWidthLabel);
+ this.Controls.Add(this.templateTextBox);
+ this.Controls.Add(this.templateLabel);
+ this.Controls.Add(this.orientationComboBox);
+ this.Controls.Add(this.orientationLabel);
+ this.Controls.Add(this.supressPrintingCheckBox);
+ this.Controls.Add(this.nameTextBox);
+ this.Controls.Add(this.nameLabel);
+ this.Controls.Add(this.classNameLabel);
+ this.Name = "PrinterCfgCtrl";
+ this.Size = new System.Drawing.Size(300, 200);
+ this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox nameTextBox;
+ private System.Windows.Forms.Label nameLabel;
+ private System.Windows.Forms.Label classNameLabel;
+ private System.Windows.Forms.CheckBox supressPrintingCheckBox;
+ private System.Windows.Forms.Label orientationLabel;
+ private System.Windows.Forms.ComboBox orientationComboBox;
+ private System.Windows.Forms.TextBox templateTextBox;
+ private System.Windows.Forms.Label templateLabel;
+ private System.Windows.Forms.TextBox paperWidthTextBox;
+ private System.Windows.Forms.Label paperWidthLabel;
+ private System.Windows.Forms.TextBox paperHeightTextBox;
+ private System.Windows.Forms.Label paperHeightLabel;
+ }
+}
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.cs
new file mode 100644
index 000000000..d2b694321
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.cs
@@ -0,0 +1,123 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+using System;
+using System.IO;
+using System.Windows.Forms;
+using log4net;
+using Config.Entities;
+using TBF.BenchControl.Generic;
+
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ public partial class PrinterCfgCtrl : UserControl, IComponentCfgCtrl
+ {
+ static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
+
+ public bool ShowMore { get { return false; } }
+
+ PrinterCfg config;
+ public IComponentCfg Config
+ {
+ get { return config as IComponentCfg; }
+ set
+ {
+ config = value as PrinterCfg;
+ Redraw();
+ }
+ }
+
+ public PrinterCfgCtrl()
+ {
+ InitializeComponent();
+
+ orientationComboBox.Items.Add(PageOrientation.Portrait.ToString());
+ orientationComboBox.Items.Add(PageOrientation.Landscape.ToString());
+ }
+
+ private void PrinterCfgCtrl_Load(object sender, EventArgs e)
+ {
+ Redraw();
+ }
+
+ public void Closing()
+ {
+ }
+
+ PageOrientation GetOrientation(string str)
+ {
+ if (str.Equals(PageOrientation.Landscape.ToString())) return PageOrientation.Landscape;
+ if (str.Equals(PageOrientation.Portrait.ToString())) return PageOrientation.Portrait;
+ return (PageOrientation)(-1);
+ }
+
+ void Redraw()
+ {
+ if (config == null) return; /// Control was not loaded, settings were not changed
+ classNameLabel.Text = config.Factory.ClassName;
+ nameTextBox.Text = config.Name;
+ orientationComboBox.Text = config.PageOrientation.ToString();
+ paperWidthTextBox.Text = config.PaperWidth.ToString();
+ paperHeightTextBox.Text = config.PaperHeight.ToString();
+ templateTextBox.Text = config.TemplateFile;
+ supressPrintingCheckBox.Checked = config.SupressPrinting;
+ }
+
+ public void Unlock()
+ {
+ nameTextBox.Enabled = true;
+ orientationComboBox.Enabled = true;
+ paperWidthTextBox.Enabled = true;
+ paperHeightTextBox.Enabled = true;
+ templateTextBox.Enabled = true;
+ supressPrintingCheckBox.Enabled = true;
+ }
+
+ public CfgUpdateFlags VerifyCfg(ref string message)
+ {
+ CfgUpdateFlags flags = CfgUpdateFlags.None;
+
+ if ((int)GetOrientation(orientationComboBox.Text) < 0)
+ {
+ message += Environment.NewLine + "Invalid page orientation";
+ flags |= CfgUpdateFlags.Error;
+ }
+
+ int dummy;
+ if (!int.TryParse(paperWidthTextBox.Text, out dummy) || dummy <= 0)
+ {
+ message += Environment.NewLine + "Invalid paper width";
+ flags |= CfgUpdateFlags.Error;
+ }
+ if (!int.TryParse(paperHeightTextBox.Text, out dummy) || dummy <= 0)
+ {
+ message += Environment.NewLine + "Invalid paper height";
+ flags |= CfgUpdateFlags.Error;
+ }
+
+ if (!File.Exists(config.TemplateFile))
+ {
+ message += Environment.NewLine + "Template file missing";
+ flags |= CfgUpdateFlags.Error;
+ }
+
+ return flags;
+ }
+
+ public CfgUpdateFlags UpdateCfg()
+ {
+ CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
+
+ if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
+
+ config.Name = nameTextBox.Text;
+ config.PageOrientation = GetOrientation(orientationComboBox.Text);
+ config.PaperWidth = int.Parse(paperWidthTextBox.Text);
+ config.PaperHeight = int.Parse(paperHeightTextBox.Text);
+ config.TemplateFile = templateTextBox.Text;
+ config.SupressPrinting = supressPrintingCheckBox.Checked;
+
+ return flags;
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.resx b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.resx
new file mode 100644
index 000000000..1af7de150
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterCfgCtrl.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/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterFactory.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterFactory.cs
new file mode 100644
index 000000000..24636066c
--- /dev/null
+++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrinterFactory.cs
@@ -0,0 +1,23 @@
+///
+/// Copyright (c) 2015 Sensus Metering Systems
+///
+using TBF.BenchControl.Generic;
+
+namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
+{
+ public class PrinterFactory : IComponentFactory
+ {
+ public string ClassName { get { return "LabelPrinter"; } }
+
+ public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
+
+ public IComponent DummyComponent() { return new Printer(); }
+
+ public IComponentCfg DefaultConfig() { return new PrinterCfg(this); }
+
+ public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
+ {
+ return ComponentCfgBase.CreateFromDbEntity(typeof(PrinterCfg), component, this);
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs
index 3e959dbfc..ec787358b 100644
--- a/TestBenchFramework/BenchControl/TbfComponents.cs
+++ b/TestBenchFramework/BenchControl/TbfComponents.cs
@@ -49,6 +49,7 @@ namespace TBF.BenchControl
Factories.Add(new Cameras.IdcCamera.IdcCameraFactory());
Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl
Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication
+ Factories.Add(new ResultsPrinters.LabelPrinter.PrinterFactory()); /// LabelPrinter
Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
Factories.Add(new MettlerToledo.Standard.BalanceFactory()); /// MettlerToledo Balance
Factories.Add(new MettlerToledo.Standard.BalanceNewFactory()); /// MettlerToledoBalanceSN
diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs
index 986bdd096..6f8e224d4 100644
--- a/TestBenchFramework/Properties/AssemblyInfo.cs
+++ b/TestBenchFramework/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("2.0.162.1")]
-[assembly: AssemblyFileVersion("2.0.162.1")]
+[assembly: AssemblyVersion("2.0.163.1")]
+[assembly: AssemblyFileVersion("2.0.163.1")]
diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj
index f9f632a01..9c6929723 100644
--- a/TestBenchFramework/TBF.csproj
+++ b/TestBenchFramework/TBF.csproj
@@ -386,6 +386,18 @@
+
+ Component
+
+
+
+
+ UserControl
+
+
+ PrinterCfgCtrl.cs
+
+
Component
@@ -1552,6 +1564,9 @@
PrinterCfgCtrl.cs
+
+ PrinterCfgCtrl.cs
+
PrinterCfgCtrl.cs