tbf/TestBenchFramework/BenchControl/Network/Camera/RoI/RoI.cs

64 lines
1.4 KiB
C#

///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
namespace TBF.BenchControl.Network.Camera.RoI
{
public class RoI : ComponentBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(RoI));
public override string ToString()
{
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
}
protected readonly RoICfg roiCfg;
readonly CLP1611.Camera camera;
readonly Telnet.TelnetClient telnet;
Boxes.IntBox oroiX;
Boxes.IntBox oroiY;
Boxes.IntBox oroiWid;
Boxes.IntBox oroiHgh;
public RoI()
{
}
public RoI(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
roiCfg = cfg as RoICfg;
camera = TbfComponents.FindComponent(cfg.ParentName, components) as CLP1611.Camera;
if (camera != null) telnet = camera.Telnet;
oroiX = new Boxes.IntBox();
oroiY = new Boxes.IntBox();
oroiWid = new Boxes.IntBox();
oroiHgh = new Boxes.IntBox();
log.Debug(this.ToString());
}
public IOperation RoiDetectionOp()
{
if (camera != null && telnet != null)
{
return new RoiDetectionOp(this, camera, telnet, string.Format("clp/RoiDetection {0}", roiCfg.Args),
oroiX, oroiY, oroiWid, oroiHgh);
}
else
{
return null;
}
}
}
}