/// /// 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("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) { message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); return false; } /// /// Enumeration of counters via static fields and methods /// 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.Warn(this.ToString()); } public IList Execute(Test test, int repetNr, bool isLastRepetition) { return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel); } } }