diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-12-04 17:44:06 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-12-04 17:44:06 +0200 |
| commit | e64abeba3fd00cf6111b698384650b0e2a530436 (patch) | |
| tree | 9b44c7d5c160926e6bba548947547090f220b199 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | e5d8713b456d335c19402360f0ba3e8a6db2c31e (diff) | |
| parent | 704146a52197741c1df351e48098b91ca69a2426 (diff) | |
| download | Tango-e64abeba3fd00cf6111b698384650b0e2a530436.tar.gz Tango-e64abeba3fd00cf6111b698384650b0e2a530436.zip | |
merge conflicts
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
8 files changed, 345 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/FirmwareUpgrade/DefaultFirmwareUpgrader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/FirmwareUpgrade/DefaultFirmwareUpgrader.cs new file mode 100644 index 000000000..4cceec50c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/FirmwareUpgrade/DefaultFirmwareUpgrader.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Operation; +using Tango.Integration.Upgrade; +using Tango.MachineStudio.Common.FirmwareUpgrade; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.UI.ViewModels; +using Tango.MachineStudio.UI.Views; + +namespace Tango.MachineStudio.UI.FirmwareUpgrade +{ + /// <summary> + /// Default firmware upgrade manager. + /// </summary> + /// <seealso cref="Tango.MachineStudio.Common.FirmwareUpgrade.IFirmwareUpgrader" /> + public class DefaultFirmwareUpgrader : IFirmwareUpgrader + { + private IStudioApplicationManager _applicationManager; + private INotificationProvider _notification; + + /// <summary> + /// Initializes a new instance of the <see cref="DefaultFirmwareUpgrader"/> class. + /// </summary> + public DefaultFirmwareUpgrader(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) + { + _applicationManager = applicationManager; + _notification = notificationProvider; + } + + /// <summary> + /// Performs a firmware upgrade. + /// </summary> + /// <param name="tfpStream">The TFP stream.</param> + public Task<FirmwareUpgradeHandler> PerformUpgrade(Stream tfpStream) + { + return _applicationManager.ConnectedMachine.UpgradeFirmware(tfpStream); + } + + /// <summary> + /// Invokes the upgrade dialog. + /// </summary> + public void InvokeUpgradeUI() + { + FirmwareUpgradeViewVM vm = new FirmwareUpgradeViewVM(_applicationManager.ConnectedMachine, _notification); + + _notification.ShowModalDialog<FirmwareUpgradeViewVM, FirmwareUpgradeView>(vm, (x) => + { + + }, () => { }); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/firmware_upgrade.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/firmware_upgrade.png Binary files differnew file mode 100644 index 000000000..fc0799143 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/firmware_upgrade.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 115e3f140..98edf817b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.5.73.18305")] +[assembly: AssemblyVersion("3.5.76.18305")] [assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 1be69bf1c..b3926190f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -142,6 +142,7 @@ <DependentUpon>ConsoleWindow.xaml</DependentUpon> </Compile> <Compile Include="Console\ConsoleWindowVM.cs" /> + <Compile Include="FirmwareUpgrade\DefaultFirmwareUpgrader.cs" /> <Compile Include="Html\DefaultHtmlPresenter.cs" /> <Compile Include="Html\HtmlWindow.xaml.cs"> <DependentUpon>HtmlWindow.xaml</DependentUpon> @@ -172,6 +173,7 @@ <Compile Include="ViewModels\AboutViewVM.cs" /> <Compile Include="ViewModels\ConnectedMachineViewVM.cs" /> <Compile Include="ViewModels\ConnectionLostViewVM.cs" /> + <Compile Include="ViewModels\FirmwareUpgradeViewVM.cs" /> <Compile Include="ViewModels\LoadingViewVM.cs" /> <Compile Include="ViewModels\LoginViewVM.cs" /> <Compile Include="ViewModels\MachineConnectionViewVM.cs" /> @@ -193,6 +195,9 @@ <Compile Include="Views\ConnectionLostView.xaml.cs"> <DependentUpon>ConnectionLostView.xaml</DependentUpon> </Compile> + <Compile Include="Views\FirmwareUpgradeView.xaml.cs"> + <DependentUpon>FirmwareUpgradeView.xaml</DependentUpon> + </Compile> <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> </Compile> @@ -277,6 +282,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\FirmwareUpgradeView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\LoadingView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -449,6 +458,10 @@ <Project>{8a65ad6a-a9b4-48c0-9301-4b7434b712f8}</Project> <Name>Tango.MachineStudio.Statistics</Name> </ProjectReference> + <ProjectReference Include="..\Modules\Tango.MachineStudio.Storage\Tango.MachineStudio.Storage.csproj"> + <Project>{5991f6b5-ea4e-41e9-a4f6-7d3a50010fd6}</Project> + <Name>Tango.MachineStudio.Storage</Name> + </ProjectReference> <ProjectReference Include="..\Modules\Tango.MachineStudio.Stubs\Tango.MachineStudio.Stubs.csproj"> <Project>{22c2aa72-9493-4d0d-b421-8ef9789fb192}</Project> <Name>Tango.MachineStudio.Stubs</Name> @@ -501,6 +514,7 @@ <Resource Include="Images\settings.png" /> </ItemGroup> <ItemGroup> + <Resource Include="Images\firmware_upgrade.png" /> <Resource Include="Images\external-bridge-emulator.png" /> <EmbeddedResource Include="..\..\Versioning\ChangeLog.txt"> <Link>ChangeLog.txt</Link> @@ -595,7 +609,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> + <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 8bb33d007..cac4ee0c0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -6,6 +6,7 @@ using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.FirmwareUpgrade; using Tango.MachineStudio.Common.Html; using Tango.MachineStudio.Common.JobRunsLogging; using Tango.MachineStudio.Common.Modules; @@ -17,6 +18,7 @@ using Tango.MachineStudio.Common.Threading; using Tango.MachineStudio.Common.Video; using Tango.MachineStudio.UI.Authentication; using Tango.MachineStudio.UI.Console; +using Tango.MachineStudio.UI.FirmwareUpgrade; using Tango.MachineStudio.UI.Html; using Tango.MachineStudio.UI.Modules; using Tango.MachineStudio.UI.Navigation; @@ -70,6 +72,7 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Unregister<ITeamFoundationServiceClient>(); TangoIOC.Default.Unregister<IDispatcherProvider>(); TangoIOC.Default.Unregister<IJobRunsLogger>(); + TangoIOC.Default.Unregister<IFirmwareUpgrader>(); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispatcherProvider>(new DefaultDispatcherProvider(Application.Current.Dispatcher)); @@ -85,6 +88,7 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register<IEventLogger, DefaultEventLogger>(); TangoIOC.Default.Register<ISpeechProvider, DefaultSpeechProvider>(); TangoIOC.Default.Register<IHtmlPresenter, DefaultHtmlPresenter>(); + TangoIOC.Default.Register<IFirmwareUpgrader, DefaultFirmwareUpgrader>(); TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs new file mode 100644 index 000000000..09b63cfc9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs @@ -0,0 +1,143 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.Integration.Upgrade; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class FirmwareUpgradeViewVM : DialogViewVM + { + private IMachineOperator _operator; + private INotificationProvider _notification; + private FileStream _stream; + + private FirmwareUpgradeHandler _handler; + public FirmwareUpgradeHandler Handler + { + get { return _handler; } + set { _handler = value; RaisePropertyChangedAuto(); } + } + + private String _selectedFile; + public String SelectedFile + { + get { return _selectedFile; } + set { _selectedFile = value; RaisePropertyChangedAuto(); } + } + + private int _currentPage; + public int CurrentPage + { + get { return _currentPage; } + set { _currentPage = value; RaisePropertyChangedAuto(); } + } + + private String upgradeError; + public String UpgradeError + { + get { return upgradeError; } + set { upgradeError = value; RaisePropertyChangedAuto(); } + } + + + public RelayCommand SelectCommand { get; set; } + + public RelayCommand UpgradeCommand { get; set; } + + public RelayCommand AbortCommand { get; set; } + + public FirmwareUpgradeViewVM(IMachineOperator machineOperator, INotificationProvider notificationProvider) : base() + { + _notification = notificationProvider; + _operator = machineOperator; + SelectCommand = new RelayCommand(BrowseForFile); + UpgradeCommand = new RelayCommand(StartUpgrade, () => SelectedFile != null); + AbortCommand = new RelayCommand(AbortUpgrade, () => Handler != null && Handler.Status != FirmwareUpgradeStatus.Validating && Handler.Status != FirmwareUpgradeStatus.Activating); + } + + private async void BrowseForFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select tango firmware package file"; + dlg.Filter = "Tango Firmware Package|*.tfp"; + if (dlg.ShowDialog().Value) + { + try + { + using (FileStream fs = new FileStream(dlg.FileName, FileMode.Open)) + { + var info = await _operator.GetFirmwarePackageInfo(fs); + } + } + catch (Exception ex) + { + LogManager.Log(ex); + _notification.ShowError("The selected package seems to be invalid."); + return; + } + + SelectedFile = dlg.FileName; + InvalidateRelayCommands(); + } + } + + private async void StartUpgrade() + { + CanClose = false; + CurrentPage = 1; + + try + { + _stream = new FileStream(SelectedFile, FileMode.Open); + Handler = await _operator.UpgradeFirmware(_stream); + Handler.Progress += (_, e) => + { + InvokeUI(() => + { + AbortCommand.RaiseCanExecuteChanged(); + }); + }; + Handler.Completed += (_, __) => + { + CanClose = true; + _stream.Dispose(); + CurrentPage = 2; + }; + Handler.Canceled += (_, __) => + { + CanClose = true; + _stream.Dispose(); + CurrentPage = 0; + }; + Handler.Failed += (_, ex) => + { + UpgradeError = ex.FlattenMessage(); + CanClose = true; + _stream.Dispose(); + CurrentPage = 3; + }; + } + catch (Exception ex) + { + CanClose = true; + UpgradeError = ex.FlattenMessage(); + CurrentPage = 3; + } + } + + private async void AbortUpgrade() + { + CanClose = true; + await Handler.Cancel(); + CurrentPage = 0; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.xaml new file mode 100644 index 000000000..84f4b2d92 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.xaml @@ -0,0 +1,97 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.FirmwareUpgradeView" + 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.MachineStudio.UI.Views" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300" Width="800" Height="400" Background="White" d:DataContext="{d:DesignInstance Type=vm:FirmwareUpgradeViewVM, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> + </UserControl.Resources> + + <Grid> + <Grid Margin="10"> + <Grid.RowDefinitions> + <RowDefinition Height="121"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/firmware_upgrade.png" Height="100" /> + <TextBlock VerticalAlignment="Center" FontSize="30" FontWeight="SemiBold" Margin="20 0 0 0">FIRMWARE UPGRADE</TextBlock> + </StackPanel> + <Rectangle Stroke="Gainsboro" StrokeDashArray="5 5 5 5" Margin="20 10" /> + </StackPanel> + </Grid> + + <Grid Grid.Row="1"> + <controls:NavigationControl TransitionType="Zoom" SelectedIndex="{Binding CurrentPage}" TransitionDuration="00:00:0.3"> + + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="174*"/> + <RowDefinition Height="85*"/> + </Grid.RowDefinitions> + <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> + <TextBlock TextAlignment="Center"> + <Run>This upgrade wizard will help you upgrade the connected machine firmware version.</Run> + <LineBreak/> + <Run>Press 'SELECT' to browse for an .tfp file (Tango Firmware Package).</Run> + </TextBlock> + <DockPanel Margin="0 30 0 0" Width="600" HorizontalAlignment="Left"> + <Button DockPanel.Dock="Right" Margin="10 0 0 0" Command="{Binding SelectCommand}">SELECT</Button> + <TextBox Style="{x:Null}" VerticalContentAlignment="Center" BorderBrush="{StaticResource AccentColorBrush}" Padding="5 0" Foreground="DimGray" IsReadOnly="True" Text="{Binding SelectedFile,Mode=OneWay}"></TextBox> + </DockPanel> + </StackPanel> + + <Grid Height="60" Grid.Row="1"> + <Button Height="50" Width="200" VerticalAlignment="Top" Command="{Binding UpgradeCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Flash" Width="32" Height="32" /> + <TextBlock VerticalAlignment="Center" Margin="5 0 0 0">UPGRADE</TextBlock> + </StackPanel> + </Button> + </Grid> + </Grid> + </Grid> + + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center" FontSize="18" FontWeight="SemiBold">Upgrading Machine Firmware</TextBlock> + <TextBlock Margin="0 40 0 0" HorizontalAlignment="Center" Foreground="Gray" Text="{Binding Handler.Message,Converter={StaticResource EnumToDescriptionConverter},Mode=OneWay}"></TextBlock> + <ProgressBar Height="15" Width="600" Margin="0 5 0 0" Maximum="{Binding Handler.Total,Mode=OneWay}" Value="{Binding Handler.Current,Mode=OneWay}" ></ProgressBar> + <Button Width="150" Background="#FF5151" BorderBrush="#FF5151" Margin="0 40 0 0" Height="35" Command="{Binding AbortCommand}">ABORT</Button> + </StackPanel> + </Grid> + + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center" FontSize="18" FontWeight="SemiBold">Firmware Upgrade Completed</TextBlock> + <materialDesign:PackIcon HorizontalAlignment="Center" Width="100" Margin="0 10 0 0" Height="100" Kind="Check" Foreground="#2DCB2D" /> + <Button Width="150" Margin="0 10 0 0" Height="35" Command="{Binding CloseCommand}">CLOSE</Button> + </StackPanel> + </Grid> + + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center" FontSize="18" FontWeight="SemiBold">Firmware Upgrade Failed</TextBlock> + <materialDesign:PackIcon HorizontalAlignment="Center" Width="100" Margin="0 10 0 0" Height="100" Kind="AlertOutline" Foreground="#FF5151" /> + <TextBlock HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="{Binding UpgradeError}" Foreground="#FF5151" FontWeight="SemiBold"></TextBlock> + <Button Width="150" Margin="0 15 0 0" Height="35" Command="{Binding CloseCommand}">CLOSE</Button> + </StackPanel> + </Grid> + </controls:NavigationControl> + </Grid> + + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.xaml.cs new file mode 100644 index 000000000..17220e615 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/FirmwareUpgradeView.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.MachineStudio.UI.Views +{ + /// <summary> + /// Interaction logic for FirmwareUpgradeView.xaml + /// </summary> + public partial class FirmwareUpgradeView : UserControl + { + public FirmwareUpgradeView() + { + InitializeComponent(); + } + } +} |
