2019-05-06 10:14:57 +00:00
|
|
|
|
///
|
2021-04-02 13:59:52 +00:00
|
|
|
|
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
2019-05-06 10:14:57 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
using Config.Entities;
|
2021-03-05 13:47:21 +00:00
|
|
|
|
using TBF.Rig;
|
2019-05-06 10:14:57 +00:00
|
|
|
|
|
2021-03-05 13:47:21 +00:00
|
|
|
|
namespace TBF.Rig.TestMethods.Counter
|
2019-05-06 10:14:57 +00:00
|
|
|
|
{
|
2021-04-02 21:41:49 +00:00
|
|
|
|
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
|
2019-05-06 10:14:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
2021-03-13 10:00:31 +00:00
|
|
|
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
2019-05-06 10:14:57 +00:00
|
|
|
|
|
|
|
|
|
|
public bool CanTest(MetersKind meters) { return true; }
|
|
|
|
|
|
public bool DoTransitions() { return false; }
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public bool CheckDeviceCaps(Test test, OutputPath devices, out string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-05-06 10:14:57 +00:00
|
|
|
|
|
2019-05-06 14:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Enumeration of counters via static fields and methods
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
static int nextCounterIdx = 0;
|
|
|
|
|
|
public static int CountersCount { get { return nextCounterIdx; } }
|
2021-04-02 13:59:52 +00:00
|
|
|
|
public static TestMethod[] Counters = new TestMethod[0];
|
2019-05-06 14:16:00 +00:00
|
|
|
|
///
|
|
|
|
|
|
private int counterIdx0; /// 0-based index of this counter
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public TestMethod() { }
|
2021-04-02 21:41:49 +00:00
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public TestMethod(Generic.IComponentCfg cfg)
|
2019-05-06 10:14:57 +00:00
|
|
|
|
: base(cfg)
|
|
|
|
|
|
{
|
2021-04-02 13:59:52 +00:00
|
|
|
|
log.Warn(this.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-02 21:41:49 +00:00
|
|
|
|
public override void Initialize()
|
2021-04-02 13:59:52 +00:00
|
|
|
|
{
|
|
|
|
|
|
counterIdx0 = nextCounterIdx;
|
|
|
|
|
|
nextCounterIdx++;
|
2019-05-06 14:16:00 +00:00
|
|
|
|
///
|
2021-04-02 13:59:52 +00:00
|
|
|
|
if (Counters.Length < nextCounterIdx)
|
2019-05-06 14:16:00 +00:00
|
|
|
|
{
|
2021-04-02 13:59:52 +00:00
|
|
|
|
var contersSoFar = Counters;
|
2019-05-06 14:16:00 +00:00
|
|
|
|
Counters = new TestMethod[nextCounterIdx];
|
2021-04-02 13:59:52 +00:00
|
|
|
|
for (int i = 0; i < contersSoFar.Length; i++) Counters[i] = contersSoFar[i];
|
2019-05-06 14:16:00 +00:00
|
|
|
|
Counters[nextCounterIdx - 1] = this;
|
|
|
|
|
|
}
|
2021-04-02 13:59:52 +00:00
|
|
|
|
}
|
2021-04-02 21:41:49 +00:00
|
|
|
|
|
2019-05-06 10:14:57 +00:00
|
|
|
|
|
|
|
|
|
|
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
|
|
|
|
|
{
|
2019-05-06 14:16:00 +00:00
|
|
|
|
return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel);
|
2019-05-06 10:14:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|