tbf/TestBenchFramework/BenchControl/Network/Camera/CLP1611/GrabImageOp.cs
2017-02-17 08:50:19 +01:00

54 lines
1.1 KiB
C#

using System;
using System.Diagnostics;
using TBF.BenchControl.Network.Telnet;
namespace TBF.BenchControl.Network.Camera.CLP1611
{
public class GrabImageOp : IOperation
{
readonly Camera camera;
readonly Telnet.TelnetClient telnet;
readonly string command;
bool grabImageCommandSent;
/// <summary>
/// Events: Event.None or Event.Error
/// </summary>
/// <param name="camera">CLP1611.Camera reference</param>
public GrabImageOp(Camera camera, Telnet.TelnetClient telnet, string command)
{
this.camera = camera;
this.telnet = telnet;
this.command = command;
}
public void Start()
{
grabImageCommandSent = false;
}
public Event Run()
{
if (!grabImageCommandSent)
{
if (telnet.State == TelnetClient.TelnetState.Inactive)
{
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
grabImageCommandSent = true;
}
}
return Event.None;
}
public void Stop()
{
if (grabImageCommandSent)
{
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
}
}
}
}