Propagation of ROI parameters between ROI-s and Cameras implemented, ver. 2.12.438

This commit is contained in:
Milan Hanajik
2017-01-22 20:40:12 +01:00
parent ada96d3d83
commit 2150ced11f
14 changed files with 324 additions and 84 deletions
@@ -12,6 +12,10 @@ namespace TBF.BenchControl.GenericDevices
/// </summary> /// </summary>
int CameraNr { get; } int CameraNr { get; }
string RoiParams { get; set; }
void ClearRoiParams();
/// <summary> /// <summary>
/// Grab one image. /// Grab one image.
/// </summary> /// </summary>
@@ -11,6 +11,8 @@ namespace TBF.BenchControl.GenericDevices
bool Detected { get; set; } bool Detected { get; set; }
string RoiParams { get; }
/// <summary> /// <summary>
/// Watermeter wheel/arrow detection process. /// Watermeter wheel/arrow detection process.
/// </summary> /// </summary>
@@ -20,8 +20,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
return string.Format("{0}, Name={1}, HWAddress={2}, IPAddress={3}, Serial={4}, Image={5}", return string.Format("{0}, Name={1}, HWAddress={2}, IPAddress={3}, Serial={4}, Image={5}",
this.GetType().Namespace.Substring(17), this.GetType().Namespace.Substring(17),
cameraCfg.Name, CameraCfg.Name,
cameraCfg.HardwareAddress, CameraCfg.HardwareAddress,
ipAddress == null ? "not detected" : ipAddress.ToString(), ipAddress == null ? "not detected" : ipAddress.ToString(),
string.IsNullOrEmpty(serial) ? "not detected" : serial, string.IsNullOrEmpty(serial) ? "not detected" : serial,
string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer); string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer);
@@ -36,24 +36,33 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
const string ClpPrompt = "$ "; const string ClpPrompt = "$ ";
readonly CameraCfg cameraCfg; public readonly CameraCfg CameraCfg;
public readonly GenericDevices.INetworkAdapter NetAdapter; public readonly GenericDevices.INetworkAdapter NetAdapter;
public IPAddress IPAddress { get { return ipAddress; } } public IPAddress IPAddress { get { return ipAddress; } }
IPAddress ipAddress; IPAddress ipAddress;
public string Hardware { get { return hardware; } }
string hardware; string hardware;
public string Hardware { get { return hardware; } }
public string Revision { get { return revision; } }
string revision; string revision;
public string Revision { get { return revision; } }
public string Serial { get { return serial; } }
string serial; string serial;
public string Serial { get { return serial; } }
public string SDCardVer { get { return sdCardVer; } }
string sdCardVer; string sdCardVer;
public string SDCardVer { get { return sdCardVer; } }
string roiParams;
public string RoiParams
{
get { return roiParams; }
set { roiParams = value; }
}
public void ClearRoiParams() { roiParams = string.Empty; }
public Telnet.TelnetClient Telnet; public Telnet.TelnetClient Telnet;
@@ -77,7 +86,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public Camera(Generic.IComponentCfg cfg, IList<Generic.IComponent> components) public Camera(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg) : base(cfg)
{ {
cameraCfg = cfg as CameraCfg; CameraCfg = cfg as CameraCfg;
NetAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.INetworkAdapter; NetAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.INetworkAdapter;
if (NetAdapter == null) throw new ArgumentNullException("no network adapter"); if (NetAdapter == null) throw new ArgumentNullException("no network adapter");
@@ -86,6 +95,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
measurementUdpPortNr = GetNextUdpPortNr(); measurementUdpPortNr = GetNextUdpPortNr();
ClearRoiParams();
running = false; running = false;
log.Debug(this.ToString()); log.Debug(this.ToString());
@@ -95,20 +106,20 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void Initialize() public void Initialize()
{ {
if (cameraCfg.DebugLevel == DebugMode.Simulate) return; if (CameraCfg.DebugLevel == DebugMode.Simulate) return;
/// Detect a camera /// Detect a camera
bool cameraDetected = DetectCamera(cameraCfg.HardwareAddress, true, bool cameraDetected = DetectCamera(CameraCfg.HardwareAddress, true,
out ipAddress, out hardware, out revision, out serial, out sdCardVer); out ipAddress, out hardware, out revision, out serial, out sdCardVer);
if (!cameraDetected) throw new Exception(string.Format("Camera {0} with address {1} not detected", if (!cameraDetected) throw new Exception(string.Format("Camera {0} with address {1} not detected",
Name, cameraCfg.HardwareAddress)); Name, CameraCfg.HardwareAddress));
/// Open telnet clint and start the log-in process /// Open telnet clint and start the log-in process
Telnet = new Telnet.TelnetClient(this, cameraCfg.Name, ClpUserName, ClpPassword, ClpPrompt); Telnet = new Telnet.TelnetClient(this, CameraCfg.Name, ClpUserName, ClpPassword, ClpPrompt);
if (cameraCfg.DisplayTerminal) if (CameraCfg.DisplayTerminal)
{ {
terminalDlg = new TerminalDlg(cameraCfg.Name, Telnet); terminalDlg = new TerminalDlg(CameraCfg.Name, Telnet);
terminalDlg.Show(); terminalDlg.Show();
} }
@@ -147,7 +158,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
if (Telnet != null) if (Telnet != null)
{ {
return new MeasurementOp(this, NetAdapter.IPAddress.ToString(), measurementUdpPortNr, string.Empty); /// TODO return new MeasurementOp(this, NetAdapter.IPAddress.ToString(), measurementUdpPortNr, roiParams);
} }
else else
{ {
@@ -223,9 +234,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
string msg = string.Format("Camera {0} detected in {1} ms: HWAddress={2} IPAddress={3} {4}", string msg = string.Format("Camera {0} detected in {1} ms: HWAddress={2} IPAddress={3} {4}",
cameraCfg.Name, CameraCfg.Name,
duration_ms, duration_ms,
cameraCfg.HardwareAddress, CameraCfg.HardwareAddress,
ipAddress == null ? "not detected" : ipAddress.ToString(), ipAddress == null ? "not detected" : ipAddress.ToString(),
response); response);
log.Info(msg); log.Info(msg);
@@ -5,11 +5,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public class MeasurementOp : IOperation public class MeasurementOp : IOperation
{ {
readonly CLP1611.Camera camera; readonly CLP1611.Camera camera;
readonly CLP1611.CameraCfg cameraCfg;
readonly Telnet.TelnetClient telnet; readonly Telnet.TelnetClient telnet;
readonly string ipAddress; readonly string ipAddress;
readonly int portNr; readonly int portNr;
readonly string args; readonly string roiArgs;
string command; string command;
bool measurementCommandSent; bool measurementCommandSent;
@@ -19,13 +20,14 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// Events: Event.None or Event.Error /// Events: Event.None or Event.Error
/// </summary> /// </summary>
/// <param name="camera">CLP1611.Camera reference</param> /// <param name="camera">CLP1611.Camera reference</param>
public MeasurementOp(Camera camera, string ipAddress, int portNr, string args) public MeasurementOp(Camera camera, string ipAddress, int portNr, string roiArgs)
{ {
this.camera = camera; this.camera = camera;
this.cameraCfg = camera.CameraCfg;
this.telnet = camera.Telnet; this.telnet = camera.Telnet;
this.ipAddress = ipAddress; this.ipAddress = ipAddress;
this.portNr = portNr; this.portNr = portNr;
this.args = args; this.roiArgs = roiArgs;
measurementCommandSent = false; measurementCommandSent = false;
} }
@@ -45,8 +47,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// //
// Prepare and send (=enqueue) command // Prepare and send (=enqueue) command
// //
command = string.Format("clp/Measurement -o {4}:{5} {6}", ipAddress, portNr, args); command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 1 0 0 0",
//command = string.Format("clp/Measurement -r {0} {1} {2} {3} -o {4}:{5} {6}", roiX, roiY, roiWid, roiHgh, ipAddress, portNr, args); ipAddress,
portNr,
cameraCfg.UseTestImages ? (" -l " + cameraCfg.TestImagesCount.ToString()) : string.Empty,
roiArgs);
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command)); telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
measurementCommandSent = true; measurementCommandSent = true;
} }
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
/// ///
/// Cfg /// Cfg
/// ///
readonly RoiCfg roiCfg; public readonly RoiCfg RoiCfg;
public readonly CLP1611.Camera NetCamera; public readonly CLP1611.Camera NetCamera;
public readonly Roi PreviousRoi; public readonly Roi PreviousRoi;
@@ -32,7 +32,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
/// ///
public GenericDevices.ICamera Camera { get { return NetCamera as GenericDevices.ICamera; } } public GenericDevices.ICamera Camera { get { return NetCamera as GenericDevices.ICamera; } }
public double PulsesPerLtr { get { return (double)roiCfg.ProcParams.PulsesPerLtr; } } public double PulsesPerLtr { get { return (double)RoiCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } } public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } }
public int WMPulses { get { return wmPulses; } } public int WMPulses { get { return wmPulses; } }
@@ -56,6 +56,12 @@ namespace TBF.BenchControl.Network.Camera.Roi
public Boxes.IntBox RoiY; public Boxes.IntBox RoiY;
public Boxes.IntBox RoiWid; public Boxes.IntBox RoiWid;
public Boxes.IntBox RoiHgh; public Boxes.IntBox RoiHgh;
///
public string RoiParams
{
get { return string.Format(" -roi 1 {0} {1} {2} bkgnd.bmp", RoiX.Val, RoiY.Val, RoiCfg.RoiParams); }
}
public Roi() public Roi()
@@ -66,10 +72,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
public Roi(Generic.IComponentCfg cfg, IList<Generic.IComponent> components) public Roi(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg) : base(cfg)
{ {
roiCfg = cfg as RoiCfg; RoiCfg = cfg as RoiCfg;
NetCamera = TbfComponents.FindComponent(cfg.ParentName, components) as CLP1611.Camera; NetCamera = TbfComponents.FindComponent(cfg.ParentName, components) as CLP1611.Camera;
PreviousRoi = TbfComponents.FindComponent(roiCfg.PreviousRoi, components) as Roi; PreviousRoi = TbfComponents.FindComponent(RoiCfg.PreviousRoi, components) as Roi;
detected = false; detected = false;
RoiX = new Boxes.IntBox(); RoiX = new Boxes.IntBox();
@@ -103,9 +109,9 @@ namespace TBF.BenchControl.Network.Camera.Roi
{ {
if (args.Command == CfgChangeCmd.CfgChange) if (args.Command == CfgChangeCmd.CfgChange)
{ {
roiCfg.RoiParams = tmpcfg.RoiParams; RoiCfg.RoiParams = tmpcfg.RoiParams;
roiCfg.UseTestImages = tmpcfg.UseTestImages; RoiCfg.UseTestImages = tmpcfg.UseTestImages;
roiCfg.TestImagesCount = tmpcfg.TestImagesCount; RoiCfg.TestImagesCount = tmpcfg.TestImagesCount;
} }
} }
}; };
@@ -127,7 +133,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
if (NetCamera != null && NetCamera.Telnet != null) if (NetCamera != null && NetCamera.Telnet != null)
{ {
Telnet = NetCamera.Telnet; Telnet = NetCamera.Telnet;
return new RoiDetectionOp(this, roiCfg.RoiParams, RoiX, RoiY, RoiWid, RoiHgh); return new RoiDetectionOp(this, RoiX, RoiY, RoiWid, RoiHgh);
} }
else else
{ {
@@ -5,9 +5,9 @@ namespace TBF.BenchControl.Network.Camera.Roi
public class RoiDetectionOp : IOperation public class RoiDetectionOp : IOperation
{ {
readonly Roi roi; readonly Roi roi;
readonly RoiCfg roiCfg;
readonly CLP1611.Camera camera; readonly CLP1611.Camera camera;
readonly Telnet.TelnetClient telnet; readonly Telnet.TelnetClient telnet;
readonly string args;
string command; string command;
bool roiDetectionCommandSent; bool roiDetectionCommandSent;
@@ -28,13 +28,13 @@ namespace TBF.BenchControl.Network.Camera.Roi
/// Events: Event.None or Event.Error /// Events: Event.None or Event.Error
/// </summary> /// </summary>
/// <param name="camera">CLP1611.Camera reference</param> /// <param name="camera">CLP1611.Camera reference</param>
public RoiDetectionOp(Roi roi, string args, Boxes.IntBox roiX, Boxes.IntBox roiY, public RoiDetectionOp(Roi roi, Boxes.IntBox roiX, Boxes.IntBox roiY,
Boxes.IntBox roiWid, Boxes.IntBox roiHgh) Boxes.IntBox roiWid, Boxes.IntBox roiHgh)
{ {
this.roi = roi; this.roi = roi;
this.roiCfg = roi.RoiCfg;
this.camera = roi.NetCamera; this.camera = roi.NetCamera;
this.telnet = roi.Telnet; this.telnet = roi.Telnet;
this.args = args;
this.roiX = roiX; this.roiX = roiX;
this.roiY = roiY; this.roiY = roiY;
this.roiWid = roiWid; this.roiWid = roiWid;
@@ -90,7 +90,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
previous.RoiWid.Val, previous.RoiHgh.Val); previous.RoiWid.Val, previous.RoiHgh.Val);
previous = previous.PreviousRoi; previous = previous.PreviousRoi;
} }
command = string.Format("clp/RoiDetection{0} {1}", masks, args); command = string.Format("clp/RoiDetection{0}{1} {2}",
masks,
roiCfg.UseTestImages ? (" -l " + roiCfg.TestImagesCount.ToString()) : string.Empty,
roiCfg.RoiParams);
// //
// Send (or enqueue) command // Send (or enqueue) command
@@ -171,14 +171,44 @@ namespace TBF.BenchControl.TestMethods.Adjustment
int time = StateMachine.Time; int time = StateMachine.Time;
double currentFlow = RefFlow.Val; double currentFlow = RefFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); ///
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) /// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------ //------------------------------------------------
@@ -176,14 +176,44 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
int flowDetectTime = 0; int flowDetectTime = 0;
float estFlowSetTime = 100.0f; float estFlowSetTime = 100.0f;
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); ///
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) /// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Switching_flow_detection); Bridge.OnActivity(this, Strings.Switching_flow_detection);
//------------------------------------------------ //------------------------------------------------
@@ -149,14 +149,44 @@ namespace TBF.BenchControl.TestMethods.Endurance
/// Flying start measurement through line 1 or line 2 /// Flying start measurement through line 1 or line 2
///----------------------------------------------------- ///-----------------------------------------------------
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); ///
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) /// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------ //------------------------------------------------
@@ -208,14 +208,42 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
double currentFlow = RefFlow.Val; double currentFlow = RefFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state ///
IList<IOperation> measureOperations = new List<IOperation>(); /// Prepare cameras, ROI-s and measurementOperations
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) ///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
/// ///
/// Enter watermeter begin states here /// Enter watermeter begin states here
@@ -283,14 +283,42 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
double currentFlow = RefFlow.Val; double currentFlow = RefFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state ///
IList<IOperation> measureOperations = new List<IOperation>(); /// Prepare cameras, ROI-s and measurementOperations
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) ///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
/// ///
/// Enter watermeter begin states here /// Enter watermeter begin states here
@@ -243,14 +243,44 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
temperature_set: temperature_set:
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); ///
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) /// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------ //------------------------------------------------
@@ -344,14 +344,43 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
temperature_set: temperature_set:
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); ///
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) /// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{ {
GenericDevices.IRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.IRoi; if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasurementOp());
} }
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (!cameras.Contains(roi.Camera))
{
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois)
{
roi.Camera.RoiParams = roi.Camera.RoiParams + roi.RoiParams;
}
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras)
{
measureOperations.Add(camera.MeasurementOp());
}
if (emptyTheTank) if (emptyTheTank)
{ {
@@ -476,6 +505,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
while (!e.Contains(Event.MeasurementStarted)); while (!e.Contains(Event.MeasurementStarted));
foreach (var rr in sensPath.RegisterReaders)
{
}
foreach (var rr in sensPath.RegisterReaders) foreach (var rr in sensPath.RegisterReaders)
{ {
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name; if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.12.437.1")] [assembly: AssemblyVersion("2.12.438.1")]
[assembly: AssemblyFileVersion("2.12.437.1")] [assembly: AssemblyFileVersion("2.12.438.1")]