Possibility to switch off Telnet VirtualTerminal completely, IVirtualTerminal, DummyVT.

This commit is contained in:
Milan Hanajik 2017-04-07 16:04:43 +02:00
parent 4564f0424c
commit 6e420250b4
6 changed files with 46 additions and 6 deletions

View File

@ -174,7 +174,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
if (cameraDetected)
{
/// Open telnet clint and start the log-in process
Telnet = new Telnet.TelnetClient(this, CameraCfg.Name, ClpUserName, ClpPassword, TelnetPrompt, TelnetSkipFirstLine);
Telnet = new Telnet.TelnetClient(this, CameraCfg.Name, ClpUserName, ClpPassword, TelnetPrompt, TelnetSkipFirstLine, CameraCfg.DisplayTerminal);
if (CameraCfg.DisplayTerminal)
{

View File

@ -0,0 +1,15 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Telnet
{
public class DummyVT : IVirtualTerminal
{
public DummyVT() { }
public void ClearScreen() { }
public void WriteVt(char c) { }
public void WriteVt(string txt) { }
public string Text { get { return string.Empty; } }
}
}

View File

@ -0,0 +1,13 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Telnet
{
public interface IVirtualTerminal
{
void ClearScreen();
void WriteVt(char c);
void WriteVt(string txt);
string Text { get; }
}
}

View File

@ -146,7 +146,7 @@ namespace TBF.BenchControl.Network.Telnet
/// Private fields
///
object objRef; /// Reference to object to be included in info sent by event handlers
VirtualTerminal vt; /// Virtual terminal
IVirtualTerminal vt; /// Virtual terminal
string hostname; /// Telnet server host name or IP address.
int portNr = DefaultTelnetPortNumber; /// Telnet server port number.
TcpClient tcp = null; /// Reference to TcpClient
@ -223,7 +223,7 @@ namespace TBF.BenchControl.Network.Telnet
/// Hostname (IP address) and the port number is passed to worker thread
/// in a Command with CmdAction.CONNECT and str=hostname.
/// </summary>
public TelnetClient(object objRef, string threadId, string userName, string password, string defaultPrompt, bool skipFirstLine)
public TelnetClient(object objRef, string threadId, string userName, string password, string defaultPrompt, bool skipFirstLine, bool useVT)
{
this.objRef = objRef;
this.telnetUserName = userName;
@ -232,7 +232,17 @@ namespace TBF.BenchControl.Network.Telnet
this.skipFirstLine = skipFirstLine;
state = TelnetState.Inactive; /// Device's icon is being updated by HNIP
vt = new VirtualTerminal(); /// TODO: pass a VirtualTerminal reference
///
if (useVT)
{
vt = new VirtualTerminal();
}
else
{
vt = new DummyVT();
}
/// TODO: pass a VirtualTerminal reference
this.portNr = DefaultTelnetPortNumber;
queueEvent = new AutoResetEvent(false);
disconnectDone = new AutoResetEvent(false);
@ -986,7 +996,7 @@ namespace TBF.BenchControl.Network.Telnet
///
/// Public properties (read only)
///
public VirtualTerminal Vt { get { return vt; } }
public IVirtualTerminal Vt { get { return vt; } }
public string Hostname { get { return hostname; } }
public string NotificationText { get { return notificationText; } }
public string ErrorText { get { return fatalErrorText; } }

View File

@ -12,7 +12,7 @@ namespace TBF.BenchControl.Network.Telnet
/// - ClearScreen() and WriteVt() methods called from one thread only
/// - properties Text, etc. can be safely read from an arbitrary thread
/// </summary>
public class VirtualTerminal
public class VirtualTerminal : IVirtualTerminal
{
const uint DefaultVtRowsCount = 80; /// Default VT height (number of rows)
const uint DefaultVtColumnsCount = 132; /// Default VT width (number of columns)

View File

@ -618,7 +618,9 @@
<Compile Include="BenchControl\Network\Camera\Roi\Factory.cs" />
<Compile Include="BenchControl\Network\Camera\Roi\RoiDetectionOp.cs" />
<Compile Include="BenchControl\Network\Telnet\Command.cs" />
<Compile Include="BenchControl\Network\Telnet\DummyVT.cs" />
<Compile Include="BenchControl\Network\Telnet\EventArgsClasses.cs" />
<Compile Include="BenchControl\Network\Telnet\IVirtualTerminal.cs" />
<Compile Include="BenchControl\Network\Telnet\TelnetClient.cs" />
<Compile Include="BenchControl\Network\Telnet\VirtualTerminal.cs" />
<Compile Include="BenchControl\Network\Tftp\TftpServer.cs" />