tbf/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/Printer.cs

69 lines
1.6 KiB
C#

///
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using log4net;
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; } }
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
public Printer() { }
public Printer(PrinterCfg cfg)
: base(cfg)
{
printerCfg = cfg;
log.Debug(this.ToString());
}
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="batch">Batch results to print</param>
/// <param name="title">This parameter is unused</param>
/// <returns>Reference to the operation</returns>
public IOperation PrintResultsOp(Results.Entities.Batch batch, string title)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
if (batch.WaterMeters.Count > 0)
{
new PrintLabelDocument(batch,
printerCfg.PageOrientation,
printerCfg.PaperWidth,
printerCfg.PaperHeight,
printerCfg.TemplateFile).Print();
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}