Minor bugfixes
diff --git a/sdks/dotnet/basyx-components/BaSyx.AAS.Client.Http/AssetAdministrationShellHttpClient.cs b/sdks/dotnet/basyx-components/BaSyx.AAS.Client.Http/AssetAdministrationShellHttpClient.cs
index 13b1946..511bf95 100644
--- a/sdks/dotnet/basyx-components/BaSyx.AAS.Client.Http/AssetAdministrationShellHttpClient.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.AAS.Client.Http/AssetAdministrationShellHttpClient.cs
@@ -9,12 +9,10 @@
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
using BaSyx.API.Clients;
-using BaSyx.API.Components;
using BaSyx.Models.Core.AssetAdministrationShell.Generics;
using BaSyx.Utils.Client.Http;
using BaSyx.Utils.ResultHandling;
using System;
-using System.Collections.Generic;
using System.Net.Http;
using BaSyx.Utils.PathHandling;
using BaSyx.Models.Core.Common;
@@ -24,57 +22,72 @@
using NLog;
using BaSyx.Models.Communication;
using BaSyx.Utils.DependencyInjection;
+using System.Collections.Generic;
+using BaSyx.Models.Core.AssetAdministrationShell.Implementations;
+using Newtonsoft.Json;
+using System.Text;
namespace BaSyx.AAS.Client.Http
{
- public class AssetAdministrationShellHttpClient : SimpleHttpClient, IAssetAdministrationShellClient, ISubmodelServiceProviderRegistry
+ public class AssetAdministrationShellHttpClient : SimpleHttpClient,
+ IAssetAdministrationShellClient,
+ IAssetAdministrationShellSubmodelClient,
+ ISubmodelRepositoryClient
{
private static readonly ILogger logger = LogManager.GetCurrentClassLogger();
+
+ public static bool USE_HTTPS = true;
private const string SEPARATOR = "/";
private const string AAS = "aas";
private const string SUBMODELS = "submodels";
private const string SUBMODEL = "submodel";
private const string SUBMODEL_ELEMENTS = "submodelElements";
- private const string PROPERTIES = "properties";
- private const string OPERATIONS = "operations";
- private const string EVENTS = "events";
private const string VALUE = "value";
- private const string ASYNC = "async";
+ private const string INVOKE = "invoke";
+ private const string SYNCHRONOUS = "?async=false";
+ private const string ASYNCHRONOUS = "?async=true";
private const string INVOCATION_LIST = "invocationList";
- private const string BINDING = "binding";
- private const string BINDINGS = "bindings";
-
- private const int REQUEST_TIMEOUT = 30000;
-
public Uri Endpoint { get; }
+ public int RequestTimeout = DEFAULT_REQUEST_TIMEOUT;
- private AssetAdministrationShellHttpClient()
+ private AssetAdministrationShellHttpClient(HttpClientHandler clientHandler) : base(clientHandler)
{
JsonSerializerSettings = new DependencyInjectionJsonSerializerSettings();
}
- public AssetAdministrationShellHttpClient(Uri endpoint) : this()
+ public AssetAdministrationShellHttpClient(Uri endpoint) : this(endpoint, DEFAULT_HTTP_CLIENT_HANDLER)
+ { }
+ public AssetAdministrationShellHttpClient(Uri endpoint, HttpClientHandler clientHandler) : this (clientHandler)
{
endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
Endpoint = endpoint;
}
+ public AssetAdministrationShellHttpClient(IAssetAdministrationShellDescriptor aasDescriptor) : this(aasDescriptor, DEFAULT_HTTP_CLIENT_HANDLER)
+ { }
- public AssetAdministrationShellHttpClient(IAssetAdministrationShellDescriptor aasDescriptor) : this()
+ public AssetAdministrationShellHttpClient(IAssetAdministrationShellDescriptor aasDescriptor, HttpClientHandler clientHandler) : this(clientHandler)
{
aasDescriptor = aasDescriptor ?? throw new ArgumentNullException(nameof(aasDescriptor));
- HttpEndpoint httpEndpoint = aasDescriptor.Endpoints?.OfType<HttpEndpoint>()?.FirstOrDefault();
+ IEnumerable<HttpEndpoint> httpEndpoints = aasDescriptor.Endpoints?.OfType<HttpEndpoint>();
+ HttpEndpoint httpEndpoint = null;
+ if (USE_HTTPS)
+ httpEndpoint = httpEndpoints?.FirstOrDefault(p => p.Type == Uri.UriSchemeHttps);
+ if (httpEndpoint == null)
+ httpEndpoint = httpEndpoints?.FirstOrDefault(p => p.Type == Uri.UriSchemeHttp);
+
if (httpEndpoint == null || string.IsNullOrEmpty(httpEndpoint.Address))
throw new Exception("There is no http endpoint for instantiating a client");
else
{
- if (!httpEndpoint.Address.EndsWith(SEPARATOR + AAS) || !httpEndpoint.Address.EndsWith(SEPARATOR + AAS + SEPARATOR))
+ if (!httpEndpoint.Address.EndsWith(SEPARATOR + AAS) && !httpEndpoint.Address.EndsWith(SEPARATOR + AAS + SEPARATOR))
Endpoint = new Uri(httpEndpoint.Address + SEPARATOR + AAS);
else
Endpoint = new Uri(httpEndpoint.Address);
}
}
+
public Uri GetUri(params string[] pathElements)
@@ -87,218 +100,113 @@
public IResult<IAssetAdministrationShellDescriptor> RetrieveAssetAdministrationShellDescriptor()
{
var request = base.CreateRequest(GetUri(), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IAssetAdministrationShellDescriptor>(response, response.Entity);
}
public IResult<IAssetAdministrationShell> RetrieveAssetAdministrationShell()
{
var request = base.CreateRequest(GetUri(), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IAssetAdministrationShell>(response, response.Entity);
}
- public IResult<ISubmodel> CreateSubmodel(ISubmodel submodel)
+ public IResult<ISubmodel> CreateOrUpdateSubmodel(ISubmodel submodel)
{
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS), HttpMethod.Put, submodel);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodel.IdShort), HttpMethod.Put, submodel);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodel>(response, response.Entity);
}
public IResult<IElementContainer<ISubmodel>> RetrieveSubmodels()
{
var request = base.CreateRequest(GetUri(SUBMODELS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ElementContainer<ISubmodel>>(response, response.Entity);
}
public IResult<ISubmodel> RetrieveSubmodel(string submodelId)
{
var request = base.CreateRequest(GetUri(SUBMODELS, submodelId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodel>(response, response.Entity);
}
public IResult DeleteSubmodel(string submodelId)
{
var request = base.CreateRequest(GetUri(SUBMODELS, submodelId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
-
- public IResult<IOperation> CreateOperation(string submodelId, IOperation operation)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS), HttpMethod.Put, operation);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IOperation>(response, response.Entity);
- }
-
+
public IResult<IElementContainer<ISubmodelElement>> RetrieveSubmodelElements(string submodelId)
{
var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ElementContainer<ISubmodelElement>>(response, response.Entity);
}
- public IResult<IElementContainer<IOperation>> RetrieveOperations(string submodelId)
+ public IResult<ISubmodelElement> RetrieveSubmodelElement(string submodelId, string seIdShortPath)
{
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ElementContainer<IOperation>>(response, response.Entity);
+ var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, seIdShortPath), HttpMethod.Get);
+ var response = base.SendRequest(request, RequestTimeout);
+ return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
}
- public IResult<IOperation> RetrieveOperation(string submodelId, string operationId)
+ public IResult<ISubmodelElement> CreateOrUpdateSubmodelElement(string submodelId, string rootSeIdShortPath, ISubmodelElement submodelElement)
{
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS, operationId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IOperation>(response, response.Entity);
+ var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, rootSeIdShortPath), HttpMethod.Put, submodelElement);
+ var response = base.SendRequest(request, RequestTimeout);
+ return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
}
- public IResult DeleteOperation(string submodelId, string operationId)
+ public IResult UpdateSubmodelElementValue(string submodelId, string seIdShortPath, IValue value)
{
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS, operationId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, seIdShortPath, VALUE), HttpMethod.Put, value.Value);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
- public IResult<InvocationResponse> InvokeOperation(string submodelId, string operationId, InvocationRequest invocationRequest)
+ public IResult<IValue> RetrieveSubmodelElementValue(string submodelId, string seIdShortPath)
{
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS, operationId), HttpMethod.Post, invocationRequest);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, seIdShortPath, VALUE), HttpMethod.Get);
+ var response = base.SendRequest(request, RequestTimeout);
+ IResult result = base.EvaluateResponse(response, response.Entity);
+ if (result.Success && result.Entity != null)
+ {
+ string sValue = Encoding.UTF8.GetString((byte[])result.Entity);
+ object deserializedValue = JsonConvert.DeserializeObject(sValue);
+ return new Result<IValue>(result.Success, new ElementValue(deserializedValue, deserializedValue.GetType()), result.Messages);
+ }
+ else
+ return new Result<IValue>(result);
+ }
+
+ public IResult DeleteSubmodelElement(string submodelId, string seIdShortPath)
+ {
+ var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, seIdShortPath), HttpMethod.Delete);
+ var response = base.SendRequest(request, RequestTimeout);
+ return base.EvaluateResponse(response, response.Entity);
+ }
+
+ public IResult<InvocationResponse> InvokeOperation(string submodelId, string operationIdShortPath, InvocationRequest invocationRequest)
+ {
+ var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, operationIdShortPath, INVOKE + SYNCHRONOUS), HttpMethod.Post, invocationRequest);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<InvocationResponse>(response, response.Entity);
}
-
- public IResult<IProperty> CreateProperty(string submodelId, IProperty property)
+ public IResult<CallbackResponse> InvokeOperationAsync(string submodelId, string operationIdShortPath, InvocationRequest invocationRequest)
{
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES), HttpMethod.Put, property);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IProperty>(response, response.Entity);
- }
-
- public IResult<ISubmodelElement> CreateSubmodelElement(string submodelId, ISubmodelElement submodelElement)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS), HttpMethod.Put, submodelElement);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
- }
-
- public IResult<IElementContainer<IProperty>> RetrieveProperties(string submodelId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ElementContainer<IProperty>>(response, response.Entity);
- }
-
- public IResult<IProperty> RetrieveProperty(string submodelId, string propertyId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES, propertyId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IProperty>(response, response.Entity);
- }
-
- public IResult<ISubmodelElement> RetrieveSubmodelElement(string submodelId, string submodelElementId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, submodelElementId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
- }
-
- public IResult UpdatePropertyValue(string submodelId, string propertyId, IValue value)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES, propertyId, VALUE), HttpMethod.Put, value);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse(response, response.Entity);
- }
-
- public IResult<IValue> RetrievePropertyValue(string submodelId, string propertyId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES, propertyId, VALUE), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IValue>(response, response.Entity);
- }
-
- public IResult DeleteSubmodelElement(string submodelId, string submodelElementId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, submodelElementId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse(response, response.Entity);
- }
-
- public IResult DeleteProperty(string submodelId, string propertyId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, PROPERTIES, propertyId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse(response, response.Entity);
- }
-
- public IResult<IEvent> CreateEvent(string submodelId, IEvent eventable)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, EVENTS), HttpMethod.Put, eventable);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IEvent>(response, response.Entity);
- }
-
- public IResult<IElementContainer<IEvent>> RetrieveEvents(string submodelId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, EVENTS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ElementContainer<IEvent>>(response, response.Entity);
- }
-
- public IResult<IEvent> RetrieveEvent(string submodelId, string eventId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, EVENTS, eventId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IEvent>(response, response.Entity);
- }
-
- public IResult DeleteEvent(string submodelId, string eventId)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, EVENTS, eventId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse(response, response.Entity);
- }
-
- public IResult<ISubmodelDescriptor> RegisterSubmodelServiceProvider(string id, ISubmodelServiceProvider submodelServiceProvider)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, id, BINDING), HttpMethod.Post, submodelServiceProvider.ServiceDescriptor);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ISubmodelDescriptor>(response, response.Entity);
- }
-
- public IResult UnregisterSubmodelServiceProvider(string id)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, id, BINDING), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse(response, response.Entity);
- }
-
- public IResult<ISubmodelServiceProvider> GetSubmodelServiceProvider(string id)
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, id, BINDING), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<ISubmodelServiceProvider>(response, response.Entity);
- }
-
- public IResult<IEnumerable<ISubmodelServiceProvider>> GetSubmodelServiceProviders()
- {
- var request = base.CreateRequest(GetUri(SUBMODELS, BINDINGS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
- return base.EvaluateResponse<IEnumerable<ISubmodelServiceProvider>>(response, response.Entity);
- }
- public IResult<CallbackResponse> InvokeOperationAsync(string submodelId, string operationId, InvocationRequest invocationRequest)
- {
- var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS, operationId, ASYNC), HttpMethod.Post, invocationRequest);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var request = base.CreateJsonContentRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, operationIdShortPath, INVOKE + ASYNCHRONOUS), HttpMethod.Post, invocationRequest);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<CallbackResponse>(response, response.Entity);
}
- public IResult<InvocationResponse> GetInvocationResult(string submodelId, string operationId, string requestId)
+ public IResult<InvocationResponse> GetInvocationResult(string submodelId, string operationIdShortPath, string requestId)
{
- var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, OPERATIONS, operationId, INVOCATION_LIST, requestId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var request = base.CreateRequest(GetUri(SUBMODELS, submodelId, SUBMODEL, SUBMODEL_ELEMENTS, operationIdShortPath, INVOCATION_LIST, requestId), HttpMethod.Get);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<InvocationResponse>(response, response.Entity);
- }
-
+ }
}
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.AAS.Server.Http/AssetAdministrationShellRepositoryHttpServer.cs b/sdks/dotnet/basyx-components/BaSyx.AAS.Server.Http/AssetAdministrationShellRepositoryHttpServer.cs
index 25b972b..72e24b3 100644
--- a/sdks/dotnet/basyx-components/BaSyx.AAS.Server.Http/AssetAdministrationShellRepositoryHttpServer.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.AAS.Server.Http/AssetAdministrationShellRepositoryHttpServer.cs
@@ -11,20 +11,14 @@
using BaSyx.API.Components;
using BaSyx.Components.Common;
using BaSyx.Utils.Settings.Types;
-using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using System;
using System.Reflection;
namespace BaSyx.AAS.Server.Http
{
public class AssetAdministrationShellRepositoryHttpServer : ServerApplication
{
- private string submodelId = string.Empty;
- private string aasId = string.Empty;
-
public AssetAdministrationShellRepositoryHttpServer() : this(null, null)
{ }
@@ -44,77 +38,6 @@
{
services.AddSingleton<IAssetAdministrationShellRepositoryServiceProvider>(repositoryServiceProvider);
});
- }
-
- protected override void ConfigureServices(IServiceCollection services)
- {
- base.ConfigureServices(services);
-
- //Check whether Asset Administration Shell Service Provider exists and bind it to the AssetAdministrationShell-Services-Controller
- services.AddTransient<IAssetAdministrationShellServiceProvider>(ctx =>
- {
- IAssetAdministrationShellServiceProvider aasServiceProvider = ctx
- .GetRequiredService<IAssetAdministrationShellRepositoryServiceProvider>()
- .GetAssetAdministrationShellServiceProvider(aasId);
-
- return aasServiceProvider;
- });
-
- //Check whether Submodel Service Provider exists and bind it to the Submodel-Services-Controller
- services.AddTransient<ISubmodelServiceProvider>(ctx =>
- {
- IAssetAdministrationShellServiceProvider aasServiceProvider = ctx
- .GetRequiredService<IAssetAdministrationShellRepositoryServiceProvider>()
- .GetAssetAdministrationShellServiceProvider(aasId);
-
- var submodelServiceProvider = aasServiceProvider.SubmodelRegistry.GetSubmodelServiceProvider(submodelId);
- if (!submodelServiceProvider.Success || submodelServiceProvider.Entity == null)
- {
- SubmodelServiceProvider cssp = new SubmodelServiceProvider();
- return cssp;
- }
- else
- return submodelServiceProvider.Entity;
- });
- }
-
- protected override void Configure(IApplicationBuilder app)
- {
- base.Configure(app);
- app.Use((context, next) =>
- {
- string[] pathElements = context.Request.Path.ToUriComponent()?.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
- if (pathElements.Length >= 2)
- {
- aasId = pathElements[1];
- if (pathElements.Length == 2)
- {
- context.Request.Path = new PathString("/shells/" + aasId);
- }
- else if (pathElements.Length == 3 && pathElements[2] == "aas")
- {
- context.Request.Path = new PathString("/aas");
- }
- else if (pathElements.Length == 4 && pathElements[3] == "submodels")
- {
- context.Request.Path = new PathString("/aas/submodels");
- }
- else if (pathElements.Length == 5)
- {
- submodelId = pathElements[4];
- context.Request.Path = new PathString("/aas/submodels/" + submodelId);
- }
- else if (pathElements.Length > 5)
- {
- submodelId = pathElements[4];
- string[] restOfPathArray = new string[pathElements.Length - 5];
- Array.Copy(pathElements, 5, restOfPathArray, 0, pathElements.Length - 5);
- string restOfPath = string.Join("/", restOfPathArray);
- context.Request.Path = new PathString("/" + restOfPath);
- }
- }
- return next();
- });
- }
+ }
}
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers.AASX/BaSyx.API.Http.Controllers.AASX.xml b/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers.AASX/BaSyx.API.Http.Controllers.AASX.xml
index e4acb5e..14c3414 100644
--- a/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers.AASX/BaSyx.API.Http.Controllers.AASX.xml
+++ b/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers.AASX/BaSyx.API.Http.Controllers.AASX.xml
@@ -9,7 +9,7 @@
The AASX Package Service
</summary>
</member>
- <member name="M:BaSyx.API.Http.Controllers.PackageService.PackageService.#ctor(BaSyx.API.Components.IAssetAdministrationShellServiceProvider,Microsoft.AspNetCore.Hosting.IHostingEnvironment)">
+ <member name="M:BaSyx.API.Http.Controllers.PackageService.PackageService.#ctor(BaSyx.API.Components.IAssetAdministrationShellServiceProvider,Microsoft.AspNetCore.Hosting.IWebHostEnvironment)">
<summary>
Constructor for the AASX-Package Services Controller
</summary>
diff --git a/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers/AssetAdministrationShell/SubmodelController.cs b/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers/AssetAdministrationShell/SubmodelController.cs
index 76fabff..547301e 100644
--- a/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers/AssetAdministrationShell/SubmodelController.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.API.Http.Controllers/AssetAdministrationShell/SubmodelController.cs
@@ -142,7 +142,7 @@
seIdShortPath = HttpUtility.UrlDecode(seIdShortPath);
- var result = serviceProvider.CreateSubmodelElement(seIdShortPath, submodelElement);
+ var result = serviceProvider.CreateOrUpdateSubmodelElement(seIdShortPath, submodelElement);
return result.CreateActionResult(CrudOperation.Create, "submodel/submodelElements/" + seIdShortPath);
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Common.UI.Swagger/SwaggerExtensions.cs b/sdks/dotnet/basyx-components/BaSyx.Common.UI.Swagger/SwaggerExtensions.cs
index 6915f09..c28fb73 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Common.UI.Swagger/SwaggerExtensions.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Common.UI.Swagger/SwaggerExtensions.cs
@@ -21,7 +21,7 @@
namespace BaSyx.Common.UI.Swagger
{
- public static class OpenApiInfos
+ internal static class OpenApiInfos
{
#region Static OpenApi-Infos
internal static readonly OpenApiInfo AssetAdministrationShell_OpenApiInfo = new OpenApiInfo
@@ -98,9 +98,9 @@
All,
AssetAdministrationShell,
AssetAdministrationShellRepository,
+ AssetAdministrationShellRegistry,
Submodel,
- SubmodelRepository,
- AssetAdministrationShellRegistry
+ SubmodelRepository,
}
public static class SwaggerExtensions
{
@@ -114,12 +114,13 @@
c.SwaggerDoc("v1", info);
// Set the comments path for the Swagger JSON and UI.
- var xmlFile = $"{serverApp.ControllerAssembly.GetName().Name}.xml";
- var xmlPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), xmlFile);
+ string xmlFile = $"{serverApp.ControllerAssembly.GetName().Name}.xml";
+ string xmlPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), xmlFile);
if (EmbeddedResource.CheckOrWriteRessourceToFile(serverApp.ControllerAssembly, xmlPath))
c.IncludeXmlComments(xmlPath, true);
- c.DocumentFilter<ControllerSelector>(interfaceType);
+ if(interfaceType != Interface.All)
+ c.DocumentFilter<ControllerSelector>(interfaceType);
});
services.AddSwaggerGenNewtonsoftSupport();
});
@@ -141,10 +142,12 @@
{
private readonly Interface _interfaceType;
private readonly string _interfaceName;
+ private readonly string _controllerName;
public ControllerSelector(Interface interfaceType)
{
_interfaceType = interfaceType;
_interfaceName = Enum.GetName(typeof(Interface), _interfaceType);
+ _controllerName = _interfaceName + "Controller";
}
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
@@ -152,7 +155,7 @@
foreach (var apiDescription in context.ApiDescriptions)
{
string name = apiDescription.ActionDescriptor.DisplayName;
- if(!name.Contains(_interfaceName + "Controller"))
+ if(!name.Contains(_controllerName))
{
string route = "/" + apiDescription.ActionDescriptor.AttributeRouteInfo.Template;
swaggerDoc.Paths.Remove(route);
@@ -160,7 +163,7 @@
}
foreach (var tag in swaggerDoc.Tags.ToList())
{
- if(tag.Name != (_interfaceName + "Controller"))
+ if(tag.Name != _controllerName)
{
swaggerDoc.Tags.Remove(tag);
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_Layout.cshtml b/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_Layout.cshtml
index a1c9b3a..1be785a 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_Layout.cshtml
+++ b/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_Layout.cshtml
@@ -36,7 +36,7 @@
<div class="navbar-right">
@if (!string.IsNullOrEmpty((string)ViewData["CompanyLogo"]))
{
- <img src="@ViewData["CompanyLogo"]" width="160" height="36" />
+ <img src="@ViewData["CompanyLogo"]" width="160" />
}
</div>
</div>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_ModelElementSpecific.cshtml b/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_ModelElementSpecific.cshtml
index 33e4a54..67edca4 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_ModelElementSpecific.cshtml
+++ b/sdks/dotnet/basyx-components/BaSyx.Common.UI/Pages/Shared/_ModelElementSpecific.cshtml
@@ -58,7 +58,15 @@
{
<li class="list-group-item">
<div class="row align-items-center">
- <object data="@path" style="height:500px; width:100%"></object>
+ @if (file.MimeType.StartsWith("image"))
+ {
+ <img src="@path" style="display:block; max-width:100%; height:auto" />
+ }
+ else
+ {
+ <object data="@path" style="min-height:500px; width:100%"></object>
+ }
+
</div>
</li>
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Common/DefaultWebHostBuilder.cs b/sdks/dotnet/basyx-components/BaSyx.Components.Common/DefaultWebHostBuilder.cs
index 0e254e5..2eecd84 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Components.Common/DefaultWebHostBuilder.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Common/DefaultWebHostBuilder.cs
@@ -24,7 +24,7 @@
if (settings?.ServerConfig.Hosting?.Environment != null)
webHostBuilder.UseEnvironment(settings.ServerConfig.Hosting.Environment);
else
- webHostBuilder.UseEnvironment(Environments.Production);
+ webHostBuilder.UseEnvironment(Environments.Development);
if (settings?.ServerConfig?.Hosting?.Urls?.Count > 0)
webHostBuilder.UseUrls(settings.ServerConfig.Hosting.Urls.ToArray());
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Common/ServerApplication.cs b/sdks/dotnet/basyx-components/BaSyx.Components.Common/ServerApplication.cs
index 8e0702b..51941b3 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Components.Common/ServerApplication.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Common/ServerApplication.cs
@@ -15,7 +15,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Rewrite;
-using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
@@ -44,8 +43,8 @@
private string _webRoot;
private bool _secure = false;
- private List<Action<IApplicationBuilder>> AppBuilderPipeline;
- private List<Action<IServiceCollection>> ServiceBuilderPipeline;
+ private readonly List<Action<IApplicationBuilder>> AppBuilderPipeline;
+ private readonly List<Action<IServiceCollection>> ServiceBuilderPipeline;
public const string DEFAULT_CONTENT_ROOT = "Content";
public const string DEFAULT_WEB_ROOT = "wwwroot";
@@ -87,9 +86,9 @@
AppBuilderPipeline = new List<Action<IApplicationBuilder>>();
ServiceBuilderPipeline = new List<Action<IServiceCollection>>();
- WebHostBuilder.ConfigureServices(services =>
+ WebHostBuilder.ConfigureServices( (context, services) =>
{
- ConfigureServices(services);
+ ConfigureServices(context, services);
});
WebHostBuilder.Configure(app =>
@@ -276,14 +275,15 @@
});
}
- protected virtual void ConfigureServices(IServiceCollection services)
+ protected virtual void ConfigureServices(WebHostBuilderContext context, IServiceCollection services)
{
services.AddSingleton(typeof(ServerSettings), Settings);
services.AddSingleton<IServerApplicationLifetime>(this);
+
var urls = Settings.ServerConfig.Hosting.Urls;
var secureUrl = urls.Find(s => s.StartsWith("https"));
- if (!string.IsNullOrEmpty(secureUrl))
+ if (!string.IsNullOrEmpty(secureUrl) && !context.HostingEnvironment.IsDevelopment())
{
secureUrl = secureUrl.Replace("+", "0.0.0.0");
Uri secureUri = new Uri(secureUrl);
@@ -330,7 +330,7 @@
app.UseHsts();
}
- if(_secure)
+ if(_secure && !env.IsDevelopment())
app.UseHttpsRedirection();
app.UseStaticFiles();
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/AssetAdministrationShellClientServerTest.cs b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/AssetAdministrationShellClientServerTest.cs
new file mode 100644
index 0000000..35a2429
--- /dev/null
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/AssetAdministrationShellClientServerTest.cs
@@ -0,0 +1,188 @@
+using BaSyx.AAS.Client.Http;
+using BaSyx.AAS.Server.Http;
+using BaSyx.API.AssetAdministrationShell.Extensions;
+using BaSyx.API.Clients;
+using BaSyx.API.Components;
+using BaSyx.Models.Communication;
+using BaSyx.Models.Connectivity;
+using BaSyx.Models.Connectivity.Descriptors;
+using BaSyx.Models.Core.AssetAdministrationShell;
+using BaSyx.Models.Core.AssetAdministrationShell.Generics;
+using BaSyx.Models.Core.AssetAdministrationShell.Identification;
+using BaSyx.Models.Core.AssetAdministrationShell.Implementations;
+using BaSyx.Models.Core.AssetAdministrationShell.References;
+using BaSyx.Models.Core.Common;
+using BaSyx.Models.Extensions;
+using BaSyx.Registry.Client.Http;
+using BaSyx.Registry.ReferenceImpl.FileBased;
+using BaSyx.Registry.Server.Http;
+using BaSyx.Utils.ResultHandling;
+using BaSyx.Utils.Settings.Types;
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace BaSyx.Components.Tests
+{
+ [TestClass]
+ public class AssetAdministrationShellClientServerTest : IAssetAdministrationShellClient, IAssetAdministrationShellSubmodelClient
+ {
+ private static AssetAdministrationShellHttpServer server;
+ private static AssetAdministrationShellHttpClient client;
+
+ private static IAssetAdministrationShell aas;
+ private static ISubmodel submodel;
+ private static IAssetAdministrationShellDescriptor aasDescriptor;
+
+ static AssetAdministrationShellClientServerTest()
+ {
+ ServerSettings aasServerSettings = ServerSettings.CreateSettings();
+ aasServerSettings.ServerConfig.Hosting.ContentPath = "Content";
+ aasServerSettings.ServerConfig.Hosting.Environment = "Development";
+ aasServerSettings.ServerConfig.Hosting.Urls.Add("http://localhost:5080");
+ aasServerSettings.ServerConfig.Hosting.Urls.Add("https://localhost:5443");
+
+ aas = TestAssetAdministrationShell.GetAssetAdministrationShell();
+ submodel = TestAssetAdministrationShell.GetTestSubmodel();
+ var serviceProvider = aas.CreateServiceProvider(true);
+ serviceProvider.UseAutoEndpointRegistration(aasServerSettings.ServerConfig);
+ aasDescriptor = serviceProvider.ServiceDescriptor;
+
+ server = new AssetAdministrationShellHttpServer(aasServerSettings);
+ server.SetServiceProvider(serviceProvider);
+ _ = server.RunAsync();
+
+ client = new AssetAdministrationShellHttpClient(aasDescriptor);
+ }
+
+ [TestMethod]
+ public void Test1_RetrieveAssetAdministrationShell()
+ {
+ var retrieved = RetrieveAssetAdministrationShell();
+ retrieved.Success.Should().BeTrue();
+ }
+
+ public IResult<IAssetAdministrationShell> RetrieveAssetAdministrationShell()
+ {
+ return client.RetrieveAssetAdministrationShell();
+ }
+
+ [TestMethod]
+ public void Test2_RetrieveSubmodel()
+ {
+ var retrieved = RetrieveSubmodel(submodel.IdShort);
+ retrieved.Success.Should().BeTrue();
+ }
+ public IResult<ISubmodel> RetrieveSubmodel(string submodelId)
+ {
+ return client.RetrieveSubmodel(submodelId);
+ }
+
+ [TestMethod]
+ public void Test31_CreateOrUpdateSubmodelElement_FirstLevelHierarchy()
+ {
+ Property testProperty = new Property("TestIntegerProperty", typeof(int), 8);
+ var created = CreateOrUpdateSubmodelElement(submodel.IdShort, testProperty.IdShort, testProperty);
+ created.Success.Should().BeTrue();
+ created.Entity.Should().BeEquivalentTo(testProperty, opts => opts
+ .Excluding(p => p.Get)
+ .Excluding(p => p.Set)
+ .Excluding(p => p.EmbeddedDataSpecifications)
+ .Excluding(p => p.Parent));
+
+ submodel.SubmodelElements.Add(testProperty);
+ }
+ public IResult<ISubmodelElement> CreateOrUpdateSubmodelElement(string submodelId, string rootSeIdShortPath, ISubmodelElement submodelElement)
+ {
+ return client.CreateOrUpdateSubmodelElement(submodelId, rootSeIdShortPath, submodelElement);
+ }
+
+ [TestMethod]
+ public void Test41_RetrieveSubmodelElements()
+ {
+ var retrieved = RetrieveSubmodelElements(submodel.IdShort);
+ retrieved.Success.Should().BeTrue();
+ retrieved.Entity.Count.Should().Be(submodel.SubmodelElements.Count);
+ }
+ public IResult<IElementContainer<ISubmodelElement>> RetrieveSubmodelElements(string submodelId)
+ {
+ return client.RetrieveSubmodelElements(submodelId);
+ }
+
+ [TestMethod]
+ public void Test51_RetrieveSubmodelElement_FirstLevelHierarchy()
+ {
+ var retrieved = RetrieveSubmodelElement(submodel.IdShort, "TestIntegerProperty");
+ retrieved.Success.Should().BeTrue();
+ retrieved.Entity.Should().BeEquivalentTo(submodel.SubmodelElements["TestIntegerProperty"].Cast<Property>(), opts => opts
+ .Excluding(p => p.Get)
+ .Excluding(p => p.Set)
+ .Excluding(p => p.EmbeddedDataSpecifications)
+ .Excluding(p => p.Parent));
+ }
+ public IResult<ISubmodelElement> RetrieveSubmodelElement(string submodelId, string seIdShortPath)
+ {
+ return client.RetrieveSubmodelElement(submodelId, seIdShortPath);
+ }
+
+ [TestMethod]
+ public void Test61_RetrieveSubmodelElementValue_FirstLevelHierarchy()
+ {
+ var retrieved = RetrieveSubmodelElementValue(submodel.IdShort, "TestIntegerProperty");
+ retrieved.Success.Should().BeTrue();
+ retrieved.Entity.Value.Should().BeEquivalentTo(8);
+ }
+ public IResult<IValue> RetrieveSubmodelElementValue(string submodelId, string seIdShortPath)
+ {
+ return client.RetrieveSubmodelElementValue(submodelId, seIdShortPath);
+ }
+
+ [TestMethod]
+ public void Test71_UpdateSubmodelElementValue_FirstLevelHierarchy()
+ {
+ var updated = UpdateSubmodelElementValue(submodel.IdShort, "TestIntegerProperty", new ElementValue(5, typeof(int)));
+ updated.Success.Should().BeTrue();
+ }
+ [TestMethod]
+ public void Test72_RetrieveSubmodelElementValue_FirstLevelHierarchy_AfterUpdate()
+ {
+ var retrieved = RetrieveSubmodelElementValue(submodel.IdShort, "TestIntegerProperty");
+ retrieved.Success.Should().BeTrue();
+ retrieved.Entity.Value.Should().BeEquivalentTo(5);
+ }
+
+ public IResult UpdateSubmodelElementValue(string submodelId, string seIdShortPath, IValue value)
+ {
+ return client.UpdateSubmodelElementValue(submodelId, seIdShortPath, value);
+ }
+
+ [TestMethod]
+ public void Test81_DeleteSubmodelElement_FirstLevelHierarchy()
+ {
+ var deleted = DeleteSubmodelElement(submodel.IdShort, "TestIntegerProperty");
+ deleted.Success.Should().BeTrue();
+ }
+
+ public IResult DeleteSubmodelElement(string submodelId, string seIdShortPath)
+ {
+ return client.DeleteSubmodelElement(submodelId, seIdShortPath);
+ }
+
+ public IResult<InvocationResponse> InvokeOperation(string submodelId, string operationIdShortPath, InvocationRequest invocationRequest)
+ {
+ return client.InvokeOperation(submodelId, operationIdShortPath, invocationRequest);
+ }
+
+ public IResult<CallbackResponse> InvokeOperationAsync(string submodelId, string operationIdShortPath, InvocationRequest invocationRequest)
+ {
+ return client.InvokeOperationAsync(submodelId, operationIdShortPath, invocationRequest);
+ }
+
+ public IResult<InvocationResponse> GetInvocationResult(string submodelId, string operationIdShortPath, string requestId)
+ {
+ return client.GetInvocationResult(submodelId, operationIdShortPath, requestId);
+ }
+ }
+}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/BaSyx.Components.Tests.csproj b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/BaSyx.Components.Tests.csproj
index 3778999..b81cfe2 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/BaSyx.Components.Tests.csproj
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/BaSyx.Components.Tests.csproj
@@ -30,6 +30,8 @@
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\BaSyx.AAS.Client.Http\BaSyx.AAS.Client.Http.csproj" />
+ <ProjectReference Include="..\BaSyx.AAS.Server.Http\BaSyx.AAS.Server.Http.csproj" />
<ProjectReference Include="..\BaSyx.Registry.Client.Http\BaSyx.Registry.Client.Http.csproj" />
<ProjectReference Include="..\BaSyx.Registry.ReferenceImpl.FileBased\BaSyx.Registry.ReferenceImpl.FileBased.csproj" />
<ProjectReference Include="..\BaSyx.Registry.Server.Http\BaSyx.Registry.Server.Http.csproj" />
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/RegistryTest.cs b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/RegistryTest.cs
index f9ce150..424beef 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/RegistryTest.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/RegistryTest.cs
@@ -11,6 +11,8 @@
using BaSyx.Registry.ReferenceImpl.FileBased;
using BaSyx.Registry.Server.Http;
using BaSyx.Utils.ResultHandling;
+using BaSyx.Utils.Settings.Sections;
+using BaSyx.Utils.Settings.Types;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
@@ -27,7 +29,19 @@
static RegistryTest()
{
- registryHttpServer = new RegistryHttpServer();
+ ServerSettings registrySettings = ServerSettings.CreateSettings();
+ registrySettings.ServerConfig.Hosting = new HostingConfiguration()
+ {
+ Urls = new List<string>()
+ {
+ "http://localhost:4999",
+ "https://localhost:4499"
+ },
+ Environment = "Development",
+ ContentPath = "Content"
+ };
+
+ registryHttpServer = new RegistryHttpServer(registrySettings);
registryHttpServer.SetRegistryProvider(new FileBasedRegistry());
_ = registryHttpServer.RunAsync();
diff --git a/sdks/dotnet/basyx-components/BaSyx.Components.Tests/TestAssetAdministrationShell.cs b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/TestAssetAdministrationShell.cs
new file mode 100644
index 0000000..7e9c517
--- /dev/null
+++ b/sdks/dotnet/basyx-components/BaSyx.Components.Tests/TestAssetAdministrationShell.cs
@@ -0,0 +1,195 @@
+/*******************************************************************************
+* Copyright (c) 2020 Robert Bosch GmbH
+* Author: Constantin Ziesche (constantin.ziesche@bosch.com)
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Distribution License 1.0 which is available at
+* https://www.eclipse.org/org/documents/edl-v10.html
+*
+*
+*******************************************************************************/
+using BaSyx.Models.Core.AssetAdministrationShell;
+using BaSyx.Models.Core.AssetAdministrationShell.Generics;
+using BaSyx.Models.Core.AssetAdministrationShell.Identification;
+using BaSyx.Models.Core.AssetAdministrationShell.Implementations;
+using BaSyx.Models.Core.AssetAdministrationShell.References;
+using BaSyx.Models.Core.Common;
+using BaSyx.Models.Extensions;
+using BaSyx.Utils.ResultHandling;
+using System;
+using System.Threading.Tasks;
+
+namespace BaSyx.Components.Tests
+{
+ public static class TestAssetAdministrationShell
+ {
+ public static AssetAdministrationShell GetAssetAdministrationShell()
+ {
+ AssetAdministrationShell aas = new AssetAdministrationShell("TestAAS", new Identifier("http://basys40.de/shells/SimpleAAS/" + Guid.NewGuid().ToString(), KeyType.IRI))
+ {
+ Description = new LangStringSet()
+ {
+ new LangString("de-DE", "Einfache VWS"),
+ new LangString("en-US", "Simple AAS")
+ },
+ Administration = new AdministrativeInformation()
+ {
+ Version = "1.0",
+ Revision = "120"
+ },
+ Asset = new Asset("TestAsset", new Identifier("http://basys40.de/assets/SimpleAsset/" + Guid.NewGuid().ToString(), KeyType.IRI))
+ {
+ Kind = AssetKind.Instance,
+ Description = new LangStringSet()
+ {
+ new LangString("de-DE", "Einfaches Asset"),
+ new LangString("en-US", "Simple Asset")
+ }
+ }
+ };
+
+ Submodel testSubmodel = GetTestSubmodel();
+
+ aas.Submodels.Add(testSubmodel);
+
+ return aas;
+ }
+
+ public static Submodel GetTestSubmodel()
+ {
+ string propertyValue = "TestFromInside";
+ int i = 0;
+ double y = 2.0;
+
+ Submodel testSubmodel = new Submodel("TestSubmodel", new Identifier(Guid.NewGuid().ToString(), KeyType.Custom))
+ {
+ SubmodelElements =
+ {
+ new Property<string>("TestProperty1")
+ {
+ Set = (prop, val) => propertyValue = val,
+ Get = prop => { return propertyValue + "_" + i++; }
+ },
+ new Property<string>("TestProperty2")
+ {
+ Set = (prop, val) => propertyValue = val,
+ Get = prop => { return propertyValue + "_" + i++; }
+ },
+ new Property<int>("TestProperty3")
+ {
+ Set = (prop, val) => i = val,
+ Get = prop => { return i++; }
+ },
+ new Property<double>("TestProperty4")
+ {
+ Set = (prop, val) => y = val,
+ Get = prop => { return Math.Pow(y, i); }
+ },
+ new SubmodelElementCollection("TestSubmodelElementCollection")
+ {
+ Value =
+ {
+ new Property<string>("TestSubProperty1")
+ {
+ Set = (prop, val) => propertyValue = val,
+ Get = prop => { return propertyValue + "_" + i--; }
+ },
+ new Property<string>("TestSubProperty2")
+ {
+ Set = (prop, val) => propertyValue = val,
+ Get = prop => { return propertyValue + "_" + i--; }
+ },
+ new Property<int>("TestSubProperty3")
+ {
+ Set = (prop, val) => i = val,
+ Get = prop => { return i--; }
+ },
+ new Property<double>("TestSubProperty4")
+ {
+ Set = (prop, val) => y = val,
+ Get = prop => { return Math.Pow(y, i); }
+ }
+ }
+ },
+ new Operation("GetTime")
+ {
+ OutputVariables = new OperationVariableSet()
+ {
+ new Property<string>("Date"),
+ new Property<string>("Time"),
+ new Property<string>("Ticks")
+ },
+ OnMethodCalled = (op, inArgs, inOutArgs, outArgs, cancellationToken) =>
+ {
+ outArgs.Add(new Property<string>("Date") { Value = "Heute ist der " + DateTime.Now.Date.ToString() });
+ outArgs.Add(new Property<string>("Time") { Value = "Es ist " + DateTime.Now.TimeOfDay.ToString() + " Uhr" });
+ outArgs.Add(new Property<string>("Ticks") { Value = "Ticks: " + DateTime.Now.Ticks.ToString() });
+ return new OperationResult(true);
+ }
+ },
+ new Operation("Calculate")
+ {
+ Description = new LangStringSet()
+ {
+ new LangString("DE", "Taschenrechner mit simulierter langer Rechenzeit zum Testen von asynchronen Aufrufen"),
+ new LangString("EN", "Calculator with simulated long-running computing time for testing asynchronous calls")
+ },
+ InputVariables = new OperationVariableSet()
+ {
+ new Property<string>("Expression")
+ {
+ Description = new LangStringSet()
+ {
+ new LangString("DE", "Ein mathematischer Ausdruck (z.B. 5*9)"),
+ new LangString("EN", "A mathematical expression (e.g. 5*9)")
+ }
+ },
+ new Property<int>("ComputingTime")
+ {
+ Description = new LangStringSet()
+ {
+ new LangString("DE", "Die Bearbeitungszeit in Millisekunden"),
+ new LangString("EN", "The computation time in milliseconds")
+ }
+ }
+ },
+ OutputVariables = new OperationVariableSet()
+ {
+ new Property<double>("Result")
+ },
+ OnMethodCalled = async (op, inArgs, inOutArgs, outArgs, cancellationToken) =>
+ {
+ string expression = inArgs["Expression"]?.GetValue<string>();
+ int? computingTime = inArgs["ComputingTime"]?.GetValue<int>();
+
+ inOutArgs["HierRein"]?.SetValue("DaWiederRaus");
+
+ if(computingTime.HasValue)
+ await Task.Delay(computingTime.Value, cancellationToken);
+
+ if(cancellationToken.IsCancellationRequested)
+ return new OperationResult(false, new Message(MessageType.Information, "Cancellation was requested"));
+
+ double value = CalulcateExpression(expression);
+
+ outArgs.Add(new Property<double>("Result", value));
+ return new OperationResult(true);
+ }
+ }
+
+ }
+ };
+ return testSubmodel;
+ }
+
+ public static double CalulcateExpression(string expression)
+ {
+ string columnName = "Evaluation";
+ System.Data.DataTable dataTable = new System.Data.DataTable();
+ System.Data.DataColumn dataColumn = new System.Data.DataColumn(columnName, typeof(double), expression);
+ dataTable.Columns.Add(dataColumn);
+ dataTable.Rows.Add(0);
+ return (double)(dataTable.Rows[0][columnName]);
+ }
+ }
+}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/BaSyx.Discovery.mDNS.csproj b/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/BaSyx.Discovery.mDNS.csproj
index 2e0eaf4..5d87197 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/BaSyx.Discovery.mDNS.csproj
+++ b/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/BaSyx.Discovery.mDNS.csproj
@@ -16,7 +16,6 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="BaSyx.AAS.Client.Http" Version="1.0.0" />
<PackageReference Include="BaSyx.API" Version="1.0.0" />
<PackageReference Include="Makaretu.Dns" Version="2.0.1" />
<PackageReference Include="Makaretu.Dns.Multicast" Version="0.27.0" />
@@ -30,6 +29,10 @@
</None>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\BaSyx.AAS.Client.Http\BaSyx.AAS.Client.Http.csproj" />
+ </ItemGroup>
+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="IF EXIST %25BASYX_REPO%25 ( dotnet pack "$(ProjectPath)" --no-build --include-source --include-symbols --output "%25BASYX_REPO%25" ) ELSE ( ECHO BASYX_REPO Environment Variable not found)" />
</Target>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/DiscoveryExtensions.cs b/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/DiscoveryExtensions.cs
index 06d1ebb..a5c0aa9 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/DiscoveryExtensions.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Discovery.mDNS/DiscoveryExtensions.cs
@@ -19,6 +19,8 @@
using System.Linq;
using System.Net;
using BaSyx.Utils.Logging;
+using System.Net.Http;
+using BaSyx.Utils.Client.Http;
namespace BaSyx.Discovery.mDNS
{
@@ -108,8 +110,10 @@
private static void AssemblyDescriptor(ref IAssetAdministrationShellDescriptor aasDescriptor, Uri aasEndpoint)
{
- AssetAdministrationShellHttpClient client = new AssetAdministrationShellHttpClient(aasEndpoint);
- IResult<IAssetAdministrationShellDescriptor> retrieveDescriptor = client.RetrieveAssetAdministrationShellDescriptor();
+ IResult<IAssetAdministrationShellDescriptor> retrieveDescriptor;
+ using (var client = new AssetAdministrationShellHttpClient(aasEndpoint, SimpleHttpClient.DEFAULT_HTTP_CLIENT_HANDLER))
+ retrieveDescriptor = client.RetrieveAssetAdministrationShellDescriptor();
+
if (retrieveDescriptor.Success && retrieveDescriptor.Entity != null)
{
retrieveDescriptor.LogResult(logger, LogLevel.Info, "Successfully retrieved AAS descriptor");
diff --git a/sdks/dotnet/basyx-components/BaSyx.Registry.Client.Http/RegistryHttpClient.cs b/sdks/dotnet/basyx-components/BaSyx.Registry.Client.Http/RegistryHttpClient.cs
index 050c4be..61f5097 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Registry.Client.Http/RegistryHttpClient.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Registry.Client.Http/RegistryHttpClient.cs
@@ -36,9 +36,9 @@
private int RepeatRegistrationInterval = -1;
private string baseUrl = null;
- private int Timeout = -1;
- private CancellationTokenSource RepeatRegistrationCancellationToken = null;
+ private CancellationTokenSource RepeatRegistrationCancellationToken = null;
+ public int RequestTimeout = DEFAULT_REQUEST_TIMEOUT;
public void LoadSettings(RegistryClientSettings settings)
{
@@ -48,25 +48,30 @@
RepeatRegistrationInterval = settings.RegistryConfig.RepeatRegistration.Value;
if (settings.ClientConfig.RequestConfig.RequestTimeout.HasValue)
- Timeout = settings.ClientConfig.RequestConfig.RequestTimeout.Value;
+ RequestTimeout = settings.ClientConfig.RequestConfig.RequestTimeout.Value;
else
- Timeout = DEFAULT_REQUEST_TIMEOUT;
+ RequestTimeout = DEFAULT_REQUEST_TIMEOUT;
baseUrl = settings.RegistryConfig.RegistryUrl.TrimEnd('/') + PATH_SEPERATOR + REGISTRY_BASE_PATH;
}
- public RegistryHttpClient() : this(null)
- { }
-
- public RegistryHttpClient(RegistryClientSettings registryClientSettings)
+ private RegistryHttpClient(HttpClientHandler clientHandler, RegistryClientSettings registryClientSettings) : base(clientHandler)
{
+ JsonSerializerSettings = new DependencyInjectionJsonSerializerSettings();
+
Settings = registryClientSettings ?? RegistryClientSettings.LoadSettings();
Settings = Settings ?? throw new NullReferenceException("Settings is null");
LoadSettings(Settings);
- JsonSerializerSettings = new DependencyInjectionJsonSerializerSettings();
}
+ public RegistryHttpClient() : this (DEFAULT_HTTP_CLIENT_HANDLER, null)
+ { }
+ public RegistryHttpClient(RegistryClientSettings registryClientSettings) : this(DEFAULT_HTTP_CLIENT_HANDLER, registryClientSettings)
+ { }
+ public RegistryHttpClient(RegistryClientSettings registryClientSettings, HttpClientHandler clientHandler) : this(clientHandler, registryClientSettings)
+ { }
+
public Uri GetUri(params string[] pathElements)
{
string path = baseUrl;
@@ -107,7 +112,7 @@
return new Result<IAssetAdministrationShellDescriptor>(new ArgumentNullException(nameof(aasDescriptor)));
var request = base.CreateJsonContentRequest(GetUri(aasId), HttpMethod.Put, aasDescriptor);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IAssetAdministrationShellDescriptor>(response, response.Entity);
}
@@ -117,7 +122,7 @@
return new Result<IAssetAdministrationShellDescriptor>(new ArgumentNullException(nameof(aasId)));
var request = base.CreateRequest(GetUri(aasId), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IAssetAdministrationShellDescriptor>(response, response.Entity);
}
@@ -127,7 +132,7 @@
return new Result<IQueryableElementContainer<IAssetAdministrationShellDescriptor>>(new ArgumentNullException(nameof(predicate)));
var request = base.CreateRequest(GetUri(), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
var result = base.EvaluateResponse<IEnumerable<IAssetAdministrationShellDescriptor>>(response, response.Entity);
if (!result.Success || result.Entity == null)
@@ -142,7 +147,7 @@
public IResult<IQueryableElementContainer<IAssetAdministrationShellDescriptor>> RetrieveAllAssetAdministrationShellRegistrations()
{
var request = base.CreateRequest(GetUri(), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
var result = base.EvaluateResponse<IEnumerable<IAssetAdministrationShellDescriptor>>(response, response.Entity);
return new Result<IQueryableElementContainer<IAssetAdministrationShellDescriptor>>(result.Success, result.Entity?.AsQueryableElementContainer(), result.Messages);
}
@@ -156,7 +161,7 @@
RepeatRegistrationCancellationToken?.Cancel();
var request = base.CreateRequest(GetUri(aasId), HttpMethod.Delete);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
@@ -170,7 +175,7 @@
return new Result<ISubmodelDescriptor>(new ArgumentNullException(nameof(submodelDescriptor)));
var request = base.CreateJsonContentRequest(GetUri(aasId, SUBMODEL_PATH, submodelId), HttpMethod.Put, submodelDescriptor);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodelDescriptor>(response, response.Entity);
}
@@ -182,7 +187,7 @@
return new Result<IQueryableElementContainer<ISubmodelDescriptor>>(new ArgumentNullException(nameof(predicate)));
var request = base.CreateRequest(GetUri(aasId, SUBMODEL_PATH), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
var result = base.EvaluateResponse<IEnumerable<ISubmodelDescriptor>>(response, response.Entity);
if (!result.Success || result.Entity == null)
@@ -200,7 +205,7 @@
return new Result<IQueryableElementContainer<ISubmodelDescriptor>>(new ArgumentNullException(nameof(aasId)));
var request = base.CreateRequest(GetUri(aasId, SUBMODEL_PATH), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
var result = base.EvaluateResponse<IEnumerable<ISubmodelDescriptor>>(response, response.Entity);
return new Result<IQueryableElementContainer<ISubmodelDescriptor>>(result.Success, result.Entity?.AsQueryableElementContainer(), result.Messages);
@@ -214,7 +219,7 @@
return new Result<ISubmodelDescriptor>(new ArgumentNullException(nameof(submodelId)));
var request = base.CreateRequest(GetUri(aasId, SUBMODEL_PATH, submodelId), HttpMethod.Get);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodelDescriptor>(response, response.Entity);
}
@@ -226,7 +231,7 @@
return new Result(new ArgumentNullException(nameof(submodelId)));
var request = base.CreateRequest(GetUri(aasId, SUBMODEL_PATH, submodelId), HttpMethod.Delete);
- var response = base.SendRequest(request, Timeout);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/BaSyx.Registry.Server.Http.Component.csproj b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/BaSyx.Registry.Server.Http.Component.csproj
index a72643d..1592552 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/BaSyx.Registry.Server.Http.Component.csproj
+++ b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/BaSyx.Registry.Server.Http.Component.csproj
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<Authors>Constantin Ziesche</Authors>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/DependencySettings.xml b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/DependencySettings.xml
new file mode 100644
index 0000000..972139d
--- /dev/null
+++ b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/DependencySettings.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<DependencySettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <DependencyCollection>
+ <Dependencies>
+ <Dependency>
+ <DllPath>BaSyx.Registry.ReferenceImpl.FileBased.dll</DllPath>
+ <InterfaceType>BaSyx.API.Platform.IAssetAdministrationShellRegistry</InterfaceType>
+ <ImplementationType>BaSyx.Registry.ReferenceImpl.FileBased.FileBasedRegistry</ImplementationType>
+ <ServiceLifetime>Singleton</ServiceLifetime>
+ </Dependency>
+ </Dependencies>
+ </DependencyCollection>
+ <Miscellaneous/>
+</DependencySettings>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/FileBasedRegistrySettings.xml b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/FileBasedRegistrySettings.xml
new file mode 100644
index 0000000..ded4bda
--- /dev/null
+++ b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http.Component/FileBasedRegistrySettings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FileBasedRegistrySettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Miscellaneous>
+ <FolderPath>RegistryDatabase</FolderPath>
+ </Miscellaneous>
+</FileBasedRegistrySettings>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http/ServerSettings.xml b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http/ServerSettings.xml
index 2327275..a7ef657 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http/ServerSettings.xml
+++ b/sdks/dotnet/basyx-components/BaSyx.Registry.Server.Http/ServerSettings.xml
@@ -6,8 +6,12 @@
<ContentPath>Content</ContentPath>
<Urls>
<Url>http://+:4999</Url>
+ <Url>https://+:4499</Url>
</Urls>
</Hosting>
<DefaultRoute/>
</ServerConfig>
+ <Miscellaneous>
+ <CompanyLogo>/images/Bosch.gif</CompanyLogo>
+ </Miscellaneous>
</ServerSettings>
diff --git a/sdks/dotnet/basyx-components/BaSyx.Submodel.Client.Http/SubmodelHttpClient.cs b/sdks/dotnet/basyx-components/BaSyx.Submodel.Client.Http/SubmodelHttpClient.cs
index 533407f..150d2fd 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Submodel.Client.Http/SubmodelHttpClient.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Submodel.Client.Http/SubmodelHttpClient.cs
@@ -21,11 +21,17 @@
using BaSyx.Models.Connectivity;
using System.Linq;
using BaSyx.Utils.DependencyInjection;
+using NLog;
+using System.Collections.Generic;
namespace BaSyx.Submodel.Client.Http
{
public class SubmodelHttpClient : SimpleHttpClient, ISubmodelClient
{
+ private static readonly ILogger logger = LogManager.GetCurrentClassLogger();
+
+ public static bool USE_HTTPS = true;
+
private const string SEPARATOR = "/";
private const string SUBMODEL = "submodel";
private const string PROPERTIES = "properties";
@@ -36,35 +42,43 @@
private const string ASYNC = "async";
private const string INVOCATION_LIST = "invocationList";
- private const int REQUEST_TIMEOUT = 30000;
-
public Uri Endpoint { get; }
+ public int RequestTimeout = DEFAULT_REQUEST_TIMEOUT;
- private SubmodelHttpClient()
+ private SubmodelHttpClient(HttpClientHandler clientHandler) : base(clientHandler)
{
JsonSerializerSettings = new DependencyInjectionJsonSerializerSettings();
}
- public SubmodelHttpClient(Uri endpoint) : this()
+ public SubmodelHttpClient(Uri endpoint) : this(endpoint, DEFAULT_HTTP_CLIENT_HANDLER)
+ { }
+ public SubmodelHttpClient(Uri endpoint, HttpClientHandler clientHandler) : this(clientHandler)
{
endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
Endpoint = endpoint;
}
+ public SubmodelHttpClient(ISubmodelDescriptor submodelDescriptor) : this(submodelDescriptor, DEFAULT_HTTP_CLIENT_HANDLER)
+ { }
- public SubmodelHttpClient(ISubmodelDescriptor submodelDescriptor) : this()
+ public SubmodelHttpClient(ISubmodelDescriptor submodelDescriptor, HttpClientHandler clientHandler) : this(clientHandler)
{
submodelDescriptor = submodelDescriptor ?? throw new ArgumentNullException(nameof(submodelDescriptor));
- HttpEndpoint httpEndpoint = submodelDescriptor.Endpoints?.OfType<HttpEndpoint>()?.FirstOrDefault();
+ IEnumerable<HttpEndpoint> httpEndpoints = submodelDescriptor.Endpoints?.OfType<HttpEndpoint>();
+ HttpEndpoint httpEndpoint = null;
+ if (USE_HTTPS)
+ httpEndpoint = httpEndpoints?.FirstOrDefault(p => p.Type == Uri.UriSchemeHttps);
+ if (httpEndpoint == null)
+ httpEndpoint = httpEndpoints?.FirstOrDefault(p => p.Type == Uri.UriSchemeHttp);
+
if (httpEndpoint == null || string.IsNullOrEmpty(httpEndpoint.Address))
throw new Exception("There is no http endpoint for instantiating a client");
else
{
- if(!httpEndpoint.Address.EndsWith(SEPARATOR + SUBMODEL) || !httpEndpoint.Address.EndsWith(SEPARATOR + SUBMODEL + SEPARATOR))
+ if (!httpEndpoint.Address.EndsWith(SEPARATOR + SUBMODEL) && !httpEndpoint.Address.EndsWith(SEPARATOR + SUBMODEL + SEPARATOR))
Endpoint = new Uri(httpEndpoint.Address + SEPARATOR + SUBMODEL);
else
Endpoint = new Uri(httpEndpoint.Address);
}
-
}
public Uri GetUri(params string[] pathElements)
@@ -77,175 +91,175 @@
public IResult<ISubmodel> RetrieveSubmodel()
{
var request = base.CreateRequest(GetUri(), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodel>(response, response.Entity);
}
public IResult<IProperty> CreateProperty(IProperty property)
{
var request = base.CreateJsonContentRequest(GetUri(PROPERTIES), HttpMethod.Put, property);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IProperty>(response, response.Entity);
}
public IResult<IEvent> CreateEvent(IEvent eventable)
{
var request = base.CreateJsonContentRequest(GetUri(EVENTS), HttpMethod.Put, eventable);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IEvent>(response, response.Entity);
}
public IResult<IOperation> CreateOperation(IOperation operation)
{
var request = base.CreateJsonContentRequest(GetUri(OPERATIONS), HttpMethod.Put, operation);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IOperation>(response, response.Entity);
}
public IResult DeleteProperty(string propertyId)
{
var request = base.CreateRequest(GetUri(PROPERTIES, propertyId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
public IResult DeleteEvent(string eventId)
{
var request = base.CreateRequest(GetUri(EVENTS, eventId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
public IResult DeleteOperation(string operationId)
{
var request = base.CreateRequest(GetUri(OPERATIONS, operationId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
public IResult<InvocationResponse> InvokeOperation(string operationId, InvocationRequest invocationRequest)
{
var request = base.CreateJsonContentRequest(GetUri(OPERATIONS, operationId), HttpMethod.Post, invocationRequest);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<InvocationResponse>(response, response.Entity);
}
public IResult<IProperty> RetrieveProperty(string propertyId)
{
var request = base.CreateRequest(GetUri(PROPERTIES, propertyId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IProperty>(response, response.Entity);
}
public IResult<IElementContainer<IProperty>> RetrieveProperties()
{
var request = base.CreateRequest(GetUri(PROPERTIES), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ElementContainer<IProperty>>(response, response.Entity);
}
public IResult<IValue> RetrievePropertyValue(string propertyId)
{
var request = base.CreateRequest(GetUri(PROPERTIES, propertyId, VALUE), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IValue>(response, response.Entity);
}
public IResult<IEvent> RetrieveEvent(string eventId)
{
var request = base.CreateRequest(GetUri(EVENTS, eventId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IEvent>(response, response.Entity);
}
public IResult<IElementContainer<IEvent>> RetrieveEvents()
{
var request = base.CreateRequest(GetUri(EVENTS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IElementContainer<IEvent>>(response, response.Entity);
}
public IResult<IOperation> RetrieveOperation(string operationId)
{
var request = base.CreateRequest(GetUri(OPERATIONS, operationId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IOperation>(response, response.Entity);
}
public IResult<IElementContainer<IOperation>> RetrieveOperations()
{
var request = base.CreateRequest(GetUri(OPERATIONS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ElementContainer<IOperation>>(response, response.Entity);
}
public IResult UpdatePropertyValue(string propertyId, IValue value)
{
var request = base.CreateJsonContentRequest(GetUri(PROPERTIES, propertyId, VALUE), HttpMethod.Put, value);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
- public IResult<ISubmodelElement> CreateSubmodelElement(string rootSubmodelElementIdShort, ISubmodelElement submodelElement)
+ public IResult<ISubmodelElement> CreateOrUpdateSubmodelElement(string rootSubmodelElementIdShort, ISubmodelElement submodelElement)
{
var request = base.CreateJsonContentRequest(GetUri(SUBMODELELEMENTS), HttpMethod.Put, submodelElement);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
}
public IResult<IElementContainer<ISubmodelElement>> RetrieveSubmodelElements()
{
var request = base.CreateRequest(GetUri(SUBMODELELEMENTS), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IElementContainer<ISubmodelElement>>(response, response.Entity);
}
public IResult<ISubmodelElement> RetrieveSubmodelElement(string submodelElementId)
{
var request = base.CreateRequest(GetUri(SUBMODELELEMENTS, submodelElementId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<ISubmodelElement>(response, response.Entity);
}
public IResult<IValue> RetrieveSubmodelElementValue(string submodelElementId)
{
var request = base.CreateRequest(GetUri(SUBMODELELEMENTS, submodelElementId, VALUE), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<IValue>(response, response.Entity);
}
public IResult UpdateSubmodelElement(string submodelElementId, ISubmodelElement submodelElement)
{
var request = base.CreateJsonContentRequest(GetUri(SUBMODELELEMENTS, submodelElementId), HttpMethod.Put, submodelElement);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
public IResult DeleteSubmodelElement(string submodelElementId)
{
var request = base.CreateRequest(GetUri(SUBMODELELEMENTS, submodelElementId), HttpMethod.Delete);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
public IResult<CallbackResponse> InvokeOperationAsync(string operationId, InvocationRequest invocationRequest)
{
var request = base.CreateJsonContentRequest(GetUri(OPERATIONS, operationId, ASYNC), HttpMethod.Post, invocationRequest);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<CallbackResponse>(response, response.Entity);
}
public IResult<InvocationResponse> GetInvocationResult(string operationId, string requestId)
{
var request = base.CreateRequest(GetUri(OPERATIONS, operationId, INVOCATION_LIST, requestId), HttpMethod.Get);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse<InvocationResponse>(response, response.Entity);
}
public IResult UpdateSubmodelElementValue(string submodelElementId, IValue value)
{
var request = base.CreateJsonContentRequest(GetUri(SUBMODELELEMENTS, submodelElementId, VALUE), HttpMethod.Put, value);
- var response = base.SendRequest(request, REQUEST_TIMEOUT);
+ var response = base.SendRequest(request, RequestTimeout);
return base.EvaluateResponse(response, response.Entity);
}
}
diff --git a/sdks/dotnet/basyx-components/BaSyx.Submodel.Server.Http/SubmodelRepositoryHttpServer.cs b/sdks/dotnet/basyx-components/BaSyx.Submodel.Server.Http/SubmodelRepositoryHttpServer.cs
index 5d8cd69..7043fc7 100644
--- a/sdks/dotnet/basyx-components/BaSyx.Submodel.Server.Http/SubmodelRepositoryHttpServer.cs
+++ b/sdks/dotnet/basyx-components/BaSyx.Submodel.Server.Http/SubmodelRepositoryHttpServer.cs
@@ -19,8 +19,6 @@
{
public class SubmodelRepositoryHttpServer : ServerApplication
{
- private string submodelId = string.Empty;
-
public SubmodelRepositoryHttpServer() : this(null, null)
{ }
@@ -40,21 +38,6 @@
{
services.AddSingleton<ISubmodelRepositoryServiceProvider>(submodelRepositoryServiceProvider);
});
- }
-
- protected override void ConfigureServices(IServiceCollection services)
- {
- base.ConfigureServices(services);
-
- //Check whether Submodel Service Provider exists and bind it to the Submodel-Services-Controller
- services.AddTransient<ISubmodelServiceProvider>(ctx =>
- {
- ISubmodelServiceProvider submodelServiceProvider = ctx
- .GetRequiredService<ISubmodelRepositoryServiceProvider>()
- .GetSubmodelServiceProvider(submodelId);
-
- return submodelServiceProvider;
- });
- }
+ }
}
}