/// /// Copyright (c) 2019 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; using Common; using Config.Entities; using TBF.Rig; namespace TBF.Rig.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; } /// /// Enumeration of counters via static fields and methods /// 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 Execute(Test test, int repetNr, bool isLastRepetition) { return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel); } } }