diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs | 124 |
1 files changed, 123 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 49e7c76e2..430533768 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -59,6 +59,7 @@ namespace Tango.Integration.Operation public const String FIRMWARE_UPGRADE_FOLDER_NAME = "UpgradePackage"; public const String FIRMWARE_UPGRADE_CONFIG_FILE_NAME = "package.cfg"; public const String JOB_DESCRIPTION_FILE_NAME = "job_segments.jdf"; + public const String EUREKA_FIRMWARE_UPGRADE_DRIVE_LABEL = "NOD_H743ZI2"; public const int MAX_DISPENSER_NANOLITER = 130000000; public const double MAX_MIDTANK_LITERS = 1.8; @@ -3940,6 +3941,7 @@ namespace Tango.Integration.Operation Action validate = null; Action activate = null; Action postActivation = null; + Action upgradeEureka = null; UpdateStatus(MachineStatuses.Upgrading); @@ -4064,6 +4066,119 @@ namespace Tango.Integration.Operation } }); + upgradeEureka = new Action(() => + { + try + { + if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.DFU)) + { + if (package_info.ContainsMcu()) + { + LogManager.Log("Firmware upgrade enabled. Starting upgrade via file system..."); + + var upgradeDrive = DriveInfo.GetDrives().SingleOrDefault(x => x.VolumeLabel == EUREKA_FIRMWARE_UPGRADE_DRIVE_LABEL); + if (upgradeDrive == null) + { + throw LogManager.Log(new IOException($"Could not locate firmware upgrade volume labeled '{EUREKA_FIRMWARE_UPGRADE_DRIVE_LABEL}'")); + } + + String upgradeFolder = upgradeDrive.RootDirectory.FullName; + + LogManager.Log("Extracting MCU file..."); + ZipEntry mcuEntry = null; + try + { + mcuEntry = entries.Single(x => x.FileName == package_info.FileDescriptors.Single(y => y.Destination == VersionFileDestination.Mcu).FileName); + entries.Remove(mcuEntry); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error extracting MCU file from package."); + upgradeHandler.RaiseFailed(new IOException("Error retrieving MCU file from package.", ex)); + return; + } + + LogManager.Log("Disconnecting adapter..."); + Adapter.Disconnect().Wait(); + + ResetEvents(); + ResetInkFllingStatus(); + + try + { + if (!isEmulated) + { + LogManager.Log("Upgrading..."); + mcuEntry.Extract(upgradeFolder, ExtractExistingFileAction.OverwriteSilently); + } + else + { + LogManager.Log("Upgrading (emulated)..."); + Thread.Sleep(3000); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Firmware upgrade failed while extracting the MCU file to the upgrade location."); + UpdateStatus(MachineStatuses.Disconnected); + upgradeHandler.RaiseFailed(ex); + OnFailed(ex); + return; + } + + LogManager.Log("Waiting for the device..."); + upgradeHandler.RaiseProgress(FirmwareUpgradeStatus.Upgrading, "Waiting for the device..."); + Thread.Sleep(5000); + + LogManager.Log("Reconnecting adapter..."); + upgradeHandler.RaiseProgress(FirmwareUpgradeStatus.Upgrading, "Connecting..."); + Adapter.Connect().Wait(); + + Connect().Wait(); + + LogManager.Log("Connected..."); + upgradeHandler.RaiseProgress(FirmwareUpgradeStatus.Upgrading, "Connected."); + Thread.Sleep(2000); + + LogManager.Log("Waiting..."); + upgradeHandler.RaiseProgress(FirmwareUpgradeStatus.Upgrading, "Waiting..."); + Thread.Sleep(2000); + + UpdateStatus(MachineStatuses.Upgrading); + } + else + { + LogManager.Log("DFU is enabled but no MCU file was found on the package. Skipping..."); + } + } + + //Upload tfp package only if specified in flag && package info contains more files other than the mcu bin file. + if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.TFP_PACKAGE)) + { + if (package_info.ContainsNoneMcu()) + { + LogManager.Log("TFP package is enabled. Starting upload..."); + uploadNext(); + } + else + { + LogManager.Log("TFP package is enabled but no other files other than the MCU file were found on the package. Skipping..."); + postActivation(); + } + } + else + { + postActivation(); + } + } + catch (Exception ex) + { + UpdateStatus(MachineStatuses.ReadyToDye); + upgradeHandler.RaiseFailed(ex); + return; + } + }); + uploadNext = new Action(() => { if (entries.Count > 0) @@ -4183,7 +4298,14 @@ namespace Tango.Integration.Operation ThreadFactory.StartNew(() => { - upgradeDFU(); + if (MachineType == MachineTypes.TS1800) + { + upgradeDFU(); + } + else + { + + } }); return upgradeHandler; |
