Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ await windowService.ShowDialogAsync(
l.Add(new MenuItemViewModel("GtkWaveOpen")
{
Header = "Open with GTKWave",
Command = new RelayCommand(() =>
containerProvider.Resolve<GtkWaveService>().OpenInGtkWave(wave.FullPath))
Command = new AsyncRelayCommand(async () =>
await containerProvider.Resolve<GtkWaveService>().OpenInGtkWaveAsync(wave))
});
if (x is [IProjectFile { Extension: ".pcf" } pcf])
{
Expand Down Expand Up @@ -530,7 +530,7 @@ await windowService.ShowDialogAsync(

containerProvider.Resolve<IDockService>().RegisterFileOpenOverwrite(x =>
{
containerProvider.Resolve<GtkWaveService>().OpenInGtkWave(x.FullPath);
containerProvider.Resolve<GtkWaveService>().OpenInGtkWaveAsync(x).RunSynchronously();
return true;
}, ".ghw", ".fst");
}
Expand Down
16 changes: 14 additions & 2 deletions src/OneWare.OssCadSuiteIntegration/Tools/GtkWaveService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using OneWare.Essentials.Enums;
using OneWare.Essentials.Models;
using OneWare.Essentials.Services;
using OneWare.UniversalFpgaProjectSystem.Context;

namespace OneWare.OssCadSuiteIntegration.Tools;

public class GtkWaveService(IChildProcessService childProcessService)
{
public void OpenInGtkWave(string path)
private static readonly string[] GtkProperties = ["GtkwSaveFile", "GtkwWaveArgs"];

public async Task OpenInGtkWaveAsync(IFile file)
{
childProcessService.StartWeakProcess("gtkwave", [Path.GetFileName(path)], Path.GetDirectoryName(path) ?? "");
var context = await TestBenchContextManager.LoadContextAsync(file);
List<string> args = [Path.GetFileName(file.FullPath)];

foreach (var property in GtkProperties)
if (context.Properties.TryGetPropertyValue(property, out var jsonNode) && jsonNode != null && jsonNode.GetValueKind() == System.Text.Json.JsonValueKind.String)
args.Add(jsonNode.GetValue<string>());

// save file has to be provided as second argument without "--save"
childProcessService.StartWeakProcess("gtkwave", args, Path.GetDirectoryName(file.FullPath) ?? "");
}
}
Loading