(1) Publish.Internal&Never tests not saved to rslts.DB, (2) Publish.Never tests are in TestRslts, (3) bool Batch.IsRemoteProcedure field, etc. ver. 2.25.1410
This commit is contained in:
parent
7dcb5ba6ce
commit
a7965a7ffc
@ -67,12 +67,12 @@ namespace Config.Entities
|
||||
public class ProcedureInfo
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly Users.Entities.DBKind DBKind;
|
||||
public readonly bool IsRemote;
|
||||
|
||||
public ProcedureInfo(string name, Users.Entities.DBKind dbKind)
|
||||
public ProcedureInfo(string name, bool isRemote)
|
||||
{
|
||||
Name = name;
|
||||
DBKind = dbKind;
|
||||
IsRemote = isRemote;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ namespace Results
|
||||
d.Batch = new Batch()
|
||||
{
|
||||
BatchNr = batchNr,
|
||||
ProgramVersion = programVer,
|
||||
TestBenchId = benchId,
|
||||
TestBenchName = benchName,
|
||||
Address1 = a1,
|
||||
@ -56,7 +57,6 @@ namespace Results
|
||||
Address3 = a3,
|
||||
Address4 = a4,
|
||||
Address5 = a5,
|
||||
ProgramVersion = programVer,
|
||||
UserName = user,
|
||||
UserNumber = userNr,
|
||||
ProcedureName = procedure.Name,
|
||||
@ -99,44 +99,41 @@ namespace Results
|
||||
|
||||
foreach (var t in procedure.Tests)
|
||||
{
|
||||
if (t.Publish != (byte)Config.Entities.Publish.Never)
|
||||
TestData td = TestData.UpdateList(d.TestDataList, new TestData(t));
|
||||
|
||||
for (int rnr = 1; rnr <= t.Repeats; rnr++)
|
||||
{
|
||||
TestData td = TestData.UpdateList(d.TestDataList, new TestData(t));
|
||||
/// Create an empty test result and add it to the list
|
||||
TestRslt tr = new TestRslt(d.Batch, td, t.Part, rnr);
|
||||
d.Batch.TestRslts.Add(tr);
|
||||
|
||||
for (int rnr = 1; rnr <= t.Repeats; rnr++)
|
||||
for (int i = 0; i < d.WMPositionsCount; i++)
|
||||
{
|
||||
/// Create an empty test result and add it to the list
|
||||
TestRslt tr = new TestRslt(d.Batch, td, t.Part, rnr);
|
||||
d.Batch.TestRslts.Add(tr);
|
||||
|
||||
for (int i = 0; i < d.WMPositionsCount; i++)
|
||||
{
|
||||
if (!d.Batch.WaterMeters[i].Disabled && t.IsPartCompatible(waterMeterParts[i]))
|
||||
if (!d.Batch.WaterMeters[i].Disabled && t.IsPartCompatible(waterMeterParts[i]))
|
||||
{
|
||||
///
|
||||
/// Create empty watermeter test results and add them to the list and to dictionaries
|
||||
///
|
||||
IList<MeterTestRslt> wmtrs = d.Batch.WaterMeters[i].MeterTestRslts;
|
||||
if (d.Batch.Compound)
|
||||
{
|
||||
///
|
||||
/// Create empty watermeter test results and add them to the list and to dictionaries
|
||||
///
|
||||
IList<MeterTestRslt> wmtrs = d.Batch.WaterMeters[i].MeterTestRslts;
|
||||
if (d.Batch.Compound)
|
||||
{
|
||||
/// Compound water meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundMain));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundAux));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Compound));
|
||||
}
|
||||
else if (d.Batch.HeatMeter)
|
||||
{
|
||||
/// Heat meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.HeatMeterVolume));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.HeatMeterEnergy));
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Water meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Single));
|
||||
}
|
||||
/// Compound water meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundMain));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundAux));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Compound));
|
||||
}
|
||||
}
|
||||
else if (d.Batch.HeatMeter)
|
||||
{
|
||||
/// Heat meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.HeatMeterVolume));
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.HeatMeterEnergy));
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Water meter
|
||||
wmtrs.Add(new MeterTestRslt(d.Batch.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Single));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,7 +193,7 @@ namespace Results
|
||||
{
|
||||
foreach (var mtr in Batch.WaterMeters[wmNr0].MeterTestRslts)
|
||||
{
|
||||
if (!mtr.TestDone) return false;
|
||||
if (mtr.Evaluate() && !mtr.TestDone) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -210,10 +207,10 @@ namespace Results
|
||||
writer.Write(WMPositionsCount);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader, string expectedProgramVersion)
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Batch = new Batch();
|
||||
Batch.ReadBinary(reader, expectedProgramVersion);
|
||||
Batch.ReadBinary(reader);
|
||||
WMPositionsCount = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,17 +11,18 @@ namespace Results.Entities
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int BatchNr { get; set; }
|
||||
public virtual int TestBenchId { get; set; }
|
||||
public virtual string ProgramVersion { get; set; }
|
||||
public virtual int TestBenchId { get; set; }
|
||||
public virtual string TestBenchName { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string Address1 { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string Address2 { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string Address3 { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string Address4 { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string Address5 { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string ProgramVersion { get; set; }
|
||||
public virtual string UserName { get; set; }
|
||||
public virtual int UserNumber { get; set; }
|
||||
public virtual string ProcedureName { get; set; }
|
||||
public virtual bool IsRemoteProcedure { get; set; } /// Stara Tura, not mapped to DB
|
||||
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual int ProcedureRevision { get; set; }
|
||||
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
|
||||
@ -52,15 +53,16 @@ namespace Results.Entities
|
||||
WaterMeters = new List<WaterMeter>();
|
||||
TestRslts = new List<TestRslt>();
|
||||
|
||||
ProgramVersion = string.Empty;
|
||||
TestBenchName = string.Empty;
|
||||
Address1 = string.Empty;
|
||||
Address2 = string.Empty;
|
||||
Address3 = string.Empty;
|
||||
Address4 = string.Empty;
|
||||
Address5 = string.Empty;
|
||||
ProgramVersion = string.Empty;
|
||||
UserName = string.Empty;
|
||||
ProcedureName = string.Empty;
|
||||
IsRemoteProcedure = false;
|
||||
ProcedureDescription = string.Empty;
|
||||
WatermetersStr = string.Empty;
|
||||
ProtocolTitle = string.Empty;
|
||||
@ -224,18 +226,20 @@ namespace Results.Entities
|
||||
|
||||
public virtual string ToString(int i)
|
||||
{
|
||||
return string.Format("Batch: BatchNr={0} TestBenchId={1} ProgramVersion={2} UserName={3} UserNumber={4} ProcedureName={5} ProcedureRevision={6} ProtocolTitle={7} Remark={8} DensityCorr={9} Custom2={10} Custom3={11} StartTime={12} EndTime={13} Dirty={14} RsltsSent={15} RsltsPrinted={16}",
|
||||
BatchNr, TestBenchId, ProgramVersion, UserName, UserNumber,
|
||||
ProcedureName, ProcedureRevision, ProtocolTitle, Remark, DensityCorr,
|
||||
Custom2, Custom3, StartTime, EndTime, Dirty,
|
||||
RsltsSent, RsltsPrinted);
|
||||
return string.Format("Batch: BatchNr={0} ProgramVersion={1} TestBenchId={2} UserName={3} UserNumber={4} ProcedureName={5}{6} ProcRev={7} ProtocolTitle={8} Remark={9} DensityCorr={10} Custom2={11} Custom3={12} StartTime={13} EndTime={14} Dirty={15} RsltsSent={16} RsltsPrinted={17}",
|
||||
BatchNr, ProgramVersion, TestBenchId, UserName, UserNumber,
|
||||
ProcedureName, (IsRemoteProcedure ? "(R)" : ""), ProcedureRevision,
|
||||
ProtocolTitle, Remark, DensityCorr, Custom2, Custom3,
|
||||
StartTime, EndTime, Dirty, RsltsSent, RsltsPrinted);
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write((ProgramVersion != null) ? ProgramVersion : string.Empty);
|
||||
writer.Write(Id);
|
||||
writer.Write(BatchNr);
|
||||
writer.Write((ProgramVersion != null) ? ProgramVersion : string.Empty);
|
||||
writer.Write((ProcedureName != null) ? ProcedureName : string.Empty);
|
||||
writer.Write(IsRemoteProcedure);
|
||||
writer.Write(Id);
|
||||
writer.Write(TestBenchId);
|
||||
writer.Write((TestBenchName != null) ? TestBenchName : string.Empty);
|
||||
writer.Write((Address1 != null) ? Address1 : string.Empty);
|
||||
@ -245,7 +249,6 @@ namespace Results.Entities
|
||||
writer.Write((Address5 != null) ? Address5 : string.Empty);
|
||||
writer.Write((UserName != null) ? UserName : string.Empty);
|
||||
writer.Write(UserNumber);
|
||||
writer.Write((ProcedureName != null) ? ProcedureName : string.Empty);
|
||||
writer.Write((ProcedureDescription != null) ? ProcedureDescription : string.Empty);
|
||||
writer.Write(ProcedureRevision);
|
||||
writer.Write((WatermetersStr != null) ? WatermetersStr : string.Empty);
|
||||
@ -282,15 +285,28 @@ namespace Results.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader, string expectedProgramVersion)
|
||||
public static void ReadStart(BinaryReader reader, out int batchNr, out string programVersion, out string procedureName, out bool isRemoteProcedure)
|
||||
{
|
||||
ProgramVersion = reader.ReadString();
|
||||
if (expectedProgramVersion != null && ProgramVersion != expectedProgramVersion)
|
||||
{
|
||||
throw new Exception(string.Format("Process data were stored by TBF v.{0}", ProgramVersion));
|
||||
}
|
||||
batchNr = reader.ReadInt32();
|
||||
programVersion = reader.ReadString();
|
||||
procedureName = reader.ReadString();
|
||||
isRemoteProcedure = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
/// ReadStart() is used to avoid code repetition
|
||||
int batchNr;
|
||||
string programVersion;
|
||||
string procedureName;
|
||||
bool isRemoteProcedure;
|
||||
ReadStart(reader, out batchNr, out programVersion, out procedureName, out isRemoteProcedure);
|
||||
|
||||
BatchNr = batchNr;
|
||||
ProgramVersion = programVersion;
|
||||
ProcedureName = procedureName;
|
||||
IsRemoteProcedure = isRemoteProcedure;
|
||||
Id = reader.ReadInt32();
|
||||
BatchNr = reader.ReadInt32();
|
||||
TestBenchId = reader.ReadInt32();
|
||||
TestBenchName = reader.ReadString();
|
||||
Address1 = reader.ReadString();
|
||||
@ -300,7 +316,6 @@ namespace Results.Entities
|
||||
Address5 = reader.ReadString();
|
||||
UserName = reader.ReadString();
|
||||
UserNumber = reader.ReadInt32();
|
||||
ProcedureName = reader.ReadString();
|
||||
ProcedureDescription = reader.ReadString();
|
||||
ProcedureRevision = reader.ReadInt32();
|
||||
WatermetersStr = reader.ReadString();
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
|
||||
namespace TBF.BenchControl.Operations
|
||||
{
|
||||
public class LoadProcedureOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(LoadProcedureOp));
|
||||
|
||||
Thread loaderThread;
|
||||
bool error;
|
||||
bool completed;
|
||||
|
||||
/// <summary>
|
||||
/// Events: Wait, ProcedureLoaded or Error
|
||||
/// </summary>
|
||||
public LoadProcedureOp()
|
||||
{
|
||||
error = false;
|
||||
completed = false;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
if (loaderThread != null)
|
||||
{
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
loaderThread = new Thread(Loader);
|
||||
loaderThread.Start();
|
||||
}
|
||||
|
||||
void Loader()
|
||||
{
|
||||
try
|
||||
{
|
||||
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
StateMachine.LoadPathsAndTransitions(session);
|
||||
StateMachine.LoadProcedure(session, TBF.UiBridge.Bridge.SelectedProcedure.Name);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
completed = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.Error, Event.ProcedureLoaded or Event.Wait
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (error) return Event.Error;
|
||||
if (!completed) return Event.Wait;
|
||||
|
||||
///
|
||||
/// Check for incomplete configuration mistakes
|
||||
///
|
||||
if (StateMachine.Tests.Count == 0) return Event.ConfigurationError;
|
||||
foreach (var test in StateMachine.Tests)
|
||||
{
|
||||
if (test.FeedingPath == null || test.BenchPath == null ||
|
||||
test.OutputPath == null || test.MetersPath == null)
|
||||
{
|
||||
return Event.ConfigurationError;
|
||||
}
|
||||
}
|
||||
|
||||
return Event.ProcedureLoaded;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,13 +440,43 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
while (selection == Selection.Shutdown);
|
||||
|
||||
switch (selection)
|
||||
{
|
||||
case Selection.Q1: selectedTestName = "Q1"; break;
|
||||
case Selection.Q2: selectedTestName = "Q2"; break;
|
||||
case Selection.Q3: selectedTestName = "Q3"; break;
|
||||
default: selectedTestName = Bridge.SelectedTestName; break;
|
||||
}
|
||||
selectedTestName = (selection == Selection.Q1) ? "Q1"
|
||||
: ((selection == Selection.Q2) ? "Q2"
|
||||
: ((selection == Selection.Q3) ? "Q3" : Bridge.SelectedTestName));
|
||||
|
||||
|
||||
///
|
||||
/// Collect information about the interrupted procedure (if applicable)
|
||||
///
|
||||
bool processDataHeaderOK = false;
|
||||
string interruptedProcedureName = string.Empty;
|
||||
bool isRemoteIntProc = false;
|
||||
///
|
||||
if (selection == Selection.RestoreInterruptedSession)
|
||||
{
|
||||
int batchNr;
|
||||
string version;
|
||||
processDataHeaderOK = ProcessData.LoadProcessDataHeader(out batchNr, out version, out interruptedProcedureName, out isRemoteIntProc);
|
||||
|
||||
if (!processDataHeaderOK)
|
||||
{
|
||||
UiBridge.Bridge.OnError(this, "Invalid process data");
|
||||
continue;
|
||||
}
|
||||
else if (version != Program.Version)
|
||||
{
|
||||
/// Program version does not match the one stored in process data
|
||||
UiBridge.Bridge.OnError(this, Strings.Program_version_does_not_match);
|
||||
continue;
|
||||
}
|
||||
else if (batchNr != Program.LocalSettings.BatchNr)
|
||||
{
|
||||
/// Program version does not match the one stored in process data
|
||||
UiBridge.Bridge.OnError(this, Strings.Invalid_batch_number);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
@ -456,14 +486,31 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
|
||||
///
|
||||
/// Try to load all parameters for the selected procedure from databases as specifie in BenchInfo
|
||||
/// Try to load all parameters of selected or restored procedure from the respective database
|
||||
///
|
||||
if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
|
||||
if (processDataHeaderOK)
|
||||
{
|
||||
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Bridge.SelectedProcedure.DBKind))
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(isRemoteIntProc ?
|
||||
Users.Entities.DBKind.RemoteConfig :
|
||||
Users.Entities.DBKind.Config))
|
||||
{
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name);
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession, interruptedProcedureName, isRemoteIntProc);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
/// This is to load Procedure.Tests and tets.MoreParams for each test
|
||||
int a = 0;
|
||||
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
||||
}
|
||||
}
|
||||
else if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
|
||||
{
|
||||
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Bridge.SelectedProcedure.IsRemote ?
|
||||
Users.Entities.DBKind.RemoteConfig :
|
||||
Users.Entities.DBKind.Config))
|
||||
{
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name, Bridge.SelectedProcedure.IsRemote);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
/// This is to load Procedure.Tests and tets.MoreParams for each test
|
||||
@ -496,36 +543,33 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
||||
|
||||
///
|
||||
/// Procedure selected at this point, a new batch was started
|
||||
///
|
||||
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
|
||||
|
||||
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button
|
||||
|
||||
int newBatchNr = Program.LocalSettings.BatchNr;
|
||||
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
|
||||
|
||||
if (selection == Selection.RestoreInterruptedSession)
|
||||
{
|
||||
if (!LoadProcessData(Program.Version))
|
||||
if (!LoadProcessData())
|
||||
{
|
||||
/// Program version does not match the one stored in process data
|
||||
UiBridge.Bridge.OnError(this, Strings.Program_version_does_not_match);
|
||||
/// Restorig interrupted session failed
|
||||
UiBridge.Bridge.OnError(this, "Restorig interrupted session failed");
|
||||
goto stop;
|
||||
}
|
||||
else if (BatchRslts.Batch.BatchNr != newBatchNr)
|
||||
{
|
||||
/// Program version does not match the one stored in process data
|
||||
UiBridge.Bridge.OnError(this, Strings.Invalid_batch_number);
|
||||
goto stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Everythign is OK
|
||||
}
|
||||
}
|
||||
else if (selection == Selection.RestoreBatch)
|
||||
else
|
||||
{
|
||||
/// Clear session data in case this is not an interrupted/restored session
|
||||
ClearSessionData();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Procedure selected at this point, a new batch was started
|
||||
///
|
||||
int newBatchNr = Program.LocalSettings.BatchNr;
|
||||
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
|
||||
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button
|
||||
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
|
||||
|
||||
|
||||
if (selection == Selection.RestoreBatch)
|
||||
{
|
||||
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
|
||||
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
|
||||
@ -573,12 +617,14 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (selection != Selection.RestoreInterruptedSession)
|
||||
{
|
||||
/// This is a regular session => initialize BatchRslts
|
||||
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BatchRslts.Batch.IsRemoteProcedure = StateMachine.IsRemoteProcedure;
|
||||
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
|
||||
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure)); /// Select procedure in case of interrupted session
|
||||
|
||||
@ -801,17 +847,10 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
else if (selection == Selection.RestoreInterruptedSession)
|
||||
{
|
||||
///
|
||||
/// Make progress bars of completed test green
|
||||
///
|
||||
foreach (var testRslt in BatchRslts.Batch.TestRslts)
|
||||
{
|
||||
if (testRslt.TestDone)
|
||||
{
|
||||
TestProgressEventArgs testProgress = new TestProgressEventArgs(testRslt.Name(), Progress.Completed);
|
||||
testProgress.Progress = 100;
|
||||
Bridge.OnTestProgress(this, testProgress);
|
||||
}
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(testRslt));
|
||||
}
|
||||
|
||||
/// TODO: Try to find out where the cycle stopped
|
||||
@ -1361,33 +1400,49 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
//--------------------------------
|
||||
GenericDevices.IDataEntry dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
||||
if (dataEntryCmpnt != null)
|
||||
if (dataEntryCmpnt is IHasCycleEndForm)
|
||||
{
|
||||
if (dataEntryCmpnt is IHasCycleEndForm)
|
||||
{
|
||||
/// Open the modeless form for the end of the cycle
|
||||
State.Create("MainSeq : Enter end data")
|
||||
.AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
}
|
||||
/// Open the modeless form for the end of the cycle
|
||||
State.Create("MainSeq : Enter end data")
|
||||
.AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
}
|
||||
|
||||
if (TBF.BenchControl.Sequences.ProcessData.BatchRslts != null && Program.LocalSettings != null)
|
||||
{
|
||||
Results.Utils.GetCounterStates(ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
|
||||
///
|
||||
/// Update batch results, determine whether watermeters passed all required tests
|
||||
///
|
||||
ProcessData.BatchRslts.Batch.EndTime = DateTime.Now;
|
||||
BatchRslts.Batch.EndTime = DateTime.Now; /// Set cycle end time
|
||||
Results.Utils.GetCounterStates(BatchRslts.Batch, Program.LocalSettings.Counters); /// Update counters
|
||||
/// Remove results of internal tests
|
||||
for (int i = BatchRslts.Batch.TestRslts.Count - 1; i >= 0; i--)
|
||||
{
|
||||
foreach (var wm in BatchRslts.Batch.WaterMeters)
|
||||
{
|
||||
for (int j = wm.MeterTestRslts.Count - 1; j >= 0; j--)
|
||||
{
|
||||
MeterTestRslt mtr = wm.MeterTestRslts[j];
|
||||
if ((mtr.Publish() == Publish.Never || mtr.Publish() == Publish.Internal) && !mtr.Evaluate())
|
||||
{
|
||||
wm.MeterTestRslts.RemoveAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestRslt tr = BatchRslts.Batch.TestRslts[i];
|
||||
if ((tr.Publish() == Publish.Never || tr.Publish() == Publish.Internal) && !tr.Evaluate())
|
||||
{
|
||||
BatchRslts.Batch.TestRslts.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
/// (1) Set boolean WaterMeter.Passed variable, (2) Remove disabled water meters
|
||||
for (int wmNr0 = ProcessData.BatchRslts.Batch.WaterMeters.Count - 1; wmNr0 >= 0; wmNr0--)
|
||||
{
|
||||
WaterMeter wm = ProcessData.BatchRslts.Batch.WaterMeters[wmNr0];
|
||||
|
||||
@ -58,28 +58,61 @@ namespace TBF.BenchControl.Sequences
|
||||
{
|
||||
IperlHeads[i].WriteBinary(writer);
|
||||
}
|
||||
|
||||
writer.Write(IsQ2PreCorrectionCalculated);
|
||||
writer.Write(CalculatedQ2PreCorrectionLR);
|
||||
writer.Write(CalculatedQ2PreCorrectionRL);
|
||||
#if ORACLE_DB
|
||||
/// Write RawTestInfos
|
||||
writer.Write((RawTestInfos != null) ? RawTestInfos.Count : 0);
|
||||
if (RawTestInfos != null)
|
||||
{
|
||||
for (int i = 0; i < RawTestInfos.Count; i++) RawTestInfos[i].WriteBinary(writer);
|
||||
}
|
||||
|
||||
/// TODO: Save RawTestInfos and CompleteTestInfos
|
||||
|
||||
/// Write CompleteTestInfos
|
||||
writer.Write((CompleteTestInfos != null) ? CompleteTestInfos.Length : 0);
|
||||
if (CompleteTestInfos != null)
|
||||
{
|
||||
for (int i = 0; i < CompleteTestInfos.Length; i++) CompleteTestInfos[i].WriteBinary(writer);
|
||||
}
|
||||
#endif
|
||||
log.WarnFormat("Process data succesfully saved to file {0}", PDataFileName);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LoadProcessDataHeader(out int batchNr, out string programVersion, out string procedureName, out bool isRemoteProcedure)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(PDataFileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
Results.Entities.Batch.ReadStart(reader, out batchNr, out programVersion, out procedureName, out isRemoteProcedure);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
batchNr = 0;
|
||||
programVersion = string.Empty;
|
||||
procedureName = string.Empty;
|
||||
isRemoteProcedure = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
public static bool LoadProcessData()
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(PDataFileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
BatchRslts = new Results.BatchResults();
|
||||
BatchRslts.ReadBinary(reader, expectedProgramVersion);
|
||||
BatchRslts.ReadBinary(reader);
|
||||
int iPerlHeadsCount = reader.ReadInt32();
|
||||
for (int i = 0; i < iPerlHeadsCount; i++)
|
||||
{
|
||||
@ -92,12 +125,31 @@ namespace TBF.BenchControl.Sequences
|
||||
new TestMethods.iPerlCommunication.iPerlHead.IperlHead().ReadBinary(reader);
|
||||
}
|
||||
}
|
||||
|
||||
IsQ2PreCorrectionCalculated = reader.ReadBoolean();
|
||||
CalculatedQ2PreCorrectionLR = reader.ReadInt32();
|
||||
CalculatedQ2PreCorrectionRL = reader.ReadInt32();
|
||||
#if ORACLE_DB
|
||||
/// Read RawTestInfos
|
||||
int rawTestInfosCount = reader.ReadInt32();
|
||||
IList<Results.Output.SensusTestInfo> RawTestInfos = new List<Results.Output.SensusTestInfo>();
|
||||
for (int i = 0; i < rawTestInfosCount; i++)
|
||||
{
|
||||
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
|
||||
ti.ReadBinary(reader);
|
||||
RawTestInfos.Add(ti);
|
||||
}
|
||||
|
||||
/// TODO: Load RawTestInfos and CompleteTestInfos
|
||||
|
||||
/// Read CompleteTestInfos
|
||||
int completeTestInfosLen = reader.ReadInt32();
|
||||
Results.Output.SensusTestInfo[] CompleteTestInfos = new Results.Output.SensusTestInfo[completeTestInfosLen];
|
||||
for (int i = 0; i < completeTestInfosLen; i++)
|
||||
{
|
||||
Results.Output.SensusTestInfo ti = new Results.Output.SensusTestInfo();
|
||||
ti.ReadBinary(reader);
|
||||
CompleteTestInfos[i] = ti;
|
||||
}
|
||||
#endif
|
||||
log.WarnFormat("Process data succesfully loaded from file {0}", PDataFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -114,6 +114,7 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
public static Procedure Procedure; /// Procedure
|
||||
public static IList<Test> Tests; /// Tests
|
||||
public static bool IsRemoteProcedure;
|
||||
|
||||
|
||||
/// Hardware devices connected to the PC controlling the bench.
|
||||
@ -547,7 +548,7 @@ namespace TBF.BenchControl
|
||||
/// Loads selected procedure from the DB.
|
||||
/// Updates StateMachine.Procedure and StateMachine.Tests
|
||||
/// </summary>
|
||||
public static bool LoadProcedure(ISession session, string procedureName)
|
||||
public static bool LoadProcedure(ISession session, string procedureName, bool isRemote)
|
||||
{
|
||||
Procedure = null;
|
||||
|
||||
@ -560,6 +561,7 @@ namespace TBF.BenchControl
|
||||
|
||||
Procedure = selectedProcs[0];
|
||||
Tests = selectedProcs[0].Tests;
|
||||
IsRemoteProcedure = isRemote;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ namespace TBF
|
||||
/// </summary>
|
||||
[XmlElementAttribute("LastProcedure")]
|
||||
public string LastProcedureName;
|
||||
public Users.Entities.DBKind LastProcedureDB;
|
||||
public bool LastProcedureIsRemote;
|
||||
public int LastProcedureNr;
|
||||
public int BatchNr;
|
||||
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.25.1409.0")]
|
||||
[assembly: AssemblyFileVersion("2.25.1409.0")]
|
||||
[assembly: AssemblyVersion("2.25.1410.0")]
|
||||
[assembly: AssemblyFileVersion("2.25.1410.0")]
|
||||
|
||||
@ -1811,7 +1811,6 @@
|
||||
<Compile Include="BenchControl\Operations\AskYesNoForm.Designer.cs">
|
||||
<DependentUpon>AskYesNoForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Operations\LoadProcedureOp.cs" />
|
||||
<Compile Include="BenchControl\Operations\MessageBoxForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
@ -291,7 +291,7 @@ namespace TBF.UI
|
||||
}
|
||||
|
||||
procedureComboBox.Text = string.Format("{0}{1}{2}", Program.LocalSettings.LastProcedureNr, ProcSeparator, Program.LocalSettings.LastProcedureName);
|
||||
SelectedProcedure = new ProcedureInfo(Program.LocalSettings.LastProcedureName, Program.LocalSettings.LastProcedureDB);
|
||||
SelectedProcedure = new ProcedureInfo(Program.LocalSettings.LastProcedureName, Program.LocalSettings.LastProcedureIsRemote);
|
||||
|
||||
rightHorizSplitContainer.SplitterDistance = Program.LocalSettings.RightPaneHorizSplitterDistance;
|
||||
topVerticalSplitContainer.SplitterDistance = Program.LocalSettings.TopPaneVerticalSplitterDistance;
|
||||
@ -591,7 +591,7 @@ namespace TBF.UI
|
||||
if ((procedureNameToSelect == proc.Name) && !procedureSet)
|
||||
{
|
||||
procedureComboBox.Text = itemText;
|
||||
SelectedProcedure = new ProcedureInfo(procedureNameToSelect, dBase[i]);
|
||||
SelectedProcedure = new ProcedureInfo(procedureNameToSelect, (dBase[i] == Users.Entities.DBKind.RemoteConfig));
|
||||
procedureSet = true;
|
||||
}
|
||||
}
|
||||
@ -602,8 +602,8 @@ namespace TBF.UI
|
||||
if (allProcedures.Count > 0)
|
||||
{
|
||||
procedureComboBox.Text = string.Format("{0}{1}{2}", allProcedures[0].ItemNr + 1, ProcSeparator, allProcedures[0].Name);
|
||||
Users.Entities.DBKind dbKind = ((remoteDbUse == RemoteDBUse.BothDBsRemoteFirst) || (remoteDbUse == RemoteDBUse.RemoteDBOnly)) ? Users.Entities.DBKind.RemoteConfig : Users.Entities.DBKind.Config;
|
||||
SelectedProcedure = new ProcedureInfo(allProcedures[0].Name, dbKind);
|
||||
bool isRemoteProcedure = (remoteDbUse == RemoteDBUse.BothDBsRemoteFirst) || (remoteDbUse == RemoteDBUse.RemoteDBOnly);
|
||||
SelectedProcedure = new ProcedureInfo(allProcedures[0].Name, isRemoteProcedure);
|
||||
procedureSet = true;
|
||||
}
|
||||
else
|
||||
@ -626,28 +626,29 @@ namespace TBF.UI
|
||||
private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
int startFrom;
|
||||
Users.Entities.DBKind dbKind;
|
||||
bool isRemoteProcedure;
|
||||
|
||||
if (!string.IsNullOrEmpty(procedureComboBox.Text) && (procedureComboBox.Text[0] == 'L' || procedureComboBox.Text[0] == 'R'))
|
||||
{
|
||||
startFrom = 1;
|
||||
dbKind = (procedureComboBox.Text[0] == 'L') ? Users.Entities.DBKind.Config : Users.Entities.DBKind.RemoteConfig;
|
||||
isRemoteProcedure = (procedureComboBox.Text[0] == 'R');
|
||||
}
|
||||
else
|
||||
{
|
||||
startFrom = 0;
|
||||
dbKind = Users.Entities.DBKind.Config;
|
||||
isRemoteProcedure = false;
|
||||
}
|
||||
|
||||
int separPos = procedureComboBox.Text.IndexOf(ProcSeparator);
|
||||
|
||||
int procNr = int.Parse(procedureComboBox.Text.Substring(startFrom, separPos));
|
||||
string procName = procedureComboBox.Text.Substring(separPos + ProcSeparator.Length);
|
||||
UpdateProcedure(procNr, procName, dbKind);
|
||||
UpdateProcedure(procNr, procName, isRemoteProcedure);
|
||||
}
|
||||
|
||||
public void UpdateProcedure(int procedureNr, string procedureName, Users.Entities.DBKind dbKind)
|
||||
public void UpdateProcedure(int procedureNr, string procedureName, bool isRemoteProcedure)
|
||||
{
|
||||
SelectedProcedure = new ProcedureInfo(procedureName, dbKind);
|
||||
SelectedProcedure = new ProcedureInfo(procedureName, isRemoteProcedure);
|
||||
BenchControlPanel.ReloadTests();
|
||||
if (CurrentProcedure != null && CurrentProcedure.Description != null)
|
||||
{
|
||||
@ -660,7 +661,7 @@ namespace TBF.UI
|
||||
if (!string.IsNullOrEmpty(procedureName))
|
||||
{
|
||||
Program.LocalSettings.LastProcedureName = procedureName;
|
||||
Program.LocalSettings.LastProcedureDB = dbKind;
|
||||
Program.LocalSettings.LastProcedureIsRemote = isRemoteProcedure;
|
||||
Program.LocalSettings.LastProcedureNr = procedureNr;
|
||||
Program.LocalSettings.Save();
|
||||
}
|
||||
|
||||
@ -194,7 +194,8 @@ namespace TBF.UI.Procedures.TestWizard
|
||||
|
||||
foreach (var t in loadedProcedure.Tests)
|
||||
{
|
||||
if (t.Publish != (byte)Config.Entities.Publish.Never)
|
||||
if (t.Publish != (byte)Config.Entities.Publish.Never &&
|
||||
t.Publish != (byte)Config.Entities.Publish.Internal)
|
||||
{
|
||||
wmTestNames.Add(Results.Utils.GetTestName(t.Name, 1, 1));
|
||||
}
|
||||
|
||||
@ -168,7 +168,8 @@ namespace TBF.UI.Shared
|
||||
|
||||
string oriTestName = testComboBox.Text;
|
||||
|
||||
IList<Procedure> procedures = Config.FluentCommon.CreateSession(Program.MainWnd.SelectedProcedure.DBKind)
|
||||
IList<Procedure> procedures = Config.FluentCommon.CreateSession(Program.MainWnd.SelectedProcedure.IsRemote ?
|
||||
Users.Entities.DBKind.RemoteConfig : Users.Entities.DBKind.Config)
|
||||
.QueryOver<Procedure>()
|
||||
.Where(x => (x.ProcedureState == ProcedureState.Active))
|
||||
.And(x => (x.Name == Program.MainWnd.SelectedProcedure.Name))
|
||||
|
||||
@ -90,12 +90,23 @@ namespace TBF.UiBridge
|
||||
RepetitionNr = repetitionNr;
|
||||
}
|
||||
|
||||
|
||||
public TestProgressEventArgs(Config.Entities.Test test, Config.Entities.Progress progress)
|
||||
: this(test, 1, progress)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From TestRslt.
|
||||
/// Used after restore of an interupted session
|
||||
/// </summary>
|
||||
public TestProgressEventArgs(Results.Entities.TestRslt testRslt)
|
||||
{
|
||||
TestName = testRslt.Name();
|
||||
Part = testRslt.Part;
|
||||
Repeats = testRslt.Repeats();
|
||||
RepetitionNr = testRslt.RepetitionNr;
|
||||
Progress = testRslt.TestDone ? 100 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used by iPearl communication dialog
|
||||
|
||||
Loading…
Reference in New Issue
Block a user