blob: 8a4603b705e1e87dce5b46a07e1467cc80f9f9b6 [file] [log] [blame]
/*******************************************************************************
* 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.AAS.Server.Http;
using BaSyx.API.AssetAdministrationShell.Extensions;
using BaSyx.API.Components;
using BaSyx.Common.UI;
using BaSyx.Common.UI.Swagger;
using BaSyx.Models.Core.AssetAdministrationShell.Generics;
using BaSyx.Models.Core.AssetAdministrationShell.Implementations;
using BaSyx.Submodel.Server.Http;
using BaSyx.Utils.Settings.Types;
using System;
namespace SimpleAssetAdministrationShell
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
AssetAdministrationShell aas = SimpleAssetAdministrationShell.GetAssetAdministrationShell();
ISubmodel testSubmodel = aas.Submodels["TestSubmodel"];
ServerSettings submodelServerSettings = ServerSettings.CreateSettings();
submodelServerSettings.ServerConfig.Hosting.ContentPath = "Content";
submodelServerSettings.ServerConfig.Hosting.Environment = "Development";
submodelServerSettings.ServerConfig.Hosting.Urls.Add("http://localhost:5040");
submodelServerSettings.ServerConfig.Hosting.Urls.Add("https://localhost:5440");
SubmodelHttpServer submodelServer = new SubmodelHttpServer(submodelServerSettings);
ISubmodelServiceProvider submodelServiceProvider = testSubmodel.CreateServiceProvider();
submodelServer.SetServiceProvider(submodelServiceProvider);
submodelServiceProvider.UseAutoEndpointRegistration(submodelServerSettings.ServerConfig);
submodelServer.AddBaSyxUI(PageNames.SubmodelServer);
submodelServer.AddSwagger(Interface.Submodel);
_ = submodelServer.RunAsync();
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");
IAssetAdministrationShellServiceProvider serviceProvider = aas.CreateServiceProvider(true);
serviceProvider.SubmodelRegistry.RegisterSubmodelServiceProvider(testSubmodel.IdShort, submodelServiceProvider);
serviceProvider.UseAutoEndpointRegistration(aasServerSettings.ServerConfig);
AssetAdministrationShellHttpServer aasServer = new AssetAdministrationShellHttpServer(aasServerSettings);
aasServer.SetServiceProvider(serviceProvider);
aasServer.AddBaSyxUI(PageNames.AssetAdministrationShellServer);
aasServer.AddSwagger(Interface.AssetAdministrationShell);
aasServer.Run();
}
}
}