aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-12-19 18:01:01 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-12-19 18:01:01 +0200
commit1208554e06da8aec1b074932df488769572ffcfb (patch)
tree9858ededeb8badda5fc8b3052ef9745e419f35fd /Software/Visual_Studio/Tango.Integration
parent690604e6167bfa4fea0ab02f8b24a68142e8b546 (diff)
downloadTango-1208554e06da8aec1b074932df488769572ffcfb.tar.gz
Tango-1208554e06da8aec1b074932df488769572ffcfb.zip
Implemented auto thread loading.
Implemented advanced settings for technician. Implemented thread loading on emulator. Removed PowerUpSelectedRML from settings. Now using LoadedRml settings for ThreadLoading and PowerUp.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs1
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs31
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs170
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/ThreadLoadingConfirmationRequiredEventArgs.cs27
-rw-r--r--Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj3
5 files changed, 226 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
index 3bbef3eb6..d3344aa16 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
@@ -133,6 +133,7 @@ namespace Tango.Integration.ExternalBridge
OnEnableEventsNotification(EnableEventsNotification);
OnEnableApplicationLogsChanged(EnableApplicationLogs);
OnEnableMachineStatusUpdatesChanged(EnableMachineStatusUpdates);
+ OnEnableAutomaticThreadLoadingChanged(EnableAutomaticThreadLoading);
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs
index b5b7b7393..8156ef8c7 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs
@@ -23,6 +23,7 @@ using Tango.PMR.FirmwareUpgrade;
using Tango.Integration.JobRuns;
using Tango.Integration.Emergency;
using Tango.PMR.MachineStatus;
+using Tango.PMR.ThreadLoading;
namespace Tango.Integration.Operation
{
@@ -64,6 +65,11 @@ namespace Tango.Integration.Operation
MachineStatus MachineStatus { get; }
/// <summary>
+ /// Gets the current thread loading status.
+ /// </summary>
+ StartThreadLoadingResponse ThreadLoadingStatus { get; }
+
+ /// <summary>
/// Gets or sets the firmware upgrade mode.
/// </summary>
FirmwareUpgradeModes FirmwareUpgradeMode { get; set; }
@@ -199,6 +205,26 @@ namespace Tango.Integration.Operation
event EventHandler<PowerDownStartedEventArgs> PowerDownStarted;
/// <summary>
+ /// Occurs when the thread loading status has changed.
+ /// </summary>
+ event EventHandler<StartThreadLoadingResponse> ThreadLoadingStatusChanged;
+
+ /// <summary>
+ /// Occurs when a thread loading confirmation is required.
+ /// </summary>
+ event EventHandler<ThreadLoadingConfirmationRequiredEventArgs> ThreadLoadingConfirmationRequired;
+
+ /// <summary>
+ /// Occurs when thread loading has completed.
+ /// </summary>
+ event EventHandler<StartThreadLoadingResponse> ThreadLoadingCompleted;
+
+ /// <summary>
+ /// Occurs when thread loading has failed.
+ /// </summary>
+ event EventHandler<StartThreadLoadingResponse> ThreadLoadingFailed;
+
+ /// <summary>
/// Gets or sets a value indicating whether direct the embedded device to send diagnostics messages.
/// </summary>
bool EnableDiagnostics { get; set; }
@@ -224,6 +250,11 @@ namespace Tango.Integration.Operation
bool EnableMachineStatusUpdates { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether to enable automatic thread loading support.
+ /// </summary>
+ bool EnableAutomaticThreadLoading { get; set; }
+
+ /// <summary>
/// Gets the last process parameters table sent to the embedded device.
/// </summary>
ProcessParametersTable CurrentProcessParameters { get; }
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index e142066b6..74c64930b 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -42,6 +42,7 @@ using Newtonsoft.Json;
using Tango.PMR.Integration;
using System.Globalization;
using Tango.PMR.Power;
+using Tango.PMR.ThreadLoading;
namespace Tango.Integration.Operation
{
@@ -68,6 +69,7 @@ namespace Tango.Integration.Operation
private bool _eventsSent;
private bool _debugSent;
private bool _machineStatusSent;
+ private bool _threadLoadingSent;
private EmbeddedLogItem _last_embedded_debug_log;
private static RunningJobStatus _last_job_status;
private bool _isPowerDownRequestInProgress;
@@ -224,6 +226,26 @@ namespace Tango.Integration.Operation
/// </summary>
public event EventHandler<PowerDownStartedEventArgs> PowerDownStarted;
+ /// <summary>
+ /// Occurs when the thread loading status has changed.
+ /// </summary>
+ public event EventHandler<StartThreadLoadingResponse> ThreadLoadingStatusChanged;
+
+ /// <summary>
+ /// Occurs when a thread loading confirmation is required.
+ /// </summary>
+ public event EventHandler<ThreadLoadingConfirmationRequiredEventArgs> ThreadLoadingConfirmationRequired;
+
+ /// <summary>
+ /// Occurs when thread loading has completed.
+ /// </summary>
+ public event EventHandler<StartThreadLoadingResponse> ThreadLoadingCompleted;
+
+ /// <summary>
+ /// Occurs when thread loading has failed.
+ /// </summary>
+ public event EventHandler<StartThreadLoadingResponse> ThreadLoadingFailed;
+
#endregion
#region Properties
@@ -271,7 +293,17 @@ namespace Tango.Integration.Operation
public MachineStatus MachineStatus
{
get { return _machineStatus; }
- set { _machineStatus = value; RaisePropertyChangedAuto(); }
+ private set { _machineStatus = value; RaisePropertyChangedAuto(); }
+ }
+
+ private StartThreadLoadingResponse _threadLoadingStatus;
+ /// <summary>
+ /// Gets the current thread loading status.
+ /// </summary>
+ public StartThreadLoadingResponse ThreadLoadingStatus
+ {
+ get { return _threadLoadingStatus; }
+ private set { _threadLoadingStatus = value; RaisePropertyChangedAuto(); }
}
/// <summary>
@@ -409,6 +441,21 @@ namespace Tango.Integration.Operation
}
}
+ private bool _enableAutomaticThreadLoading;
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable automatic thread loading support.
+ /// </summary>
+ public bool EnableAutomaticThreadLoading
+ {
+ get { return _enableAutomaticThreadLoading; }
+ set
+ {
+ _enableAutomaticThreadLoading = value;
+ RaisePropertyChangedAuto();
+ OnEnableAutomaticThreadLoadingChanged(value);
+ }
+ }
+
private bool _enableJobResume;
/// <summary>
/// Gets or sets a value indicating whether to check whether a job is in progress after connection was successful.
@@ -745,6 +792,65 @@ namespace Tango.Integration.Operation
}
}
+ protected virtual async void OnEnableAutomaticThreadLoadingChanged(bool value)
+ {
+ if (value && State == TransportComponentState.Connected && !_threadLoadingSent)
+ {
+ var request = new StartThreadLoadingRequest();
+
+ bool responseLogged = false;
+ _threadLoadingSent = true;
+
+ SendContinuousRequest<StartThreadLoadingRequest, StartThreadLoadingResponse>(request).ObserveOn(new NewThreadScheduler()).Subscribe(
+ (response) =>
+ {
+ OnThreadLoadingStatusChanged(response);
+
+ if (!responseLogged)
+ {
+ LogResponseReceived(response.Message);
+ responseLogged = true;
+ }
+ },
+ (ex) =>
+ {
+ _threadLoadingSent = false;
+
+ if (!(ex is ContinuousResponseAbortedException))
+ {
+ LogRequestFailed(request, ex);
+ }
+ },
+ () =>
+ {
+ _threadLoadingSent = false;
+ LogManager.Log("Thread loading response completed!?", LogCategory.Warning);
+ });
+
+ LogRequestSent(request);
+ }
+ else if (_threadLoadingSent)
+ {
+ _threadLoadingSent = false;
+
+ if (State == TransportComponentState.Connected)
+ {
+ var req = new StopThreadLoadingRequest();
+
+ try
+ {
+ LogRequestSent(req);
+ var res = await SendRequest<StopThreadLoadingRequest, StopThreadLoadingResponse>(req);
+ LogResponseReceived(res.Message);
+ }
+ catch (Exception ex)
+ {
+ LogRequestFailed(req, ex);
+ }
+ }
+ }
+ }
+
/// <summary>
/// Invokes the <see cref="DiagnosticsDataAvailable"/> event.
/// </summary>
@@ -797,7 +903,7 @@ namespace Tango.Integration.Operation
}
/// <summary>
- /// Called when the machine status has been update
+ /// Called when the machine status has been updated.
/// </summary>
/// <param name="response">The response.</param>
protected async virtual void OnMachineStatusChanged(StartMachineStatusUpdateResponse response)
@@ -824,9 +930,9 @@ namespace Tango.Integration.Operation
case MachineState.Ready:
Status = MachineStatuses.ReadyToDye;
break;
- //case MachineState.Sleep:
- // Status = MachineStatuses.Standby;
- // break;
+ case MachineState.Sleep:
+ Status = MachineStatuses.Standby;
+ break;
case MachineState.PowerOff:
Status = MachineStatuses.ShuttingDown;
if (!_isPowerDownRequestInProgress)
@@ -846,6 +952,59 @@ namespace Tango.Integration.Operation
}
/// <summary>
+ /// Called when the thread loading status has been changed.
+ /// </summary>
+ /// <param name="response">The response.</param>
+ protected virtual void OnThreadLoadingStatusChanged(StartThreadLoadingResponse response)
+ {
+ bool changed = (ThreadLoadingStatus == null || response.State != ThreadLoadingStatus.State || response.ErrorReason != ThreadLoadingStatus.ErrorReason);
+
+ if (changed)
+ {
+ ThreadLoadingStatus = response;
+ ThreadLoadingStatusChanged?.Invoke(this, response);
+
+ LogManager.Log($"Thread Loading Status Changed: {ThreadLoadingStatus.State}.");
+
+ switch (ThreadLoadingStatus.State)
+ {
+ case ThreadLoadingState.ReadyForLoading:
+
+ LogManager.Log("Thread loading is ready for loading. Invoking confirmation event...");
+
+ ThreadLoadingConfirmationRequired?.Invoke(this, new ThreadLoadingConfirmationRequiredEventArgs((processTable) =>
+ {
+ //Confirm Action
+ try
+ {
+ var process = processTable.ToProcessParametersPMR();
+ LogManager.Log($"Thread loading confirmation received with process parameters:\n{process.ToJsonString()}");
+ LogManager.Log("Sending continue thread loading request...");
+ var r = SendRequest<ContinueThreadLoadingRequest, ContinueThreadLoadingResponse>(new ContinueThreadLoadingRequest()
+ {
+ ProcessParameters = process,
+ }).Result;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error confirming thread loading sequence.");
+ }
+ })
+ {
+ Status = ThreadLoadingStatus,
+ });
+ break;
+ case ThreadLoadingState.Completed:
+ ThreadLoadingCompleted?.Invoke(this, ThreadLoadingStatus);
+ break;
+ case ThreadLoadingState.FinalizationError:
+ ThreadLoadingFailed?.Invoke(this, ThreadLoadingStatus);
+ break;
+ }
+ }
+ }
+
+ /// <summary>
/// Called when the request has been sent
/// </summary>
/// <param name="response">The request.</param>
@@ -1065,6 +1224,7 @@ namespace Tango.Integration.Operation
OnEnableEmbeddedDebuggingChanged(EnableEmbeddedDebugging);
OnEnableEventsNotification(EnableEventsNotification);
OnEnableMachineStatusUpdatesChanged(EnableMachineStatusUpdates);
+ OnEnableAutomaticThreadLoadingChanged(EnableAutomaticThreadLoading);
if (EnableJobResume)
{
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/ThreadLoadingConfirmationRequiredEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/ThreadLoadingConfirmationRequiredEventArgs.cs
new file mode 100644
index 000000000..e5594dd01
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Operation/ThreadLoadingConfirmationRequiredEventArgs.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.PMR.ThreadLoading;
+
+namespace Tango.Integration.Operation
+{
+ public class ThreadLoadingConfirmationRequiredEventArgs : EventArgs
+ {
+ private Action<ProcessParametersTable> _confirm;
+
+ public StartThreadLoadingResponse Status { get; set; }
+
+ internal ThreadLoadingConfirmationRequiredEventArgs(Action<ProcessParametersTable> confirm)
+ {
+ _confirm = confirm;
+ }
+
+ public void Confirm(ProcessParametersTable processTable)
+ {
+ _confirm.Invoke(processTable);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
index 5a4fcadf1..a3feac546 100644
--- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
+++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
@@ -112,6 +112,7 @@
<Compile Include="Operation\PowerDownStatusChangedEventArgs.cs" />
<Compile Include="Operation\PreparingJobProgressEventArgs.cs" />
<Compile Include="Operation\SpoolChangeRequiredEventArgs.cs" />
+ <Compile Include="Operation\ThreadLoadingConfirmationRequiredEventArgs.cs" />
<Compile Include="Upgrade\FirmwareUpgradeHandler.cs" />
<Compile Include="Upgrade\FirmwareUpgradeModes.cs" />
<Compile Include="Upgrade\FirmwareUpgradeProgressEventArgs.cs" />
@@ -198,7 +199,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file