WinSCPnet package replaced by Renci.SshNet, Camera, GrabImagesOp and RoiDetectionOp modified, ver. 2.16.651
This commit is contained in:
parent
3c85440d34
commit
8a2287c685
@ -10,10 +10,10 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
using log4net;
|
||||
using Renci.SshNet;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Network.Telnet;
|
||||
using TBF.Resources;
|
||||
using WinSCP;
|
||||
|
||||
namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
{
|
||||
@ -70,21 +70,21 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
private TerminalDlg terminalDlg;
|
||||
|
||||
///
|
||||
/// WinSCP support
|
||||
/// scp support
|
||||
///
|
||||
Thread wscpThread;
|
||||
SessionOptions wscpSessionOptions;
|
||||
Session wscpSession;
|
||||
bool wscpOpened;
|
||||
bool closeWscpThread;
|
||||
string wscpSrcFileName;
|
||||
string wscpDstFileName;
|
||||
enum WscpCommand
|
||||
Thread scpThread;
|
||||
PasswordConnectionInfo connectionInfo;
|
||||
ScpClient scpClient;
|
||||
bool scpConnected;
|
||||
bool closeScpThread;
|
||||
string scpSrcFileName;
|
||||
string scpDstFileName;
|
||||
enum ScpCommand
|
||||
{
|
||||
None,
|
||||
Get,
|
||||
}
|
||||
WscpCommand wscpCommand;
|
||||
ScpCommand scpCommand;
|
||||
|
||||
|
||||
///
|
||||
@ -200,8 +200,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
//new Thread(new ThreadStart(MeasurementUdpListener)).Start();
|
||||
|
||||
|
||||
wscpThread = new Thread(new ThreadStart(WscpWorker));
|
||||
wscpThread.Start();
|
||||
scpThread = new Thread(new ThreadStart(ScpWorker));
|
||||
scpThread.Start();
|
||||
|
||||
running = true;
|
||||
|
||||
@ -215,7 +215,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
|
||||
public void StopDevice()
|
||||
{
|
||||
closeWscpThread = true;
|
||||
closeScpThread = true;
|
||||
|
||||
if (Telnet != null)
|
||||
{
|
||||
@ -223,7 +223,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
Telnet = null;
|
||||
}
|
||||
|
||||
if (wscpThread != null) wscpThread.Join(500);
|
||||
if (scpThread != null) scpThread.Join(500);
|
||||
|
||||
running = false;
|
||||
}
|
||||
@ -236,7 +236,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
{
|
||||
// if (running)
|
||||
// {
|
||||
// Console.WriteLine("Time={0} IP={1} scp={2}", StateMachine.Time, IPAddress, wscpOpened ? "Opened" : "Closed");
|
||||
// Console.WriteLine("Time={0} IP={1} scp={2}", StateMachine.Time, IPAddress, scpConnected ? "connected" : "disconnected");
|
||||
// }
|
||||
}
|
||||
|
||||
@ -354,44 +354,40 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
|
||||
|
||||
|
||||
void WscpWorker()
|
||||
void ScpWorker()
|
||||
{
|
||||
wscpSessionOptions = new SessionOptions();
|
||||
wscpSessionOptions.HostName = IPAddress.ToString();
|
||||
wscpSessionOptions.UserName = ClpUserName;
|
||||
wscpSessionOptions.Password = ClpPassword;
|
||||
wscpSessionOptions.Protocol = Protocol.Scp;
|
||||
wscpSessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = true;
|
||||
|
||||
wscpSession = new WinSCP.Session();
|
||||
wscpSession.Open(wscpSessionOptions);
|
||||
|
||||
TransferOptions transferOptions = new TransferOptions();
|
||||
transferOptions.TransferMode = TransferMode.Binary;
|
||||
|
||||
TransferOperationResult transferResult;
|
||||
|
||||
wscpOpened = wscpSession.Opened;
|
||||
|
||||
if (wscpOpened)
|
||||
try
|
||||
{
|
||||
while (!closeWscpThread)
|
||||
connectionInfo = new PasswordConnectionInfo(IPAddress.ToString(), ClpUserName, ClpPassword);
|
||||
scpClient = new ScpClient(connectionInfo);
|
||||
scpClient.Connect();
|
||||
scpConnected = scpClient.IsConnected;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
switch (wscpCommand)
|
||||
scpConnected = false;
|
||||
}
|
||||
|
||||
|
||||
if (scpConnected)
|
||||
{
|
||||
case WscpCommand.Get:
|
||||
wscpCommand = WscpCommand.None;
|
||||
transferResult = wscpSession.GetFiles(wscpSrcFileName, wscpDstFileName, false, transferOptions);
|
||||
///transferResult.Check();
|
||||
while (!closeScpThread)
|
||||
{
|
||||
switch (scpCommand)
|
||||
{
|
||||
case ScpCommand.Get:
|
||||
scpCommand = ScpCommand.None;
|
||||
scpClient.Download(scpSrcFileName, new System.IO.FileInfo(scpDstFileName));
|
||||
break;
|
||||
|
||||
default:
|
||||
Thread.Sleep(250);
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
|
||||
wscpSession.Close();
|
||||
wscpOpened = false;
|
||||
scpClient.Disconnect();
|
||||
scpConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,14 +397,14 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
/// <param name="srcFileName"></param>
|
||||
/// <returns>0 (success), -1 (busy), -2 (no session)</returns>
|
||||
|
||||
public int WscpTransferFile(string srcFileName, string dstFileName)
|
||||
public int TransferFileViaScp(string srcFileName, string dstFileName)
|
||||
{
|
||||
if (!wscpOpened) return -2;
|
||||
if (wscpCommand != WscpCommand.None) return -1;
|
||||
if (!scpConnected) return -2;
|
||||
if (scpCommand != ScpCommand.None) return -1;
|
||||
|
||||
wscpSrcFileName = srcFileName;
|
||||
wscpDstFileName = dstFileName;
|
||||
wscpCommand = WscpCommand.Get;
|
||||
scpSrcFileName = srcFileName;
|
||||
scpDstFileName = dstFileName;
|
||||
scpCommand = ScpCommand.Get;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
/// Grab passed and image transfer is in progress
|
||||
return Event.GrabPassed;
|
||||
}
|
||||
else if (0 == camera.WscpTransferFile(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp", imgFileNames[0]))
|
||||
else if (0 == camera.TransferFileViaScp(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp", imgFileNames[0]))
|
||||
{
|
||||
/// File transfer successfully started
|
||||
transferringGrabbedImage = true;
|
||||
@ -142,7 +142,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
///
|
||||
/// Start the file transfer
|
||||
///
|
||||
if (0 == camera.WscpTransferFile(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp", imgFileNames[0]))
|
||||
if (0 == camera.TransferFileViaScp(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp", imgFileNames[0]))
|
||||
{
|
||||
/// File transfer successfully started
|
||||
transferringGrabbedImage = true;
|
||||
|
||||
@ -128,7 +128,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
/// ROI detection passed and image transfer is in progress
|
||||
return Event.RoiDetectionPassed;
|
||||
}
|
||||
else if (0 == camera.WscpTransferFile("detected.jpg", detectedImageName))
|
||||
else if (0 == camera.TransferFileViaScp("detected.jpg", detectedImageName))
|
||||
{
|
||||
/// File transfer successfully started
|
||||
transferringDetectedImage = true;
|
||||
@ -179,7 +179,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
///
|
||||
/// Start the file transfer
|
||||
///
|
||||
if (0 == camera.WscpTransferFile("detected.jpg", detectedImageName))
|
||||
if (0 == camera.TransferFileViaScp("detected.jpg", detectedImageName))
|
||||
{
|
||||
/// File transfer successfully started
|
||||
transferringDetectedImage = true;
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.16.650.1")]
|
||||
[assembly: AssemblyFileVersion("2.16.650.1")]
|
||||
[assembly: AssemblyVersion("2.16.651.1")]
|
||||
[assembly: AssemblyFileVersion("2.16.651.1")]
|
||||
|
||||
@ -126,6 +126,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Oracle\Oracle.DataAccess.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Renci.SshNet">
|
||||
<HintPath>..\packages\Renci.SshNet\Renci.SshNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
@ -134,9 +137,6 @@
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WinSCPnet">
|
||||
<HintPath>..\packages\WinSCP\WinSCPnet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BenchControl\Ambient\Comet\Ambient.cs" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentNHibernate" version="1.3.0.733" targetFramework="net40" />
|
||||
<package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
|
||||
<package id="FluentNHibernate" version="2.0.3.0" targetFramework="net40" />
|
||||
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net40" />
|
||||
<package id="log4net" version="2.0.2" targetFramework="net40" />
|
||||
<package id="MySql.Data" version="6.6.5" targetFramework="net20" />
|
||||
<package id="NHibernate" version="3.3.3.4001" targetFramework="net40" />
|
||||
<package id="NHibernate" version="4.0.4.4000" targetFramework="net40" />
|
||||
<package id="System.Data.SQLite" version="1.0.90.0" targetFramework="net40" />
|
||||
</packages>
|
||||
BIN
packages/Renci.SshNet/Renci.SshNet.dll
Normal file
BIN
packages/Renci.SshNet/Renci.SshNet.dll
Normal file
Binary file not shown.
18882
packages/Renci.SshNet/Renci.SshNet.xml
Normal file
18882
packages/Renci.SshNet/Renci.SshNet.xml
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user