73 lines
1.8 KiB
C#
73 lines
1.8 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.BenchControl;
|
|
|
|
namespace TBF.BenchControl.TestMethods.GrabImage
|
|
{
|
|
public class Component : ComponentBase, GenericDevices.ITestMethod
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
|
public override string ToString() { return string.Format("TestMethods.LiveStream({0})", Cfg.ToString(1)); }
|
|
|
|
public bool CanTest(MetersKind meters) { return true; }
|
|
public bool DoTransitions() { return false; }
|
|
|
|
readonly GrabImageCfg cfg;
|
|
|
|
#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)
|
|
{
|
|
GrabImageCfg tmpcfg = args.Cfg as GrabImageCfg;
|
|
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
|
|
{
|
|
if (args.Command == CfgChangeCmd.CfgChange)
|
|
{
|
|
cfg.ImageFileName = tmpcfg.ImageFileName;
|
|
cfg.BlackAndWhite = tmpcfg.BlackAndWhite;
|
|
cfg.LowResolution = tmpcfg.LowResolution;
|
|
cfg.ImageRotation = tmpcfg.ImageRotation;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endregion Configuration Change Handling
|
|
|
|
|
|
public Component()
|
|
{
|
|
}
|
|
|
|
public Component(Generic.IComponentCfg cfg)
|
|
: base(cfg)
|
|
{
|
|
this.cfg = cfg as GrabImageCfg;
|
|
StartChangeHandler();
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
public IList<Event> Execute(Test test, int idummy, bool bdummy)
|
|
{
|
|
return (new GrabImageSeq()).Execute(test, cfg);
|
|
}
|
|
|
|
}
|
|
}
|