54 lines
1.8 KiB
C#
54 lines
1.8 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.Counter
|
|
{
|
|
public class CounterSeq : Sequences.SequenceBase
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(CounterSeq));
|
|
|
|
/// <summary>
|
|
/// Counter method sequence
|
|
/// </summary>
|
|
/// <param name="test">Test entity</param>
|
|
/// <returns>
|
|
/// Event.Done . . . . . . . OK
|
|
/// </returns>
|
|
public IList<Event> Execute(Test test, int counterIdx0, int repetitionNr, bool isLastRepetition, DebugMode mode)
|
|
{
|
|
if (Program.LocalSettings.Counters == null || Program.LocalSettings.Counters.Length < counterIdx0 + 1)
|
|
{
|
|
int[] oriCounters = Program.LocalSettings.Counters;
|
|
Program.LocalSettings.Counters = new int[counterIdx0 + 1];
|
|
if (oriCounters != null)
|
|
{
|
|
for (int i = 0; i < oriCounters.Length; i++) Program.LocalSettings.Counters[i] = oriCounters[i];
|
|
}
|
|
}
|
|
|
|
Program.LocalSettings.Counters[counterIdx0] = Program.LocalSettings.Counters[counterIdx0] + 1;
|
|
|
|
TBF.UiBridge.Bridge.OnSaveSettings(this, null);
|
|
|
|
/// Update results
|
|
var testName = Common.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
var testResults = BatchRslts.GetTestRslt(testName, test.Part);
|
|
global::Results.Utils.GetCounterStates(testResults, Program.LocalSettings.Counters);
|
|
if (testResults != null)
|
|
{
|
|
testResults.TestDone = true;
|
|
}
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, testResults));
|
|
|
|
return new List<Event> { Event.Done };
|
|
}
|
|
}
|
|
}
|