Skip to content

Enhance repository proficiency by introducing Async Gateway APIs and Connection Status tracking - #3

Open
anoop6543 wants to merge 1 commit into
masterfrom
async-gateway-and-connection-status-17288054008961105129
Open

Enhance repository proficiency by introducing Async Gateway APIs and Connection Status tracking#3
anoop6543 wants to merge 1 commit into
masterfrom
async-gateway-and-connection-status-17288054008961105129

Conversation

@anoop6543

Copy link
Copy Markdown
Owner

Enhance repository proficiency by introducing Async Gateway APIs and Connection Status tracking

  • Converted synchronous IMachineGatewayService and IDataGatewayService methods to Task-based asynchronous signatures to prepare for remote machine boundaries and network latency.
  • Updated TryApplyOrchestration to use Task<(bool Success, string Message)> to replace out parameters.
  • Replaced synchronous ExecuteWithRetry calls with ExecuteWithRetryAsync in the backend services (ErrorHandlingService, RemoteTwinCatMachineGatewayMock).
  • Created a comprehensive GatewayConnectionState enum and implemented connection status tracking across the stack (Services, ViewModels, and UI).
  • Modified MainViewModel to execute backend commands asynchronously, improving UI thread responsiveness.
  • Added GitHub Actions CI workflow for automated .NET 10.0 Windows build validation.

PR created automatically by Jules for task 17288054008961105129 started by @anoop6543

…Connection Status tracking

- Converted synchronous `IMachineGatewayService` and `IDataGatewayService` methods to `Task`-based asynchronous signatures to prepare for remote machine boundaries and network latency.
- Updated `TryApplyOrchestration` to use `Task<(bool Success, string Message)>` to replace `out` parameters.
- Replaced synchronous `ExecuteWithRetry` calls with `ExecuteWithRetryAsync` in the backend services (`ErrorHandlingService`, `RemoteTwinCatMachineGatewayMock`).
- Created a comprehensive `GatewayConnectionState` enum and implemented connection status tracking across the stack (Services, ViewModels, and UI).
- Modified `MainViewModel` to execute backend commands asynchronously, improving UI thread responsiveness.
- Added GitHub Actions CI workflow for automated `.NET 10.0` Windows build validation.

Co-authored-by: anoop6543 <21349508+anoop6543@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 19:02
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Converts the IMachineGatewayService / IDataGatewayService surface from synchronous to Task-based async, replaces TryApplyOrchestration's out parameter with a tuple return, and introduces a GatewayConnectionState enum plumbed through services, the MainViewModel, and the WPF status panel. Also adds a GitHub Actions workflow for .NET 10 Windows builds.

Changes:

  • Async-ify gateway contracts and update both LocalSimulationServiceGateway and RemoteTwinCatMachineGatewayMock implementations (plus a new ExecuteWithRetryAsync helper).
  • Add GatewayConnectionState, expose it on IMachineGatewayService, and bind a status indicator in MainWindow.xaml via MainViewModel.
  • Add .github/workflows/dotnet.yml CI workflow and enable EnableWindowsTargeting in the project file.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Services/HmiServiceContracts.cs Adds GatewayConnectionState enum and async signatures across both gateway interfaces.
Services/LocalSimulationServiceGateway.cs Implements async wrappers using Task.FromResult; stubs the connection-state event/property.
Services/RemoteTwinCatMock/RemoteTwinCatMachineGatewayMock.cs Adopts async pipeline, forwards connection-state event to inner gateway, uses ExecuteWithRetryAsync.
Services/ErrorHandlingService.cs Adds ExecuteWithRetryAsync<T> with circuit-breaker + retry semantics mirroring the sync version.
ViewModels/MainViewModel.cs Awaits new async gateway calls, adds connection-state properties, and converts several command handlers to async void.
MainWindow.xaml Adds gateway-mode and connection-state indicator UI bound to the new VM properties.
XTSPrimeMoverProject.csproj Adds <EnableWindowsTargeting>true</EnableWindowsTargeting> to enable non-Windows builds.
.github/workflows/dotnet.yml New CI workflow building the project on windows-latest with .NET 10.


public event EventHandler? StateChanged;
public event EventHandler<string>? LogGenerated;
public event EventHandler<GatewayConnectionState>? ConnectionStateChanged { add { } remove { } }
private string _orchestrationStatus;
private string _orchestrationValidationStatus;
private string _gatewayModeStatus;
private string _gatewayMode;
Comment on lines 307 to +529
@@ -327,9 +371,9 @@ private void LoadSelectedDbTableRows()

try
{
var columns = _data.GetTableColumns(SelectedDbTable);
int totalRows = _data.GetTableRowCount(SelectedDbTable);
var rows = _data.GetTableRows(SelectedDbTable, 500);
var columns = await _data.GetTableColumnsAsync(SelectedDbTable);
int totalRows = await _data.GetTableRowCountAsync(SelectedDbTable);
var rows = await _data.GetTableRowsAsync(SelectedDbTable, 500);

var table = new DataTable(SelectedDbTable);
foreach (var col in columns)
@@ -354,12 +398,17 @@ private void LoadSelectedDbTableRows()
}
catch (Exception ex)
{
_errorHandler.ReportException(ErrorCategory.ViewModel, "MainVM.LoadSelectedDbTableRows", ex);
_errorHandler.ReportException(ErrorCategory.ViewModel, "LoadSelectedDbTableRowsAsync", ex);
DbTableRowsView = CreateEmptyDbTableView();
DbTableStatus = $"DB table validation/load failed: {ex.Message}";
}
}

private void LoadSelectedDbTableRows()
{
_ = LoadSelectedDbTableRowsAsync();
}

private static DataView CreateEmptyDbTableView()
{
var t = new DataTable("DbTableRows");
@@ -451,23 +500,24 @@ private void ReindexOrchestrationSteps()
}
}

private void ApplyOrchestrationFromHmi()
private async void ApplyOrchestrationFromHmi()
{
try
{
var stepDefs = BuildStepDefinitionsFromEditor();
if (_machine.TryApplyOrchestration(stepDefs, out var message))
var result = await _machine.TryApplyOrchestrationAsync(stepDefs);
if (result.Success)
{
OrchestrationStatus = message;
OrchestrationStatus = result.Message;
OrchestrationValidationStatus = "Apply successful.";
LoadOrchestrationSteps();
}
else
{
OrchestrationStatus = message;
OrchestrationStatus = result.Message;
}

RefreshSafetyGates();
await RefreshSafetyGatesAsync();
}
catch (Exception ex)
{
@@ -476,10 +526,10 @@ private void ApplyOrchestrationFromHmi()
}
}

private void PreviewOrchestrationValidation()
private async void PreviewOrchestrationValidation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants