60 lines
1.8 KiB
C#
60 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.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("{0}({1})", ClassName, 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 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)
|
|
{
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
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.FatalFormat("{0} initialized: {1}", Name, this);
|
|
}
|
|
|
|
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
|
{
|
|
return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel);
|
|
}
|
|
}
|
|
}
|