70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
///
|
|
/// 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.ManualEntry
|
|
{
|
|
public class Component : ComponentBase, GenericDevices.ITestMethod
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
|
public override string ToString() { return string.Format("ManualEntry({0})", Cfg.ToString(1)); }
|
|
|
|
readonly ManualEntryCfg myCfg;
|
|
|
|
public bool CanTest(MetersKind meters) { return true; }
|
|
public bool DoTransitions() { return false; }
|
|
|
|
|
|
public Component() { }
|
|
|
|
public Component(Generic.IComponentCfg cfg)
|
|
: base(cfg)
|
|
{
|
|
myCfg = cfg as ManualEntryCfg;
|
|
StartChangeHandler();
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
|
{
|
|
return (new ManualEntrySeq()).Execute(test, repetNr, isLastRepetition, myCfg, DebugLevel);
|
|
}
|
|
|
|
|
|
#region Configuration Change Handling
|
|
|
|
public static void OnCfgChange(object sender, CfgChangeArgs args)
|
|
{
|
|
if (CfgChangeHandler == null) return;
|
|
try { CfgChangeHandler(sender, args); }
|
|
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
|
|
}
|
|
|
|
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
|
|
|
|
public override void StartChangeHandler()
|
|
{
|
|
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
|
|
{
|
|
ManualEntryCfg newCfg = args.Cfg as ManualEntryCfg;
|
|
if ((newCfg != null) && newCfg.Name.Equals(Name))
|
|
{
|
|
if (args.Command == CfgChangeCmd.CfgChange)
|
|
{
|
|
myCfg.Culture = newCfg.Culture;
|
|
myCfg.Prompt = newCfg.Prompt;
|
|
myCfg.Items = newCfg.Items;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endregion Configuration Change Handling
|
|
}
|
|
}
|