aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-25 06:02:06 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-25 06:02:06 +0200
commite3f44f81af2cc5a650041d06fe2106937af03560 (patch)
tree82c9906491d02fe2d0e770d382dc687479159cd8 /Software/Visual_Studio
parent838378bae2944477177a4af641c356976173d8f6 (diff)
downloadTango-e3f44f81af2cc5a650041d06fe2106937af03560.tar.gz
Tango-e3f44f81af2cc5a650041d06fe2106937af03560.zip
Several bug fixes.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs4
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs45
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs5
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs9
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs20
-rw-r--r--Software/Visual_Studio/Tango.PMR/Integration/UpdateStatus.cs29
-rw-r--r--Software/Visual_Studio/Tango.Transport/ITransporter.cs7
-rw-r--r--Software/Visual_Studio/Tango.Transport/TransporterBase.cs16
-rw-r--r--Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs8
11 files changed, 108 insertions, 39 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
index d76acd60e..c97837fcf 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
@@ -337,7 +337,9 @@ namespace Tango.FSE.UI.Connection
if (MachineOperator is ExternalBridgeTcpClient)
{
- (MachineOperator as ExternalBridgeTcpClient).EnableApplicationLogs = true;
+ ExternalBridgeTcpClient tcpClient = MachineOperator as ExternalBridgeTcpClient;
+ tcpClient.EnableApplicationLogs = true;
+ tcpClient.InjectApplicationLogsToDefaultLogManager = false;
}
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
index b13b797e9..6f25e1774 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
@@ -25,7 +25,8 @@ namespace Tango.FSE.UI.FileSystem
private BasicTransporter _webRtcTransporter;
private const string WEB_RTC_CHANNEL_NAME = "FileSystemChannel";
private const long MAX_CHUNK_SIZE = 1024 * 10;
- private const long MAX_CHUNK_SIZE_WEB_RTC = 1024 * 15;
+ private const long MAX_CHUNK_SIZE_WEB_RTC = 1024 * 50;
+ private const int WEB_RTC_MAX_RETRIES = 8;
private List<FileSystemHandler> _activeHandlers;
private bool _enableWebRTC;
@@ -52,7 +53,7 @@ namespace Tango.FSE.UI.FileSystem
_machineProvider.MachineDisconnected += _machineProvider_MachineDisconnected;
}
- private void _machineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e)
+ private async void _machineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e)
{
IsWebRtcAvailable = false;
@@ -69,6 +70,19 @@ namespace Tango.FSE.UI.FileSystem
}
_activeHandlers.Clear();
+
+ if (_webRtcTransporter != null)
+ {
+ try
+ {
+ LogManager.Log("Machine disconnected. Disconnecting FileSystem WebRTC Transporter...");
+ await _webRtcTransporter.Disconnect();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error while disconnecting FileSystem WebRTC Transporter.");
+ }
+ }
}
private async void _machineProvider_MachineConnected(object sender, MachineConnectedEventArgs e)
@@ -100,8 +114,6 @@ namespace Tango.FSE.UI.FileSystem
catch (Exception ex)
{
IsWebRtcAvailable = false;
- EnableWebRTC = false;
-
LogManager.Log(ex, "Error initializing FileSystem via WebRTC.");
}
}
@@ -226,6 +238,7 @@ namespace Tango.FSE.UI.FileSystem
long position = 0;
bool webRtcFailed = false;
+ int webRtcRetries = WEB_RTC_MAX_RETRIES;
var tempFile = TemporaryManager.CreateFile();
@@ -252,18 +265,34 @@ namespace Tango.FSE.UI.FileSystem
try
{
request.MaxChunkSize = MAX_CHUNK_SIZE_WEB_RTC;
- response = await _webRtcTransporter.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30), Priority = QueuePriority.Low });
+ response = await _webRtcTransporter.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig()
+ {
+ Timeout = TimeSpan.FromSeconds(2),
+ Priority = QueuePriority.Low
+ });
+
+ webRtcRetries = WEB_RTC_MAX_RETRIES;
}
catch (Exception ex)
{
- webRtcFailed = true;
- LogManager.Log(ex, "WebRTC chunk download failed. Falling back to standard download...");
+ webRtcRetries--;
+
+ if (webRtcRetries == 0)
+ {
+ webRtcFailed = true;
+ LogManager.Log(ex, "WebRTC chunk download failed. Falling back to standard download...");
+ }
+
continue;
}
}
else
{
- response = await _machineProvider.MachineOperator.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30), Priority = QueuePriority.Low });
+ response = await _machineProvider.MachineOperator.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig()
+ {
+ Timeout = TimeSpan.FromSeconds(30),
+ Priority = QueuePriority.Low
+ });
}
using (FileStream fs = new FileStream(tempFile, FileMode.Append))
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs
index c9b5d8bbb..69184290a 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs
@@ -31,7 +31,10 @@ namespace Tango.FSE.UI.Performance
OnPerformancePackageAvailable(response.Package);
}, (ex) =>
{
- LogManager.Log(ex, "Error starting performance updates.");
+ if (!(ex is Transport.TransporterDisconnectedException))
+ {
+ LogManager.Log(ex, "Error starting performance updates.");
+ }
}, () =>
{
//Do nothing.
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
index ded395e08..128a93548 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
@@ -56,7 +56,7 @@
<DataTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Image Stretch="Fill" Width="32" Height="32" RenderOptions.BitmapScalingMode="Fant" Source="../Images/NewJob/twine.png"></Image>
- <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Text="{Binding Name}"></TextBlock>
+ <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" TextAlignment="Center" Text="{Binding Name}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"></TextBlock>
</StackPanel>
</DataTemplate>
</touch:TouchStaticListBox.ItemTemplate>
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs
index fa6d37377..96c2ea4c4 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs
@@ -256,6 +256,7 @@ namespace Tango.Integration.Operation
internal void RaiseCompleted()
{
//This will compensate on any missing progress from Shlomo, but also will tell the wrong progress if job is really completed with a large progress mistake.
+ // Might be worth to compensate only on small drifts like the below (ProgressMinusSettingsUp)...
//InvalidateJobProgress(new JobStatus()
//{
// Progress = Status.TotalProgress,
@@ -263,6 +264,14 @@ namespace Tango.Integration.Operation
//});
LogManager.Log($"Job completed at position {Status.Progress}/{Status.TotalProgress}...");
+
+ //If drift is smaller than 10cm auto correct it.
+ if (Math.Abs(Status.TotalProgressMinusSettingUp - Status.ProgressMinusSettingUp) < 0.1)
+ {
+ LogManager.Log($"Job completed with a small drift in the progress minus settings up calculation. ({Status.ProgressMinusSettingUp}/{Status.TotalProgressMinusSettingUp}). Compensating...");
+ Status.ProgressMinusSettingUp = Status.TotalProgressMinusSettingUp;
+ }
+
Status.Segments.Last().Completed = true;
Status.RemainingUnits = 0;
Status.IsFinalizing = false;
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index b29ffd6e3..cad9f80c7 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -2329,6 +2329,7 @@ namespace Tango.Integration.Operation
if (handler.CanCancel)
{
handler.CanCancel = false;
+ handler.IsCanceled = true;
LogManager.Log("Aborting current job...");
LogManager.Log($"Aborting current gradient generation...");
GradientGenerationConfiguration.AbortCurrentGeneration();
@@ -2351,7 +2352,6 @@ namespace Tango.Integration.Operation
if (requestSent)
{
var result = await SendRequest<AbortJobRequest, AbortJobResponse>(new AbortJobRequest(), new TransportRequestConfig() { ShouldLog = true });
- handler.IsCanceled = true;
}
SaveLastJobLiquidQuantities(clonedJob, originalJob.Machine.Configuration, processParameters, handler);
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs
index d9a5d9f3f..fb21b27fa 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs
@@ -10,24 +10,24 @@ namespace Tango.Integration.Operation
public enum MachineStatuses
{
[Description("Disconnected")]
- Disconnected,
+ Disconnected = 0,
[Description("Getting Ready")]
- PowerUp,
+ PowerUp = 1,
[Description("Standby")]
- Standby,
+ Standby = 2,
[Description("Ready To Dye")]
- ReadyToDye,
+ ReadyToDye = 3,
[Description("Getting Ready")]
- GettingReady,
+ GettingReady = 4,
[Description("Dyeing")]
- Printing,
+ Printing = 5,
[Description("Service")]
- Service,
+ Service = 6,
[Description("Upgrading")]
- Upgrading,
+ Upgrading = 7,
[Description("Shutting Down")]
- ShuttingDown,
+ ShuttingDown = 8,
[Description("Error")]
- Error,
+ Error = 9,
}
}
diff --git a/Software/Visual_Studio/Tango.PMR/Integration/UpdateStatus.cs b/Software/Visual_Studio/Tango.PMR/Integration/UpdateStatus.cs
index b15f24799..bdf5fba08 100644
--- a/Software/Visual_Studio/Tango.PMR/Integration/UpdateStatus.cs
+++ b/Software/Visual_Studio/Tango.PMR/Integration/UpdateStatus.cs
@@ -22,12 +22,12 @@ namespace Tango.PMR.Integration {
static UpdateStatusReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
- "ChJVcGRhdGVTdGF0dXMucHJvdG8SFVRhbmdvLlBNUi5JbnRlZ3JhdGlvbiqW",
- "AQoMVXBkYXRlU3RhdHVzEhAKDERpc2Nvbm5lY3RlZBAAEgsKB1N0YW5kYnkQ",
- "ARIOCgpSZWFkeVRvRHllEAISEAoMR2V0dGluZ1JlYWR5EAMSDAoIUHJpbnRp",
- "bmcQBBILCgdTZXJ2aWNlEAUSDQoJVXBncmFkaW5nEAYSEAoMU2h1dHRpbmdE",
- "b3duEAcSCQoFRXJyb3IQCEIhCh9jb20udHdpbmUudGFuZ28ucG1yLmludGVn",
- "cmF0aW9uYgZwcm90bzM="));
+ "ChJVcGRhdGVTdGF0dXMucHJvdG8SFVRhbmdvLlBNUi5JbnRlZ3JhdGlvbiqj",
+ "AQoMVXBkYXRlU3RhdHVzEhAKDERpc2Nvbm5lY3RlZBAAEgsKB1Bvd2VyVXAQ",
+ "ARILCgdTdGFuZGJ5EAISDgoKUmVhZHlUb0R5ZRADEhAKDEdldHRpbmdSZWFk",
+ "eRAEEgwKCFByaW50aW5nEAUSCwoHU2VydmljZRAGEg0KCVVwZ3JhZGluZxAH",
+ "EhAKDFNodXR0aW5nRG93bhAIEgkKBUVycm9yEAlCIQofY29tLnR3aW5lLnRh",
+ "bmdvLnBtci5pbnRlZ3JhdGlvbmIGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Integration.UpdateStatus), }, null));
@@ -38,14 +38,15 @@ namespace Tango.PMR.Integration {
#region Enums
public enum UpdateStatus {
[pbr::OriginalName("Disconnected")] Disconnected = 0,
- [pbr::OriginalName("Standby")] Standby = 1,
- [pbr::OriginalName("ReadyToDye")] ReadyToDye = 2,
- [pbr::OriginalName("GettingReady")] GettingReady = 3,
- [pbr::OriginalName("Printing")] Printing = 4,
- [pbr::OriginalName("Service")] Service = 5,
- [pbr::OriginalName("Upgrading")] Upgrading = 6,
- [pbr::OriginalName("ShuttingDown")] ShuttingDown = 7,
- [pbr::OriginalName("Error")] Error = 8,
+ [pbr::OriginalName("PowerUp")] PowerUp = 1,
+ [pbr::OriginalName("Standby")] Standby = 2,
+ [pbr::OriginalName("ReadyToDye")] ReadyToDye = 3,
+ [pbr::OriginalName("GettingReady")] GettingReady = 4,
+ [pbr::OriginalName("Printing")] Printing = 5,
+ [pbr::OriginalName("Service")] Service = 6,
+ [pbr::OriginalName("Upgrading")] Upgrading = 7,
+ [pbr::OriginalName("ShuttingDown")] ShuttingDown = 8,
+ [pbr::OriginalName("Error")] Error = 9,
}
#endregion
diff --git a/Software/Visual_Studio/Tango.Transport/ITransporter.cs b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
index 1187b2684..15a864a0a 100644
--- a/Software/Visual_Studio/Tango.Transport/ITransporter.cs
+++ b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
@@ -44,6 +44,13 @@ namespace Tango.Transport
void RegisterRequestHandler<Request>(RequestHandlerCallbackDelegate<Request> callback) where Request : class;
/// <summary>
+ /// Unregisters a custom request handler.
+ /// </summary>
+ /// <typeparam name="Request">The type of the request.</typeparam>
+ /// <param name="callback">The callback.</param>
+ void UnregisterRequestHandler<Request>(RequestHandlerCallbackDelegate<Request> callback) where Request : class;
+
+ /// <summary>
/// Copies this instance request handlers to the specified instance.
/// </summary>
/// <param name="transporter">The transporter to copy the handlers to.</param>
diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
index 11ce20b0a..916992bc3 100644
--- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
+++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
@@ -38,6 +38,7 @@ namespace Tango.Transport
{
public Type RequestType { get; set; }
public Action<ITransporter, Object, String> Callback { get; set; }
+ public object RegisteredCallback { get; set; }
}
private const int MESSAGE_TOKEN_LENGTH = 36;
@@ -1216,6 +1217,7 @@ namespace Tango.Transport
{
RequestHandler handler = new RequestHandler();
handler.RequestType = typeof(Request);
+ handler.RegisteredCallback = callback;
handler.Callback = (transporter, obj, token) =>
{
callback?.Invoke(transporter, obj as Request, token);
@@ -1225,6 +1227,20 @@ namespace Tango.Transport
}
/// <summary>
+ /// Unregisters a custom request handler.
+ /// </summary>
+ /// <typeparam name="Request">The type of the request.</typeparam>
+ /// <param name="callback">The callback.</param>
+ public void UnregisterRequestHandler<Request>(RequestHandlerCallbackDelegate<Request> callback) where Request : class
+ {
+ var handler = _requestHandlers.FirstOrDefault(x => (x.RegisteredCallback as RequestHandlerCallbackDelegate<Request>) == callback);
+ if (handler != null)
+ {
+ _requestHandlers.Remove(handler);
+ }
+ }
+
+ /// <summary>
/// Copies this instance request handlers to the specified instance.
/// </summary>
/// <param name="transporter">The transporter to copy the handlers to.</param>
diff --git a/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs b/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs
index 850ddb3de..d0bfc886d 100644
--- a/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs
+++ b/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs
@@ -246,16 +246,16 @@ namespace Tango.WebRTC
{
try
{
- LogManager.Log("Ice candidate request received from the remote peer.");
+ LogManager.Log($"{ComponentName}: Ice candidate request received from the remote peer.");
await SignalingTransporter.SendGenericResponse(new IceCandidateResponse() { }, token);
LogManager.Log("Adding ice candidate...");
_client.AddIceCandidate(request.IceCandidate);
- LogManager.Log("Ice candidate added.");
+ LogManager.Log($"{ComponentName}: Ice candidate added.");
}
catch (Exception ex)
{
- LogManager.Log(ex, "Error occurred on ice candidate received handling.");
+ LogManager.Log(ex, $"{ComponentName}: Error occurred on ice candidate received handling.");
}
}
@@ -284,6 +284,8 @@ namespace Tango.WebRTC
{
_client.Dispose();
_client = null;
+ SignalingTransporter.UnregisterRequestHandler<IceCandidateRequest>(OnIceCandidateRequestReceived);
+ SignalingTransporter.UnregisterRequestHandler<OfferRequest>(OnOfferRequestReceived);
LogManager.Log("WebRTC client disposed.");
}
catch (Exception ex)