tbf/TBF/BenchControl/TestMethods/Counter/TestMethod.cs

61 lines
1.8 KiB
C#
Raw Normal View History

///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.BenchControl;
namespace TBF.BenchControl.TestMethods.Counter
{
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString() { return string.Format("TestMethods.Counter({0})", Cfg.ToString(1)); }
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return false; }
/// <summary>
/// Enumeration of counters via static fields and methods
/// </summary>
static int nextCounterIdx = 0;
public static new void ResetStaticProperties()
{
nextCounterIdx = 0;
}
public static int CountersCount { get { return nextCounterIdx; } }
public static TestMethod[] Counters;
///
private int counterIdx0; /// 0-based index of this counter
public TestMethod()
{
}
public TestMethod(Generic.IComponentCfg cfg)
: base(cfg)
{
counterIdx0 = nextCounterIdx++;
///
if (Counters == null || Counters.Length < nextCounterIdx)
{
TestMethod[] contersSoFar = Counters;
Counters = new TestMethod[nextCounterIdx];
if (contersSoFar != null) for (int i = 0; i < contersSoFar.Length; i++) Counters[i] = contersSoFar[i];
Counters[nextCounterIdx - 1] = this;
}
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel);
}
}
}