83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using log4net;
|
|
using Config.Entities;
|
|
|
|
namespace TBF.BenchControl.Various.ErrorFlags
|
|
{
|
|
public class Errors : ComponentBase, GenericDevices.IErrorFlags
|
|
{
|
|
/// TODO: Implement support for sharing one camera by multiple ROI-s
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Errors));
|
|
public override string ToString()
|
|
{
|
|
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
|
|
}
|
|
|
|
///
|
|
/// Cfg
|
|
///
|
|
readonly ErrorsCfg errorsCfg;
|
|
|
|
public ErrorFlagsMode Mode { get { return errorsCfg.TestParams.Mode; } }
|
|
|
|
public int GetErrorFlags()
|
|
{
|
|
if (Mode != ErrorFlagsMode.Info && Mode != ErrorFlagsMode.On) return 0; /// return 0 when Mode == ErrorFlagsMode.Off
|
|
|
|
/// TODO : Return real error conditions
|
|
return 0;
|
|
}
|
|
|
|
|
|
public Errors()
|
|
{
|
|
}
|
|
|
|
public Errors(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
errorsCfg = cfg as ErrorsCfg;
|
|
|
|
StartChangeHandler();
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
#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)
|
|
{
|
|
ErrorsCfg tmpcfg = args.Cfg as ErrorsCfg;
|
|
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
|
|
{
|
|
if (args.Command == CfgChangeCmd.CfgChange)
|
|
{
|
|
//errorsCfg.BlackAndWhite = tmpcfg.BlackAndWhite;
|
|
//errorsCfg.LowResolution = tmpcfg.LowResolution;
|
|
//errorsCfg.ImageRotation = tmpcfg.ImageRotation;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endregion Configuration Change Handling
|
|
}
|
|
}
|