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

77 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using log4net;
using TBF.BenchControl;
namespace TBF.BenchControl.ResultsPrinters.Basic
{
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
public override string ToString() { return string.Format("ResultsPrinters.Basic({0})", Cfg.ToString(1)); }
readonly PrinterCfg printerCfg;
/// <summary>
/// Data to print
/// </summary>
BenchControl.BenchId.Component benchId;
Entities.Procedure procedure;
IList<Entities.TestResult> unsortedResults;
public Printer(PrinterCfg cfg)
: base(cfg)
{
printerCfg = cfg;
log.Debug(this.ToString());
}
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="benchId">Bench ID</param>
/// <param name="waterMeters">This parameter is unused</param>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to print</param>
/// <param name="title">This parameter is unused</param>
/// <returns>Reference to the operation</returns>
public IOperation PrintResultsOp(BenchControl.BenchId.Component benchId,
IList<GenericDevices.IWaterMeter> waterMeters,
Entities.Procedure procedure,
IList<Entities.TestResult> unsortedResults,
string title)
{
if ((procedure == null) || (unsortedResults == null) || (unsortedResults.Count < 1))
{
return null;
}
this.benchId = benchId;
this.procedure = procedure;
this.unsortedResults = unsortedResults;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
new BasicPrintDocument(benchId, procedure, unsortedResults).Print();
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}