diff --git a/src/AasxCsharpLibrary/IOperationReceiver.cs b/src/AasxCsharpLibrary/IOperationReceiver.cs index 577ad66b..e21845fe 100644 --- a/src/AasxCsharpLibrary/IOperationReceiver.cs +++ b/src/AasxCsharpLibrary/IOperationReceiver.cs @@ -7,5 +7,6 @@ public interface IOperationReceiver { OperationResult OnOperationInvoke(IOperation operation, string submodelId, int? timestamp, string requestId); Task OnOperationInvokeAsync(string handleId, IOperation operation, string submodelId, int? timestamp, string requestId); + OperationResult GetResult(string handleId); } } \ No newline at end of file diff --git a/src/AasxServerStandardBib/OperationInvoker.cs b/src/AasxServerStandardBib/OperationInvoker.cs index 71c9f171..fa8e22ed 100644 --- a/src/AasxServerStandardBib/OperationInvoker.cs +++ b/src/AasxServerStandardBib/OperationInvoker.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using AdminShellNS.Models; using AdminShellNS; using System.Threading.Tasks; @@ -8,8 +7,6 @@ namespace AasOperationInvocation public class OperationInvoker : IOperationInvoker { public IOperationCommand Command { get; init; } - - private static readonly Dictionary _asyncHandles = []; private static long _asyncHandleCounter = 0; public OperationInvoker(IOperationCommand command) @@ -29,30 +26,7 @@ public Task InvokeAsync(out OperationHandle operationHandle) ExecutionState = ExecutionState.InitiatedEnum, Task = Command.ExecuteAsync("" + _asyncHandleCounter++) }; - _asyncHandles.Add(operationHandle.HandleId, operationHandle); return operationHandle.Task; } - - public static OperationResult GetAsyncResult(string handleId) - { - OperationHandle operationHandle = _asyncHandles[handleId]; - - // Remove if terminated - if ((int) operationHandle.ExecutionState > 1) { - _asyncHandles.Remove(handleId); - return operationHandle.Task.Result; - } - - return new OperationResult() { - RequestId = operationHandle.RequestId, - ExecutionState = operationHandle.ExecutionState, - Message = "" - }; - } - - public static void UpdateExecutionState(string handleId, ExecutionState executionState) - { - _asyncHandles[handleId].ExecutionState = executionState; - } } } \ No newline at end of file diff --git a/src/AasxServerStandardBib/OperationReceiver.cs b/src/AasxServerStandardBib/OperationReceiver.cs index 464fb9c5..0df73855 100644 --- a/src/AasxServerStandardBib/OperationReceiver.cs +++ b/src/AasxServerStandardBib/OperationReceiver.cs @@ -7,6 +7,11 @@ namespace AasOperationInvocation { public class OperationReceiver : IOperationReceiver { + public OperationResult GetResult(string handleId) + { + throw new NotImplementedException("invoking operations not yet supported"); + } + public OperationResult OnOperationInvoke(IOperation operation, string submodelId, int? timestamp, string requestId) { throw new NotImplementedException("invoking operations not yet supported"); @@ -14,18 +19,6 @@ public OperationResult OnOperationInvoke(IOperation operation, string submodelId public Task OnOperationInvokeAsync(string handleId, IOperation operation, string submodelId, int? timestamp, string requestId) { - // Console.WriteLine("Task initiated..."); - // OperationInvoker.UpdateExecutionState(handleId, ExecutionState.InitiatedEnum); - - // Console.WriteLine("Task running..."); - // OperationInvoker.UpdateExecutionState(handleId, ExecutionState.RunningEnum); - // await Task.Delay(5000); - - // Console.WriteLine("Task done..."); - // OperationInvoker.UpdateExecutionState(handleId, ExecutionState.CompletedEnum); - - // return new OperationResult() { ExecutionState = ExecutionState.CompletedEnum }; - throw new NotImplementedException("invoking operations not yet supported"); } diff --git a/src/AasxServerStandardBib/Services/SubmodelService.cs b/src/AasxServerStandardBib/Services/SubmodelService.cs index 9a5b6d35..e233b241 100644 --- a/src/AasxServerStandardBib/Services/SubmodelService.cs +++ b/src/AasxServerStandardBib/Services/SubmodelService.cs @@ -672,7 +672,7 @@ public OperationHandle InvokeOperationAsync(string submodelIdentifier, string id public OperationResult GetOperationAsyncResult(string handleId) { - return OperationInvoker.GetAsyncResult(handleId); + return _operationReceiver.GetResult(handleId); } } }