aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/ExternalBridge
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-05 20:38:47 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-05 20:38:47 +0300
commit822707058d3fe957e03887a3969d553a65537031 (patch)
treea40546d5cd0c32a83cf548e2ce0bd54c46d932bc /Software/Visual_Studio/Tango.Integration/ExternalBridge
parent5571ab086f6288b27117e3eaae443415a162403c (diff)
downloadTango-822707058d3fe957e03887a3969d553a65537031.tar.gz
Tango-822707058d3fe957e03887a3969d553a65537031.zip
Improved safety operations handling from ExternalBridgeReceiver.
Suppress firmware upgrade on remote upgrade feature.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/ExternalBridge')
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs33
1 files changed, 30 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs
index 9c61f9e8b..f3d8711f1 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs
@@ -23,6 +23,13 @@ namespace Tango.Integration.ExternalBridge
{
public class ExternalBridgeReceiver : BasicTransporter
{
+ /// <summary>
+ /// A dictionary containing the last time a user name has made a request or response.
+ /// This is used to bypass the safety operations confirmation.
+ /// FullName, Contact Time
+ /// </summary>
+ public static Dictionary<String,DateTime> LastSafetyLevelContactsTimes { get; private set; }
+
#region Message Handler
private class MessageHandler
@@ -53,7 +60,7 @@ namespace Tango.Integration.ExternalBridge
private IMachineOperator _machineOperator;
private Dictionary<MessageType, MessageHandler> _messageHandlers;
- private HashSet<MessageType> _safetyOperations;
+ private static HashSet<MessageType> _safetyOperations; //Static list containing all safety operations.
#region Events
@@ -76,6 +83,7 @@ namespace Tango.Integration.ExternalBridge
public bool IsLoggedIn { get; private set; }
public ExternalBridgeLoginIntent LoginIntent { get; private set; }
+ public String UserName { get; set; }
public bool IsLoggedInAndRequiresDiagnostics
{
@@ -87,6 +95,12 @@ namespace Tango.Integration.ExternalBridge
#region Constructors
+ static ExternalBridgeReceiver()
+ {
+ LastSafetyLevelContactsTimes = new Dictionary<string, DateTime>();
+ _safetyOperations = new HashSet<MessageType>(); //TODO: initialize this from some repository of messages..
+ }
+
public ExternalBridgeReceiver(IMachineOperator machineOperator)
{
ComponentName = $"External Bridge Receiver {_component_counter++}";
@@ -123,8 +137,6 @@ namespace Tango.Integration.ExternalBridge
_messageHandlers.Add(MessageType.JobRequest, new MessageHandler(OnJobRequest, ExternalBridgeLoginIntent.Diagnostics));
_messageHandlers.Add(MessageType.StartPowerDownRequest, new MessageHandler(OnStartPowerDownRequest, ExternalBridgeLoginIntent.Diagnostics));
-
- _safetyOperations = new HashSet<MessageType>();
}
public ExternalBridgeReceiver(TcpClient tcpClient, IMachineOperator machineOperator) : this(machineOperator)
@@ -155,6 +167,13 @@ namespace Tango.Integration.ExternalBridge
return;
}
}
+ else
+ {
+ if (UserName != null)
+ {
+ LastSafetyLevelContactsTimes[UserName] = DateTime.Now;
+ }
+ }
if (_messageHandlers.ContainsKey(container.Type))
{
@@ -275,6 +294,7 @@ namespace Tango.Integration.ExternalBridge
IsLoggedIn = true;
LoginIntent = request.Message.Intent;
+ UserName = request.Message.UserName;
var response = new ExternalBridgeLoginResponse();
response.Authenticated = true;
@@ -289,6 +309,8 @@ namespace Tango.Integration.ExternalBridge
UpdateMachineOperatorStatus((UpdateStatus)_machineOperator.Status);
UseKeepAlive = true;
+
+ LastSafetyLevelContactsTimes[UserName] = DateTime.Now;
},
(reason) =>
{
@@ -511,6 +533,11 @@ namespace Tango.Integration.ExternalBridge
{
try
{
+ if (AllowSafetyLevelOperations && UserName != null) //Usually all clients require diagnostics so we will update the last contact time here..
+ {
+ LastSafetyLevelContactsTimes[UserName] = DateTime.Now;
+ }
+
if (_diagnosticsToken != null)
{
var cloned = container.Clone();