aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-31 15:45:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-31 15:45:54 +0300
commite514b66b261c24257b149ecc6aaa52195509a2b5 (patch)
treeae889a11eb88c36e3b70ebe8d83b7e60bc80408b
parenta56427605302770b4c0a71a5ff4da439300a2250 (diff)
downloadTango-e514b66b261c24257b149ecc6aaa52195509a2b5.tar.gz
Tango-e514b66b261c24257b149ecc6aaa52195509a2b5.zip
Working on external bridge.
-rw-r--r--Software/DB/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/Tango_log.ldfbin1835008 -> 1835008 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs7
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs47
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs7
-rw-r--r--Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs2
-rw-r--r--Software/Visual_Studio/Tango.Transport/TransporterBase.cs3
7 files changed, 43 insertions, 23 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf
index 8bc139925..2f7bd7806 100644
--- a/Software/DB/Tango.mdf
+++ b/Software/DB/Tango.mdf
Binary files differ
diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf
index 0581051cd..a6d603748 100644
--- a/Software/DB/Tango_log.ldf
+++ b/Software/DB/Tango_log.ldf
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index 81f47c4ba..d0bddf3f2 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -37,6 +37,7 @@ using Tango.Settings;
using Tango.SharedUI;
using Tango.SharedUI.Controls;
using Tango.SharedUI.Helpers;
+using Tango.Transport;
using Tango.Transport.Adapters;
namespace Tango.MachineStudio.UI.ViewModels
@@ -471,6 +472,12 @@ namespace Tango.MachineStudio.UI.ViewModels
_eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber));
}
+ catch (ResponseErrorException ex)
+ {
+ LogManager.Log(ex);
+ _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Container.ErrorMessage);
+ }
catch (Exception ex)
{
LogManager.Log(ex);
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
index e17a8eb71..99d841dd6 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
@@ -387,35 +387,44 @@ namespace Tango.Integration.ExternalBridge
protected async virtual void OnExternalBridgeLoginRequest(MessageContainer container)
{
+
var request = MessageFactory.ParseTangoMessageFromContainer<ExternalBridgeLoginRequest>(container);
- LogManager.Log(String.Format("External bridge login attempt:{0}{1}", Environment.NewLine, request.ToJsonString()));
+ LogManager.Log(String.Format("External bridge login attempt:{0}{1}", Environment.NewLine, request.Message.ToJsonString()));
- ExternalBridgeClientConnectedEventArgs args = new ExternalBridgeClientConnectedEventArgs();
- args.Request = request;
- args.IpAddress = Adapter.Address;
- ConnectionRequest?.Invoke(this, args);
+ if (MachineOperator.Status != MachineStatuses.Printing || request.Message.Intent != ExternalBridgeLoginIntent.Override)
+ {
+ ExternalBridgeClientConnectedEventArgs args = new ExternalBridgeClientConnectedEventArgs();
+ args.Request = request;
+ args.IpAddress = Adapter.Address;
+ ConnectionRequest?.Invoke(this, args);
- var response = new ExternalBridgeLoginResponse();
- response.Authenticated = args.Confirmed;
- response.SerialNumber = Machine.SerialNumber;
- response.DeviceInformation = MachineOperator.DeviceInformation;
+ var response = new ExternalBridgeLoginResponse();
+ response.Authenticated = args.Confirmed;
+ response.SerialNumber = Machine.SerialNumber;
+ response.DeviceInformation = MachineOperator.DeviceInformation;
- IsInSession = args.Confirmed;
+ IsInSession = args.Confirmed;
- if (IsInSession)
- {
- LogManager.Log("External bridge client has logged-in successfully.");
- MachineOperator.EnableDiagnostics = false;
- MachineOperator.EnableEmbeddedDebugging = false;
- SessionIntent = request.Message.Intent;
+ if (IsInSession)
+ {
+ LogManager.Log("External bridge client has logged-in successfully.");
+ MachineOperator.EnableDiagnostics = false;
+ MachineOperator.EnableEmbeddedDebugging = false;
+ SessionIntent = request.Message.Intent;
+ }
+ else
+ {
+ LogManager.Log("External bridge client login failed, invalid password.");
+ }
+
+ await SendResponse<ExternalBridgeLoginResponse>(response, container.Token);
}
else
{
- LogManager.Log("External bridge client login failed.");
+ LogManager.Log("External bridge client login failed because the machine is currently printing.");
+ await SendResponse<ExternalBridgeLoginResponse>(new ExternalBridgeLoginResponse(), container.Token, false, ErrorCode.GeneralError, "Machine connection override is not permitted while printing.");
}
-
- await SendResponse<ExternalBridgeLoginResponse>(response, container.Token);
}
#endregion
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
index a704d30d1..9492386ed 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
@@ -100,7 +100,12 @@ namespace Tango.Integration.ExternalBridge
catch (Exception ex)
{
LogRequestFailed(login, ex);
- await base.Disconnect();
+ try
+ {
+ await Adapter.Disconnect();
+ }
+ catch { }
+
throw ex;
}
diff --git a/Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs b/Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs
index 81b162eac..3bb5023ca 100644
--- a/Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs
+++ b/Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs
@@ -24,7 +24,7 @@ namespace Tango.Transport
/// Initializes a new instance of the <see cref="ResponseErrorException{T}"/> class.
/// </summary>
/// <param name="error">The error.</param>
- public ResponseErrorException(MessageContainer container) : base("Response " + container.Type.ToString() + " returned with error " + container.Error.ToString() + " - " + container.ErrorMessage)
+ public ResponseErrorException(MessageContainer container) : base(String.Format("{0} has returned with an error ({1}).{2}{3}", container.Type.ToString(), container.Error.ToString(), Environment.NewLine, container.ErrorMessage))
{
Container = container;
}
diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
index a39371372..c67489007 100644
--- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
+++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
@@ -943,8 +943,7 @@ namespace Tango.Transport
}
else
{
- LogManager.Log("Response has returned with error: " + container.Error.ToString(), LogCategory.Warning);
- request.SetException(new ResponseErrorException(container));
+ request.SetException(LogManager.Log(new ResponseErrorException(container), LogCategory.Warning));
}
}
catch (Exception ex)