ProcessData (aka BatchResults) serialization part 2
This commit is contained in:
parent
61747166ae
commit
12c9e72d0c
@ -1,41 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using log4net;
|
||||
using Results.Entities;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public class BatchResults
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(BatchResults));
|
||||
public virtual System.Xml.Schema.XmlSchema GetSchema() { return null; }
|
||||
|
||||
|
||||
public Batch Batch;
|
||||
public int WMPositionsCount;
|
||||
|
||||
|
||||
[XmlIgnore]
|
||||
public IList<Entities.TestData> TestDataList;
|
||||
|
||||
[XmlIgnore]
|
||||
public IList<Entities.Components> ComponentsList;
|
||||
|
||||
[XmlIgnore]
|
||||
public IList<Entities.WaterMeterData> WaterMeterDataList;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor required for serialization
|
||||
/// </summary>
|
||||
private BatchResults()
|
||||
: this(Config.Data.WMsCount)
|
||||
public BatchResults()
|
||||
{
|
||||
TestDataList = new List<Entities.TestData>();
|
||||
ComponentsList = new List<Entities.Components>();
|
||||
WaterMeterDataList = new List<Entities.WaterMeterData>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -43,12 +32,9 @@ namespace Results
|
||||
/// </summary>
|
||||
/// <param name="wmPositionsCount">Watermeters count</param>
|
||||
private BatchResults(int wmPositionsCount)
|
||||
: this()
|
||||
{
|
||||
WMPositionsCount = wmPositionsCount;
|
||||
|
||||
TestDataList = new List<Entities.TestData>();
|
||||
ComponentsList = new List<Entities.Components>();
|
||||
WaterMeterDataList = new List<Entities.WaterMeterData>();
|
||||
}
|
||||
|
||||
|
||||
@ -218,41 +204,17 @@ namespace Results
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Save public fields of this class to the XML file.
|
||||
/// </summary>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(fileName)))
|
||||
{
|
||||
WriteBinary(writer);
|
||||
log.Warn("LocalSettings succesfully saved");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
Batch.WriteBinary(writer);
|
||||
writer.Write(WMPositionsCount);
|
||||
}
|
||||
|
||||
public static BatchResults Load(string fileName)
|
||||
{
|
||||
BatchResults br = new BatchResults();
|
||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(fileName)))
|
||||
{
|
||||
br.ReadBinary(reader);
|
||||
log.Warn("LocalSettings succesfully saved");
|
||||
}
|
||||
return br;
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
public virtual void ReadBinary(BinaryReader reader, string expectedProgramVersion)
|
||||
{
|
||||
Batch = new Batch();
|
||||
Batch.ReadBinary(reader);
|
||||
Batch.ReadBinary(reader, expectedProgramVersion);
|
||||
WMPositionsCount = reader.ReadInt32();
|
||||
int waterMetersLength = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,6 +233,7 @@ namespace Results.Entities
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(ProgramVersion);
|
||||
writer.Write(Id);
|
||||
writer.Write(BatchNr);
|
||||
writer.Write(TestBenchId);
|
||||
@ -242,7 +243,6 @@ namespace Results.Entities
|
||||
writer.Write(Address3);
|
||||
writer.Write(Address4);
|
||||
writer.Write(Address5);
|
||||
writer.Write(ProgramVersion);
|
||||
writer.Write(UserName);
|
||||
writer.Write(UserNumber);
|
||||
writer.Write(ProcedureName);
|
||||
@ -267,11 +267,28 @@ namespace Results.Entities
|
||||
writer.Write(Compound);
|
||||
writer.Write(HeatMeter);
|
||||
|
||||
/// TODO: Write lists
|
||||
IList<TestData> savedTestDatas = new List<TestData>(); /// Initially empty
|
||||
writer.Write(TestRslts.Count);
|
||||
for (int i = 0; i < TestRslts.Count; i++)
|
||||
{
|
||||
TestRslts[i].WriteBinary(writer, savedTestDatas);
|
||||
}
|
||||
|
||||
IList<WaterMeterData> savedWMDatas = new List<WaterMeterData>(); /// Initially empty
|
||||
writer.Write(WaterMeters.Count);
|
||||
for (int i = 0; i < WaterMeters.Count; i++)
|
||||
{
|
||||
WaterMeters[i].WriteBinary(writer, savedWMDatas);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
public virtual void ReadBinary(BinaryReader reader, string expectedProgramVersion)
|
||||
{
|
||||
ProgramVersion = reader.ReadString();
|
||||
if (expectedProgramVersion != null && ProgramVersion != expectedProgramVersion)
|
||||
{
|
||||
throw new Exception(string.Format("Process data were stored by TBF v.{0}", ProgramVersion));
|
||||
}
|
||||
Id = reader.ReadInt32();
|
||||
BatchNr = reader.ReadInt32();
|
||||
TestBenchId = reader.ReadInt32();
|
||||
@ -281,7 +298,6 @@ namespace Results.Entities
|
||||
Address3 = reader.ReadString();
|
||||
Address4 = reader.ReadString();
|
||||
Address5 = reader.ReadString();
|
||||
ProgramVersion = reader.ReadString();
|
||||
UserName = reader.ReadString();
|
||||
UserNumber = reader.ReadInt32();
|
||||
ProcedureName = reader.ReadString();
|
||||
@ -306,7 +322,27 @@ namespace Results.Entities
|
||||
Compound = reader.ReadBoolean();
|
||||
HeatMeter = reader.ReadBoolean();
|
||||
|
||||
/// TODO: Read lists
|
||||
}
|
||||
Tests = new List<TestData>(); /// Initially empty
|
||||
|
||||
int testRsltsCount = reader.ReadInt32();
|
||||
TestRslts = new List<TestRslt>();
|
||||
for (int i = 0; i < testRsltsCount; i++)
|
||||
{
|
||||
TestRslts.Add(new TestRslt());
|
||||
TestRslts[i].ReadBinary(reader, Tests);
|
||||
TestRslts[i].Batch = this;
|
||||
}
|
||||
|
||||
IList<WaterMeterData> wmDatasRetirevedSoFar = new List<WaterMeterData>(); /// Initially empty
|
||||
|
||||
int waterMetersCount = reader.ReadInt32();
|
||||
WaterMeters = new List<WaterMeter>();
|
||||
for (int i = 0; i < waterMetersCount; i++)
|
||||
{
|
||||
WaterMeters.Add(new WaterMeter());
|
||||
WaterMeters[i].ReadBinary(reader, wmDatasRetirevedSoFar, TestRslts);
|
||||
WaterMeters[i].Batch = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace Results.Entities
|
||||
public virtual string Custom2 { get; set; }
|
||||
public virtual string Custom3 { get; set; }
|
||||
|
||||
protected Components()
|
||||
public Components()
|
||||
{
|
||||
TestBenchId = 0;
|
||||
TestBenchName = string.Empty;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Results.Entities
|
||||
@ -168,10 +169,10 @@ namespace Results.Entities
|
||||
#if ORACLE_DB
|
||||
writer.Write(LastError);
|
||||
#endif
|
||||
/// TODO: Write lists
|
||||
writer.Write(TestRslt.Name());
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
public virtual void ReadBinary(BinaryReader reader, IList<TestRslt> testResults)
|
||||
{
|
||||
Id = reader.ReadInt32();
|
||||
CompoundMeterId = reader.ReadByte();
|
||||
@ -195,7 +196,19 @@ namespace Results.Entities
|
||||
#if ORACLE_DB
|
||||
LastError = reader.ReadDouble();
|
||||
#endif
|
||||
/// TODO: Read lists
|
||||
TestRslt = null;
|
||||
string trName = reader.ReadString();
|
||||
if (testResults != null)
|
||||
{
|
||||
foreach (var tr in testResults)
|
||||
{
|
||||
if (tr.Name() == trName)
|
||||
{
|
||||
TestRslt = tr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Results.Entities
|
||||
public virtual bool Evaluate { get; set; }
|
||||
|
||||
|
||||
protected TestData()
|
||||
public TestData()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Method = string.Empty;
|
||||
|
||||
@ -222,8 +222,10 @@ namespace Results.Entities
|
||||
public virtual Config.Entities.Publish Publish() { return (Config.Entities.Publish)TestData.Publish; }
|
||||
|
||||
|
||||
protected TestRslt()
|
||||
public TestRslt()
|
||||
{
|
||||
MethodClass = string.Empty;
|
||||
Remark = string.Empty;
|
||||
}
|
||||
|
||||
public TestRslt(Batch batch, TestData testData, int part, int repetitionNr)
|
||||
@ -397,11 +399,35 @@ namespace Results.Entities
|
||||
DiverterStart, DiverterEnd);
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer, IList<TestData> savedTestDatas)
|
||||
{
|
||||
writer.Write(Id);
|
||||
TestData.WriteBinary(writer); /// Writes TestData, does not write batch
|
||||
Components.WriteBinary(writer); /// Writes Components
|
||||
|
||||
/// Save TestData or TestData.Name
|
||||
if (savedTestDatas != null && !savedTestDatas.Contains(TestData))
|
||||
{
|
||||
writer.Write(true);
|
||||
TestData.WriteBinary(writer);
|
||||
savedTestDatas.Add(TestData);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(false);
|
||||
writer.Write(TestData.Name);
|
||||
}
|
||||
|
||||
/// Save Components if not null
|
||||
if (Components != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
Components.WriteBinary(writer); /// Write Components
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(false);
|
||||
}
|
||||
|
||||
writer.Write(Part);
|
||||
writer.Write(RepetitionNr);
|
||||
writer.Write(MethodClass);
|
||||
@ -514,11 +540,35 @@ namespace Results.Entities
|
||||
writer.Write(Counter5);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
public virtual void ReadBinary(BinaryReader reader, IList<TestData> testDatas)
|
||||
{
|
||||
Id = reader.ReadInt32();
|
||||
TestData.ReadBinary(reader); /// Reads TestData, does not read batch
|
||||
Components.ReadBinary(reader); /// Reads Components
|
||||
|
||||
/// Retrieve TestData
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
(TestData = new TestData()).ReadBinary(reader);
|
||||
if (testDatas != null) testDatas.Add(TestData);
|
||||
}
|
||||
else
|
||||
{
|
||||
TestData = null;
|
||||
string testDataName = reader.ReadString();
|
||||
foreach (var td in testDatas)
|
||||
{
|
||||
if (td.Name == testDataName)
|
||||
{
|
||||
TestData = td;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
(Components = new Components()).ReadBinary(reader); /// Read Components
|
||||
}
|
||||
|
||||
Part = reader.ReadInt32();
|
||||
RepetitionNr = reader.ReadInt32();
|
||||
MethodClass = reader.ReadString();
|
||||
|
||||
@ -353,7 +353,25 @@ namespace Results.Entities
|
||||
SessionId = 0;
|
||||
ErrorFlags = 0;
|
||||
LastRecordIsNok = false;
|
||||
}
|
||||
|
||||
/// Initialize strings
|
||||
SerialNr = string.Empty;
|
||||
SerialNrAux = string.Empty;
|
||||
PurchaseOrder = string.Empty;
|
||||
EndState = string.Empty;
|
||||
EndStateAux = string.Empty;
|
||||
ArchivePath = string.Empty;
|
||||
Remark = string.Empty;
|
||||
#if TURA_SPECIAL
|
||||
CompleteSerialNr = string.Empty;
|
||||
RadioAddress = string.Empty;
|
||||
ProdUserName = string.Empty;
|
||||
ProdPurchaseOrder = string.Empty;
|
||||
#endif
|
||||
#if IPERL
|
||||
FWVersion = string.Empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public virtual void CopyContentFrom(WaterMeter src)
|
||||
@ -535,7 +553,7 @@ namespace Results.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
public virtual void WriteBinary(BinaryWriter writer, IList<WaterMeterData> savedWMDatas)
|
||||
{
|
||||
writer.Write(Id);
|
||||
writer.Write(SerialNr);
|
||||
@ -593,11 +611,30 @@ namespace Results.Entities
|
||||
writer.Write(SessionId);
|
||||
writer.Write(LastRecordIsNok);
|
||||
|
||||
/// TODO: Write lists
|
||||
/// Save WaterMeterData or WaterMeterData.Id
|
||||
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
|
||||
{
|
||||
writer.Write(true);
|
||||
WaterMeterData.WriteBinary(writer);
|
||||
savedWMDatas.Add(WaterMeterData);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(false);
|
||||
}
|
||||
|
||||
/// Write MeterTestRslts
|
||||
int mtrCount = MeterTestRslts != null ? MeterTestRslts.Count : 0;
|
||||
writer.Write(mtrCount);
|
||||
for (int i = 0; i < mtrCount; i++)
|
||||
{
|
||||
MeterTestRslts[i].WriteBinary(writer);
|
||||
}
|
||||
|
||||
/// TODO: lastMeterTestRslts ???
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
public virtual void ReadBinary(BinaryReader reader, IList<WaterMeterData> wmDatasRetrievedSoFar, IList<TestRslt> testRslts)
|
||||
{
|
||||
Id = reader.ReadInt32();
|
||||
SerialNr = reader.ReadString();
|
||||
@ -655,7 +692,31 @@ namespace Results.Entities
|
||||
SessionId = reader.ReadInt32();
|
||||
LastRecordIsNok = reader.ReadBoolean();
|
||||
|
||||
/// TODO: Read lists
|
||||
/// Retrieve TestData
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
(WaterMeterData = new WaterMeterData()).ReadBinary(reader);
|
||||
if (wmDatasRetrievedSoFar != null) wmDatasRetrievedSoFar.Add(WaterMeterData);
|
||||
}
|
||||
else
|
||||
{
|
||||
WaterMeterData = null;
|
||||
foreach (var wmd in wmDatasRetrievedSoFar)
|
||||
{
|
||||
WaterMeterData = wmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Read MeterTestRslts
|
||||
int meterTestRsltsCount = reader.ReadInt32();
|
||||
MeterTestRslts = new List<MeterTestRslt>();
|
||||
for (int i = 0; i < meterTestRsltsCount; i++)
|
||||
{
|
||||
MeterTestRslts.Add(new MeterTestRslt());
|
||||
MeterTestRslts[i].ReadBinary(reader, testRslts);
|
||||
}
|
||||
|
||||
/// TODO: lastMeterTestRslts ???
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,8 +136,8 @@ namespace Results.Entities
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Id);
|
||||
writer.Write(ProductName);
|
||||
writer.Write(Producer);
|
||||
writer.Write((ProductName != null) ? ProductName : string.Empty);
|
||||
writer.Write((Producer != null) ? Producer : string.Empty);
|
||||
writer.Write(DN);
|
||||
writer.Write(L);
|
||||
writer.Write((int)Mounting);
|
||||
@ -146,24 +146,24 @@ namespace Results.Entities
|
||||
writer.Write(Q3_Qn);
|
||||
writer.Write(Q2_Qt);
|
||||
writer.Write(Q1_Qmin);
|
||||
writer.Write(MetrologicalClass);
|
||||
writer.Write((MetrologicalClass != null) ? MetrologicalClass : string.Empty);
|
||||
writer.Write((int)TemperatureClass);
|
||||
writer.Write((int)PressureLossClass);
|
||||
writer.Write((int)MaxAdmissiblePressure);
|
||||
writer.Write((int)FlowProfileSensitivityClass);
|
||||
writer.Write(ApprovalInfo);
|
||||
writer.Write(Certificate);
|
||||
writer.Write((ApprovalInfo != null) ? ApprovalInfo : string.Empty);
|
||||
writer.Write((Certificate != null) ? Certificate : string.Empty);
|
||||
writer.Write(PulsesPerLtr);
|
||||
writer.Write(ProducerAux);
|
||||
writer.Write((ProducerAux != null) ? ProducerAux : string.Empty);
|
||||
writer.Write(Q3_Qn_Aux);
|
||||
writer.Write(MetrologicalClassAux);
|
||||
writer.Write(ApprovalInfoAux);
|
||||
writer.Write((MetrologicalClassAux != null) ? MetrologicalClassAux : string.Empty);
|
||||
writer.Write((ApprovalInfoAux != null) ? ApprovalInfoAux : string.Empty);
|
||||
writer.Write((int)Medium);
|
||||
writer.Write(Text1);
|
||||
writer.Write(Text2);
|
||||
writer.Write(Text3);
|
||||
writer.Write(Text4);
|
||||
writer.Write(Text5);
|
||||
writer.Write((Text1 != null) ? Text1 : string.Empty);
|
||||
writer.Write((Text2 != null) ? Text2 : string.Empty);
|
||||
writer.Write((Text3 != null) ? Text3 : string.Empty);
|
||||
writer.Write((Text4 != null) ? Text4 : string.Empty);
|
||||
writer.Write((Text5 != null) ? Text5 : string.Empty);
|
||||
writer.Write(Compound);
|
||||
writer.Write(HeatMeter);
|
||||
#if ORACLE_DB
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using log4net;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
|
||||
@ -7,13 +9,118 @@ namespace TBF.BenchControl.Sequences
|
||||
{
|
||||
public class ProcessData
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(ProcessData));
|
||||
public static readonly string PDataFileName = "process_data.tbf";
|
||||
|
||||
///
|
||||
/// References to components initialized on StateMachine start-up
|
||||
///
|
||||
public static IBenchInfo BenchInfo;
|
||||
public static IErrorFlags ErrorFlagsComp;
|
||||
public static Output.DB.SensusOracle.Database OracleDB;
|
||||
|
||||
///
|
||||
/// State variables to be saved after each completed test
|
||||
///
|
||||
public static Results.BatchResults BatchRslts;
|
||||
///
|
||||
/// iPERL related state variables to be saved after each completed test
|
||||
public static IList<TestMethods.iPerlCommunication.iPerlHead.IperlHead> IperlHeads;
|
||||
public static bool IsQ2PreCorrectionCalculated;
|
||||
public static int CalculatedQ2PreCorrectionLR;
|
||||
public static int CalculatedQ2PreCorrectionRL;
|
||||
public static IList<Output.SensusTestInfo> RawTestInfos; /// Incomplete raw test infos from Oracle DB
|
||||
public static Output.SensusTestInfo[] CompleteTestInfos; /// Complete TBF test infos obtained as a best mathch
|
||||
|
||||
public static FloatBox AmbTemp = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; /// [Celsius]
|
||||
|
||||
static ProcessData()
|
||||
{
|
||||
///
|
||||
/// RegisterReaders should never be null, RegisterReader.Length should be Config.Data.WMsCount
|
||||
/// RegisterReader[i] where i = 0..Config.Data.WMsCount-1 may be null and should always be tested
|
||||
///
|
||||
RegisterReaders = new IRegisterReader[Config.Data.WMsCount];
|
||||
IsQ2PreCorrectionCalculated = false;
|
||||
CalculatedQ2PreCorrectionLR = 0;
|
||||
CalculatedQ2PreCorrectionRL = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save process data to file (invoked after each completed test).
|
||||
/// </summary>
|
||||
public static void SaveProcessData()
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(PDataFileName)))
|
||||
{
|
||||
BatchRslts.WriteBinary(writer);
|
||||
writer.Write(IperlHeads.Count);
|
||||
for (int i = 0; i < IperlHeads.Count; i++)
|
||||
{
|
||||
IperlHeads[i].WriteBinary(writer);
|
||||
}
|
||||
writer.Write(IsQ2PreCorrectionCalculated);
|
||||
writer.Write(CalculatedQ2PreCorrectionLR);
|
||||
writer.Write(CalculatedQ2PreCorrectionRL);
|
||||
|
||||
/// TODO: Save RawTestInfos and CompleteTestInfos
|
||||
|
||||
log.WarnFormat("Process data succesfully saved to file {0}", PDataFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load process data from file (invoked when cycle is continued after it has been interrupted).
|
||||
/// </summary>
|
||||
/// <returns>true when successful</returns>
|
||||
public static bool LoadProcessData(string expectedProgramVersion = null)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(PDataFileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
BatchRslts = new Results.BatchResults();
|
||||
BatchRslts.ReadBinary(reader, expectedProgramVersion);
|
||||
int iPerlHeadsCount = reader.ReadInt32();
|
||||
for (int i = 0; i < iPerlHeadsCount; i++)
|
||||
{
|
||||
if (IperlHeads != null && i < IperlHeads.Count)
|
||||
{
|
||||
IperlHeads[i].ReadBinary(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
new TestMethods.iPerlCommunication.iPerlHead.IperlHead().ReadBinary(reader);
|
||||
}
|
||||
}
|
||||
IsQ2PreCorrectionCalculated = reader.ReadBoolean();
|
||||
CalculatedQ2PreCorrectionLR = reader.ReadInt32();
|
||||
CalculatedQ2PreCorrectionRL = reader.ReadInt32();
|
||||
|
||||
/// TODO: Load RawTestInfos and CompleteTestInfos
|
||||
|
||||
log.WarnFormat("Process data succesfully loaded from file {0}", PDataFileName);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.ErrorFormat("Error loading Process data from file {0}: {1}", PDataFileName, exc.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearProcessData()
|
||||
{
|
||||
File.Delete(PDataFileName);
|
||||
}
|
||||
|
||||
///
|
||||
/// Process values.
|
||||
/// These variables contain immediate values or values overwritten in each test.
|
||||
///
|
||||
public static IRegisterReader[] RegisterReaders;
|
||||
///
|
||||
public static FloatBox AmbTemp = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; /// [Celsius]
|
||||
public static FloatBox AmbPress = new FloatBox() { Name = "Ambient Pressure", Format = "F0", Factor = 1000 }; /// [bar], printed by ToString() in [mbar]
|
||||
public static FloatBox AmbHumi = new FloatBox() { Name = "Ambient Humidity", Format = "F1" }; /// [%]
|
||||
public static DoubleBox TempUp = new DoubleBox() { Name = "Temperature Up", Format = "F2" }; /// [°C]
|
||||
@ -35,7 +142,6 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
public static DateTime TestStartTime;
|
||||
public static DateTime TestEndTime;
|
||||
|
||||
public static double StartTime;
|
||||
public static double EndTime;
|
||||
|
||||
@ -45,27 +151,6 @@ namespace TBF.BenchControl.Sequences
|
||||
public static DoubleBox TempRefLo1 = new DoubleBox() { Name = "T lo ac 1", Format = "F3" }; /// [°C]
|
||||
public static DoubleBox TempRefLo2 = new DoubleBox() { Name = "T lo ac 2", Format = "F3" }; /// [°C]
|
||||
|
||||
public static Results.BatchResults BatchRslts;
|
||||
|
||||
public static IRegisterReader[] RegisterReaders;
|
||||
|
||||
public static bool IsQ2PreCorrectionCalculated;
|
||||
public static int CalculatedQ2PreCorrectionLR;
|
||||
public static int CalculatedQ2PreCorrectionRL;
|
||||
///
|
||||
static ProcessData()
|
||||
{
|
||||
///
|
||||
/// RegisterReaders should never be null, RegisterReader.Length should be Config.Data.WMsCount
|
||||
/// RegisterReader[i] where i = 0..Config.Data.WMsCount-1 may be null and should always be tested
|
||||
///
|
||||
RegisterReaders = new IRegisterReader[Config.Data.WMsCount];
|
||||
|
||||
IsQ2PreCorrectionCalculated = false;
|
||||
CalculatedQ2PreCorrectionLR = 0;
|
||||
CalculatedQ2PreCorrectionRL = 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// To clear process values at the beginning of each test
|
||||
@ -87,7 +172,8 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
|
||||
///
|
||||
/// Statistics of 'continuous' variables (temperature, pressure, flow, etc.)
|
||||
/// Statistics of 'continuous' variables (temperature, pressure, flow, etc.).
|
||||
/// All statistics are re-initialized in each test.
|
||||
///
|
||||
public static Statistics AmbTempStat = new Statistics(new Plotter("Ambient temperature"));
|
||||
public static Statistics AmbPressStat = new Statistics(new Plotter("Ambient pressure"));
|
||||
|
||||
@ -219,6 +219,7 @@ namespace TBF.BenchControl
|
||||
/// Find all balances (to initialize tank capacities in the control board)
|
||||
/// Find the control board
|
||||
IList<IScaleOrTank> tanks = new List<IScaleOrTank>();
|
||||
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
|
||||
SequenceBase.FlowMeters = new List<IFlowMeter>();
|
||||
SequenceBase.RegulValves = new List<IRegulValve>();
|
||||
SequenceBase.PumpsWithFM = new List<IPumpFM>();
|
||||
@ -234,6 +235,10 @@ namespace TBF.BenchControl
|
||||
{
|
||||
ProcessData.OracleDB = cmpnt as Output.DB.SensusOracle.Database;
|
||||
}
|
||||
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
|
||||
{
|
||||
ProcessData.IperlHeads.Add(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead);
|
||||
}
|
||||
if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter);
|
||||
if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
@ -193,5 +194,49 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
MeterSealed,
|
||||
CheckSum.ToString("X2"));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterType);
|
||||
writer.Write(Calibration);
|
||||
writer.Write((byte)VolumeUnits);
|
||||
writer.Write((byte)FlowArrow);
|
||||
writer.Write(FWVersion);
|
||||
writer.Write(TargetField[0]);
|
||||
writer.Write(TargetField[1]);
|
||||
writer.Write(TargetField[2]);
|
||||
writer.Write(RecipMeanCurrent);
|
||||
writer.Write(ThresholdVolume);
|
||||
writer.Write(ThresholdTime);
|
||||
writer.Write(FlowActivationThr);
|
||||
writer.Write(VolumeArrowThr);
|
||||
writer.Write(CalibrationTime);
|
||||
writer.Write(SerialNumber);
|
||||
writer.Write((byte)MeterSealed);
|
||||
writer.Write(CheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterType = (MeterType)reader.ReadByte();
|
||||
Calibration = reader.ReadUInt16();
|
||||
VolumeUnits = (VolumeUnits)reader.ReadByte();
|
||||
FlowArrow = (FlowArrow)reader.ReadByte();
|
||||
FWVersion = reader.ReadUInt16();
|
||||
TargetField[0] = reader.ReadUInt16();
|
||||
TargetField[1] = reader.ReadUInt16();
|
||||
TargetField[2] = reader.ReadUInt16();
|
||||
RecipMeanCurrent = reader.ReadUInt16();
|
||||
ThresholdVolume = reader.ReadUInt16();
|
||||
ThresholdTime = reader.ReadUInt16();
|
||||
FlowActivationThr = reader.ReadUInt16();
|
||||
VolumeArrowThr = reader.ReadUInt16();
|
||||
CalibrationTime = reader.ReadUInt32();
|
||||
SerialNumber = reader.ReadUInt64();
|
||||
MeterSealed = (MeterSealed)reader.ReadByte();
|
||||
CheckSum = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
@ -207,5 +208,51 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
CalibrationLNA,
|
||||
CheckSum.ToString("X2"));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterType);
|
||||
writer.Write(Calibration);
|
||||
writer.Write((byte)VolumeUnits);
|
||||
writer.Write((byte)FlowArrow);
|
||||
writer.Write(FWVersion);
|
||||
writer.Write(TargetField[0]);
|
||||
writer.Write(TargetField[1]);
|
||||
writer.Write(TargetField[2]);
|
||||
writer.Write(RecipMeanCurrent);
|
||||
writer.Write(ThresholdVolume);
|
||||
writer.Write(ThresholdTime);
|
||||
writer.Write(FlowActivationThr);
|
||||
writer.Write(VolumeArrowThr);
|
||||
writer.Write(CalibrationTime);
|
||||
writer.Write(SerialNumber);
|
||||
writer.Write((byte)MeterSealed);
|
||||
writer.Write(CalibrationLNA);
|
||||
writer.Write(CheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterType = (MeterType)reader.ReadByte();
|
||||
Calibration = reader.ReadUInt16();
|
||||
VolumeUnits = (VolumeUnits)reader.ReadByte();
|
||||
FlowArrow = (FlowArrow)reader.ReadByte();
|
||||
FWVersion = reader.ReadUInt16();
|
||||
TargetField[0] = reader.ReadUInt16();
|
||||
TargetField[1] = reader.ReadUInt16();
|
||||
TargetField[2] = reader.ReadUInt16();
|
||||
RecipMeanCurrent = reader.ReadUInt16();
|
||||
ThresholdVolume = reader.ReadUInt16();
|
||||
ThresholdTime = reader.ReadUInt16();
|
||||
FlowActivationThr = reader.ReadUInt16();
|
||||
VolumeArrowThr = reader.ReadUInt16();
|
||||
CalibrationTime = reader.ReadUInt32();
|
||||
SerialNumber = reader.ReadUInt64();
|
||||
MeterSealed = (MeterSealed)reader.ReadByte();
|
||||
CalibrationLNA = reader.ReadUInt16();
|
||||
CheckSum = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
@ -221,5 +222,45 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
AlarmMask.ToString("X4"),
|
||||
ConfigCheckSum.ToString("X4"));
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterState);
|
||||
writer.Write(TargetTimeVeryLowBatt);
|
||||
writer.Write(TargetTimeLowBatt);
|
||||
writer.Write(TestModeTime);
|
||||
writer.Write(EmptyPipeThreshold);
|
||||
writer.Write(PCBNumber[0]);
|
||||
writer.Write(PCBNumber[1]);
|
||||
writer.Write(PCBNumber[2]);
|
||||
writer.Write(PCBNumber[3]);
|
||||
writer.Write(PCBNumber[4]);
|
||||
writer.Write(TestModeConfig);
|
||||
writer.Write(RadioAddress);
|
||||
writer.Write(TempCalibration);
|
||||
writer.Write(AlarmMask);
|
||||
writer.Write(ConfigCheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterState = (MeterState)reader.ReadByte();
|
||||
TargetTimeVeryLowBatt = reader.ReadUInt32();
|
||||
TargetTimeLowBatt = reader.ReadUInt32();
|
||||
TestModeTime = reader.ReadUInt32();
|
||||
EmptyPipeThreshold = reader.ReadUInt16();
|
||||
PCBNumber[0] = reader.ReadByte();
|
||||
PCBNumber[1] = reader.ReadByte();
|
||||
PCBNumber[2] = reader.ReadByte();
|
||||
PCBNumber[3] = reader.ReadByte();
|
||||
PCBNumber[4] = reader.ReadByte();
|
||||
TestModeConfig = reader.ReadByte();
|
||||
RadioAddress = reader.ReadUInt32();
|
||||
TempCalibration = reader.ReadUInt16();
|
||||
AlarmMask = reader.ReadUInt16();
|
||||
ConfigCheckSum = reader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -65,20 +65,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
set { }
|
||||
}
|
||||
|
||||
public string EndState
|
||||
{
|
||||
get { return endState; }
|
||||
set { endState = value; }
|
||||
}
|
||||
string endState;
|
||||
|
||||
public string BeginState
|
||||
{
|
||||
get { return beginState; }
|
||||
set { beginState = value; }
|
||||
}
|
||||
string beginState;
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
get { return disabled; }
|
||||
@ -170,8 +156,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
|
||||
/// <summary> Result of the last test used to calculate Q2 correction factors, etc </summary>
|
||||
public Results.Entities.MeterTestRslt LastTestResult2;
|
||||
public Results.Entities.MeterTestRslt LastTestResult;
|
||||
public Results.Entities.MeterTestRslt LastTestResult2;
|
||||
|
||||
|
||||
///
|
||||
@ -184,7 +170,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
public double EndWMState { get { return endWMState; } }
|
||||
public double WMTestTime { get { return wmTestTime; } }
|
||||
|
||||
|
||||
double beginWMState;
|
||||
double endWMState;
|
||||
double wmVolume;
|
||||
@ -426,8 +411,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
disabled = false;
|
||||
commFailed = false;
|
||||
endState = string.Empty;
|
||||
beginState = string.Empty;
|
||||
|
||||
configStruct = null;
|
||||
calibrationStruct = null;
|
||||
@ -984,5 +967,82 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
case MeterType.DN40: return 16.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(disabled);
|
||||
writer.Write(commFailed);
|
||||
writer.Write(resultCode);
|
||||
writer.Write(PositiveCounting);
|
||||
|
||||
if (configStruct != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
configStruct.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
if (calibrationStruct != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
calibrationStruct.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
if (calibrationStructV4 != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
calibrationStructV4.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
writer.Write(OrigCalibFactor);
|
||||
writer.Write(OrigCalibFactorLNA);
|
||||
writer.Write(Q2ErrWOCorrection);
|
||||
writer.Write(Q2CorrRL);
|
||||
writer.Write(Q2CorrLR);
|
||||
writer.Write(Diff2Hz8Hz);
|
||||
writer.Write(Hz2CorrectionDone);
|
||||
writer.Write(Hz2Correction);
|
||||
|
||||
if (LastTestResult != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
LastTestResult.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
if (LastTestResult2 != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
LastTestResult2.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
}
|
||||
|
||||
public void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
disabled = reader.ReadBoolean();
|
||||
commFailed = reader.ReadBoolean();
|
||||
resultCode = reader.ReadInt32();
|
||||
PositiveCounting = reader.ReadBoolean();
|
||||
|
||||
if (reader.ReadBoolean()) (configStruct = new ConfigStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (calibrationStruct = new CalibrationStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (calibrationStructV4 = new CalibrationStructV4()).ReadBinary(reader);
|
||||
|
||||
OrigCalibFactor = reader.ReadUInt16();
|
||||
OrigCalibFactorLNA = reader.ReadUInt16();
|
||||
Q2ErrWOCorrection = reader.ReadDouble();
|
||||
Q2CorrRL = reader.ReadInt32();
|
||||
Q2CorrLR = reader.ReadInt32();
|
||||
Diff2Hz8Hz = reader.ReadDouble();
|
||||
Hz2CorrectionDone = reader.ReadBoolean();
|
||||
Hz2Correction = reader.ReadInt32();
|
||||
|
||||
if (reader.ReadBoolean()) (LastTestResult = new Results.Entities.MeterTestRslt()).ReadBinary(reader, null);
|
||||
if (reader.ReadBoolean()) (LastTestResult2 = new Results.Entities.MeterTestRslt()).ReadBinary(reader, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user