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,140 @@
using System;
using System.Collections.Generic;
using System.IO;
using TBF.BenchControl;
namespace TBF.BenchControl.ResultsWriters.Basic
{
public class Writer : Generic.IComponent, IOperation, GenericDevices.IResultsWriter
{
readonly WriterCfg writerCfg;
public Generic.IComponentCfg Cfg { get { return writerCfg; } }
public static void ResetStaticProperties() { }
public string Name { get { return writerCfg.Name; } }
/// <summary>
/// Results to print
/// </summary>
IList<Entities.TestResult> results;
DateTime now;
Stream stream;
StreamWriter writer;
public Writer(WriterCfg cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.writerCfg = cfg;
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="results">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation WriteResultsOp(IList<Entities.TestResult> results)
{
this.results = results;
this.now = DateTime.Now;
this.stream = System.IO.File.Create(string.Format("{0}Results\\{1}-{2}-{3}\\{4}-{5}.txt",
Program.HomeDir,
now.Year, now.Month, now.Date,
now.Hour, now.Minute));
this.writer = new StreamWriter(stream);
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
writer.WriteLine("Staatlich anerkante Prüfstelle für Meßgeräte für Wasser WB2");
writer.WriteLine("");
writer.WriteLine(string.Format(" PROTOKOLL Nummer {0}", 0));
writer.WriteLine("");
writer.WriteLine("Ver. 3/13");
writer.WriteLine(string.Format("Datum / Zeit : {0}.{1}.{2} / {3}:{4} Seite : 1/ 1 / 1",
now.Date, now.Month, now.Year, now.Hour, now.Minute));
writer.WriteLine("Wasserzähler Type : 110338");
writer.WriteLine("Gerät Nr. : 1");
writer.WriteLine("Benutzer : Bauer");
writer.WriteLine("Impulsrate : 1 67.422 1");
writer.WriteLine("Bereich : 22,9 °C 947 mbar 43 %");
writer.WriteLine("");
writer.WriteLine("Test Metode MIDFehler Durchfluss Test Zeit T1 T2 Dichte Masse Druck Volume Bor");
writer.WriteLine(" [%] [m3/h] [s] [°C] [°C] [kg/m3] [kg] [MPa] [L] [m3/h]");
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
foreach (var tr in results)
{
if (tr.MetersKind == Entities.MetersKind.Single)
{
writer.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"),
tr.Name,
tr.Method,
tr.Meters[0].VolumeErrorPct,
tr.FlowMass,
tr.Time,
tr.TempInAvrg,
tr.TempDivAvrg,
tr.DensityOut,
tr.MassDiff,
tr.PressInAvrg,
tr.PressOutAvrg,
tr.VolumeCTV);
}
else if (tr.MetersKind == Entities.MetersKind.Combined)
{
writer.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"),
tr.Name,
tr.Method,
tr.CombinedMeters[0].VolumeErrorPct,
tr.FlowMass,
tr.Time,
tr.TempInAvrg,
tr.TempDivAvrg,
tr.DensityOut,
tr.MassDiff,
tr.PressInAvrg,
tr.PressOutAvrg,
tr.VolumeCTV);
}
}
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
writer.WriteLine("No| Zähler Nr| Test. Volume [L] | Zählerabweichung [%] | Messunsicherheit k=2 |Prüfergebnis");
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
writer.WriteLine(" Qmin Qt Qmax Qmin Qt Qmax Qmin Qt Qmax");
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
writer.WriteLine("");
writer.WriteLine("Hersteller : Bemerkung : M - Prüfung gegen Waage");
writer.WriteLine(" V - Prüfung gegen MID");
writer.WriteLine(" P - Start / Stopp");
writer.WriteLine(" F - Fliegender Start");
writer.WriteLine(" S - Impulskompensation");
writer.WriteLine(" C - Impulszählung");
writer.WriteLine("");
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
if (writer != null) writer.Close();
if (stream != null) stream.Close();
writer = null;
stream = null;
}
}
}
@@ -0,0 +1,54 @@
using System;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsWriters.Basic
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
/// Parameterless constructor
public WriterCfg()
{
}
/// <summary>
/// Basic results printer configuration parameters
/// </summary>
/// <param name="factory">BasicPrinter factory</param>
/// <param name="name">Printer name</param>
public WriterCfg(IComponentFactory factory, string name)
: base(factory, name)
{
}
public IComponentCfg Clone()
{
return new WriterCfg(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))
{
WriterCfg config = (WriterCfg)(new XmlSerializer(typeof(WriterCfg))).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.ResultsWriters.Basic
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
public WriterCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_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.ResultsWriters.Basic
{
partial class WriterCfgCtrl
{
/// <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.WriterCfgCtrl_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,40 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsWriters.Basic
{
public class WriterFactory : IComponentFactory
{
public string ClassName { get { return "BasicResultsWriter"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <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 WriterCfg(this, "BasicResultsWriter");
}
public IComponentCfgCtrl CreateCfgCtrl()
{
return new WriterCfgCtrl();
}
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
{
return new Writer((WriterCfg)config);
}
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
{
return WriterCfg.CreateFromDbEntity(component, this);
}
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
}
}