95 lines
4.7 KiB
C#
95 lines
4.7 KiB
C#
///
|
|
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.UiBridge;
|
|
|
|
namespace TBF.Rig.TestMethods.Dummy
|
|
{
|
|
public class DummySeq : Sequences.SequenceBase
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(DummySeq));
|
|
|
|
/// <summary>
|
|
/// Adjustment method sequence
|
|
/// </summary>
|
|
/// <param name="test">Test entity</param>
|
|
/// <returns>
|
|
/// Event.Done . . . . . . . OK
|
|
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
|
|
/// Event.OpArgumentError . Target flow is out of range
|
|
/// Event.Error . . . . . . Unspecified error
|
|
/// </returns>
|
|
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition, DebugMode mode)
|
|
{
|
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
|
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
|
|
|
IList<IOperation> readTempPressOps = new List<IOperation>();
|
|
if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp));
|
|
if (benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown));
|
|
if (outPath.TempMtrDiv != null) readTempPressOps.Add(outPath.TempMtrDiv.ReadTempOp(ref TempDiv));
|
|
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
|
|
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
|
|
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
|
|
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref ElectricUp));
|
|
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref ElectricDown));
|
|
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref ElectricDelta));
|
|
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
|
|
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
|
|
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
|
|
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
|
|
|
|
/// Start the test, initialize test results
|
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath));
|
|
|
|
StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0);
|
|
|
|
/// Read pressure and temperature once
|
|
State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name))
|
|
.AddOperation(checkUiOp)
|
|
.AddOperations(readTempPressOps)
|
|
.EnterState();
|
|
do {
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
if (e.Contains(Event.Error)) return new List<Event> { Event.Error };
|
|
if (TestAndLogUiCmdStop(test, e)) return new List<Event> { Event.UiCmdStop };
|
|
}
|
|
while (e.Contains(Event.Busy));
|
|
|
|
StopRecordingStatistics();
|
|
|
|
/// Populate TestResult data entity with data
|
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
bool stopCycle = false;
|
|
if (tstRslt != null)
|
|
{
|
|
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
|
UpdateTempPressDensAmb(tstRslt);
|
|
|
|
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
|
tstRslt.StartTime = DateTime.Now;
|
|
tstRslt.EndTime = DateTime.Now;
|
|
tstRslt.TestDone = true;
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
{
|
|
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
|
|
if (meterRslt != null)
|
|
{
|
|
meterRslt.TestDone = true;
|
|
meterRslt.Passed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return new List<Event> { Event.Done };
|
|
}
|
|
}
|
|
}
|