aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
index 4932d1e72..9ae77df6f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
@@ -13,6 +13,7 @@ using Tango.Core;
using Tango.Core.DB;
using Tango.Core.Helpers;
using Tango.Core.IO;
+using Tango.Integration.Operation;
using Tango.PMR.Synchronization;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Connection;
@@ -83,6 +84,23 @@ namespace Tango.PPC.Common.MachineUpdate
{
LogManager.Log($"Starting machine update for serial number {serialNumber}...");
+ //Connecting to machine...
+ LogManager.Log("Verifying machine connection and state...");
+
+ UpdateProgress("Verifying machine state", "Initializing...");
+
+ await Task.Delay(1000);
+
+ IMachineOperator op = _machineProvider.MachineOperator;
+ if (op.State != Transport.TransportComponentState.Connected)
+ {
+ throw new InvalidOperationException("Could not perform an update while the machine is not connected.");
+ }
+ if (op.Status != MachineStatuses.ReadyToDye)
+ {
+ throw new InvalidOperationException($"Could not perform an update while the machine is in a {op.Status} status.");
+ }
+
//Connect to machine service and get matching packages for this machine.
UpdateProgress("Downloading software package", "Connecting to machine service...");
@@ -217,7 +235,6 @@ namespace Tango.PPC.Common.MachineUpdate
LogManager.Log("");
LogManager.Log("-------------------------------------------------------------------------");
LogManager.Log("Updating Firmware...");
- var op = _machineProvider.MachineOperator;
UpdateProgress("Updating Firmware", "Loading firmware package...");
var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp");