diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-07-05 10:37:21 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-07-05 10:37:21 +0300 |
| commit | 93f4cb963fa4ba040809779e60e64fb1161ea50d (patch) | |
| tree | d3f47dde9f92f20c480f9d3ccee88945fdbdf82a | |
| parent | 4d3782e72e3bc9db6aab280abe7dd8c9cc2b5dbe (diff) | |
| download | Tango-93f4cb963fa4ba040809779e60e64fb1161ea50d.tar.gz Tango-93f4cb963fa4ba040809779e60e64fb1161ea50d.zip | |
Several corrections
24 files changed, 286 insertions, 35 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index 46327eeae..95e4b4a52 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -123,7 +123,7 @@ <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryForegroundBrush}"></Setter> </DataTrigger> <DataTrigger Binding="{Binding RemoteDesktopProvider.IsWebRtcActive}" Value="True"> - <Setter Property="Text" Value="Remote desktop session is active using a fast communication channel."></Setter> + <Setter Property="Text" Value="Remote desktop session is active using a P2P communication channel."></Setter> </DataTrigger> </Style.Triggers> </Style> @@ -159,7 +159,7 @@ <Button IsEnabled="{Binding RemoteDesktopProvider.InSession}" Width="250" Margin="5" Style="{StaticResource FSE_Button_Polygon}" Content="Open Task Manager" Command="{Binding OpenTaskManagerCommand}" /> - <CheckBox Margin="5" HorizontalAlignment="Center" IsEnabled="{Binding RemoteDesktopProvider.InSession,Converter={StaticResource BooleanInverseConverter}}" IsChecked="{Binding RemoteDesktopProvider.EnableWebRtc}">Enable fast communication channel</CheckBox> + <CheckBox Margin="5" HorizontalAlignment="Center" IsEnabled="{Binding RemoteDesktopProvider.InSession,Converter={StaticResource BooleanInverseConverter}}" IsChecked="{Binding RemoteDesktopProvider.EnableWebRtc}">Enable P2P communication channel</CheckBox> </UniformGrid> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/ResultGridView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/ResultGridView.xaml.cs index 5dc17ed66..c16086d9f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/ResultGridView.xaml.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/ResultGridView.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; @@ -81,18 +82,22 @@ namespace Tango.FSE.Procedures.Dialogs //Generate columns foreach (var prop in model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { + var att = prop.GetCustomAttribute<DescriptionAttribute>(); + grid.Columns.Add(new DataGridTextColumn() { - Header = prop.Name, + Header = att != null ? att.Description : prop.Name, Binding = new Binding($"V{columnCount++}"), }); } foreach (var field in model.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) { + var att = field.GetCustomAttribute<DescriptionAttribute>(); + grid.Columns.Add(new DataGridTextColumn() { - Header = field.Name, + Header = att != null ? att.Description : field.Name, Binding = new Binding($"V{columnCount++}"), }); } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/UserInputDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/UserInputDialogViewVM.cs index 738c71ca9..e8fc957d9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/UserInputDialogViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/UserInputDialogViewVM.cs @@ -40,6 +40,7 @@ namespace Tango.FSE.Procedures.Dialogs if (Model.GetType().IsValueTypeOrString()) { Parameter p = new Parameter(); + p.Value = Model.ToStringSafe(); p.Name = "Value"; Parameters.Add(p); } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/IProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/IProcedureContext.cs index 84301896d..a142e183c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/IProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/IProcedureContext.cs @@ -294,8 +294,9 @@ namespace Tango.FSE.Procedures /// <summary> /// Gets the latest diagnostics package. /// </summary> + /// <param name="waitForNext">Waits for a fresh package.</param> /// <returns></returns> - DiagnosticsPackage GetDiagnosticsPackage(); + DiagnosticsPackage GetDiagnosticsPackage(bool waitForNext = false); /// <summary> /// Pauses the script execution for the specified time in milliseconds. diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProcedureContext.cs index 2ce26daa7..8724b12a5 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProcedureContext.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reactive.Concurrency; @@ -31,6 +32,7 @@ namespace Tango.FSE.Procedures private IProcedureLogger _logger; private ProcedureProject _project; private Dictionary<String, ProcedureInput> _inputs; + private DiagnosticsFrame _lastDiagnosticsFrame; [TangoInject] private IMachineProvider MachineProvider { get; set; } @@ -471,8 +473,26 @@ namespace Tango.FSE.Procedures WriteLine(line); } - public DiagnosticsPackage GetDiagnosticsPackage() + public DiagnosticsPackage GetDiagnosticsPackage(bool waitForNext = false) { + if (waitForNext) + { + Stopwatch watch = new Stopwatch(); + watch.Start(); + + while (_lastDiagnosticsFrame == DiagnosticsProvider.CurrentFrame) + { + Thread.Sleep(10); + + if (watch.Elapsed.TotalSeconds > 5) + { + throw new TimeoutException("Diagnostics package did not arrive within the given time of 5 seconds."); + } + } + } + + _lastDiagnosticsFrame = DiagnosticsProvider.CurrentFrame; + return DiagnosticsProvider.CurrentFrame.ToPackage(); } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/lib_template.csx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/lib_template.csx index 3b317dbad..0fcf7da88 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/lib_template.csx +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/lib_template.csx @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx index 8c17cf72f..4f0dd0922 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Result.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Result.cs index 3cd093f7f..ef63ae108 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Result.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Result.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -13,8 +14,11 @@ namespace Tango.FSE.Procedures public ResultType Type { get; set; } public String Name { get; set; } public Object Value { get; set; } + + [JsonIgnore] public bool IsGraph { get; set; } + [JsonIgnore] public bool IsValueArray { get { return Value != null && typeof(IEnumerable).IsAssignableFrom(Value.GetType()) && Value.GetType() != typeof(String); } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Procedures.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Procedures.csproj index b062266b3..79a5eb152 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Procedures.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Procedures.csproj @@ -224,6 +224,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.CSV\Tango.CSV.csproj"> + <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> + <Name>Tango.CSV</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/ProcedureRunnerViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/ProcedureRunnerViewVM.cs index cf54087ba..1c4fc18c9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/ProcedureRunnerViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/ProcedureRunnerViewVM.cs @@ -1,11 +1,15 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; using Tango.Core; using Tango.Core.Commands; +using Tango.CSV; using Tango.FSE.Common; using Tango.FSE.Procedures.Dialogs; using Tango.FSE.Procedures.Messages; @@ -21,6 +25,52 @@ namespace Tango.FSE.Procedures.ViewModels ProcedureRunnerExecutionView } + private class CsvRow + { + public Object V0 { get; set; } + public Object V1 { get; set; } + public Object V2 { get; set; } + public Object V3 { get; set; } + public Object V4 { get; set; } + public Object V5 { get; set; } + public Object V6 { get; set; } + public Object V7 { get; set; } + public Object V8 { get; set; } + public Object V9 { get; set; } + public Object V10 { get; set; } + public Object V11 { get; set; } + public Object V12 { get; set; } + public Object V13 { get; set; } + public Object V14 { get; set; } + public Object V15 { get; set; } + public Object V16 { get; set; } + public Object V17 { get; set; } + public Object V18 { get; set; } + public Object V19 { get; set; } + public Object V20 { get; set; } + } + + private class CsvColumn + { + public String Name { get; set; } + public String Description { get; set; } + public bool IsProperty { get; set; } + public PropertyInfo PropertyInfo { get; set; } + public FieldInfo FieldInfo { get; set; } + + public Object GetValue(Object obj) + { + if (IsProperty) + { + return PropertyInfo.GetValue(obj); + } + else + { + return FieldInfo.GetValue(obj); + } + } + } + private bool _requiresReloadingOfProjects; private RunnerView _selectedView; @@ -104,6 +154,7 @@ namespace Tango.FSE.Procedures.ViewModels public RelayCommand StartProjectCommand { get; set; } public RelayCommand StopProjectCommand { get; set; } public RelayCommand<Result> DisplayResultGridCommand { get; set; } + public RelayCommand<Result> ExportResultGridCommand { get; set; } public ProcedureRunnerViewVM() { @@ -112,6 +163,7 @@ namespace Tango.FSE.Procedures.ViewModels StartProjectCommand = new RelayCommand(StartProject, () => ProjectRunner != null && ProjectRunner.CanRun); StopProjectCommand = new RelayCommand(StopProject, () => ProjectRunner != null && ProjectRunner.IsRunning); DisplayResultGridCommand = new RelayCommand<Result>(DisplayResultGrid); + ExportResultGridCommand = new RelayCommand<Result>(ExportResultGrid); _requiresReloadingOfProjects = true; RegisterForMessage<ProcedureProjectPublishedOrSuppressed>((x) => _requiresReloadingOfProjects = true); @@ -251,5 +303,98 @@ namespace Tango.FSE.Procedures.ViewModels NotificationProvider.ShowDialog(vm); } } + + private async void ExportResultGrid(Result result) + { + if (result != null && result.IsValueArray && (result.Value as IList).Count > 0) + { + var r = await StorageProvider.SaveFile("Export procedure result", "CSV Files|*.csv", result.Name + ".csv", ".csv"); + if (r.Confirmed) + { + using (NotificationProvider.PushTaskItem("Exporting csv file...")) + { + try + { + await Task.Factory.StartNew(() => + { + List<Object> values = (result.Value as IEnumerable).Cast<Object>().ToList(); + + var model = values.First(); + + if (model.GetType().IsValueTypeOrString()) + { + CsvFile<CsvRow> csvFile = new CsvFile<CsvRow>(new CsvDestination(r.SelectedItem), new CsvDefinition() { Columns = new List<String>() { "Values" } }); + + foreach (var value in values) + { + csvFile.Append(new CsvRow() + { + V0 = value + }); + } + + csvFile.Dispose(); + } + else + { + List<CsvColumn> columns = new List<CsvColumn>(); + + //prop columns + foreach (var prop in model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + var att = prop.GetCustomAttribute<DescriptionAttribute>(); + columns.Add(new CsvColumn() + { + Name = prop.Name, + Description = att != null ? att.Description : prop.Name, + IsProperty = true, + PropertyInfo = prop + }); + } + + //field columns + foreach (var field in model.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) + { + var att = field.GetCustomAttribute<DescriptionAttribute>(); + columns.Add(new CsvColumn() + { + Name = field.Name, + Description = att != null ? att.Description : field.Name, + FieldInfo = field + }); + } + + CsvFile<CsvRow> csvFile = new CsvFile<CsvRow>(new CsvDestination(r.SelectedItem), new CsvDefinition() { Columns = columns.Select(x => x.Description).ToList() }); + + List<PropertyInfo> rowProps = typeof(CsvRow).GetProperties().ToList(); + + foreach (var value in values) + { + CsvRow row = new CsvRow(); + + for (int i = 0; i < columns.Count; i++) + { + var column = columns[i]; + rowProps[i].SetValue(row, column.GetValue(value)); + } + + csvFile.Append(row); + } + + csvFile.Dispose(); + } + }); + + await NotificationProvider.ShowSuccess("File exported successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting csv file."); + await NotificationProvider.ShowError($"Error occurred while exporting the csv file.\n{ex.FlattenMessage()}"); + } + } + } + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureDesignerView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureDesignerView.xaml index b76b3af5d..26c1e19b8 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureDesignerView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureDesignerView.xaml @@ -234,7 +234,7 @@ <TextBox Background="{StaticResource FSE_PrimaryBackgroundBrush}" Padding="5" Text="{Binding Project.Name,UpdateSourceTrigger=PropertyChanged,NotifyOnValidationError=True,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" Margin="0 2 0 0" Style="{StaticResource FSE_Rounded_Corners_TextBox}"></TextBox> <TextBlock Foreground="{StaticResource FSE_GrayBrush}" Margin="2 15 0 0" FontSize="{StaticResource FSE_SmallFontSize}">Description</TextBlock> - <TextBox Text="{Binding Project.Description,UpdateSourceTrigger=PropertyChanged}" Margin="0 2 0 0" Style="{StaticResource FSE_Rounded_Corners_TextBox_Multiline}" MinHeight="100"></TextBox> + <TextBox Text="{Binding Project.Description,UpdateSourceTrigger=PropertyChanged}" Margin="0 2 0 0" Style="{StaticResource FSE_Rounded_Corners_TextBox_Multiline}" MinHeight="100" TextWrapping="Wrap"></TextBox> </StackPanel> <DockPanel Margin="0 20 0 0"> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureRunnerExecutionView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureRunnerExecutionView.xaml index a85a3e024..1f682c033 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureRunnerExecutionView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Views/ProcedureRunnerExecutionView.xaml @@ -149,6 +149,7 @@ <Run Text="Values."></Run> </TextBlock> <Button Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.DisplayResultGridCommand}" CommandParameter="{Binding}" Height="22" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" Background="Transparent" BorderBrush="Transparent" Margin="0 -4 0 0">(Grid View)</Button> + <Button Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.ExportResultGridCommand}" CommandParameter="{Binding}" Height="22" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" Background="Transparent" Padding="0" BorderBrush="Transparent" Margin="0 -4 0 0">(Export To CSV)</Button> </StackPanel> <StackPanel Visibility="{Binding IsGraph,Converter={StaticResource BooleanToVisibilityConverter}}"> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeGeneratedViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeGeneratedViewVM.cs index f1737463d..003aebab0 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeGeneratedViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeGeneratedViewVM.cs @@ -247,14 +247,17 @@ namespace Tango.FSE.Upgrade.ViewModels { var abort = await NotificationProvider.ShowWarningQuestion("Are you sure you want to abort the upgrade operation?"); - if (Handler.CanAbort) + if (Handler.Status == RemoteUpgradeHandlerStatus.Started) { - Handler.Abort(); - } - else - { - await NotificationProvider.ShowWarning("Cannot abort the operation at this stage."); - return false; + if (Handler.CanAbort) + { + Handler.Abort(); + } + else + { + await NotificationProvider.ShowWarning("Cannot abort the operation at this stage."); + return false; + } } return abort; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeGeneratedViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeGeneratedViewVM.cs index ec35a9581..57cd3aa43 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeGeneratedViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeGeneratedViewVM.cs @@ -219,14 +219,17 @@ namespace Tango.FSE.Upgrade.ViewModels { var abort = await NotificationProvider.ShowWarningQuestion("Are you sure you want to abort the upgrade operation?"); - if (Handler.CanAbort) + if (Handler.Status == RemoteUpgradeHandlerStatus.Started) { - Handler.Abort(); - } - else - { - await NotificationProvider.ShowWarning("Cannot abort the operation at this stage."); - return false; + if (Handler.CanAbort) + { + Handler.Abort(); + } + else + { + await NotificationProvider.ShowWarning("Cannot abort the operation at this stage."); + return false; + } } return abort; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeViewVM.cs index 6a5ba78b1..ed434d92f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/FirmwareUpgradeViewVM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -40,6 +41,14 @@ namespace Tango.FSE.Upgrade.ViewModels set { _existingTfpFileLocation = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private String _existingTfpFileVersion; + public String ExistingTfpFileVersion + { + get { return _existingTfpFileVersion; } + set { _existingTfpFileVersion = value; RaisePropertyChangedAuto(); } + } + + private RemoteUpgradeHandler _handler; public RemoteUpgradeHandler Handler { @@ -77,6 +86,22 @@ namespace Tango.FSE.Upgrade.ViewModels var result = await StorageProvider.OpenFile("Select existing firmware package file", "Tango Firmware Package|*.tfp"); if (result) { + try + { + LogManager.Log("Validating firmware package file..."); + using (FileStream s = File.OpenRead(result.SelectedItem)) + { + var package = MachineProvider.MachineOperator.GetFirmwarePackageInfo(s).Result; + package.Validate(); + ExistingTfpFileVersion = package.GetMcuVersion().ToString(); + } + } + catch (Exception ex) + { + await NotificationProvider.ShowError($"Error loading the selected tfp file.\n{ex.FlattenMessage()}"); + return; + } + ExistingTfpFileLocation = result.SelectedItem; } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeGeneratedView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeGeneratedView.xaml index 3c775f3f3..c1f60d813 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeGeneratedView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeGeneratedView.xaml @@ -69,7 +69,7 @@ <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource FSE_LargeFontSize}">UPGRADE NOW</TextBlock> </StackPanel> </Button> - <Button material:ButtonAssist.CornerRadius="25" Command="{Binding SaveTupFileCommand}" Visibility="{Binding ElementName=chkSaveToDisk,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="250" Height="50"> + <Button material:ButtonAssist.CornerRadius="25" Command="{Binding SaveTupFileCommand}" Visibility="{Binding ElementName=chkSaveToDisk,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="250" Height="50" VerticalAlignment="Bottom"> <StackPanel Orientation="Horizontal"> <material:PackIcon Width="32" Height="28" Kind="ContentSaveEdit" /> <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource FSE_LargeFontSize}">SAVE PACKAGE</TextBlock> @@ -78,7 +78,7 @@ </Grid> <StackPanel VerticalAlignment="Bottom" Margin="0 0 40 0"> - <TextBlock Text="{Binding Handler.Progress.Message}" ToolTip="{Binding Handler.Progress.Message}" TextTrimming="CharacterEllipsis" Style="{StaticResource FSE_HandlerStatusTextBlock}"></TextBlock> + <TextBlock Text="{Binding Handler.Progress.Message}" TextWrapping="NoWrap" MaxHeight="110" TextTrimming="CharacterEllipsis" ToolTip="{Binding Handler.Progress.Message}" Style="{StaticResource FSE_HandlerStatusTextBlock}"></TextBlock> <ProgressBar Margin="0 5 0 0" Minimum="0" Maximum="{Binding Handler.Progress.Maximum}" Value="{Binding Handler.Progress.Value}" IsIndeterminate="{Binding Handler.Progress.IsIndeterminate}"></ProgressBar> </StackPanel> </DockPanel> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml index 046259d75..3a1ab183d 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml @@ -22,7 +22,7 @@ </Style> </Grid.Style> <StackPanel> - <TextBlock FontSize="{StaticResource FSE_LargeFontSize}">Application Upgrade</TextBlock> + <TextBlock FontSize="{StaticResource FSE_LargeFontSize}">Full Upgrade</TextBlock> <TextBlock Margin="0 10 0 0" Foreground="{StaticResource FSE_GrayBrush}" LineHeight="20" Visibility="{Binding ResolutionService.IsHighResolution,Converter={StaticResource BooleanToVisibilityConverter}}"> <Run>You chose to perform a machine application and firmware upgrade.</Run> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeGeneratedView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeGeneratedView.xaml index a8739b347..a9d6034fd 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeGeneratedView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeGeneratedView.xaml @@ -52,7 +52,7 @@ <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="1000"> <DockPanel> <Grid DockPanel.Dock="Right" > - <Button material:ButtonAssist.CornerRadius="25" Visibility="{Binding ElementName=chkUpgradeNow,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding StartUpgradeCommand}" HorizontalAlignment="Right" Width="250" Height="50"> + <Button material:ButtonAssist.CornerRadius="25" Visibility="{Binding ElementName=chkUpgradeNow,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding StartUpgradeCommand}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="250" Height="50"> <StackPanel Orientation="Horizontal"> <material:PackIcon Width="32" Height="28" Kind="ClockFast" /> <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource FSE_LargeFontSize}">UPGRADE NOW</TextBlock> @@ -67,7 +67,7 @@ </Grid> <StackPanel VerticalAlignment="Bottom" Margin="0 0 40 0"> - <TextBlock Text="{Binding Handler.Progress.Message}" Style="{StaticResource FSE_HandlerStatusTextBlock}"></TextBlock> + <TextBlock Text="{Binding Handler.Progress.Message}" TextWrapping="NoWrap" MaxHeight="110" TextTrimming="CharacterEllipsis" ToolTip="{Binding Handler.Progress.Message}" Style="{StaticResource FSE_HandlerStatusTextBlock}"></TextBlock> <ProgressBar Margin="0 5 0 0" Minimum="0" Maximum="{Binding Handler.Progress.Maximum}" Value="{Binding Handler.Progress.Value}" IsIndeterminate="{Binding Handler.Progress.IsIndeterminate}"></ProgressBar> </StackPanel> </DockPanel> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeView.xaml index d105c5617..6aeb0fcb1 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/FirmwareUpgradeView.xaml @@ -67,12 +67,17 @@ </DockPanel> </RadioButton> - <StackPanel IsEnabled="{Binding ElementName=chkExisting,Path=IsChecked}" Margin="80 10 0 0" Width="380" HorizontalAlignment="Left"> + <StackPanel IsEnabled="{Binding ElementName=chkExisting,Path=IsChecked}" Margin="80 10 0 0" HorizontalAlignment="Left"> <TextBlock>Select an existing .tfp file on your computer</TextBlock> <DockPanel Margin="0 0 0 0"> + <DockPanel DockPanel.Dock="Right" Margin="0 0 0 0" Visibility="{Binding ExistingTfpFileLocation,Converter={StaticResource IsNullToVisibilityConverter}}"> + <TextBlock Margin="10 0 0 0" Foreground="{StaticResource FSE_PrimaryAccentBrush}" FontSize="{StaticResource FSE_SmallFontSize}" VerticalAlignment="Center"> + <Run>v</Run><Run Text="{Binding ExistingTfpFileVersion}"></Run> + </TextBlock> + </DockPanel> <controls:IconButton ToolTip="Browse for .tfp file" Margin="5 0 0 0" DockPanel.Dock="Right" Icon="FolderOpenOutline" Width="38" Height="38" Command="{Binding SelectExistingTfpFileLocationCommand}" /> - <TextBox FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" IsReadOnly="True" Text="{Binding ExistingTfpFileLocation,Converter={StaticResource FilePathToFileNameConverter}}" VerticalContentAlignment="Bottom"></TextBox> + <TextBox Width="350" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" IsReadOnly="True" Text="{Binding ExistingTfpFileLocation,Converter={StaticResource FilePathToFileNameConverter}}" VerticalContentAlignment="Bottom"></TextBox> </DockPanel> </StackPanel> </StackPanel> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs index 85e48a045..e06c2f95b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs @@ -102,18 +102,21 @@ namespace Tango.FSE.Common.RemoteUpgrade { FailedException = exception; Status = RemoteUpgradeHandlerStatus.Failed; + CanAbort = true; _completionSource.SetException(exception); } internal void RaiseCompleted() { Status = RemoteUpgradeHandlerStatus.Completed; + CanAbort = true; _completionSource.SetResult(Status); } internal void RaiseAborted() { Status = RemoteUpgradeHandlerStatus.Aborted; + CanAbort = true; _completionSource.SetException(new OperationCanceledException("Remote upgrade operation aborted.")); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs index 087e30be6..7869e6990 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs @@ -24,6 +24,7 @@ namespace Tango.PPC.Jobs.ViewModels public class MainViewVM : PPCViewModel { private NotificationItem _last_failed_job_notification; + private bool resuming; /// <summary> /// Called when the application has been started. @@ -33,15 +34,14 @@ namespace Tango.PPC.Jobs.ViewModels MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; MachineProvider.MachineOperator.ResumingJob += MachineOperator_ResumingJob; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; } - private void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e) + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) { - LogManager.Log($"Trying to resume job '{e.JobGuid}'..."); - - try + if (resuming) { - e.Approve(); + resuming = false; InvokeUI(() => { @@ -54,6 +54,17 @@ namespace Tango.PPC.Jobs.ViewModels } }); } + } + + private void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e) + { + LogManager.Log($"Job resume request '{e.JobGuid}' approving..."); + + try + { + e.Approve(); + resuming = true; + } catch (Exception ex) { LogManager.Log(ex, "An error occurred while trying to resume the job."); 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 54a92aa5c..d4d78dac6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -609,6 +609,7 @@ namespace Tango.PPC.UI.ViewModels { _update_result = await MachineUpdateManager.UpdateFromTUP(request.RemoteTupFilePath, request.SetupFirmware, request.SetupFPGA); LogManager.Log("Machine update from package completed."); + stopReporting = true; InvokeUI(() => { @@ -624,6 +625,8 @@ namespace Tango.PPC.UI.ViewModels { NavigateTo(MachineUpdateView.UpdateFailedFromPackageView); }); + + throw ex; } await receiver.SendGenericResponse(new StartRemoteApplicationUpgradeResponse() @@ -646,10 +649,13 @@ namespace Tango.PPC.UI.ViewModels } catch (Exception ex) { + stopReporting = true; await receiver.SendErrorResponse(ex, token); } finally { + stopReporting = true; + try { File.Delete(request.RemoteTupFilePath); @@ -707,6 +713,7 @@ namespace Tango.PPC.UI.ViewModels try { await MachineUpdateManager.UpdateFromTFP(request.RemoteTfpFilePath); + stopReporting = true; LogManager.Log("Firmware upgrade from package completed."); _update_result = new MachineUpdateResult() { @@ -720,6 +727,8 @@ namespace Tango.PPC.UI.ViewModels } catch (Exception ex) { + stopReporting = true; + LogManager.Log(ex, "Firmware upgrade from package failed."); FailedError = ex.FlattenMessage(); @@ -727,6 +736,8 @@ namespace Tango.PPC.UI.ViewModels { NavigateTo(MachineUpdateView.UpdateFailedFromPackageView); }); + + throw ex; } await receiver.SendGenericResponse(new StartRemoteFirmwareUpgradeResponse() @@ -749,10 +760,13 @@ namespace Tango.PPC.UI.ViewModels } catch (Exception ex) { + stopReporting = true; await receiver.SendErrorResponse(ex, token); } finally { + stopReporting = true; + try { File.Delete(request.RemoteTfpFilePath); diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs index 6417e34f8..3ceecae4b 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs @@ -1939,6 +1939,8 @@ namespace Tango.Scripting.Editors currentLine = currentLine.Split('(')[currentLine.Split('(').Length - 2]; } + currentLine = Regex.Replace(currentLine, "(?<=\")(.*?)(?=\")", string.Empty); + var words = currentLine.Split(' '); if (words.Count() > 0 && (words.First() == "private" || words.First() == "public" || words.First() == "void")) @@ -1951,6 +1953,8 @@ namespace Tango.Scripting.Editors if (expression != null) { int parameterIndex = expression.Count(x => x == ','); + + expression = new string(expression.TakeWhile(x => x != '(').ToArray()); var tree = expression.Split('.').Select(x => x.Remove(@"\n|\r|\s|\t|\(|\)|\[|\]|<.*>")).ToList(); diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 81166ac2e..cba768fce 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -1201,7 +1201,7 @@ namespace Tango.Transport { ErrorCode = ErrorCode.GeneralError, Completed = true, - ErrorMessage = exception.Message + ErrorMessage = exception.FlattenMessage() }); } |
