diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-24 11:37:59 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-24 11:37:59 +0200 |
| commit | 6230a690fcfae2c51aadf4ce57d555e502fcce93 (patch) | |
| tree | 6702b4f6929885335564b17b120727367846e30c /Software/Visual_Studio | |
| parent | b6d9b453d2f14f1bbcc3b907d6cc30b513370e5a (diff) | |
| download | Tango-6230a690fcfae2c51aadf4ce57d555e502fcce93.tar.gz Tango-6230a690fcfae2c51aadf4ce57d555e502fcce93.zip | |
Implemented offline firmware upgrade support on PPC.
Diffstat (limited to 'Software/Visual_Studio')
15 files changed, 286 insertions, 11 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index fb3818e41..08f3adba6 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -321,7 +321,7 @@ namespace Tango.PPC.Jobs.ViewModels RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); - if (!directlyToEdit && MachineProvider.MachineOperator.Status == Integration.Operation.MachineStatuses.ReadyToDye) + if (!directlyToEdit && MachineProvider.MachineOperator.CanPrint) { await NavigationManager.NavigateWithObject<JobsModule, JobSummeryView, JobSummeryNavigationObject>(new JobSummeryNavigationObject() { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs index 421b4ee54..3e3fbcc27 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -54,6 +54,13 @@ namespace Tango.PPC.Common.MachineUpdate Task<MachineUpdateResult> UpdateFromTUP(String fileName, bool setupFirmware, bool setupFPGA); /// <summary> + /// Performs a firmware upgrade from the specified TFP file. + /// </summary> + /// <param name="fileName">Name of the file.</param> + /// <returns></returns> + Task UpdateFromTFP(String fileName); + + /// <summary> /// Checks if any update are available for the specified machine serial number. /// </summary> /// <param name="serialNumber">The serial number.</param> 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 8d6e02020..7228c53d3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -517,6 +517,22 @@ namespace Tango.PPC.Common.MachineUpdate _isUpdating = false; } + private void OnFailed(Exception ex, TaskCompletionSource<object> completionSource) + { + LogManager.Log(ex, "An error occurred in firmware upgrade."); + + completionSource.SetException(ex); + String logs = GetLogsStringAndClear(); + _isUpdating = false; + } + + private void OnCompleted(TaskCompletionSource<object> completionSource) + { + LogManager.Log("Firmware upgrade completed successfully."); + completionSource.SetResult(true); + _isUpdating = false; + } + private String GetLogsStringAndClear() { String logsString = String.Join(Environment.NewLine, _logs.ToList().Select(x => x.ToString())); @@ -585,7 +601,7 @@ namespace Tango.PPC.Common.MachineUpdate { throw LogManager.Log(new InvalidOperationException("Could not perform an update while the machine is not connected.")); } - if (op.Status != MachineStatuses.ReadyToDye) + if (!op.CanPrint) { throw LogManager.Log(new InvalidOperationException($"Could not perform an update while the machine is in {op.Status} status.")); } @@ -819,6 +835,81 @@ namespace Tango.PPC.Common.MachineUpdate return await result.Task; } + public async Task UpdateFromTFP(String fileName) + { + _updateStartDate = DateTime.UtcNow; + _logs.Clear(); + + TaskCompletionSource<object> result = new TaskCompletionSource<object>(); + + try + { + _isUpdating = true; + + 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 LogManager.Log(new InvalidOperationException("Could not perform a firmware upgrade while the machine is not connected.")); + } + if (!op.CanPrint) + { + throw LogManager.Log(new InvalidOperationException($"Could not perform a firmware upgrade while the machine is in {op.Status} status.")); + } + + UpdateProgress("Updating Firmware", "Connecting to firmware device..."); + LogManager.Log(""); + LogManager.Log("-------------------------------------------------------------------------"); + LogManager.Log("Updating Firmware..."); + + UpdateProgress("Updating Firmware", "Loading firmware package..."); + var stream = new FileStream(fileName, FileMode.Open); + + if (!_machineProvider.Machine.IsDemo) + { + op.FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE; + } + else + { + op.FirmwareUpgradeMode = FirmwareUpgradeModes.TFP_PACKAGE; + } + + var handler = await op.UpgradeFirmware(stream); + handler.Failed += (_, ex) => + { + stream.Dispose(); + OnFailed(ex, result); + }; + handler.Completed += (_, __) => + { + UpdateProgress("Updating Firmware", "Firmware update completed successfully."); + stream.Dispose(); + OnCompleted(result); + }; + handler.Canceled += (_, __) => + { + stream.Dispose(); + OnFailed(new Exception("The operation has been canceled."), result); + }; + handler.Progress += (_, e) => + { + UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); + }; + } + catch (Exception ex) + { + OnFailed(ex, result); + } + + await result.Task; + } + /// <summary> /// Checks if any update are available for the specified machine serial number. /// </summary> @@ -1166,7 +1257,7 @@ namespace Tango.PPC.Common.MachineUpdate { throw LogManager.Log(new InvalidOperationException("Could not perform an update while the machine is not connected.")); } - if (op.Status != MachineStatuses.ReadyToDye) + if (!op.CanPrint) { throw LogManager.Log(new InvalidOperationException($"Could not perform an update while the machine is in {op.Status} status.")); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml new file mode 100644 index 000000000..66bd0392d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml @@ -0,0 +1,28 @@ +<UserControl x:Class="Tango.PPC.UI.Dialogs.FirmwareUpgradeFromFileView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.PPC.UI.Dialogs" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="570" Height="700" d:DataContext="{d:DesignInstance Type=local:FirmwareUpgradeFromFileViewVM, IsDesignTimeCreatable=False}"> + <Grid Margin="20"> + <DockPanel> + <Grid DockPanel.Dock="Bottom"> + <touch:TouchButton HorizontalAlignment="Left" CornerRadius="25" Command="{Binding CloseCommand}" Style="{StaticResource TangoHollowButton}" Width="150" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> + <touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Style="{StaticResource TangoHollowButton}" Width="150" Height="50" VerticalAlignment="Bottom">UPGRADE</touch:TouchButton> + </Grid> + <StackPanel> + <Image Source="../Images/firmware.png" Stretch="Uniform" Height="120"></Image> + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Tango Firmware Upgrade</TextBlock> + <TextBlock Margin="20 10" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">The selected file contains a firmware upgrade package. Press 'UPGRADE' to start updating your system.</TextBlock> + + <TextBlock TextAlignment="Center" HorizontalAlignment="Center" Margin="0 40 0 0" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> + <Run FontWeight="SemiBold">Firmware:</Run> + <Run Text="{Binding Version}"></Run> + </TextBlock> + </StackPanel> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml.cs new file mode 100644 index 000000000..e7e1eb86c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// <summary> + /// Interaction logic for UpdateFromFileView.xaml + /// </summary> + public partial class FirmwareUpgradeFromFileView : UserControl + { + public FirmwareUpgradeFromFileView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileViewVM.cs new file mode 100644 index 000000000..9a7322565 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/FirmwareUpgradeFromFileViewVM.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Publish; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class FirmwareUpgradeFromFileViewVM : DialogViewVM + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml index a175b655e..fec166264 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml @@ -18,9 +18,12 @@ <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Tango Update Package</TextBlock> <TextBlock Margin="20 10" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">The selected file contains a software update package. Press 'UPDATE' to start updating your system.</TextBlock> - <TextBlock HorizontalAlignment="Center" Margin="0 40 0 0" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> - <Run>Version</Run> - <Run Text="{Binding Version}"></Run> + <TextBlock TextAlignment="Center" HorizontalAlignment="Center" Margin="0 40 0 0" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> + <Run FontWeight="SemiBold">Application:</Run> + <Run Text="{Binding PublishInfo.ApplicationVersion}"></Run> + <LineBreak/> + <Run FontWeight="SemiBold">Firmware:</Run> + <Run Text="{Binding FirmwareVersion}"></Run> </TextBlock> </StackPanel> </DockPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs index b9e876809..a38b0431a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs @@ -3,12 +3,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Common.Publish; using Tango.SharedUI; namespace Tango.PPC.UI.Dialogs { public class UpdateFromFileViewVM : DialogViewVM { - public String Version { get; set; } + public PublishInfo PublishInfo { get; set; } + + public String FirmwareVersion + { + get { return PublishInfo.GetFirmwareVersion(); } + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/firmware.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/firmware.png Binary files differnew file mode 100644 index 000000000..af3ea4850 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/firmware.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index bac736d98..eef669d4f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -153,9 +153,13 @@ <Compile Include="Dialogs\ScreenLockViewVM.cs" /> <Compile Include="Dialogs\TechnicianModeLoginViewVM.cs" /> <Compile Include="Dialogs\ThreadLoadingViewVM.cs" /> + <Compile Include="Dialogs\FirmwareUpgradeFromFileView.xaml.cs"> + <DependentUpon>FirmwareUpgradeFromFileView.xaml</DependentUpon> + </Compile> <Compile Include="Dialogs\UpdateFromFileView.xaml.cs"> <DependentUpon>UpdateFromFileView.xaml</DependentUpon> </Compile> + <Compile Include="Dialogs\FirmwareUpgradeFromFileViewVM.cs" /> <Compile Include="Dialogs\UpdateFromFileViewVM.cs" /> <Compile Include="InternalModule.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> @@ -266,6 +270,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\FirmwareUpgradeFromFileView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Dialogs\UpdateFromFileView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -419,6 +427,7 @@ <Resource Include="Images\power_off.gif" /> <Resource Include="Images\thread_loading.gif" /> <Resource Include="Images\thread_loading.png" /> + <Resource Include="Images\firmware.png" /> <Content Include="Manifests\release.xml" /> <Content Include="Manifests\debug.xml" /> <None Include="firmware_package.tfp"> @@ -682,7 +691,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"</ </PropertyGroup> <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 diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 0af977614..3942a1b84 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -8,8 +8,10 @@ using System.Text; using System.Threading.Tasks; using Tango.BL; using Tango.Core.Commands; +using Tango.Core.ExtensionMethods; using Tango.Core.Helpers; using Tango.Explorer; +using Tango.PMR.FirmwareUpgrade; using Tango.PPC.Common; using Tango.PPC.Common.MachineUpdate; using Tango.PPC.Common.Publish; @@ -313,6 +315,7 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Update.Extension, HandleSoftwareUpdatePackageLoaded); + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Firmware.Extension, HandleFirmwareUpgradeLoaded); if (ApplicationManager.IsAfterUpdate) { @@ -401,6 +404,8 @@ namespace Tango.PPC.UI.ViewModels { PublishInfo packageFile = null; + LogManager.Log("TUP file loaded from storage..."); + try { packageFile = await MachineUpdateManager.GetUpdatePackageFileInfo(fileItem.Path); @@ -413,7 +418,11 @@ namespace Tango.PPC.UI.ViewModels } UpdateFromFileViewVM vm = new UpdateFromFileViewVM(); - vm.Version = packageFile.ApplicationVersion; + vm.PublishInfo = packageFile; + + LogManager.Log($"TUP publish info:\n{packageFile.ToJson()}"); + + LogManager.Log("Displaying TUP update dialog..."); await NotificationProvider.ShowDialog(vm); @@ -439,6 +448,62 @@ namespace Tango.PPC.UI.ViewModels } } + private async void HandleFirmwareUpgradeLoaded(ExplorerFileItem fileItem) + { + LogManager.Log("TFP file loaded from storage..."); + + VersionPackageDescriptor packageInfo; + FirmwareUpgradeFromFileViewVM vm = new FirmwareUpgradeFromFileViewVM(); + + try + { + using (FileStream st = File.OpenRead(fileItem.Path)) + { + packageInfo = await MachineProvider.MachineOperator.GetFirmwarePackageInfo(st); + } + + vm.Version = packageInfo.FileDescriptors.SingleOrDefault(x => x.Destination == VersionFileDestination.Mcu).Version; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading package info from {fileItem.Path}."); + await NotificationProvider.ShowError("An error occurred while trying to load the selected firmware upgrade package. Please make sure the package is valid."); + return; + } + + + LogManager.Log($"TFP publish info:\n{packageInfo.ToJsonString()}"); + + LogManager.Log("Displaying TFP update dialog..."); + + await NotificationProvider.ShowDialog(vm); + + if (vm.DialogResult) + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView); + await NavigateTo(MachineUpdateView.UpdateProgressView); + + LogManager.Log("Starting firmware upgrade from package..."); + + try + { + await MachineUpdateManager.UpdateFromTFP(fileItem.Path); + LogManager.Log("Firmware upgrade from package completed."); + _update_result = new MachineUpdateResult() + { + RequiresBinariesUpdate = false, + }; + await NavigateTo(MachineUpdateView.UpdateCompletedView); + } + catch (Exception ex) + { + LogManager.Log(ex, "Firmware upgrade from package failed."); + FailedError = ex.FlattenMessage(); + await NavigateTo(MachineUpdateView.UpdateFailedFromPackageView); + } + } + } + #endregion #region Auto Check For Update diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs index 5b9fcba02..d9c5d61e7 100644 --- a/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs @@ -59,10 +59,17 @@ namespace Tango.Explorer public static ExplorerFileDefinition Backup => new ExplorerFileDefinition() { Icon = ResourceHelper.GetImageFromResources("/Images/backup.png"), - Description = "Tango Backup File", + Description = "Tango Backup", Extension = ".tb", }; + public static ExplorerFileDefinition Firmware => new ExplorerFileDefinition() + { + Icon = ResourceHelper.GetImageFromResources("/Images/firmware.png"), + Description = "Tango Firmware Upgrade", + Extension = ".tfp", + }; + static ExplorerFileDefinition() { _definitions = typeof(ExplorerFileDefinition).GetProperties(BindingFlags.Public | BindingFlags.Static).Where(x => x.PropertyType == typeof(ExplorerFileDefinition)).ToList().Select(x => x.GetValue(null, null) as ExplorerFileDefinition).ToList(); diff --git a/Software/Visual_Studio/Tango.Explorer/Images/firmware.png b/Software/Visual_Studio/Tango.Explorer/Images/firmware.png Binary files differnew file mode 100644 index 000000000..af3ea4850 --- /dev/null +++ b/Software/Visual_Studio/Tango.Explorer/Images/firmware.png diff --git a/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj b/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj index a39630940..5412405ef 100644 --- a/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj +++ b/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj @@ -114,5 +114,8 @@ <ItemGroup> <Resource Include="Images\backup.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\firmware.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 4b0066d7f..7b3ed0612 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -24,6 +24,8 @@ namespace Tango.Integration.Operation private bool _finalizing; private JobHandlerModes _mode; private double _last_progress; + private const int PROGRESS_REPORT_RANGE_METERS = 5; + private bool loggedContinueMessage; #region Events @@ -225,6 +227,7 @@ namespace Tango.Integration.Operation /// <param name="ex">The ex.</param> internal void RaiseFailed(Exception ex) { + LogManager.Log($"Job failed at position {Status.Progress}/{Status.TotalProgress}..."); Status.IsFailed = true; StatusChanged?.Invoke(this, Status); RaisePropertyChanged(nameof(Status)); @@ -237,6 +240,7 @@ namespace Tango.Integration.Operation /// </summary> internal void RaiseCompleted() { + LogManager.Log($"Job completed at position {Status.Progress}/{Status.TotalProgress}..."); Status.Segments.Last().Completed = true; Status.RemainingUnits = 0; Status.IsFinalizing = false; @@ -252,6 +256,7 @@ namespace Tango.Integration.Operation /// </summary> internal void RaiseCanceled() { + LogManager.Log($"Job canceled at position {Status.Progress}/{Status.TotalProgress}..."); Status.IsCanceled = true; StatusChanged?.Invoke(this, Status); RaisePropertyChanged(nameof(Status)); @@ -279,7 +284,15 @@ namespace Tango.Integration.Operation { bool invalidProgress = false; - LogManager.Log($"Updating job progress {s.Progress}/{Status.TotalProgress}..."); + if (s.Progress <= PROGRESS_REPORT_RANGE_METERS || s.Progress >= Status.TotalProgress - PROGRESS_REPORT_RANGE_METERS) + { + LogManager.Log($"Updating job progress {s.Progress}/{Status.TotalProgress}..."); + } + else if (!loggedContinueMessage) + { + loggedContinueMessage = true; + LogManager.Log($"Progress logging will continue {PROGRESS_REPORT_RANGE_METERS} meters before completion..."); + } if (s.Progress < 0) { |
