tbf/TBF/Rig/TestMethods/AllyCalibration/TestMethod.cs
Michal Buzik c71fe75446 Ally iPerl initial - reader,test method, unit test
Add AllyReader and AllyCalibration support with tests: Introduce new register readers, calibration methods, and comprehensive unit tests for integration and functionality validation. Update project files accordingly.
2026-08-18 10:01:02 +02:00

95 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using Common;
using Config.Entities;
using log4net;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Rig.Sequences;
using TBF.UiBridge;
namespace TBF.Rig.TestMethods.AllyCalibration
{
public class TestMethod : ComponentBase, ISimultTestMethod, ITestMethodSmart
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
private readonly TestMethodCfg allyCfg;
public TestMethod()
{
}
public TestMethod(IComponentCfg cfg)
: base(cfg)
{
allyCfg = cfg as TestMethodCfg;
}
public override string ToString()
{
return Cfg == null ? ClassName : string.Format("{0}({1})", ClassName, Cfg.ToString(-1));
}
public FlowType MethodFlowType { get { return FlowType.volume; } }
public bool SimultWithPrevious
{
get
{
TestMethodParams parameters = allyCfg == null ? null : allyCfg.TestParams as TestMethodParams;
return parameters != null && parameters.SimultWithPrevious;
}
}
public bool SimultWithNext
{
get
{
TestMethodParams parameters = allyCfg == null ? null : allyCfg.TestParams as TestMethodParams;
return parameters != null && parameters.SimultWithNext;
}
}
public bool CanTest(MetersKind meters)
{
return meters == MetersKind.Single;
}
public bool DoTransitions()
{
return false;
}
public bool CheckDeviceCaps(Test test, OutputPath devices, out string message)
{
message = string.Empty;
return true;
}
public override void Initialize()
{
if (allyCfg == null)
throw new InvalidOperationException("ALLY calibration test method configuration is missing.");
log.FatalFormat("{0} initialized: {1}", Name, this);
}
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition)
{
TestMethodParams parameters = allyCfg.TestParams as TestMethodParams;
if (parameters == null)
throw new InvalidOperationException("ALLY calibration test parameters are missing.");
if (DebugLevel == DebugMode.Normal)
return new AllyCalibrationSeq().Execute(test, repetitionNr, this, allyCfg, parameters);
new AllyCalibrationSeq().MakeSimulatedTrivial(test, repetitionNr, test.Part);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Progress.Completed));
Bridge.OnTestCompleted(
this,
new TestCompletedEventArgs(
test.Name,
ProcessData.BatchRslts.GetTestRslt(Common.Utils.GetTestName(test.Name, 1, 1), 0)));
return new List<Event> { Event.Done };
}
}
}