Enhance repository proficiency by introducing Async Gateway APIs and Connection Status tracking - #3
Conversation
…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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
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
LocalSimulationServiceGatewayandRemoteTwinCatMachineGatewayMockimplementations (plus a newExecuteWithRetryAsynchelper). - Add
GatewayConnectionState, expose it onIMachineGatewayService, and bind a status indicator inMainWindow.xamlviaMainViewModel. - Add
.github/workflows/dotnet.ymlCI workflow and enableEnableWindowsTargetingin 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; |
| @@ -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() | |||
Enhance repository proficiency by introducing Async Gateway APIs and Connection Status tracking
IMachineGatewayServiceandIDataGatewayServicemethods toTask-based asynchronous signatures to prepare for remote machine boundaries and network latency.TryApplyOrchestrationto useTask<(bool Success, string Message)>to replaceoutparameters.ExecuteWithRetrycalls withExecuteWithRetryAsyncin the backend services (ErrorHandlingService,RemoteTwinCatMachineGatewayMock).GatewayConnectionStateenum and implemented connection status tracking across the stack (Services, ViewModels, and UI).MainViewModelto execute backend commands asynchronously, improving UI thread responsiveness..NET 10.0Windows build validation.PR created automatically by Jules for task 17288054008961105129 started by @anoop6543