diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-24 19:32:33 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-24 19:32:33 +0200 |
| commit | 0c696317f92460cdbed77493f57523fbb617d65c (patch) | |
| tree | add70e5b2c23a0c970e6563865e2d29f119ddcaf /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs | |
| parent | 40746c60fed9e70f3cb7f6f12f55595a77a1adfa (diff) | |
| download | Tango-0c696317f92460cdbed77493f57523fbb617d65c.tar.gz Tango-0c696317f92460cdbed77493f57523fbb617d65c.zip | |
Fixed some issues with PPC update.
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.cs | 80 |
1 files changed, 48 insertions, 32 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 2a53d765e..64827f15f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -113,13 +113,19 @@ namespace Tango.PPC.Common.MachineUpdate 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) + + if (_machineProvider.Machine.SetupFirmware) { - throw new InvalidOperationException($"Could not perform an update while the machine is in a {op.Status} status."); + LogManager.Log("Machine is configured to update firmware..."); + + if (op.State != Transport.TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException("Could not perform an update while the machine is not connected.")); + } + if (op.Status != MachineStatuses.ReadyToDye) + { + throw LogManager.Log(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. @@ -238,38 +244,48 @@ namespace Tango.PPC.Common.MachineUpdate } //Updating firmware - UpdateProgress("Updating Firmware", "Connecting to firmware device..."); - LogManager.Log(""); - LogManager.Log("-------------------------------------------------------------------------"); - LogManager.Log("Updating Firmware..."); - - UpdateProgress("Updating Firmware", "Loading firmware package..."); - var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); - var stream = new FileStream(tfpPath, FileMode.Open); - var handler = await op.UpgradeFirmware(stream); - handler.Failed += (_, ex) => + if (_machineProvider.Machine.SetupFirmware) { - stream.Dispose(); - result.SetException(ex); - }; - handler.Completed += (_, __) => + UpdateProgress("Updating Firmware", "Connecting to firmware device..."); + LogManager.Log(""); + LogManager.Log("-------------------------------------------------------------------------"); + LogManager.Log("Updating Firmware..."); + + UpdateProgress("Updating Firmware", "Loading firmware package..."); + var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); + var stream = new FileStream(tfpPath, FileMode.Open); + var handler = await op.UpgradeFirmware(stream); + handler.Failed += (_, ex) => + { + stream.Dispose(); + result.SetException(ex); + }; + handler.Completed += (_, __) => + { + UpdateProgress("Updating Firmware", "Firmware update completed successfully."); + stream.Dispose(); + result.SetResult(new MachineUpdateResult() + { + UpdatePackagePath = _newPackageTempFolder, + }); + }; + handler.Canceled += (_, __) => + { + stream.Dispose(); + result.SetException(new Exception("The operation has been canceled.")); + }; + handler.Progress += (_, e) => + { + UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); + }; + } + else { - UpdateProgress("Updating Firmware", "Firmware update completed successfully."); - stream.Dispose(); result.SetResult(new MachineUpdateResult() { UpdatePackagePath = _newPackageTempFolder, }); - }; - handler.Canceled += (_, __) => - { - stream.Dispose(); - result.SetException(new Exception("The operation has been canceled.")); - }; - handler.Progress += (_, e) => - { - UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); - }; + } } catch (Exception ex) { |
