/// /// Copyright (c) 2019-2021 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; } 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 int CountersCount { get { return nextCounterIdx; } } public static TestMethod[] Counters = new TestMethod[0]; /// private int counterIdx0; /// 0-based index of this counter public TestMethod() { } public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { log.Warn(this.ToString()); } public override void Initialize() { counterIdx0 = nextCounterIdx; nextCounterIdx++; /// if (Counters.Length < nextCounterIdx) { var contersSoFar = Counters; Counters = new TestMethod[nextCounterIdx]; for (int i = 0; i < contersSoFar.Length; i++) Counters[i] = contersSoFar[i]; Counters[nextCounterIdx - 1] = this; } } public IList Execute(Test test, int repetNr, bool isLastRepetition) { return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel); } } }