tbf/TestBenchFramework/BenchControl/Network/Camera/Roi/Roi.cs
2017-01-14 14:23:32 +01:00

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;
}
}
}
}