Introduced the CJMS11 camera component and its factory in TbfComponents. Added implementation for the CJMS11 camera class, along with unit tests to validate its functionality and integration. This enhances existing camera support in the system.
92 lines
1.6 KiB
C#
92 lines
1.6 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace TBF.Rig.Network.Camera.CJMS11
|
|
{
|
|
public class RoisAndResults
|
|
{
|
|
public const int MaxRegisteredRois = 4; /// Max. count of registered (and measured) ROI-s
|
|
|
|
public long CameraTimeMs;
|
|
public int[] Angles;
|
|
|
|
private IList<string> roiParams;
|
|
public int RegisteredRoisCount { get { return roiParams.Count; } }
|
|
|
|
|
|
public RoisAndResults()
|
|
{
|
|
Angles = new int[MaxRegisteredRois];
|
|
roiParams = new List<string>();
|
|
}
|
|
|
|
|
|
public void ClearRoiParams()
|
|
{
|
|
lock (this)
|
|
{
|
|
roiParams.Clear();
|
|
}
|
|
}
|
|
|
|
public int RegisterRoi(string roiParam)
|
|
{
|
|
lock (this)
|
|
{
|
|
if (this.roiParams.Count >= MaxRegisteredRois) return 0;
|
|
|
|
this.roiParams.Add(roiParam);
|
|
return this.roiParams.Count; /// return a handle 1 .. MaxRegisteredRois
|
|
}
|
|
}
|
|
|
|
public string GetRoiParams(int roiHandle)
|
|
|
|
{
|
|
lock (this)
|
|
{
|
|
if (roiHandle > 0 && roiHandle <= roiParams.Count)
|
|
{
|
|
return roiParams[roiHandle - 1];
|
|
}
|
|
else
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetResults(long timeMs, int[] angles)
|
|
{
|
|
lock (this)
|
|
{
|
|
CameraTimeMs = timeMs;
|
|
for (int i = 0; i < Math.Min(angles.Length, Angles.Length); i++)
|
|
{
|
|
Angles[i] = angles[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
public int GetResult(int roiHandle, out long timeMs)
|
|
{
|
|
lock (this)
|
|
{
|
|
if (roiHandle > 0 && roiHandle <= roiParams.Count)
|
|
{
|
|
timeMs = CameraTimeMs;
|
|
return Angles[roiHandle - 1];
|
|
}
|
|
else
|
|
{
|
|
timeMs = 0;
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|