Interfaces between Camera and Roi and sequences finalized, TODO: network communication, ver. 2.12.446

Sequences more robust for debugging, T and Pr-meters checked for null
This commit is contained in:
Milan Hanajik
2017-01-25 17:28:57 +01:00
parent 02ce6bf7c0
commit 38c199f6f9
13 changed files with 160 additions and 132 deletions
@@ -13,7 +13,7 @@ using Config.Entities;
namespace TBF.BenchControl.Network.Camera.CLP1611
{
public class Camera : ComponentBase, Generic.IDevice
public class Camera : ComponentBase, GenericDevices.ICamera, Generic.IDevice
{
private static readonly ILog log = LogManager.GetLogger(typeof(Camera));
public override string ToString()
@@ -57,17 +57,27 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
IList<string> roiParams;
int[] result;
///
public void ClearRois() { roiParams.Clear(); }
public int RegisterRoi(string roiParams)
public int RegisterRoi(string rParams)
{
this.roiParams.Add(roiParams);
return this.roiParams.Count;
this.roiParams.Add(rParams);
int newHandle = this.roiParams.Count;
result = new int[newHandle];
return newHandle;
}
///
public int GetResult(int roiHandle)
{
if (roiHandle <= roiParams.Count) return 0;
else return 0;
if (roiHandle > 0 && roiHandle <= roiParams.Count)
{
return 0;
}
else
{
return result[roiHandle - 1];
}
}
@@ -131,8 +141,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Telnet.Enqueue(new Telnet.Command(Network.Telnet.CmdAction.CONNECT, ipAddress.ToString(), 10, 30));
//measurementListener = new UdpClient(new IPEndPoint(IPAddress.Any, measurementUdpPortNr));
//new Thread(new ThreadStart(MeasurementUdpListener)).Start();
measurementListener = new UdpClient(measurementUdpPortNr);
new Thread(new ThreadStart(MeasurementUdpListener)).Start();
running = true;
@@ -154,12 +164,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void RunDeviceAfter() {}
public IOperation LiveStreamOp(bool hiRes)
{
return new LiveStreamOp(this, Telnet, hiRes ? "clp/hrlivestream.sh" : "clp/livestream.sh");
}
public IOperation MeasurementOp()
{
if (Telnet != null)
@@ -172,6 +182,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
}
public IOperation GrabImageOp()
{
return null;
}
/// <summary>
/// Detect the camera with specified hardware address (DIP switches)
@@ -283,7 +299,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
while (true)
{
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, measurementUdpPortNr);
byte[] byteArray = measurementListener.Receive(ref ipEndPoint);
string receivedData = Encoding.ASCII.GetString(byteArray, 0, byteArray.Length);
int from = receivedData.IndexOf('[');
@@ -1,5 +1,6 @@
using System;
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using System.Text;
using TBF.BenchControl.Network.Telnet;
@@ -39,11 +39,11 @@ namespace TBF.BenchControl.Network.Camera.Roi
public int WMRefPulses { get { return wmRefPulses; } }
public double WMVolume { get { return LtrsPerPulse * (double)wmPulses; } }
int wmPulses;
int wmRefPulses;
///
/// Roi specific
///
@@ -146,21 +146,25 @@ namespace TBF.BenchControl.Network.Camera.Roi
}
public IOperation MeasurementOp()
/// <summary>
/// Updates wmPulses, caled from 'Start' and 'Run' functions of 'ReadRegisterOp'
/// </summary>
void UdatePulses()
{
return null; /// TODO: To be implemented in a Camera
if (detected && roiHandle != 0)
{
wmPulses = NetCamera.GetResult(roiHandle);
}
}
///
/// Note: Measurement operations of cameras should preceeede ReadRegister operations of ROI-s
///
public IOperation ReadRegisterOp()
{
return this;
}
void UdatePulses()
{
}
/// <summary>Start this operation</summary>
public void Start()
{