-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
424088d
commit fbdded7
Showing
12 changed files
with
276 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
src/OneWare.Quartus/ViewModels/QuartusCompileSettingsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
src/OneWare.Quartus/ViewModels/QuartusLoaderSettingsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using DynamicData; | ||
using OneWare.Essentials.Controls; | ||
using OneWare.Essentials.ViewModels; | ||
using OneWare.Settings; | ||
using OneWare.Settings.ViewModels; | ||
using OneWare.Settings.ViewModels.SettingTypes; | ||
using OneWare.UniversalFpgaProjectSystem.Fpga; | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
using OneWare.UniversalFpgaProjectSystem.Parser; | ||
|
||
namespace OneWare.Quartus.ViewModels; | ||
|
||
public class QuartusLoaderSettingsViewModel : FlexibleWindowViewModelBase | ||
{ | ||
private readonly UniversalFpgaProjectRoot _projectRoot; | ||
private readonly Dictionary<string, string> _settings; | ||
private readonly IFpga _fpga; | ||
private readonly ComboBoxSetting _shortTermModeSetting; | ||
private readonly TitledSetting _shortTermOperationSetting; | ||
private readonly TitledSetting _shortTermArgumentsSetting; | ||
private readonly ComboBoxSetting _longTermModeSetting; | ||
private readonly TitledSetting _longTermOperationSetting; | ||
private readonly ComboBoxSetting _longTermFormatSetting; | ||
private readonly TitledSetting _longTermCpfArgumentsSetting; | ||
private readonly TitledSetting _longTermArgumentsSetting; | ||
|
||
public SettingsCollectionViewModel SettingsCollection { get; } = new("Quartus Loader Settings") | ||
{ | ||
ShowTitle = false | ||
}; | ||
|
||
public QuartusLoaderSettingsViewModel(UniversalFpgaProjectRoot projectRoot, IFpga fpga) | ||
{ | ||
_projectRoot = projectRoot; | ||
_fpga = fpga; | ||
|
||
Title = "Quartus Loader Settings"; | ||
Id = "Quartus Loader Settings"; | ||
|
||
var defaultProperties = fpga.Properties; | ||
_settings = FpgaSettingsParser.LoadSettings(projectRoot, fpga.Name); | ||
|
||
_shortTermModeSetting = new ComboBoxSetting("Short Term Mode", "Mode to use for Short Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_ShortTerm_Mode") ?? "", ["JTAG", "CJTAG", "AS", "PS"]); | ||
|
||
_shortTermOperationSetting = new TitledSetting("Short Term Operation", "Operation to use for Short Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_ShortTerm_Operation") ?? ""); | ||
|
||
_shortTermArgumentsSetting = new TitledSetting("Short Term Additional Arguments", "Additional Arguments to use for Short Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_ShortTerm_Arguments") ?? ""); | ||
|
||
_longTermModeSetting = new ComboBoxSetting("Long Term Mode", "Mode to use for Long Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_LongTerm_Mode") ?? "", ["JTAG", "CJTAG", "AS", "PS"]); | ||
|
||
_longTermOperationSetting = new TitledSetting("Long Term Operation", "Operation to use for Long Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_LongTerm_Operation") ?? ""); | ||
|
||
_longTermFormatSetting = new ComboBoxSetting("Long Term Format", "Programming Format to use", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_LongTerm_Format") ?? "", ["POF", "JIC"]); | ||
|
||
_longTermCpfArgumentsSetting = new TitledSetting("Long Term Cpf Arguments", "If format is different from POF, these arguments will be used to convert .sof to given format", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_LongTerm_CpfArguments") ?? ""); | ||
|
||
_longTermArgumentsSetting = new TitledSetting("Long Term Additional Arguments", "Additional Arguments to use for Long Term Programming", | ||
defaultProperties.GetValueOrDefault("QuartusProgrammer_LongTerm_Arguments") ?? ""); | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_ShortTerm_Mode", out var qPstMode)) | ||
_shortTermModeSetting.Value = qPstMode; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_ShortTerm_Operation", out var qPstOperation)) | ||
_shortTermOperationSetting.Value = qPstOperation; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_ShortTerm_Arguments", out var qPstArguments)) | ||
_shortTermArgumentsSetting.Value = qPstArguments; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_LongTerm_Mode", out var qPltMode)) | ||
_longTermModeSetting.Value = qPltMode; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_LongTerm_Operation", out var qPltOperation)) | ||
_longTermOperationSetting.Value = qPltOperation; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_LongTerm_Format", out var qPltFormat)) | ||
_longTermFormatSetting.Value = qPltFormat; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_LongTerm_CpfArguments", out var qPltCpfArguments)) | ||
_longTermCpfArgumentsSetting.Value = qPltCpfArguments; | ||
|
||
if (_settings.TryGetValue("QuartusProgrammer_LongTerm_Arguments", out var qPltArguments)) | ||
_longTermArgumentsSetting.Value = qPltArguments; | ||
|
||
SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_shortTermModeSetting)); | ||
SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_shortTermOperationSetting)); | ||
SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_shortTermArgumentsSetting)); | ||
SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_longTermModeSetting)); | ||
SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_longTermOperationSetting)); | ||
SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_longTermFormatSetting)); | ||
SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_longTermCpfArgumentsSetting)); | ||
SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_longTermArgumentsSetting)); | ||
} | ||
|
||
public void Save(FlexibleWindow flexibleWindow) | ||
{ | ||
_settings["QuartusProgrammer_ShortTerm_Mode"] = _shortTermModeSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_ShortTerm_Operation"] = _shortTermOperationSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_ShortTerm_Arguments"] = _shortTermArgumentsSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_LongTerm_Mode"] = _longTermModeSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_LongTerm_Operation"] = _longTermOperationSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_LongTerm_Format"] = _longTermFormatSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_LongTerm_CpfArguments"] = _longTermCpfArgumentsSetting.Value.ToString()!; | ||
_settings["QuartusProgrammer_LongTerm_Arguments"] = _longTermArgumentsSetting.Value.ToString()!; | ||
|
||
FpgaSettingsParser.SaveSettings(_projectRoot, _fpga.Name, _settings); | ||
|
||
Close(flexibleWindow); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
foreach (var setting in SettingsCollection.SettingModels) | ||
{ | ||
setting.Setting.Value = setting.Setting.DefaultValue; | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/OneWare.Quartus/ViewModels/QuartusLoaderWindowExtensionViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Threading; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using OneWare.Essentials.Services; | ||
using OneWare.Quartus.Views; | ||
using OneWare.UniversalFpgaProjectSystem.Fpga; | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
using OneWare.UniversalFpgaProjectSystem.Services; | ||
using Prism.Ioc; | ||
|
||
namespace OneWare.Quartus.ViewModels; | ||
|
||
public class QuartusLoaderWindowExtensionViewModel : ObservableObject | ||
{ | ||
private readonly IWindowService _windowService; | ||
private readonly UniversalFpgaProjectRoot _projectRoot; | ||
private readonly IFpga? _fpga; | ||
|
||
public bool IsVisible { get; } | ||
|
||
public bool IsEnabled { get; } | ||
|
||
public QuartusLoaderWindowExtensionViewModel(UniversalFpgaProjectRoot projectRoot, IWindowService windowService, FpgaService fpgaService) | ||
{ | ||
_windowService = windowService; | ||
_projectRoot = projectRoot; | ||
|
||
_fpga = fpgaService.Fpgas.FirstOrDefault(x => x.Name == projectRoot.GetProjectProperty("Fpga")); | ||
|
||
IsVisible = projectRoot.Loader is QuartusLoader; | ||
IsEnabled = _fpga != null; | ||
} | ||
|
||
public async Task OpenSettingsAsync(Control control) | ||
{ | ||
if (_fpga == null) return; | ||
|
||
var ownerWindow = TopLevel.GetTopLevel(control) as Window; | ||
await Dispatcher.UIThread.InvokeAsync(async () => | ||
{ | ||
try | ||
{ | ||
await _windowService.ShowDialogAsync(new QuartusLoaderSettingsView() | ||
{ DataContext = new QuartusLoaderSettingsViewModel(_projectRoot, _fpga) }, ownerWindow); | ||
} | ||
catch (Exception e) | ||
{ | ||
ContainerLocator.Container.Resolve<ILogger>().Error(e.Message, e); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<controls:FlexibleWindow xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:controls="clr-namespace:OneWare.Essentials.Controls;assembly=OneWare.Essentials" | ||
xmlns:behaviours="clr-namespace:OneWare.Essentials.Behaviours;assembly=OneWare.Essentials" | ||
xmlns:viewModels="clr-namespace:OneWare.Quartus.ViewModels" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" PrefHeight="370" PrefWidth="400" | ||
CustomIcon="{DynamicResource Material.SettingsOutline}" | ||
Icon="avares://OneWare.Core/Assets/Images/Icons/Settings_White.png" | ||
x:Class="OneWare.Quartus.Views.QuartusLoaderSettingsView" Name="QuartusLoaderSettingsViewView" | ||
WindowStartupLocation="CenterOwner" Title="Quartus Loader Settings" x:DataType="viewModels:QuartusLoaderSettingsViewModel"> | ||
<Interaction.Behaviors> | ||
<behaviours:CommandOnEnterBehaviour Command="{Binding Save}" | ||
CommandParameter="{Binding #QuartusLoaderSettingsViewView}" /> | ||
</Interaction.Behaviors> | ||
<DockPanel> | ||
<StackPanel DockPanel.Dock="Bottom" Margin="8" Classes="WindowButtons" HorizontalAlignment="Right" | ||
VerticalAlignment="Bottom"> | ||
<Button Command="{Binding Reset}" ToolTip.Tip="Reset to Device Default"> | ||
<TextBlock Text="Reset" /> | ||
</Button> | ||
<Button Background="{DynamicResource HighlightBrush}" Command="{Binding Save}" | ||
CommandParameter="{Binding #QuartusLoaderSettingsViewView}"> | ||
<TextBlock Text="Save" /> | ||
</Button> | ||
</StackPanel> | ||
<ScrollViewer DockPanel.Dock="Top" > | ||
<ContentControl Padding="4" Content="{Binding SettingsCollection}"/> | ||
</ScrollViewer> | ||
</DockPanel> | ||
</controls:FlexibleWindow> |
11 changes: 11 additions & 0 deletions
11
src/OneWare.Quartus/Views/QuartusLoaderSettingsView.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using OneWare.Essentials.Controls; | ||
|
||
namespace OneWare.Quartus.Views; | ||
|
||
public partial class QuartusLoaderSettingsView : FlexibleWindow | ||
{ | ||
public QuartusLoaderSettingsView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OneWare.Quartus/Views/QuartusLoaderWindowExtensionView.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:viewModels1="clr-namespace:OneWare.Quartus.ViewModels" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" IsVisible="{Binding IsVisible}" | ||
x:Class="OneWare.Quartus.Views.QuartusLoaderWindowExtensionView" x:DataType="viewModels1:QuartusLoaderWindowExtensionViewModel"> | ||
<MenuItem Header="Quartus Loader Settings" | ||
Command="{Binding OpenSettingsAsync}" | ||
IsEnabled="{Binding IsEnabled}"> | ||
<MenuItem.Icon> | ||
<Image Source="{DynamicResource Material.SettingsOutline}"/> | ||
</MenuItem.Icon> | ||
</MenuItem> | ||
</UserControl> |
11 changes: 11 additions & 0 deletions
11
src/OneWare.Quartus/Views/QuartusLoaderWindowExtensionView.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Avalonia.Controls; | ||
|
||
namespace OneWare.Quartus.Views; | ||
|
||
public partial class QuartusLoaderWindowExtensionView : UserControl | ||
{ | ||
public QuartusLoaderWindowExtensionView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters