Initial commit almost identical to SVN-repo rev.340

This commit is contained in:
Milan Hanajik
2014-07-28 09:56:40 +02:00
commit 175a92f633
575 changed files with 186534 additions and 0 deletions
@@ -0,0 +1,325 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using TBF.BenchControl;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public class MunichPrintDocument : PrintDocument
{
const int SpacingOne = 20;
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
const int TitleX = 240;
const int TitleY = 200; /// Depends on the size of the header
const int FirstLineNr = 14; /// Depends on the size of the header
const int Tab1 = 80; /// Positions of columns above the table
const int Tab2 = 240;
const int Tab3 = 430;
const int Tab4 = 590;
const int BorderW = 1; /// Table border line width
const int Margin = 7; /// Margins of the text from table lines
/// Initialized in the constructor
readonly Printer prn;
readonly bool combined; /// true when MetersKind is MetersKind.Combined
readonly int secondTableOffset; /// Calculated in the constructor
/// Top coordinate of the table
int top;
/// <summary>
/// Property variable for the Font the user wishes to use
/// </summary>
public Font Font
{
get { return font; }
set { font = value; }
}
Font font;
Font fontTitle;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public MunichPrintDocument(Printer printer)
{
prn = printer;
combined = (prn.Results[0].MetersKind == Entities.MetersKind.Combined);
secondTableOffset = (prn.Results.Count + 2) * SpacingOneAndHalf;
}
/// <summary>
/// Override the default onbeginPrint method of the PrintDocument Object.
/// </summary>
/// <param name=e></param>
/// <remarks></remarks>
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
base.OnBeginPrint(e);
if (font == null) { font = new Font("Times New Roman", 10); }
if (fontTitle == null) { fontTitle = new Font("Times New Roman", 24); }
}
/// <summary>
/// Override the default OnPrintPage method of the PrintDocument.
/// </summary>
/// <param name=e></param>
/// <remarks>This provides the print logic for our document</remarks>
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
// Run base code
base.OnPrintPage(e);
e.Graphics.DrawImageUnscaled(Properties.Resources.Headpic, 0, 0);
/// 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);
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 50);
e.Graphics.DrawString(prn.Title, this.fontTitle, Brushes.Black, printArea);
int lineNr = FirstLineNr;
PrintAt(e, Tab1, lineNr * SpacingOne, prn.Version);
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.BenchId.TestBenchNr.ToString());
PrintAt(e, Tab3, lineNr * SpacingOne, "Datum :");
PrintAt(e, Tab4, lineNr * SpacingOne, DateTime.Now.Date.ToString("d"));
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Zahlertyp :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.Zaehlertyp);
PrintAt(e, Tab3, lineNr * SpacingOne, "Eichjahr :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.Eichjahr);
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Prüfvorlage :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.Pruefvorlage);
lineNr += 2;
if (combined)
{
PrintAt(e, Tab1, lineNr * SpacingOne, "Hauptzahler");
PrintAt(e, Tab3, lineNr * SpacingOne, "Nebenzahler");
lineNr++;
}
PrintAt(e, Tab1, lineNr * SpacingOne, "Hersteller :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].Producer);
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Hersteller :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].Producer);
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Seriennummer :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].SerialNr);
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Seriennummer :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].SerialNr);
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qn :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].Qn.ToString());
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Qn :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].Qn.ToString());
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Zulassungszeichen :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].ApprovalInfo);
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Zulassungszeichen :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].ApprovalInfo);
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Metr. klasse :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].MetrologicalClass);
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Metr. klasse :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].MetrologicalClass);
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Stand :");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.WaterMeters[0].State);
if (combined)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Stand :");
PrintAt(e, Tab4, lineNr * SpacingOne, prn.WaterMeters[1].State);
lineNr += 2;
PrintAt(e, Tab1, lineNr * SpacingOne, "Umschaltpunkte :");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qsteig");
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0f * Sequences.SequenceBase.Qrise).ToString("F1") + " l/h");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qfall");
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0f * Sequences.SequenceBase.Qfall).ToString("F1") + " l/h");
}
lineNr += 2;
top = SpacingOne * lineNr;
PrintTable(e);
DrawTable(e);
lineNr += (secondTableOffset * 2) / SpacingOne;
PrintAt(e, Tab1, lineNr * SpacingOne, "Temperatur");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.Results[0].AmbientTempAve.ToString("F1") + " \x00b0C");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Feuchtigkeit");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.Results[0].AmbientHumiAve.ToString("F0") + " %");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Luftdruck");
PrintAt(e, Tab2, lineNr * SpacingOne, prn.Results[0].AmbientPressAve.ToString("F0") + " mbar");
lineNr++;
PrintAt(e, Tab3, lineNr * SpacingOne, DateTime.Now.Date.ToString("d"));
lineNr ++;
PrintAt(e, Tab3, lineNr * SpacingOne, "Datum");
PrintAt(e, Tab4, lineNr * SpacingOne, "Unterschrift");
}
/// <summary>
/// Print table texts.
/// </summary>
void PrintTable(System.Drawing.Printing.PrintPageEventArgs e)
{
PrintAt(e, FromTest(-1, -1), "Prüflauf");
PrintAt(e, FromTest(-1, 0), "Q [l/h]");
PrintAt(e, FromTest(-1, 1), "Prüf-Vol.[l]");
PrintAt(e, FromTest(-1, 2), combined ? "HZ-Vol.[l]" : "Z-Vol.[l]");
PrintAt(e, FromTest(-1, 3), combined ? "NZ-Vol.[l]" : "-");
PrintAt(e, FromTest(-1, 4), "Fehler [%]");
PrintAt(e, FromTest(-1, 5), "Ergebnis");
PrintAt(e, FromTest(-1, 6), "Q [l/h]");
PrintAt(e, FromTest(-1, 7), "Temperatur");
PrintAt(e, FromTest(-1, 8), "Dichte");
PrintAt(e, FromTest(-1, 9), "Prüfzeit");
PrintAt(e, FromTest(-1, 10), "Druck Eing.");
PrintAt(e, FromTest(-1, 11), "Druck Ausg.");
for (int i = 0; i < prn.Results.Count; i++)
{
Point p = FromTest(i, -1);
PrintAt(e, p.X, p.Y, prn.Results[i].Name);
PrintAt(e, p.X, p.Y + (prn.Results.Count + 2) * SpacingOneAndHalf, prn.Results[i].Name);
PrintAt(e, FromTest(i, 0), prn.Results[i].FlowMass.ToString("F1"));
PrintAt(e, FromTest(i, 1), prn.Results[i].VolumeCTV.ToString("F2"));
PrintAt(e, FromTest(i, 2), prn.Results[i].Meters[0].VolumeMeter.ToString("F2"));
if (combined)
{
PrintAt(e, FromTest(i, 3), prn.Results[i].Meters[1].VolumeMeter.ToString("F2"));
PrintAt(e, FromTest(i, 4), prn.Results[i].CombinedMeters[0].VolumeErrorPct.ToString("F2"));
PrintAt(e, FromTest(i, 5), prn.Results[i].CombinedMeters[0].Passed ? "iO" : "NiO");
}
else
{
PrintAt(e, FromTest(i, 3), "-");
PrintAt(e, FromTest(i, 4), prn.Results[i].Meters[0].VolumeErrorPct.ToString("F2"));
PrintAt(e, FromTest(i, 5), prn.Results[i].Meters[0].Passed ? "iO" : "NiO");
}
PrintAt(e, FromTest(i, 6), prn.Results[i].FlowMass.ToString("F1"));
PrintAt(e, FromTest(i, 7), prn.Results[i].TempOutAvrg.ToString("F2"));
PrintAt(e, FromTest(i, 8), prn.Results[i].DensityDiv.ToString("F2"));
PrintAt(e, FromTest(i, 9), prn.Results[i].Time.ToString("F1"));
PrintAt(e, FromTest(i, 10), prn.Results[i].PressInAvrg.ToString("F2"));
PrintAt(e, FromTest(i, 11), prn.Results[i].PressOutAvrg.ToString("F2"));
}
}
/// <summary>
/// Draw table lines.
/// </summary>
void DrawTable(System.Drawing.Printing.PrintPageEventArgs e)
{
int mid = top + SpacingOneAndHalf;
int bot = top + (prn.Results.Count + 1) * SpacingOneAndHalf;
int top2 = top + secondTableOffset;
int mid2 = mid + secondTableOffset;
int bot2 = bot + secondTableOffset;
// Horizontal lines
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, top), new Point(747, top));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, mid), new Point(747, mid));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, bot), new Point(747, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, top2), new Point(747, top2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, mid2), new Point(747, mid2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, bot2), new Point(747, bot2));
// Vertical lines
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point( 80, top), new Point( 80, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(267, top), new Point(267, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(347, top), new Point(347, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(427, top), new Point(427, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(507, top), new Point(507, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(587, top), new Point(587, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(667, top), new Point(667, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(747, top), new Point(747, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point( 80, top2), new Point( 80, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(267, top2), new Point(267, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(347, top2), new Point(347, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(427, top2), new Point(427, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(507, top2), new Point(507, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(587, top2), new Point(587, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(667, top2), new Point(667, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(747, top2), new Point(747, bot2));
}
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);
}
Point FromTest(int testNr, int parNr)
{
const int NrParamsInOneTableRow = 6;
int x = 267 + (parNr % NrParamsInOneTableRow) * 80 + Margin;
int y = top + SpacingOneAndHalf + Margin + testNr * SpacingOneAndHalf
+ ((parNr >= NrParamsInOneTableRow) ? secondTableOffset : 0);
if (parNr < 0) x = 80 + Margin; /// When parNr == -1 return the left column x coordinate
return new Point(x, y);
}
}
}
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using TBF.BenchControl;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public class Printer : ComponentBase, Generic.IComponent, IOperation, GenericDevices.IResultsPrinter
{
readonly PrinterCfg printerCfg;
public static void ResetStaticProperties() { }
/// <summary>
/// Data to print
/// </summary>
public BenchControl.BenchId.Component BenchId;
public IList<GenericDevices.IWaterMeter> WaterMeters;
public IList<Entities.TestResult> Results;
public string Title;
public string Version
{
get { return (ProcedureParams is ProcParams) ? (ProcedureParams as ProcParams).Version : ""; }
}
public string Zaehlertyp
{
get { return (ProcedureParams is ProcParams) ? (ProcedureParams as ProcParams).Zaehlertyp : ""; }
}
public string Pruefvorlage
{
get { return (ProcedureParams is ProcParams) ? (ProcedureParams as ProcParams).Pruefvorlage : ""; }
}
public string Eichjahr
{
get { return (ProcedureParams is ProcParams) ? (ProcedureParams as ProcParams).Eichjahr : ""; }
}
public Printer(PrinterCfg cfg)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.printerCfg = cfg;
}
/// <summary>Events: ResultsPrinted</summary>
/// <param name="results">Results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation PrintResultsOp(BenchControl.BenchId.Component benchId,
IList<GenericDevices.IWaterMeter> waterMeters,
IList<Entities.TestResult> results,
string title)
{
this.BenchId = benchId;
this.WaterMeters = waterMeters;
this.Results = results;
this.Title = title;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
if (Results != null && Results.Count >= 1)
{
new MunichPrintDocument(this).Print();
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
@@ -0,0 +1,54 @@
using System;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
{
/// Parameterless constructor
public PrinterCfg()
{
}
/// <summary>
/// Basic results printer configuration parameters
/// </summary>
/// <param name="factory">BasicPrinter factory</param>
/// <param name="name">Printer name</param>
public PrinterCfg(IComponentFactory factory, string name)
: base(factory, name)
{
}
public IComponentCfg Clone()
{
return new PrinterCfg(Factory, Name);
}
public string ToString(int i)
{
return string.Empty;
}
public TBF.Entities.Component CreateDbEntity()
{
using (var writer = new StringWriter())
{
(new XmlSerializer(GetType())).Serialize(writer, this);
return Entities.Component.CreateFromCfg(Name, Factory.ClassName, ParentName, ItemNr, DebugLevel, LogLevel, writer.ToString());
}
}
public static IComponentCfg CreateFromDbEntity(Entities.Component component, IComponentFactory factory)
{
using (var reader = new StringReader(component.Parameters))
{
PrinterCfg config = (PrinterCfg)(new XmlSerializer(typeof(PrinterCfg))).Deserialize(reader);
config.InitCfgBaseFromEntity(component, factory);
return config;
}
}
}
}
@@ -0,0 +1,58 @@
using System;
using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public partial class PrinterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
PrinterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PrinterCfg;
Redraw();
}
}
public PrinterCfgCtrl()
{
InitializeComponent();
}
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
}
public void Unlock()
{
nameTextBox.Enabled = true;
}
public CfgVerifyFlags VerifyCfg(ref string message)
{
CfgVerifyFlags flags = CfgVerifyFlags.None;
return flags;
}
public void UpdateCfg()
{
if (config == null) return; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
}
}
}
@@ -0,0 +1,83 @@
namespace TBF.BenchControl.ResultsPrinters.Munich
{
partial class PrinterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(137, 57);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 5;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(27, 60);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 4;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(134, 33);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 3;
this.classNameLabel.Text = "ComonentName";
//
// BasicPrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "BasicPrinterCfgCtrl";
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;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public class PrinterFactory : IComponentFactory
{
public string ClassName { get { return "ResultsPrinter4Munich"; } }
public bool HasProcedureParams { get { return true; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams)
{
return ProcParams.GetProcedureParams(procedureParams);
}
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 1; } }
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
{
return new PrinterCfg(this, "PrintedProtocol");
}
public IComponentCfgCtrl CreateCfgCtrl()
{
return new PrinterCfgCtrl();
}
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
{
return new Printer((PrinterCfg)config);
}
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
{
return PrinterCfg.CreateFromDbEntity(component, this);
}
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
}
}
@@ -0,0 +1,163 @@
using System.IO;
using System.Text;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.ResultsPrinters.Munich
{
public class ProcParams : IParamsProvider, IProcedureParams
{
public string Version;
public string Zaehlertyp;
public string Pruefvorlage;
public string Eichjahr;
string[] paramNames = new string[]
{
Strings.Version,
"Zählertyp",
"Prüfvorlage",
"Eichjahr",
};
public string ParamName(int i) { return paramNames[i]; }
public string ToString(int i)
{
switch (i)
{
case 0: return Version;
case 1: return Zaehlertyp;
case 2: return Pruefvorlage;
case 3: return Eichjahr;
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: Version = strValue; return;
case 1: Zaehlertyp = strValue; return;
case 2: Pruefvorlage = strValue; return;
case 3: Eichjahr = strValue; return;
default: return;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
case 1:
case 2:
case 3:
return true;
default:
message = "Invalid index";
return false;
}
}
#region Boilerplate code
public int ParamsCount() { return paramNames.Length; }
public override string ToString()
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ParamsCount(); i++)
{
if (i != 0) sb.Append("; ");
sb.Append(ParamName(i));
sb.Append("=");
sb.Append(ToString(i));
}
return sb.ToString();
}
[XmlIgnore]
public Entities.ComponentProcedure ProcedureParamsEntity { get { return procParamsEntity; } }
Entities.ComponentProcedure procParamsEntity;
[XmlIgnore]
public string ComponentName { get { return componentName; } }
string componentName;
[XmlIgnore]
public Entities.Procedure Test { get { return test; } }
Entities.Procedure test;
/// Parameterless constructor
public ProcParams()
{
Version = "4/13";
Zaehlertyp = "";
Pruefvorlage = "";
Eichjahr = "2014";
}
public ProcParams(Entities.ComponentProcedure procParamsEntity, string componentName, Entities.Procedure test)
: this()
{
this.procParamsEntity = procParamsEntity;
this.componentName = componentName;
this.test = test;
}
public TBF.Entities.ComponentProcedure ToDbEntity(IComponent component, Entities.Procedure procedure)
{
using (var writer = new StringWriter())
{
/// Serialize this class with parameters
(new XmlSerializer(GetType())).Serialize(writer, this);
/// Create and return the ComponentProcedure entity
TBF.Entities.ComponentProcedure entity = new TBF.Entities.ComponentProcedure();
entity.CmpntName = component.Cfg.Name;
entity.Parameters = writer.ToString();
entity.Procedure = procedure;
return entity;
}
}
public void UpdateDbEntity()
{
using (var writer = new StringWriter())
{
/// Serialize this class and update the entity
(new XmlSerializer(GetType())).Serialize(writer, this);
procParamsEntity.Parameters = writer.ToString();
procParamsEntity.CmpntName = componentName;
procParamsEntity.Procedure = test;
}
}
public static IParamsProvider GetProcedureParams(Entities.ComponentProcedure procParamsEntity)
{
if (procParamsEntity == null) return new ProcParams();
ProcParams procParams;
try
{
procParams = (ProcParams)(new XmlSerializer(typeof(ProcParams)))
.Deserialize(new StringReader(procParamsEntity.Parameters));
}
catch
{
procParams = new ProcParams();
}
procParams.procParamsEntity = procParamsEntity;
procParams.componentName = procParamsEntity.CmpntName;
procParams.test = procParamsEntity.Procedure;
return procParams;
}
#endregion
}
}