66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using TBF.BenchControl.Network.Telnet;
|
|
|
|
namespace TBF.BenchControl.Network.Camera.CLP1611
|
|
{
|
|
public class MeasurementOp : IOperation
|
|
{
|
|
readonly CLP1611.Camera camera;
|
|
readonly Telnet.TelnetClient telnet;
|
|
|
|
readonly string ipAddress;
|
|
readonly int portNr;
|
|
readonly string args;
|
|
|
|
string command;
|
|
bool measurementCommandSent;
|
|
|
|
|
|
/// <summary>
|
|
/// Events: Event.None or Event.Error
|
|
/// </summary>
|
|
/// <param name="camera">CLP1611.Camera reference</param>
|
|
public MeasurementOp(Camera camera, string ipAddress, int portNr, string args)
|
|
{
|
|
this.camera = camera;
|
|
this.telnet = camera.Telnet;
|
|
this.ipAddress = ipAddress;
|
|
this.portNr = portNr;
|
|
this.args = args;
|
|
|
|
measurementCommandSent = false;
|
|
}
|
|
|
|
|
|
public void Start()
|
|
{
|
|
measurementCommandSent = false;
|
|
}
|
|
|
|
public Event Run()
|
|
{
|
|
if (!measurementCommandSent)
|
|
{
|
|
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
|
{
|
|
//
|
|
// Prepare and send (=enqueue) command
|
|
//
|
|
command = string.Format("clp/Measurement -o {4}:{5} {6}", ipAddress, portNr, args);
|
|
//command = string.Format("clp/Measurement -r {0} {1} {2} {3} -o {4}:{5} {6}", roiX, roiY, roiWid, roiHgh, ipAddress, portNr, args);
|
|
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
|
|
measurementCommandSent = true;
|
|
}
|
|
}
|
|
return Event.None;
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
if (measurementCommandSent)
|
|
{
|
|
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
|
}
|
|
}
|
|
}
|
|
}
|