diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-14 18:50:59 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-14 18:50:59 +0200 |
| commit | 73196dd48da9d16b6949ab9dec0ae0a5d63accfe (patch) | |
| tree | 04bbaade70fb016423d7cd43161f4cbc8bc04b79 /Software/Visual_Studio/Utilities/Tango.UITests | |
| parent | b6283ab40fafa8e738e8e3fec260777a4d250597 (diff) | |
| download | Tango-73196dd48da9d16b6949ab9dec0ae0a5d63accfe.tar.gz Tango-73196dd48da9d16b6949ab9dec0ae0a5d63accfe.zip | |
Working on DFU firmware upgrade...
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.UITests')
3 files changed, 35 insertions, 51 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index 8714e65c3..d9180c4dd 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -21,7 +21,6 @@ <TextBlock HorizontalAlignment="Center" Margin="0 0 0 10" x:Name="txtStatus"></TextBlock> <ProgressBar x:Name="prog" VerticalAlignment="Center" Height="15" Width="700"></ProgressBar> <Button x:Name="btnStart" Click="btnStart_Click" HorizontalAlignment="Center" Padding="30 10" Margin="0 10 0 0">START</Button> - <Button x:Name="btnSwitch" Click="btnSwitch_Click" HorizontalAlignment="Center" Padding="30 10" Margin="0 10 0 0">SWITCH</Button> </StackPanel> </Grid> </Window> diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index e7db48435..e2b4586db 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Windows.Threading; using Tango.BL; using Tango.BL.Builders; using Tango.BL.Catalogs; @@ -24,6 +25,8 @@ using Tango.Core; using Tango.Core.Commands; using Tango.DragAndDrop; using Tango.FirmwareUpdateLib; +using Tango.FirmwareUpdateLib.WPF; +using Tango.Logging; using Tango.SharedUI; namespace Tango.UITests @@ -33,71 +36,45 @@ namespace Tango.UITests /// </summary> public partial class MainWindow : Window { - private FirmwareUpdateManager _manager; - private DFUDevice _device; + private FirmwareUpgradeManager manager; public MainWindow() { - - Start(); InitializeComponent(); - //this.ContentRendered += MainWindow_ContentRendered; - } - private async void Start() - { - using (var db = ObservablesContext.CreateDefault()) - { - MachineVersion version = db.MachineVersions.FirstOrDefault(); - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == "1111"); - await version.ApplyPrototypeMachine(machine, db); - } + LogManager.Default.RegisterLogger(new VSOutputLogger()); + + manager = new FirmwareUpgradeManager(); + manager.UpgradeProgress += Manager_UpgradeProgress; } - private void MainWindow_ContentRendered(object sender, EventArgs e) + private void Manager_UpgradeProgress(object sender, FirmwareUpgradeProgressEventArgs e) { - Task.Factory.StartNew(() => + Dispatcher.Invoke(new Action(() => { - _manager = new FirmwareUpdateManager(); - _manager.Initialize(); - - _device = _manager.GetAvailableDevices(false).FirstOrDefault(); + txtStatus.Text = e.State.ToDescription(); + prog.Maximum = e.Total; + prog.Value = e.Progress; + })); - if (_device != null) - { - MessageBox.Show($"Detected device: '{_device.DeviceName}'."); - } - }); + Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, + new Action(delegate { })); } - private void btnStart_Click(object sender, RoutedEventArgs e) + private async void btnStart_Click(object sender, RoutedEventArgs e) { - OpenFileDialog dlg = new OpenFileDialog(); - if (dlg.ShowDialog().Value) + try { - byte[] data = File.ReadAllBytes(dlg.FileName); - _device.Upload(data, OnProgress); + OpenFileDialog dlg = new OpenFileDialog(); + if (dlg.ShowDialog().Value) + { + //await manager.PerformUpgrade(dlg.FileName); + MessageBox.Show("Completed !"); + } } - } - - private void OnProgress(ProgressMode progressMode, int current, int total) - { - this.BeginInvoke(() => - { - txtStatus.Text = progressMode.ToString(); - prog.Maximum = total; - prog.Value = current; - }); - } - - private void btnSwitch_Click(object sender, RoutedEventArgs e) - { - _device.SwitchToDFUMode(); - _device = _manager.GetAvailableDevices(false).FirstOrDefault(); - - if (_device.Mode == DFUMode.DFU) + catch (Exception ex) { - MessageBox.Show($"Switched to DFU mode: '{_device.DeviceName}'."); + MessageBox.Show(ex.ToString()); } } } diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj index 64ab69afe..dd160e480 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj +++ b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj @@ -111,6 +111,10 @@ <None Include="App.config" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Firmware\Tango.FirmwareUpdateLib.WPF\Tango.FirmwareUpdateLib.WPF.csproj"> + <Project>{25d7cc4d-a11c-4065-a797-4a1944f636c0}</Project> + <Name>Tango.FirmwareUpdateLib.WPF</Name> + </ProjectReference> <ProjectReference Include="..\..\Firmware\Tango.FirmwareUpdateLib\Tango.FirmwareUpdateLib.vcxproj"> <Project>{db79fb33-ce7a-49cf-aa89-f697e5cdb0f6}</Project> <Name>Tango.FirmwareUpdateLib</Name> @@ -135,6 +139,10 @@ <Project>{4399af76-db52-4cfb-8020-6f85bdb29fd5}</Project> <Name>Tango.Explorer</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> @@ -151,7 +159,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
