tbf/TBF/Rig/TestMethods/PMaxTest/TestMethod.cs
2021-10-26 19:38:09 +02:00

58 lines
1.8 KiB
C#

///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Common;
using Config.Entities;
using TBF.Rig;
using TBF.Rig.Sequences;
using TBF.UiBridge;
namespace TBF.Rig.TestMethods.PMaxTest
{
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString()
{
return string.Format("{0}({1})", this.GetType().Namespace.Substring(8), Cfg.ToString(1));
}
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return true; }
readonly TestMethodCfg testMethodCfg;
public TestMethod() { }
public TestMethod(Generic.IComponentCfg cfg)
: base(cfg)
{
testMethodCfg = cfg as TestMethodCfg;
}
public override void Initialize()
{
log.FatalFormat("{0} initialized: {1}", Name, this);
}
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
if (DebugLevel == DebugMode.Normal)
{
return (new PMaxTestSeq()).Execute(test, repetNr, isLastRepetition, testMethodCfg.TestParams);
}
else
{
/// DebugLevel == DebugMode.Simulate
(new PMaxTestSeq()).MakeSimulatedTrivial(test, repetNr, test.Part);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
return new List<Event> { Event.Done };
}
}
}
}