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