Code cleanup : Config.Entities.TestResult, Config.Entities.MeterTestResult, ResultsPrinters.Zapiska.Printer, etc. removed.
This commit is contained in:
parent
420d016ee8
commit
5cb3955903
@ -78,12 +78,10 @@
|
||||
<Compile Include="Entities\IHasValves.cs" />
|
||||
<Compile Include="Entities\MeasurementCorrection.cs" />
|
||||
<Compile Include="Entities\MetersPath.cs" />
|
||||
<Compile Include="Entities\MeterTestResult.cs" />
|
||||
<Compile Include="Entities\OutputPath.cs" />
|
||||
<Compile Include="Entities\Procedure.cs" />
|
||||
<Compile Include="Entities\ProcedureHistory.cs" />
|
||||
<Compile Include="Entities\Test.cs" />
|
||||
<Compile Include="Entities\TestResult.cs" />
|
||||
<Compile Include="Entities\TransitionSequence.cs" />
|
||||
<Compile Include="Entities\TransitionStep.cs" />
|
||||
<Compile Include="Entities\User.cs" />
|
||||
@ -101,11 +99,9 @@
|
||||
<Compile Include="Mappings\HeatMetersPathMap.cs" />
|
||||
<Compile Include="Mappings\MeasurementCorrectionMap.cs" />
|
||||
<Compile Include="Mappings\MetersPathMap.cs" />
|
||||
<Compile Include="Mappings\MeterTestResultMap.cs" />
|
||||
<Compile Include="Mappings\OutputPathMap.cs" />
|
||||
<Compile Include="Mappings\ProcedureMap.cs" />
|
||||
<Compile Include="Mappings\TestMap.cs" />
|
||||
<Compile Include="Mappings\TestResultMap.cs" />
|
||||
<Compile Include="Mappings\TransitionSequenceMap.cs" />
|
||||
<Compile Include="Mappings\TransitionStepMap.cs" />
|
||||
<Compile Include="Mappings\UserMap.cs" />
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class MeterTestResult
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual TestResult TestResult { get; set; } /// reference to the TestResult entity
|
||||
|
||||
public virtual bool Disabled { get; set; } /// true = this meter was disabled and the results should be disregarded
|
||||
public virtual string SerialNr { get; set; }
|
||||
public virtual string EndState { get; set; }
|
||||
public virtual float VolumeStart { get; set; } /// liter
|
||||
public virtual float VolumeEnd { get; set; } /// liter
|
||||
public virtual float VolumeMeter { get; set; } /// liter
|
||||
public virtual float VolumeRef { get; set; } /// liter
|
||||
public virtual float VolumeErrorPct { get; set; } /// %
|
||||
public virtual float PulsesMeter { get; set; } /// # of pulses
|
||||
public virtual float PulsesPerLiter { get; set; } /// Pulses per liter
|
||||
public virtual float PulsesMaster { get; set; }
|
||||
public virtual float Time { get; set; } /// sec.
|
||||
public virtual float TimeStart { get; set; } /// sec. - Not mapped to DB !!!
|
||||
public virtual float TimeEnd { get; set; } /// sec. - Not mapped to DB !!!
|
||||
public virtual int CalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!!
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!!
|
||||
public virtual bool Passed { get; set; } /// true=test passed - Not mapped to DB !!!
|
||||
|
||||
public MeterTestResult()
|
||||
{
|
||||
PulsesPerLiter = 1.0f;
|
||||
}
|
||||
|
||||
public MeterTestResult(TestResult testResult)
|
||||
: this()
|
||||
{
|
||||
TestResult = testResult;
|
||||
}
|
||||
|
||||
public virtual MeterTestResult Clone(TestResult testResult)
|
||||
{
|
||||
MeterTestResult result = new MeterTestResult(testResult);
|
||||
|
||||
result.Disabled = Disabled;
|
||||
result.SerialNr = SerialNr;
|
||||
result.EndState = EndState;
|
||||
result.VolumeStart = VolumeStart;
|
||||
result.VolumeEnd = VolumeEnd;
|
||||
result.VolumeMeter = VolumeMeter;
|
||||
result.VolumeRef = VolumeRef;
|
||||
result.VolumeErrorPct = VolumeErrorPct;
|
||||
result.PulsesMeter = PulsesMeter;
|
||||
result.PulsesPerLiter = PulsesPerLiter;
|
||||
result.PulsesMaster = PulsesMaster;
|
||||
result.Time = Time;
|
||||
result.TimeStart = TimeStart;
|
||||
result.TimeEnd = TimeEnd;
|
||||
result.CalibFactor = CalibFactor;
|
||||
result.Q2Correction = Q2Correction;
|
||||
result.Passed = Passed;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,176 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class TestResult
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual int BatchNr { get; set; }
|
||||
public virtual string PurchaseOrder { get; set; }
|
||||
public virtual MetersKind MetersKind { get; set; }
|
||||
public virtual IList<MeterTestResult> Meters { get; set; }
|
||||
public virtual IList<MeterTestResult> CombinedMeters { get; set; }
|
||||
|
||||
/// Value copied from the procedure (Entities.Procedure)
|
||||
public virtual string ProcedureName { get; set; }
|
||||
public virtual string ProtocolTitle { get; set; }
|
||||
|
||||
/// Values copied from the test (Entities.Test)
|
||||
public virtual int TestId { get; set; } /// Test entity ID to distinguish between tests with the same name
|
||||
public virtual string TestName { get; set; }
|
||||
public virtual int Part { get; set; }
|
||||
public virtual bool DoNotEvaluate { get; set; } /// Not mapped to the database
|
||||
public virtual bool DoNotPublish { get; set; } /// Not mapped to the database
|
||||
public virtual float Qfrom { get; set; } /// [m3/h] Water flow low limit
|
||||
public virtual float Qto { get; set; } /// [m3/h] Water flow high limit
|
||||
public virtual float Volume { get; set; } /// [l] Target test volume
|
||||
public virtual float TstTime { get; set; } /// [s] Test time estimate
|
||||
public virtual int Repeats { get; set; }
|
||||
public virtual bool Emptying { get; set; }
|
||||
public virtual bool Zeroing { get; set; }
|
||||
public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
|
||||
public virtual int Time2MassMsrmt { get; set; }
|
||||
public virtual string Method { get; set; }
|
||||
public virtual float ErrLimLo { get; set; } /// [%] Lower error limit (usually < 0)
|
||||
public virtual float ErrLimHi { get; set; } /// [%] Upper error limit (usually > 0)
|
||||
public virtual float Uncertainty { get; set; } /// [%] Makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
||||
|
||||
/// To be replaced by the virtual bench component parameters
|
||||
public virtual string FeedingPath { get; set; }
|
||||
public virtual string BenchPath { get; set; }
|
||||
public virtual string OutputPath { get; set; }
|
||||
public virtual string MetersPath { get; set; }
|
||||
|
||||
/// Results
|
||||
public virtual DateTime TimeStart { get; set; } /// Date and time of the test start
|
||||
public virtual DateTime TimeEnd { get; set; } /// Date and time of the test end
|
||||
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
|
||||
public virtual float AmbientTempAve { get; set; } /// [deg.C] Average ambient air temperature
|
||||
public virtual float AmbientPressAve { get; set; } /// Average ambient air pressure
|
||||
public virtual float AmbientHumiAve { get; set; } /// [%] Average ambient air relative humidity
|
||||
public virtual float PressInAvrg { get; set; } /// [Bar] Input water pressure (average)
|
||||
public virtual float PressInStart { get; set; } /// [Bar]
|
||||
public virtual float PressInEnd { get; set; } /// [Bar]
|
||||
public virtual float PressOutAvrg { get; set; } /// [Bar]
|
||||
public virtual float PressOutStart { get; set; } /// [Bar]
|
||||
public virtual float PressOutEnd { get; set; } /// [Bar]
|
||||
public virtual float TempInAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempInStart { get; set; } /// [deg.C]
|
||||
public virtual float TempInEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempOutAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempOutStart { get; set; } /// [deg.C]
|
||||
public virtual float TempOutEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempDivAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempDivStart { get; set; } /// [deg.C]
|
||||
public virtual float TempDivEnd { get; set; } /// [deg.C]
|
||||
public virtual float MassStartRaw { get; set; } /// [kg]
|
||||
public virtual float MassStart { get; set; } /// [kg]
|
||||
public virtual float MassEndRaw { get; set; } /// [kg]
|
||||
public virtual float MassEnd { get; set; } /// [kg]
|
||||
public virtual float MassDiff { get; set; } /// [kg]
|
||||
public virtual float DensityIn { get; set; } /// [kg/m3]
|
||||
public virtual float DensityOut { get; set; } /// [kg/m3]
|
||||
public virtual float DensityDiv { get; set; } /// [kg/m3]
|
||||
public virtual float Buoyancy { get; set; } ///TODO -> map
|
||||
public virtual float FlowMass { get; set; } /// [kg/h] calculated from conventional true value
|
||||
public virtual float FlowVolume { get; set; } /// [l/h] calculated from conventional true value
|
||||
public virtual float VolumeCTV { get; set; } /// [l] Volume conventional true value
|
||||
public virtual float VolumeMaster { get; set; } /// [l] Volume from the master flow meter
|
||||
public virtual float Time { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual float ErrorMaster { get; set; } /// [%]
|
||||
public virtual float PulsesMaster { get; set; }
|
||||
public virtual float ConstMaster { get; set; } /// [pls/l] Pulses per liter master flow meter
|
||||
public virtual float QRise { get; set; } /// Detected Q_rise of a composed meter
|
||||
public virtual float QFall { get; set; } /// Detected Q_fall of a composed meter
|
||||
public virtual float TimeDivStart0 { get; set; }
|
||||
public virtual float TimeDivStart1 { get; set; }
|
||||
public virtual float TimeDivStart2 { get; set; }
|
||||
public virtual float TimeDivStart3 { get; set; }
|
||||
public virtual float TimeDivStart4 { get; set; }
|
||||
public virtual float TimeDivStart5 { get; set; }
|
||||
public virtual float TimeDivEnd0 { get; set; }
|
||||
public virtual float TimeDivEnd1 { get; set; }
|
||||
public virtual float TimeDivEnd2 { get; set; }
|
||||
public virtual float TimeDivEnd3 { get; set; }
|
||||
public virtual float TimeDivEnd4 { get; set; }
|
||||
public virtual float TimeDivEnd5 { get; set; }
|
||||
|
||||
public TestResult()
|
||||
{
|
||||
Meters = new List<MeterTestResult>();
|
||||
CombinedMeters = new List<MeterTestResult>();
|
||||
}
|
||||
|
||||
public TestResult(MetersKind kind)
|
||||
: this()
|
||||
{
|
||||
MetersKind = kind;
|
||||
|
||||
if (kind == MetersKind.Single)
|
||||
{
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++) Meters.Add(new MeterTestResult(this));
|
||||
}
|
||||
else if (kind == MetersKind.Combined)
|
||||
{
|
||||
for (int i = 0; i < 2 * Config.Data.CompoundWMsCount; i++) Meters.Add(new MeterTestResult(this));
|
||||
for (int i = 0; i < Config.Data.CompoundWMsCount; i++) CombinedMeters.Add(new MeterTestResult(this));
|
||||
}
|
||||
else if (kind == MetersKind.HeatMeter)
|
||||
{
|
||||
/// TODO: Verify if this is OK
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++) Meters.Add(new MeterTestResult(this));
|
||||
}
|
||||
}
|
||||
|
||||
public TestResult(Test test, int repetitionNr, MetersKind kind)
|
||||
: this(kind)
|
||||
{
|
||||
if (test.Repeats == 1)
|
||||
{
|
||||
Name = test.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = string.Format("{0} ({1}/{2})", test.Name, repetitionNr, test.Repeats);
|
||||
}
|
||||
RepetitionNr = repetitionNr;
|
||||
|
||||
/// Copy test parameters from Entities.Procedure object
|
||||
ProcedureName = test.Procedure.Name;
|
||||
ProtocolTitle = test.Procedure.ProtocolTitle;
|
||||
|
||||
/// Copy test parameters from Entities.Test object
|
||||
TestId = test.Id;
|
||||
TestName = test.Name;
|
||||
Part = test.Part;
|
||||
Qfrom = test.Qfrom;
|
||||
Qto = test.Qto;
|
||||
Volume = test.Volume;
|
||||
TstTime = test.TstTime;
|
||||
Repeats = test.Repeats;
|
||||
Emptying = test.Draining;
|
||||
Zeroing = test.Zeroing;
|
||||
PumpPower = PumpPower;
|
||||
Time2MassMsrmt = test.TimeStop2Mass;
|
||||
Method = test.Method;
|
||||
ErrLimLo = test.ErrLimLo;
|
||||
ErrLimHi = test.ErrLimHi;
|
||||
Uncertainty = test.Uncertainty;
|
||||
|
||||
FeedingPath = test.FeedingPath;
|
||||
BenchPath = test.BenchPath;
|
||||
OutputPath = test.OutputPath;
|
||||
MetersPath = test.MetersPath;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", BatchNr, ProcedureName, TestName, TimeStart.ToShortDateString(), TimeStart.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class MeterTestResultMap : ClassMap<MeterTestResult>
|
||||
{
|
||||
public MeterTestResultMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
References(x => x.TestResult);
|
||||
Map(x => x.Disabled);
|
||||
Map(x => x.SerialNr);
|
||||
Map(x => x.EndState);
|
||||
Map(x => x.VolumeStart);
|
||||
Map(x => x.VolumeEnd);
|
||||
Map(x => x.VolumeMeter);
|
||||
Map(x => x.VolumeRef);
|
||||
Map(x => x.VolumeErrorPct);
|
||||
Map(x => x.PulsesMeter);
|
||||
Map(x => x.PulsesPerLiter);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.Time);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class TestResultMap : ClassMap<TestResult>
|
||||
{
|
||||
public TestResultMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.BatchNr);
|
||||
Map(x => x.PurchaseOrder);
|
||||
Map(x => x.MetersKind);
|
||||
HasMany(x => x.Meters)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.CombinedMeters)
|
||||
.Cascade.All();
|
||||
|
||||
Map(x => x.ProcedureName);
|
||||
Map(x => x.ProtocolTitle);
|
||||
|
||||
Map(x => x.TestId);
|
||||
Map(x => x.TestName);
|
||||
Map(x => x.Part);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Volume);
|
||||
Map(x => x.TstTime);
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.Emptying);
|
||||
Map(x => x.Zeroing);
|
||||
Map(x => x.PumpPower);
|
||||
Map(x => x.Time2MassMsrmt);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
|
||||
Map(x => x.FeedingPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.BenchPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.OutputPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.MetersPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
|
||||
Map(x => x.TimeStart);
|
||||
Map(x => x.TimeEnd);
|
||||
Map(x => x.RepetitionNr);
|
||||
Map(x => x.AmbientTempAve);
|
||||
Map(x => x.AmbientPressAve);
|
||||
Map(x => x.AmbientHumiAve);
|
||||
Map(x => x.PressInAvrg);
|
||||
Map(x => x.PressInStart);
|
||||
Map(x => x.PressInEnd);
|
||||
Map(x => x.PressOutAvrg);
|
||||
Map(x => x.PressOutStart);
|
||||
Map(x => x.PressOutEnd);
|
||||
Map(x => x.TempInAvrg);
|
||||
Map(x => x.TempInStart);
|
||||
Map(x => x.TempInEnd);
|
||||
Map(x => x.TempOutAvrg);
|
||||
Map(x => x.TempOutStart);
|
||||
Map(x => x.TempOutEnd);
|
||||
Map(x => x.TempDivAvrg);
|
||||
Map(x => x.TempDivStart);
|
||||
Map(x => x.TempDivEnd);
|
||||
Map(x => x.MassStartRaw);
|
||||
Map(x => x.MassStart);
|
||||
Map(x => x.MassEndRaw);
|
||||
Map(x => x.MassEnd);
|
||||
Map(x => x.MassDiff);
|
||||
Map(x => x.DensityIn);
|
||||
Map(x => x.DensityOut);
|
||||
Map(x => x.DensityDiv);
|
||||
Map(x => x.FlowMass); /// from conventional true value
|
||||
Map(x => x.FlowVolume); /// from conventional true value
|
||||
Map(x => x.VolumeCTV); /// volume conventional true value
|
||||
Map(x => x.VolumeMaster); /// volume from the master flow meter
|
||||
Map(x => x.Time); /// measurement time in seconds
|
||||
Map(x => x.ErrorMaster);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.ConstMaster); /// Pulses per liter master flow meter
|
||||
Map(x => x.QRise);
|
||||
Map(x => x.QFall);
|
||||
Map(x => x.TimeDivStart0);
|
||||
Map(x => x.TimeDivStart1);
|
||||
Map(x => x.TimeDivStart2);
|
||||
Map(x => x.TimeDivStart3);
|
||||
Map(x => x.TimeDivStart4);
|
||||
Map(x => x.TimeDivStart5);
|
||||
Map(x => x.TimeDivEnd0);
|
||||
Map(x => x.TimeDivEnd1);
|
||||
Map(x => x.TimeDivEnd2);
|
||||
Map(x => x.TimeDivEnd3);
|
||||
Map(x => x.TimeDivEnd4);
|
||||
Map(x => x.TimeDivEnd5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Config.Entities;
|
||||
|
||||
namespace TBF.BenchControl
|
||||
{
|
||||
/// <summary>
|
||||
/// This class keeps the current values used or measured by the test bench.
|
||||
/// </summary>
|
||||
public class Current
|
||||
{
|
||||
/// <summary>
|
||||
/// Procedure, Tests and TestResults data
|
||||
/// </summary>
|
||||
public static Procedure Procedure;
|
||||
|
||||
public static Test Test;
|
||||
public static int TestId = 0;
|
||||
|
||||
public static TestResult TestResult;
|
||||
public static int TestResultId = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Measured data
|
||||
/// </summary>
|
||||
public static double StartMass;
|
||||
public static double StopMass;
|
||||
|
||||
static Current()
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
public Current()
|
||||
{
|
||||
/// There should always be some raw data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes current 'tick' data during measurement.
|
||||
/// </summary>
|
||||
public static void ProcessTickData()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,444 +0,0 @@
|
||||
///
|
||||
/// 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.Zapiska
|
||||
{
|
||||
public class MyPrintDocument : PrintDocument
|
||||
{
|
||||
const string FontFamilyName = "Arial"; //"Times New Roman";
|
||||
|
||||
const int SpacingOne = 18;
|
||||
const int Padding = 10;
|
||||
const int TitleX = 100;
|
||||
const int TitleY = 160;
|
||||
int HdrTop = 220; /// Depends on the size of the title
|
||||
int TableTopFirstPage = 390; /// Depends on the size of the header
|
||||
int TableTopNextPage = TitleY;
|
||||
|
||||
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
/// </summary>
|
||||
Font font;
|
||||
Font boldFont;
|
||||
Font titleFont;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly Procedure procedure;
|
||||
readonly IList<TestResult> allResults;
|
||||
readonly string tester;
|
||||
readonly DateTime dateTime;
|
||||
readonly int batchMin;
|
||||
readonly int batchMax;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
readonly IList<string> testNames;
|
||||
readonly int testsPerMeter;
|
||||
readonly IList<Results.ItemSpec> resultItems;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly int maxNrRows;
|
||||
readonly int nrRows;
|
||||
readonly int nrColumns;
|
||||
string[,] dataToPrint;
|
||||
|
||||
///
|
||||
/// Layout and status
|
||||
///
|
||||
int nrTabLinesOnFirstPage;
|
||||
int nrTabLinesOnNextPage;
|
||||
int nextTableRow; /// nr. of table row 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
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// Precalculates some values and dimensions and stores strings for the table
|
||||
/// to be printed into a 2-dimensional array of strings 'dataToprint'.
|
||||
/// </summary>
|
||||
/// <param name="procedure">Procedure belonging to the results</param>
|
||||
/// <param name="batch">Results to be printed (multiple batches)</param>
|
||||
public MyPrintDocument(Results.Entities.Batch batch)
|
||||
{
|
||||
//this.procedure = procedure;
|
||||
//this.allResults = allResults;
|
||||
//this.tester = tester;
|
||||
|
||||
dateTime = DateTime.Now;
|
||||
|
||||
batchMin = int.MaxValue;
|
||||
batchMax = int.MinValue;
|
||||
foreach (var tr in allResults)
|
||||
{
|
||||
if (tr.BatchNr < batchMin) batchMin = tr.BatchNr;
|
||||
if (tr.BatchNr > batchMax) batchMax = tr.BatchNr;
|
||||
}
|
||||
|
||||
resultItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
|
||||
|
||||
testNames = Utils.GetDecoratedTestNames(procedure, 1);
|
||||
testsPerMeter = testNames.Count;
|
||||
|
||||
maxNrRows = (batchMax - batchMin + 1) * Config.Data.WMsCount;
|
||||
nrColumns = testsPerMeter * resultItems.Count + 2;
|
||||
|
||||
///
|
||||
/// Prepare raw data to print
|
||||
///
|
||||
dataToPrint = new string[maxNrRows, nrColumns];
|
||||
nrRows = 0;
|
||||
for (int i = batchMin; i <= batchMax; i++)
|
||||
{
|
||||
/// Collect all results belonging to one batch
|
||||
IList<TestResult> unsortedResults = new List<TestResult>();
|
||||
foreach (var tr in allResults) if (tr.BatchNr == i) unsortedResults.Add(tr);
|
||||
|
||||
if (unsortedResults.Count == 0) continue;
|
||||
|
||||
for (int wmNr = 0; wmNr < Config.Data.WMsCount; wmNr++) /// wmNr is 0-based
|
||||
{
|
||||
if (!unsortedResults[0].Meters[wmNr].Disabled)
|
||||
{
|
||||
dataToPrint[nrRows, 0] = (nrRows + 1).ToString();
|
||||
dataToPrint[nrRows, 1] = unsortedResults[0].Meters[wmNr].SerialNr;
|
||||
|
||||
IList<TestResult> results =
|
||||
Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr + 1, false));
|
||||
|
||||
for (int j = 0; j < testsPerMeter; j++)
|
||||
{
|
||||
if (results[j] != null)
|
||||
{
|
||||
int k = 2 + j * resultItems.Count;
|
||||
foreach (var item in resultItems)
|
||||
{
|
||||
///TODO
|
||||
//string str = item.Print(results[j].Meters[wmNr]);
|
||||
//int pos = str.IndexOf('|');
|
||||
//dataToPrint[nrRows, k++] = (pos < 0) ? str : str.Substring(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nrRows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pageNr = 1;
|
||||
nextTableRow = 0;
|
||||
}
|
||||
|
||||
/// <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(FontFamilyName, 10, FontStyle.Regular); }
|
||||
if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
|
||||
if (titleFont == null) { titleFont = new Font(FontFamilyName, 18, FontStyle.Bold); }
|
||||
}
|
||||
|
||||
/// <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);
|
||||
|
||||
/// 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
|
||||
|
||||
if (base.DefaultPageSettings.Landscape)
|
||||
{
|
||||
/// Landscape mode: we need to swap height/width parameters
|
||||
int tmp = printHeight;
|
||||
printHeight = printWidth;
|
||||
printWidth = tmp;
|
||||
|
||||
if (File.Exists("C:\\TBF\\header-landscape.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-landscape.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 1169, 827));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists("C:\\TBF\\header-portrait.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-portrait.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
|
||||
}
|
||||
}
|
||||
|
||||
///---------------
|
||||
/// Common info
|
||||
///---------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(allResults[0].ProtocolTitle))
|
||||
{
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
|
||||
e.Graphics.DrawString(allResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
TableTopFirstPage -= (HdrTop - TitleY);
|
||||
HdrTop = TitleY;
|
||||
}
|
||||
|
||||
string[] leftColumn = new string[]
|
||||
{
|
||||
Strings.Purchase_order + ": ",
|
||||
Strings.Date_and_time + ": ",
|
||||
Strings.Procedure + ": ",
|
||||
Strings.Tester + ": ",
|
||||
Strings.Approval + ": ",
|
||||
Strings.Ambient_temperature + ": ",
|
||||
Strings.Ambient_pressure + ": ",
|
||||
Strings.Ambient_humidity + ": ",
|
||||
};
|
||||
|
||||
string[] rightColumn = new string[]
|
||||
{
|
||||
allResults[0].PurchaseOrder,
|
||||
string.Format("{0:dd.MM.yyyy HH:mm}", dateTime),
|
||||
procedure.Name,
|
||||
tester,
|
||||
string.Empty,
|
||||
allResults[0].AmbientTempAve.ToString("F1") + " °C",
|
||||
Config.Units.ConvertTo(Config.Unit.mbar, allResults[0].AmbientPressAve).ToString("F0") + " mbar",
|
||||
allResults[0].AmbientHumiAve.ToString("F0") + " %",
|
||||
};
|
||||
|
||||
/// Determine max. left column width in characters
|
||||
float maxWdth = 0;
|
||||
foreach (var s in leftColumn)
|
||||
{
|
||||
float wdth = e.Graphics.MeasureString(s, font).Width;
|
||||
if (wdth > maxWdth) maxWdth = wdth;
|
||||
}
|
||||
|
||||
/// Write aligned columns
|
||||
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
|
||||
{
|
||||
PrintAt(e, 100, HdrTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, 100 + (int)maxWdth + 20, HdrTop + SpacingOne * i, rightColumn[i]);
|
||||
}
|
||||
}
|
||||
|
||||
///----------------
|
||||
/// More pages ?
|
||||
///----------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
/// Determine the number of pages once
|
||||
nrTabLinesOnFirstPage = (topMargin + printHeight - TableTopFirstPage - 70) / SpacingOne;
|
||||
nrTabLinesOnNextPage = (topMargin + printHeight - TableTopNextPage - 70) / SpacingOne;
|
||||
nrTabLinesOnNextPage = Math.Max(1, nrTabLinesOnNextPage); /// Prevent division by zero
|
||||
|
||||
if (nrRows <= nrTabLinesOnFirstPage)
|
||||
{
|
||||
nrPages = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nrPages = 1 + ((nrRows - nrTabLinesOnFirstPage) + nrTabLinesOnNextPage - 1) / nrTabLinesOnNextPage;
|
||||
}
|
||||
}
|
||||
int nrTabLinesOnThisPage = (pageNr == 1) ? nrTabLinesOnFirstPage : nrTabLinesOnNextPage;
|
||||
int rowFrom = nextTableRow;
|
||||
int rowTo;
|
||||
if (nrRows <= nextTableRow + nrTabLinesOnThisPage)
|
||||
{
|
||||
rowTo = nrRows - 1;
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rowTo = rowFrom + nrTabLinesOnThisPage - 1;
|
||||
nextTableRow = rowFrom + nrTabLinesOnThisPage;
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
|
||||
///--------
|
||||
/// Body
|
||||
///--------
|
||||
int[] columnPos = GetColumnPositions(e, dataToPrint, rowFrom, rowTo, leftMargin + Padding, 2 * Padding);
|
||||
int tableLeft = leftMargin;
|
||||
int tableRight = columnPos[nrColumns] - Padding;
|
||||
|
||||
int currentTableTop = (pageNr == 1) ? TableTopFirstPage : TableTopNextPage;
|
||||
int yyy = currentTableTop;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with test names (larger columns, names centered)
|
||||
for (int bigcol = 0; bigcol < testsPerMeter; bigcol++)
|
||||
{
|
||||
float width = e.Graphics.MeasureString(testNames[bigcol], font).Width;
|
||||
int bc = 2 + bigcol * resultItems.Count;
|
||||
int xxx = (columnPos[bc] + columnPos[bc + resultItems.Count]) / 2 - Padding - (int)(width / 2 + 0.5f);
|
||||
PrintAt(e, xxx, yyy, testNames[bigcol]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
int tableTop2 = yyy;
|
||||
|
||||
/// Indented horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[2] - Padding, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with header texts
|
||||
PrintAt(e, columnPos[0], yyy - SpacingOne / 2, GetHeaderItem(0));
|
||||
PrintAt(e, columnPos[1], yyy - SpacingOne / 2, GetHeaderItem(1));
|
||||
for (int col = 2; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, GetHeaderItem(col));
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Table with results
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
for (int col = 0; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, dataToPrint[row, col]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
}
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
int tableBottom = yyy;
|
||||
|
||||
/// Vertical lines
|
||||
for (int col = 0; col <= nrColumns; col++)
|
||||
{
|
||||
if (col < 2 || ((col-2) % resultItems.Count) == 0)
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, currentTableTop),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, tableTop2),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
}
|
||||
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
PrintAt(e, leftMargin, topMargin + printHeight - SpacingOne, string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns header text for each column of the table.
|
||||
/// </summary>
|
||||
/// <param name="column">COlumn nymber (0-based)</param>
|
||||
/// <returns>Header text</returns>
|
||||
string GetHeaderItem(int column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0: return "Nr.";
|
||||
case 1: return "S/N";
|
||||
default: return resultItems[(column - 2) % resultItems.Count].ClmnHeaderText;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine column widths and return column left positions for a subset of table rows
|
||||
/// </summary>
|
||||
/// <param name="dataToPrint">string[nrRows, nrColumns]</param>
|
||||
/// <param name="rowFrom">First row to consider</param>
|
||||
/// <param name="rowTo">Last row to consider</param>
|
||||
/// <returns>Left column positions and right side float[nrColumns + 1]</returns>
|
||||
int[] GetColumnPositions(System.Drawing.Printing.PrintPageEventArgs e,
|
||||
string[,] dataToPrint, int rowFrom, int rowTo,
|
||||
int leftMargin, int padding)
|
||||
{
|
||||
int nrColumns = dataToPrint.GetLength(1);
|
||||
int[] columnPos = new int[nrColumns + 1];
|
||||
columnPos[0] = leftMargin;
|
||||
|
||||
for (int column = 0; column < nrColumns; column++)
|
||||
{
|
||||
float columnWidth = e.Graphics.MeasureString(GetHeaderItem(column), font).Width;
|
||||
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
float itemWidth = e.Graphics
|
||||
.MeasureString(dataToPrint[row, column] == null ? string.Empty : dataToPrint[row, column], font)
|
||||
.Width;
|
||||
if (itemWidth > columnWidth) columnWidth = itemWidth;
|
||||
}
|
||||
|
||||
columnPos[column + 1] = columnPos[column] + (int)(columnWidth + 0.5f) + padding;
|
||||
}
|
||||
|
||||
return columnPos;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
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;
|
||||
|
||||
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
|
||||
|
||||
|
||||
/// <summary> Data to print </summary>
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
|
||||
public Printer() { }
|
||||
|
||||
|
||||
public Printer(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
printerCfg = cfg as PrinterCfg;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints the test cycle results, Events: Event.ResultsPrinted
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch results to print</param>
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation PrintResultsOp(Results.Entities.Batch batch)
|
||||
{
|
||||
this.batch = batch;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
if (batch.WaterMeters.Count > 0)
|
||||
{
|
||||
new MyPrintDocument(batch).Print();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.ResultsPrinted;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public IComponentCfgCtrl GetControl() { return new PrinterCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public bool SupressPrinting; /// Bypass printing when true
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
PrinterCfg()
|
||||
{
|
||||
Name = "Zapiska";
|
||||
ParentName = string.Empty;
|
||||
SupressPrinting = false;
|
||||
}
|
||||
|
||||
public PrinterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, SupressPrinting={1}",
|
||||
Name,
|
||||
SupressPrinting ? "yes" : "no"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
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.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(106, 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(34, 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(103, 33);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// supressPrintingCheckBox
|
||||
//
|
||||
this.supressPrintingCheckBox.AutoSize = true;
|
||||
this.supressPrintingCheckBox.Enabled = false;
|
||||
this.supressPrintingCheckBox.Location = new System.Drawing.Point(106, 87);
|
||||
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
|
||||
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
|
||||
this.supressPrintingCheckBox.TabIndex = 12;
|
||||
this.supressPrintingCheckBox.Text = "Supress printing";
|
||||
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// PrinterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
supressPrintingCheckBox.Checked = config.SupressPrinting;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
supressPrintingCheckBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
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.SupressPrinting = supressPrintingCheckBox.Checked;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
<?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>
|
||||
@ -1,26 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class PrinterFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "Zapiska"; } }
|
||||
|
||||
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new Printer(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new PrinterCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PrinterCfg), component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +113,6 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new Elde.ValveEx.ValveFactory());
|
||||
Factories.Add(new WaterMeters.Munich.WaterMeterFactory()); /// WaterMeter
|
||||
Factories.Add(new WaterMeters.WaterMeter.WaterMeterFactory()); /// WaterMeter
|
||||
Factories.Add(new ResultsPrinters.Zapiska.PrinterFactory()); /// Zapiska
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -528,95 +528,95 @@ namespace TBF
|
||||
|
||||
private void printToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
TBF.Forms.PrintOrderForm dlg = new TBF.Forms.PrintOrderForm();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string purchaseOrder = dlg.PurchaseOrder;
|
||||
string tester = dlg.Tester;
|
||||
//TBF.Forms.PrintOrderForm dlg = new TBF.Forms.PrintOrderForm();
|
||||
//if (dlg.ShowDialog() == DialogResult.OK)
|
||||
//{
|
||||
// string purchaseOrder = dlg.PurchaseOrder;
|
||||
// string tester = dlg.Tester;
|
||||
|
||||
NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
// NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
|
||||
IList<TestResult> testResults = session.QueryOver<TestResult>()
|
||||
.Where(x => (x.PurchaseOrder == purchaseOrder))
|
||||
.List();
|
||||
// IList<TestResult> testResults = session.QueryOver<TestResult>()
|
||||
// .Where(x => (x.PurchaseOrder == purchaseOrder))
|
||||
// .List();
|
||||
|
||||
if (testResults.Count == 0)
|
||||
{
|
||||
MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
// if (testResults.Count == 0)
|
||||
// {
|
||||
// MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (dlg.OnlyGoodResults)
|
||||
{
|
||||
/// Proceed from the end of the list so that items can be removed by index
|
||||
for (int i = testResults.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// TODO: Complete
|
||||
}
|
||||
}
|
||||
// if (dlg.OnlyGoodResults)
|
||||
// {
|
||||
// /// Proceed from the end of the list so that items can be removed by index
|
||||
// for (int i = testResults.Count - 1; i >= 0; i--)
|
||||
// {
|
||||
// // TODO: Complete
|
||||
// }
|
||||
// }
|
||||
|
||||
if (dlg.OnlyLastResult)
|
||||
{
|
||||
/// Remove test results if there exist a later test results for the same sn
|
||||
/// Proceed from the end of the list so that items can be removed by index
|
||||
for (int i = testResults.Count - 1; i >= 0; i--)
|
||||
{
|
||||
string name = testResults[i].Name;
|
||||
int batchNr = testResults[i].BatchNr;
|
||||
foreach (var tr in testResults)
|
||||
{
|
||||
if (tr.Name == name && tr.BatchNr > batchNr)
|
||||
{
|
||||
bool allWMsAreTheSame = true;
|
||||
// if (dlg.OnlyLastResult)
|
||||
// {
|
||||
// /// Remove test results if there exist a later test results for the same sn
|
||||
// /// Proceed from the end of the list so that items can be removed by index
|
||||
// for (int i = testResults.Count - 1; i >= 0; i--)
|
||||
// {
|
||||
// string name = testResults[i].Name;
|
||||
// int batchNr = testResults[i].BatchNr;
|
||||
// foreach (var tr in testResults)
|
||||
// {
|
||||
// if (tr.Name == name && tr.BatchNr > batchNr)
|
||||
// {
|
||||
// bool allWMsAreTheSame = true;
|
||||
|
||||
int cnt = Math.Min(testResults[i].Meters.Count, tr.Meters.Count);
|
||||
for (int j = 0; j < cnt; j++)
|
||||
{
|
||||
if (testResults[i].Meters[j].SerialNr != tr.Meters[j].SerialNr)
|
||||
{
|
||||
allWMsAreTheSame = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// int cnt = Math.Min(testResults[i].Meters.Count, tr.Meters.Count);
|
||||
// for (int j = 0; j < cnt; j++)
|
||||
// {
|
||||
// if (testResults[i].Meters[j].SerialNr != tr.Meters[j].SerialNr)
|
||||
// {
|
||||
// allWMsAreTheSame = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (allWMsAreTheSame)
|
||||
{
|
||||
/// Remove as there exists a more recent measurement with the same meters
|
||||
testResults.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (allWMsAreTheSame)
|
||||
// {
|
||||
// /// Remove as there exists a more recent measurement with the same meters
|
||||
// testResults.RemoveAt(i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
IList<Procedure> procedure = session.QueryOver<Procedure>()
|
||||
.Where(x => (x.ProcedureState == ProcedureState.Active))
|
||||
.And(x => (x.Name == testResults[0].ProcedureName))
|
||||
.List();
|
||||
// IList<Procedure> procedure = session.QueryOver<Procedure>()
|
||||
// .Where(x => (x.ProcedureState == ProcedureState.Active))
|
||||
// .And(x => (x.Name == testResults[0].ProcedureName))
|
||||
// .List();
|
||||
|
||||
if (procedure.Count != 1)
|
||||
{
|
||||
MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
// if (procedure.Count != 1)
|
||||
// {
|
||||
// MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == MetersKind.Single))
|
||||
{
|
||||
PrintOrderDocument doc = new PrintOrderDocument(procedure[0], testResults, tester);
|
||||
doc.DefaultPageSettings.Landscape = true;
|
||||
doc.Print();
|
||||
}
|
||||
else if((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == MetersKind.Combined))
|
||||
{
|
||||
/// Do nothing right now
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if ((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == MetersKind.Single))
|
||||
// {
|
||||
// PrintOrderDocument doc = new PrintOrderDocument(procedure[0], testResults, tester);
|
||||
// doc.DefaultPageSettings.Landscape = true;
|
||||
// doc.Print();
|
||||
// }
|
||||
// else if((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == MetersKind.Combined))
|
||||
// {
|
||||
// /// Do nothing right now
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// MessageBox.Show(Strings.No_results_to_print, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void upgradeTSMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
@ -1,443 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-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
|
||||
{
|
||||
public class PrintOrderDocument : PrintDocument
|
||||
{
|
||||
const string FontFamilyName = "Arial"; //"Times New Roman";
|
||||
|
||||
const int SpacingOne = 18;
|
||||
const int Padding = 10;
|
||||
const int TitleX = 100;
|
||||
const int TitleY = 160;
|
||||
int HdrTop = 220; /// Depends on the size of the title
|
||||
int TableTopFirstPage = 390; /// Depends on the size of the header
|
||||
int TableTopNextPage = TitleY;
|
||||
|
||||
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
/// </summary>
|
||||
Font font;
|
||||
Font boldFont;
|
||||
Font titleFont;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly Procedure procedure;
|
||||
readonly IList<TestResult> allResults;
|
||||
readonly string tester;
|
||||
readonly DateTime dateTime;
|
||||
readonly int batchMin;
|
||||
readonly int batchMax;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
readonly IList<string> testNames;
|
||||
readonly int testsPerMeter;
|
||||
readonly IList<Results.ItemSpec> resultItems;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly int maxNrRows;
|
||||
readonly int nrRows;
|
||||
readonly int nrColumns;
|
||||
string[,] dataToPrint;
|
||||
|
||||
///
|
||||
/// Layout and status
|
||||
///
|
||||
int nrTabLinesOnFirstPage;
|
||||
int nrTabLinesOnNextPage;
|
||||
int nextTableRow; /// nr. of table row 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
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// Precalculates some values and dimensions and stores strings for the table
|
||||
/// to be printed into a 2-dimensional array of strings 'dataToprint'.
|
||||
/// </summary>
|
||||
/// <param name="procedure">Procedure belonging to the results</param>
|
||||
/// <param name="allResults">Results to be printed (multiple batches)</param>
|
||||
public PrintOrderDocument(Procedure procedure, IList<TestResult> allResults, string tester)
|
||||
{
|
||||
this.procedure = procedure;
|
||||
this.allResults = allResults;
|
||||
this.tester = tester;
|
||||
|
||||
dateTime = DateTime.Now;
|
||||
|
||||
batchMin = int.MaxValue;
|
||||
batchMax = int.MinValue;
|
||||
foreach (var tr in allResults)
|
||||
{
|
||||
if (tr.BatchNr < batchMin) batchMin = tr.BatchNr;
|
||||
if (tr.BatchNr > batchMax) batchMax = tr.BatchNr;
|
||||
}
|
||||
|
||||
resultItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
|
||||
|
||||
testNames = Utils.GetDecoratedTestNames(procedure, 1);
|
||||
testsPerMeter = testNames.Count;
|
||||
|
||||
maxNrRows = (batchMax - batchMin + 1) * Config.Data.WMsCount;
|
||||
nrColumns = testsPerMeter * resultItems.Count + 2;
|
||||
|
||||
///
|
||||
/// Prepare raw data to print
|
||||
///
|
||||
dataToPrint = new string[maxNrRows, nrColumns];
|
||||
nrRows = 0;
|
||||
for (int i = batchMin; i <= batchMax; i++)
|
||||
{
|
||||
/// Collect all results belonging to one batch
|
||||
IList<TestResult> unsortedResults = new List<TestResult>();
|
||||
foreach (var tr in allResults) if (tr.BatchNr == i) unsortedResults.Add(tr);
|
||||
|
||||
if (unsortedResults.Count == 0) continue;
|
||||
|
||||
for (int wmNr = 0; wmNr < Config.Data.WMsCount; wmNr++) /// wmNr is 0-based
|
||||
{
|
||||
if (!unsortedResults[0].Meters[wmNr].Disabled)
|
||||
{
|
||||
dataToPrint[nrRows, 0] = (nrRows + 1).ToString();
|
||||
dataToPrint[nrRows, 1] = unsortedResults[0].Meters[wmNr].SerialNr;
|
||||
|
||||
IList<TestResult> results =
|
||||
Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr + 1, false));
|
||||
|
||||
for (int j = 0; j < testsPerMeter; j++)
|
||||
{
|
||||
if (results[j] != null)
|
||||
{
|
||||
int k = 2 + j * resultItems.Count;
|
||||
foreach (var item in resultItems)
|
||||
{
|
||||
///TODO
|
||||
//string str = item.Print(results[j].Meters[wmNr]);
|
||||
//int pos = str.IndexOf('|');
|
||||
//dataToPrint[nrRows, k++] = (pos < 0) ? str : str.Substring(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nrRows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pageNr = 1;
|
||||
nextTableRow = 0;
|
||||
}
|
||||
|
||||
/// <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(FontFamilyName, 10, FontStyle.Regular); }
|
||||
if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
|
||||
if (titleFont == null) { titleFont = new Font(FontFamilyName, 18, FontStyle.Bold); }
|
||||
}
|
||||
|
||||
/// <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);
|
||||
|
||||
/// 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
|
||||
|
||||
if (base.DefaultPageSettings.Landscape)
|
||||
{
|
||||
/// Landscape mode: we need to swap height/width parameters
|
||||
int tmp = printHeight;
|
||||
printHeight = printWidth;
|
||||
printWidth = tmp;
|
||||
|
||||
if (File.Exists("C:\\TBF\\header-landscape.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-landscape.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 1169, 827));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists("C:\\TBF\\header-portrait.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-portrait.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
|
||||
}
|
||||
}
|
||||
|
||||
///---------------
|
||||
/// Common info
|
||||
///---------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(allResults[0].ProtocolTitle))
|
||||
{
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
|
||||
e.Graphics.DrawString(allResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
TableTopFirstPage -= (HdrTop - TitleY);
|
||||
HdrTop = TitleY;
|
||||
}
|
||||
|
||||
string[] leftColumn = new string[]
|
||||
{
|
||||
Strings.Purchase_order + ": ",
|
||||
Strings.Date_and_time + ": ",
|
||||
Strings.Procedure + ": ",
|
||||
Strings.Tester + ": ",
|
||||
Strings.Approval + ": ",
|
||||
Strings.Ambient_temperature + ": ",
|
||||
Strings.Ambient_pressure + ": ",
|
||||
Strings.Ambient_humidity + ": ",
|
||||
};
|
||||
|
||||
string[] rightColumn = new string[]
|
||||
{
|
||||
allResults[0].PurchaseOrder,
|
||||
string.Format("{0:yyyy.MM.dd HH:mm}", dateTime),
|
||||
procedure.Name,
|
||||
tester,
|
||||
string.Empty,
|
||||
allResults[0].AmbientTempAve.ToString("F1") + " °C",
|
||||
allResults[0].AmbientPressAve.ToString("F0") + " mbar",
|
||||
allResults[0].AmbientHumiAve.ToString("F0") + " %",
|
||||
};
|
||||
|
||||
/// Determine max. left column width in characters
|
||||
float maxWdth = 0;
|
||||
foreach (var s in leftColumn)
|
||||
{
|
||||
float wdth = e.Graphics.MeasureString(s, font).Width;
|
||||
if (wdth > maxWdth) maxWdth = wdth;
|
||||
}
|
||||
|
||||
/// Write aligned columns
|
||||
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
|
||||
{
|
||||
PrintAt(e, 100, HdrTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, 100 + (int)maxWdth + 20, HdrTop + SpacingOne * i, rightColumn[i]);
|
||||
}
|
||||
}
|
||||
|
||||
///----------------
|
||||
/// More pages ?
|
||||
///----------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
/// Determine the number of pages once
|
||||
nrTabLinesOnNextPage = (topMargin + printHeight - TableTopNextPage - 70) / SpacingOne;
|
||||
nrTabLinesOnFirstPage = (topMargin + printHeight - TableTopFirstPage - 70) / SpacingOne;
|
||||
|
||||
if (nrRows <= nrTabLinesOnFirstPage)
|
||||
{
|
||||
nrPages = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nrPages = 1 + ((nrRows - nrTabLinesOnFirstPage) + nrTabLinesOnNextPage - 1) / nrTabLinesOnNextPage;
|
||||
}
|
||||
}
|
||||
int nrTabLinesOnThisPage = (pageNr == 1) ? nrTabLinesOnFirstPage : nrTabLinesOnNextPage;
|
||||
int rowFrom = nextTableRow;
|
||||
int rowTo;
|
||||
if (nrRows <= nextTableRow + nrTabLinesOnThisPage)
|
||||
{
|
||||
rowTo = nrRows - 1;
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rowTo = rowFrom + nrTabLinesOnThisPage - 1;
|
||||
nextTableRow = rowFrom + nrTabLinesOnThisPage;
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
|
||||
///--------
|
||||
/// Body
|
||||
///--------
|
||||
int[] columnPos = GetColumnPositions(e, dataToPrint, rowFrom, rowTo, leftMargin + Padding, 2 * Padding);
|
||||
int tableLeft = leftMargin;
|
||||
int tableRight = columnPos[nrColumns] - Padding;
|
||||
|
||||
int currentTableTop = (pageNr == 1) ? TableTopFirstPage : TableTopNextPage;
|
||||
int yyy = currentTableTop;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with test names (larger columns, names centered)
|
||||
for (int bigcol = 0; bigcol < testsPerMeter; bigcol++)
|
||||
{
|
||||
float width = e.Graphics.MeasureString(testNames[bigcol], font).Width;
|
||||
int bc = 2 + bigcol * resultItems.Count;
|
||||
int xxx = (columnPos[bc] + columnPos[bc + resultItems.Count]) / 2 - Padding - (int)(width / 2 + 0.5f);
|
||||
PrintAt(e, xxx, yyy, testNames[bigcol]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
int tableTop2 = yyy;
|
||||
|
||||
/// Indented horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[2] - Padding, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with header texts
|
||||
PrintAt(e, columnPos[0], yyy - SpacingOne / 2, GetHeaderItem(0));
|
||||
PrintAt(e, columnPos[1], yyy - SpacingOne / 2, GetHeaderItem(1));
|
||||
for (int col = 2; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, GetHeaderItem(col));
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Table with results
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
for (int col = 0; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, dataToPrint[row, col]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
}
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
int tableBottom = yyy;
|
||||
|
||||
/// Vertical lines
|
||||
for (int col = 0; col <= nrColumns; col++)
|
||||
{
|
||||
if (col < 2 || ((col-2) % resultItems.Count) == 0)
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, currentTableTop),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, tableTop2),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
}
|
||||
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
PrintAt(e, leftMargin, topMargin + printHeight - SpacingOne, string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns header text for each column of the table.
|
||||
/// </summary>
|
||||
/// <param name="column">COlumn nymber (0-based)</param>
|
||||
/// <returns>Header text</returns>
|
||||
string GetHeaderItem(int column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0: return "Nr.";
|
||||
case 1: return "S/N";
|
||||
default: return resultItems[(column - 2) % resultItems.Count].ClmnHeaderText;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine column widths and return column left positions for a subset of table rows
|
||||
/// </summary>
|
||||
/// <param name="dataToPrint">string[nrRows, nrColumns]</param>
|
||||
/// <param name="rowFrom">First row to consider</param>
|
||||
/// <param name="rowTo">Last row to consider</param>
|
||||
/// <returns>Left column positions and right side float[nrColumns + 1]</returns>
|
||||
int[] GetColumnPositions(System.Drawing.Printing.PrintPageEventArgs e,
|
||||
string[,] dataToPrint, int rowFrom, int rowTo,
|
||||
int leftMargin, int padding)
|
||||
{
|
||||
int nrColumns = dataToPrint.GetLength(1);
|
||||
int[] columnPos = new int[nrColumns + 1];
|
||||
columnPos[0] = leftMargin;
|
||||
|
||||
for (int column = 0; column < nrColumns; column++)
|
||||
{
|
||||
float columnWidth = e.Graphics.MeasureString(GetHeaderItem(column), font).Width;
|
||||
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
float itemWidth = e.Graphics
|
||||
.MeasureString(dataToPrint[row, column] == null ? string.Empty : dataToPrint[row, column], font)
|
||||
.Width;
|
||||
if (itemWidth > columnWidth) columnWidth = itemWidth;
|
||||
}
|
||||
|
||||
columnPos[column + 1] = columnPos[column] + (int)(columnWidth + 0.5f) + padding;
|
||||
}
|
||||
|
||||
return columnPos;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
<?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>
|
||||
<metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>zh-CN</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@ -707,18 +707,6 @@
|
||||
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\ResultsPrinters\LabelPrinter\PrinterFactory.cs" />
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\MyPrintDocument.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\Printer.cs" />
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\PrinterCfg.cs" />
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\PrinterCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\PrinterCfgCtrl.designer.cs">
|
||||
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\ResultsPrinters\Zapiska\PrinterFactory.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Basic\Writer.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Basic\WriterCfg.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Basic\WriterCfgCtrl.cs">
|
||||
@ -923,9 +911,6 @@
|
||||
<Compile Include="Forms\UpgradeSelectionDlg.Designer.cs">
|
||||
<DependentUpon>UpgradeSelectionDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PrintOrderDocument.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\CfgChangeArgs.cs" />
|
||||
<Compile Include="BenchControl\CmdResponseArgs.cs" />
|
||||
<Compile Include="BenchControl\ComponentBase.cs" />
|
||||
@ -1375,7 +1360,6 @@
|
||||
<Compile Include="BenchControl\Elde\Valve\Valve.cs" />
|
||||
<Compile Include="BenchControl\Elde\Valve\ValveCfg.cs" />
|
||||
<Compile Include="BenchControl\Elde\Valve\ValveFactory.cs" />
|
||||
<Compile Include="BenchControl\Current.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IScale.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IScale2.cs" />
|
||||
<Compile Include="BenchControl\Generic\IComponentCfgCtrl.cs" />
|
||||
@ -2021,9 +2005,6 @@
|
||||
<EmbeddedResource Include="BenchControl\ResultsPrinters\Munich\PrinterCfgCtrl.resx">
|
||||
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\ResultsPrinters\Zapiska\PrinterCfgCtrl.resx">
|
||||
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Output\FileWriters\Basic\WriterCfgCtrl.resx">
|
||||
<DependentUpon>WriterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -2165,9 +2146,6 @@
|
||||
<EmbeddedResource Include="PreferencesDlg.ru.resx">
|
||||
<DependentUpon>PreferencesDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="PrintOrderDocument.resx">
|
||||
<DependentUpon>PrintOrderDocument.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ProcedureDlg.pl.resx">
|
||||
<DependentUpon>ProcedureDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@ -247,50 +247,6 @@ namespace TBF
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pre-fetch the test results from the currently available results.
|
||||
/// The order of the returned results is the same as the order of tests in the procedure specification.
|
||||
/// </summary>
|
||||
/// <param name="procedure">Current procedure, it is used to determine the order of resulting test results</param>
|
||||
/// <param name="testResults">Currently available unsorted test results (can also be null)</param>
|
||||
/// <param name="meterPartNr">Water meter number (1-based) or 0=all (also compared with nonzero 'Part' number)</param>
|
||||
/// <returns>Ordered list of test results containing null-s for missing results</returns>
|
||||
public static IList<TestResult> GetSortedTestResults(Procedure procedure, IList<TestResult> testResults, int meterPartNr)
|
||||
{
|
||||
IList<TestResult> rslts = new List<TestResult>();
|
||||
|
||||
if (procedure == null) return rslts; /// Return an empty list if no procedure specified
|
||||
|
||||
foreach (var test in procedure.Tests)
|
||||
{
|
||||
BenchControl.GenericDevices.ITestMethod method =
|
||||
BenchControl.TbfComponents.FindComponent(test.Method) as BenchControl.GenericDevices.ITestMethod;
|
||||
|
||||
if ((method != null) && method.Publish(test) && ((test.Part == 0) || (meterPartNr == 0) || (test.Part == meterPartNr)))
|
||||
{
|
||||
for (int rpt = 1; rpt <= test.Repeats; rpt++)
|
||||
{
|
||||
bool added = false;
|
||||
if (testResults != null)
|
||||
{
|
||||
foreach (var testRslt in testResults)
|
||||
{
|
||||
if ((testRslt.TestId == test.Id) && (testRslt.RepetitionNr == rpt))
|
||||
{
|
||||
rslts.Add(testRslt);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!added) rslts.Add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rslts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pre-fetch the test names given the procedure and the meter number.
|
||||
/// The order or test names is the same as in the procedure specification.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user