diff options
| author | Roy Ben-Shabat <Roy.mail.net@gmail.com> | 2023-07-16 12:09:56 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy.mail.net@gmail.com> | 2023-07-16 12:09:56 +0300 |
| commit | ac39b49638cb1b2f3602f51c7f5a1cde7e0df673 (patch) | |
| tree | d3c6cdf0fa913cc07cbfc8c9cf8c065d1bce0dae /Software/Visual_Studio/Tango.Integration | |
| parent | 48fe4a21077ae4ec4b78e1b3fd76934a20b58dda (diff) | |
| parent | a353bf2a5fae2eb8d81c342a5c5dce0e3de2b086 (diff) | |
| download | Tango-ac39b49638cb1b2f3602f51c7f5a1cde7e0df673.tar.gz Tango-ac39b49638cb1b2f3602f51c7f5a1cde7e0df673.zip | |
Merge branch 'eureka' of https://twinetfs.visualstudio.com/Tango/_git/Tango into eureka
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
3 files changed, 162 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 5db477b6b..68ed696fa 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -593,5 +593,18 @@ namespace Tango.Integration.Operation /// </summary> /// <param name="approved">Approve or decline the sequence.</param> Task CompleteWasteReplacement(bool approved); + + /// <summary> + /// Gets the list of firmware version descriptors. + /// </summary> + /// <returns></returns> + Task<List<VersionFileDescriptor>> GetFirmwareVersionDescriptors(); + + /// <summary> + /// Resets the firmware card by the specified card id. + /// </summary> + /// <param name="cardID">The card identifier.</param> + /// <returns></returns> + Task ResetCard(int cardID); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 23bd2b1ba..4579ff08c 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -516,7 +516,8 @@ namespace Tango.Integration.Operation TimeSpan segmentsDuration = Job.TranslateProgressToTime(previousSegmentsLengthWithThis, ProcessParameters); TimeSpan segmentRemainingTime = segmentsDuration - Job.TranslateProgressToTime(Status.Progress, ProcessParameters); - segment.Progress = Math.Min(Math.Max((previousSegmentsLengthWithThis - segment.Length - Status.Progress) * -1, 0), segment.Length); + // segment.Progress = Math.Min(Math.Max((previousSegmentsLengthWithThis - segment.Length - Status.Progress) * -1, 0), segment.Length); + segment.Progress = Math.Min(Math.Max((previousSegmentsLengthWithThis - segment.Length - Status.ProgressMinusSettingUp) * -1, 0), segment.Length); if (i == 0 && Status.Progress > 0) { @@ -526,8 +527,9 @@ namespace Tango.Integration.Operation Status.CurrentSegment = segment; } } - - if (Status.Progress >= previousSegmentsLengthWithThis) + + //if (Status.Progress >= previousSegmentsLengthWithThis) + if (Status.ProgressMinusSettingUp >= previousSegmentsLengthWithThis) { if (!segment.Completed) { diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 49e7c76e2..d312f0066 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; @@ -2646,7 +2647,7 @@ namespace Tango.Integration.Operation bool useLightInks = config.UseLightInks; //Use light inks only if one segment or inter segment is enabled. - if (job.OrderedSegmentsWithGroups.Count > 1 && !job.EnableInterSegment) useLightInks = false; + if (MachineType == MachineTypes.TS1800 && job.OrderedSegmentsWithGroups.Count > 1 && !job.EnableInterSegment) useLightInks = false; foreach (var segment in jobSegments) { @@ -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 + { + upgradeEureka(); + } }); return upgradeHandler; @@ -4515,6 +4637,26 @@ namespace Tango.Integration.Operation } } + /// <summary> + /// Gets the list of firmware version descriptors. + /// </summary> + /// <returns></returns> + public async Task<List<VersionFileDescriptor>> GetFirmwareVersionDescriptors() + { + var response = await SendRequest<GetVersionDescriptorsRequest, GetVersionDescriptorsResponse>(new GetVersionDescriptorsRequest()); + return response.Message.Descriptors.ToList(); + } + + /// <summary> + /// Resets the firmware card by the specified card id. + /// </summary> + /// <param name="cardID">The card identifier.</param> + /// <returns></returns> + public Task ResetCard(int cardID) + { + return SendRequest<ResetCardRequest, ResetCardResponse>(new ResetCardRequest() { }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(10) }); + } + #endregion } } |
