aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-04-24 14:01:40 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-04-24 14:01:40 +0300
commitafca405892ace809c498c010a2d4484bec5adf11 (patch)
treee3a1640a7ff89ecc0d246287a4281efe616f5715 /Software/Visual_Studio/Tango.Integration
parent636ad730569dfef1a4ee04c8d716d510bcc47ee1 (diff)
downloadTango-afca405892ace809c498c010a2d4484bec5adf11.tar.gz
Tango-afca405892ace809c498c010a2d4484bec5adf11.zip
Implemented USB adapter finalizer.
Added exception logging for USB adapter disconnection error. Added Volume color space icon to PPC. Implemented KeepAlive suppression on StorageAPI. Suppressed KeepAlive when uploading job. Implemented keep alive skipping when arrived responses queue is busy.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs3
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs81
3 files changed, 84 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
index 2f63ca3b3..b84942643 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Globalization;
using System.IO.Ports;
using System.Linq;
@@ -130,6 +131,7 @@ namespace Tango.Integration.ExternalBridge
/// <summary>
/// TCP discovery thread method.
/// </summary>
+ [DebuggerStepThrough]
private void TcpDiscoveryThreadMethod()
{
while (IsStarted)
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 4f7c4c619..ea3e6b8a0 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -1457,6 +1457,9 @@ namespace Tango.Integration.Operation
var storage = CreateStorageManager();
+ //Suppress keep alive while job uploads.
+ storage.SuppressKeepAliveWhileFileUploads = true;
+
var storageInfo = await storage.GetStorageDrive();
var root_folder = await storage.GetRootFolder();
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
index 6f04cd0f3..623e331d0 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
@@ -32,6 +32,9 @@ namespace Tango.Integration.Storage
}
private StorageFolder _currentFolder;
+ /// <summary>
+ /// Gets or sets the current folder.
+ /// </summary>
public StorageFolder CurrentFolder
{
get { return _currentFolder; }
@@ -39,12 +42,20 @@ namespace Tango.Integration.Storage
}
private StorageDrive _storageDrive;
+ /// <summary>
+ /// Gets or sets the storage drive.
+ /// </summary>
public StorageDrive StorageDrive
{
get { return _storageDrive; }
set { _storageDrive = value; RaisePropertyChangedAuto(); }
}
+ /// <summary>
+ /// Gets or sets a value indicating whether to disable the transporter keep alive mechanism while a file is being uploaded.
+ /// </summary>
+ public bool SuppressKeepAliveWhileFileUploads { get; set; }
+
#endregion
#region Constructor
@@ -107,6 +118,12 @@ namespace Tango.Integration.Storage
#endregion
+ #region Public Methods
+
+ /// <summary>
+ /// Gets the storage drive information.
+ /// </summary>
+ /// <returns></returns>
public async Task<StorageDrive> GetStorageDrive()
{
EnsureTransporter();
@@ -134,6 +151,10 @@ namespace Tango.Integration.Storage
return StorageDrive;
}
+ /// <summary>
+ /// Gets the root folder of the current storage driver.
+ /// </summary>
+ /// <returns></returns>
public Task<StorageFolder> GetRootFolder()
{
return GetFolder(new StorageFolder()
@@ -142,11 +163,21 @@ namespace Tango.Integration.Storage
});
}
+ /// <summary>
+ /// Gets the specified folder information.
+ /// </summary>
+ /// <param name="folder">The folder.</param>
+ /// <returns></returns>
public Task<StorageFolder> GetFolder(StorageFolder folder)
{
return GetFolder(folder.Path);
}
+ /// <summary>
+ /// Gets the specified path folder information.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <returns></returns>
public async Task<StorageFolder> GetFolder(String path)
{
EnsureTransporter();
@@ -201,6 +232,13 @@ namespace Tango.Integration.Storage
return sf;
}
+ /// <summary>
+ /// Uploads the specified file stream to the specified destination path.
+ /// Returns a file handler for keeping track on the upload progress.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <param name="stream">The stream.</param>
+ /// <returns></returns>
public async Task<StorageFileHandler> UploadFile(String path, Stream stream)
{
FileUploadRequest request = new FileUploadRequest();
@@ -226,8 +264,15 @@ namespace Tango.Integration.Storage
ThreadFactory.StartNew(() =>
{
+ bool oldKeepAlive = _transporter.UseKeepAlive;
+
try
{
+ if (SuppressKeepAliveWhileFileUploads)
+ {
+ _transporter.UseKeepAlive = false;
+ }
+
while (stream.Position < stream.Length)
{
if (!canceled)
@@ -267,23 +312,36 @@ namespace Tango.Integration.Storage
{
handler.RaiseFailed(ex);
}
+ finally
+ {
+ if (SuppressKeepAliveWhileFileUploads)
+ {
+ _transporter.UseKeepAlive = oldKeepAlive;
+ }
+ }
});
return handler;
}
+ /// <summary>
+ /// Uploads the specified file stream to the specified destination path.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <param name="stream">The stream.</param>
+ /// <returns></returns>
public async Task UploadFileSync(String path, Stream stream)
{
TaskCompletionSource<object> source = new TaskCompletionSource<object>();
var handler = await UploadFile(path, stream);
- handler.Completed += (_, __) =>
+ handler.Completed += (_, __) =>
{
source.SetResult(true);
};
- handler.Failed += (_, ex) =>
+ handler.Failed += (_, ex) =>
{
source.SetException(ex);
};
@@ -291,6 +349,13 @@ namespace Tango.Integration.Storage
await source.Task;
}
+ /// <summary>
+ /// Downloads the specified storage file to the specified stream.
+ /// Returns a file handler for keeping track on the download progress.
+ /// </summary>
+ /// <param name="file">The file.</param>
+ /// <param name="stream">The stream.</param>
+ /// <returns></returns>
public async Task<StorageFileHandler> DownloadFile(StorageFile file, Stream stream)
{
FileDownloadRequest request = new FileDownloadRequest();
@@ -359,6 +424,11 @@ namespace Tango.Integration.Storage
return handler;
}
+ /// <summary>
+ /// Deletes the specified storage item.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <returns></returns>
public async Task DeleteItem(StorageItem item)
{
await _transporter.SendRequest<DeleteRequest, DeleteResponse>(new DeleteRequest()
@@ -368,6 +438,11 @@ namespace Tango.Integration.Storage
});
}
+ /// <summary>
+ /// Creates a new folder on the specified destination path.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <returns></returns>
public async Task CreateFolder(String path)
{
await _transporter.SendRequest<CreateRequest, CreateResponse>(new CreateRequest()
@@ -376,5 +451,7 @@ namespace Tango.Integration.Storage
Attribute = FileAttribute.Directory,
});
}
+
+ #endregion
}
}