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.Threading;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using Renci.SshNet;
|
||||||
using Config.Entities;
|
using Config.Entities;
|
||||||
using TBF.BenchControl.Network.Telnet;
|
using TBF.BenchControl.Network.Telnet;
|
||||||
using TBF.Resources;
|
using TBF.Resources;
|
||||||
using WinSCP;
|
|
||||||
|
|
||||||
namespace TBF.BenchControl.Network.Camera.CLP1611
|
namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||||
{
|
{
|
||||||
@ -70,21 +70,21 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
private TerminalDlg terminalDlg;
|
private TerminalDlg terminalDlg;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// WinSCP support
|
/// scp support
|
||||||
///
|
///
|
||||||
Thread wscpThread;
|
Thread scpThread;
|
||||||
SessionOptions wscpSessionOptions;
|
PasswordConnectionInfo connectionInfo;
|
||||||
Session wscpSession;
|
ScpClient scpClient;
|
||||||
bool wscpOpened;
|
bool scpConnected;
|
||||||
bool closeWscpThread;
|
bool closeScpThread;
|
||||||
string wscpSrcFileName;
|
string scpSrcFileName;
|
||||||
string wscpDstFileName;
|
string scpDstFileName;
|
||||||
enum WscpCommand
|
enum ScpCommand
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Get,
|
Get,
|
||||||
}
|
}
|
||||||
WscpCommand wscpCommand;
|
ScpCommand scpCommand;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -200,8 +200,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
//new Thread(new ThreadStart(MeasurementUdpListener)).Start();
|
//new Thread(new ThreadStart(MeasurementUdpListener)).Start();
|
||||||
|
|
||||||
|
|
||||||
wscpThread = new Thread(new ThreadStart(WscpWorker));
|
scpThread = new Thread(new ThreadStart(ScpWorker));
|
||||||
wscpThread.Start();
|
scpThread.Start();
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
|
|
||||||
public void StopDevice()
|
public void StopDevice()
|
||||||
{
|
{
|
||||||
closeWscpThread = true;
|
closeScpThread = true;
|
||||||
|
|
||||||
if (Telnet != null)
|
if (Telnet != null)
|
||||||
{
|
{
|
||||||
@ -223,7 +223,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
Telnet = null;
|
Telnet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wscpThread != null) wscpThread.Join(500);
|
if (scpThread != null) scpThread.Join(500);
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
{
|
{
|
||||||
// if (running)
|
// 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();
|
try
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
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:
|
while (!closeScpThread)
|
||||||
wscpCommand = WscpCommand.None;
|
{
|
||||||
transferResult = wscpSession.GetFiles(wscpSrcFileName, wscpDstFileName, false, transferOptions);
|
switch (scpCommand)
|
||||||
///transferResult.Check();
|
{
|
||||||
|
case ScpCommand.Get:
|
||||||
|
scpCommand = ScpCommand.None;
|
||||||
|
scpClient.Download(scpSrcFileName, new System.IO.FileInfo(scpDstFileName));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Thread.Sleep(250);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Thread.Sleep(250);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wscpSession.Close();
|
scpClient.Disconnect();
|
||||||
wscpOpened = false;
|
scpConnected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,14 +397,14 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
/// <param name="srcFileName"></param>
|
/// <param name="srcFileName"></param>
|
||||||
/// <returns>0 (success), -1 (busy), -2 (no session)</returns>
|
/// <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 (!scpConnected) return -2;
|
||||||
if (wscpCommand != WscpCommand.None) return -1;
|
if (scpCommand != ScpCommand.None) return -1;
|
||||||
|
|
||||||
wscpSrcFileName = srcFileName;
|
scpSrcFileName = srcFileName;
|
||||||
wscpDstFileName = dstFileName;
|
scpDstFileName = dstFileName;
|
||||||
wscpCommand = WscpCommand.Get;
|
scpCommand = ScpCommand.Get;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
/// Grab passed and image transfer is in progress
|
/// Grab passed and image transfer is in progress
|
||||||
return Event.GrabPassed;
|
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
|
/// File transfer successfully started
|
||||||
transferringGrabbedImage = true;
|
transferringGrabbedImage = true;
|
||||||
@ -142,7 +142,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
///
|
///
|
||||||
/// Start the file transfer
|
/// 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
|
/// File transfer successfully started
|
||||||
transferringGrabbedImage = true;
|
transferringGrabbedImage = true;
|
||||||
|
|||||||
@ -128,7 +128,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
|||||||
/// ROI detection passed and image transfer is in progress
|
/// ROI detection passed and image transfer is in progress
|
||||||
return Event.RoiDetectionPassed;
|
return Event.RoiDetectionPassed;
|
||||||
}
|
}
|
||||||
else if (0 == camera.WscpTransferFile("detected.jpg", detectedImageName))
|
else if (0 == camera.TransferFileViaScp("detected.jpg", detectedImageName))
|
||||||
{
|
{
|
||||||
/// File transfer successfully started
|
/// File transfer successfully started
|
||||||
transferringDetectedImage = true;
|
transferringDetectedImage = true;
|
||||||
@ -179,7 +179,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
|||||||
///
|
///
|
||||||
/// Start the file transfer
|
/// Start the file transfer
|
||||||
///
|
///
|
||||||
if (0 == camera.WscpTransferFile("detected.jpg", detectedImageName))
|
if (0 == camera.TransferFileViaScp("detected.jpg", detectedImageName))
|
||||||
{
|
{
|
||||||
/// File transfer successfully started
|
/// File transfer successfully started
|
||||||
transferringDetectedImage = true;
|
transferringDetectedImage = true;
|
||||||
|
|||||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.16.650.1")]
|
[assembly: AssemblyVersion("2.16.651.1")]
|
||||||
[assembly: AssemblyFileVersion("2.16.650.1")]
|
[assembly: AssemblyFileVersion("2.16.651.1")]
|
||||||
|
|||||||
@ -126,6 +126,9 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Oracle\Oracle.DataAccess.dll</HintPath>
|
<HintPath>..\packages\Oracle\Oracle.DataAccess.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Renci.SshNet">
|
||||||
|
<HintPath>..\packages\Renci.SshNet\Renci.SshNet.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
@ -134,9 +137,6 @@
|
|||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="WinSCPnet">
|
|
||||||
<HintPath>..\packages\WinSCP\WinSCPnet.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BenchControl\Ambient\Comet\Ambient.cs" />
|
<Compile Include="BenchControl\Ambient\Comet\Ambient.cs" />
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="FluentNHibernate" version="1.3.0.733" targetFramework="net40" />
|
<package id="FluentNHibernate" version="2.0.3.0" targetFramework="net40" />
|
||||||
<package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
|
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net40" />
|
||||||
<package id="log4net" version="2.0.2" targetFramework="net40" />
|
<package id="log4net" version="2.0.2" targetFramework="net40" />
|
||||||
<package id="MySql.Data" version="6.6.5" targetFramework="net20" />
|
<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" />
|
<package id="System.Data.SQLite" version="1.0.90.0" targetFramework="net40" />
|
||||||
</packages>
|
</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