Esempio n. 1
0
        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.Urls.Add("http://localhost:5222");

            SubmodelHttpServer       submodelServer          = new SubmodelHttpServer(submodelServerSettings);
            ISubmodelServiceProvider submodelServiceProvider = testSubmodel.CreateServiceProvider();

            submodelServer.SetServiceProvider(submodelServiceProvider);
            submodelServiceProvider.UseAutoEndpointRegistration(submodelServerSettings.ServerConfig);
            Task runSubmodelTask = submodelServer.RunAsync();

            ServerSettings aasServerSettings = ServerSettings.CreateSettings();

            aasServerSettings.ServerConfig.Hosting.ContentPath = "Content";
            aasServerSettings.ServerConfig.Hosting.Urls.Add("http://localhost:5111");

            IAssetAdministrationShellServiceProvider serviceProvider = aas.CreateServiceProvider(true);

            serviceProvider.SubmodelRegistry.RegisterSubmodelServiceProvider(testSubmodel.IdShort, submodelServiceProvider);
            serviceProvider.UseAutoEndpointRegistration(aasServerSettings.ServerConfig);

            AssetAdministrationShellHttpServer aasServer = new AssetAdministrationShellHttpServer(aasServerSettings);

            aasServer.SetServiceProvider(serviceProvider);
            aasServer.Run();
        }
Esempio n. 2
0
        private static void LoadSingleShell()
        {
            AssetAdministrationShell aas = SimpleAssetAdministrationShell.SimpleAssetAdministrationShell.GetAssetAdministrationShell();
            ISubmodel testSubmodel       = aas.Submodels["TestSubmodel"];

            ServerSettings submodelServerSettings = ServerSettings.CreateSettings();

            submodelServerSettings.ServerConfig.Hosting.ContentPath = "Content";
            submodelServerSettings.ServerConfig.Hosting.Urls.Add("http://localhost:5222");

            SubmodelHttpServer       submodelServer          = new SubmodelHttpServer(submodelServerSettings);
            ISubmodelServiceProvider submodelServiceProvider = testSubmodel.CreateServiceProvider();

            submodelServer.SetServiceProvider(submodelServiceProvider);
            submodelServiceProvider.UseAutoEndpointRegistration(submodelServerSettings.ServerConfig);
            submodelServer.RunAsync();

            ServerSettings aasServerSettings = ServerSettings.CreateSettings();

            aasServerSettings.ServerConfig.Hosting.ContentPath = "Content";
            aasServerSettings.ServerConfig.Hosting.Urls.Add("http://localhost:5111");

            IAssetAdministrationShellServiceProvider aasServiceProvider = aas.CreateServiceProvider(true);

            aasServiceProvider.SubmodelRegistry.RegisterSubmodelServiceProvider(testSubmodel.IdShort, submodelServiceProvider);
            aasServiceProvider.UseAutoEndpointRegistration(aasServerSettings.ServerConfig);

            AssetAdministrationShellHttpServer aasServer = new AssetAdministrationShellHttpServer(aasServerSettings);

            aasServer.SetServiceProvider(aasServiceProvider);
            aasServer.ApplicationStopping = () => { registryClient.DeleteAssetAdministrationShell(aas.Identification.Id); };
            aasServer.RunAsync();

            registryClient.CreateAssetAdministrationShell(new AssetAdministrationShellDescriptor(aas, aasServiceProvider.ServiceDescriptor.Endpoints));
            registryClient.CreateSubmodel(aas.Identification.Id, new SubmodelDescriptor(testSubmodel, submodelServiceProvider.ServiceDescriptor.Endpoints));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            ServerSettings aasRepositorySettings = ServerSettings.CreateSettings();

            aasRepositorySettings.ServerConfig.Hosting.ContentPath = "Content";
            aasRepositorySettings.ServerConfig.Hosting.Urls.Add("http://+:5999");

            MultiAssetAdministrationShellHttpServer           server            = new MultiAssetAdministrationShellHttpServer(aasRepositorySettings);
            AssetAdministrationShellRepositoryServiceProvider repositoryService = new AssetAdministrationShellRepositoryServiceProvider();

            for (int i = 0; i < 10; i++)
            {
                AssetAdministrationShell aas = new AssetAdministrationShell()
                {
                    IdShort        = "MultiAAS_" + i,
                    Identification = new Identifier("http://basys40.de/shells/MultiAAS/" + Guid.NewGuid().ToString(), KeyType.IRI),
                    Description    = new LangStringSet()
                    {
                        new LangString("de-DE", i + ". VWS"),
                        new LangString("en-US", i + ". AAS")
                    },
                    Administration = new AdministrativeInformation()
                    {
                        Version  = "1.0",
                        Revision = "120"
                    },
                    Asset = new Asset()
                    {
                        IdShort        = "Asset_" + i,
                        Identification = new Identifier("http://basys40.de/assets/MultiAsset/" + Guid.NewGuid().ToString(), KeyType.IRI),
                        Kind           = AssetKind.Instance,
                        Description    = new LangStringSet()
                        {
                            new LangString("de-DE", i + ". Asset"),
                            new LangString("en-US", i + ". Asset")
                        }
                    }
                };

                aas.Submodels.Create(new Submodel()
                {
                    Identification   = new Identifier("http://basys40.de/submodels/" + Guid.NewGuid().ToString(), KeyType.IRI),
                    IdShort          = "TestSubmodel",
                    SubmodelElements = new ElementContainer <ISubmodelElement>()
                    {
                        new Property <string>()
                        {
                            IdShort = "Property_" + i
                        }
                    }
                });

                var aasServiceProvider = aas.CreateServiceProvider(true);
                repositoryService.RegisterAssetAdministrationShellServiceProvider(aas.IdShort, aasServiceProvider);
            }

            List <HttpEndpoint> endpoints = server.Settings.ServerConfig.Hosting.Urls.ConvertAll(c => new HttpEndpoint(c.Replace("+", "127.0.0.1")));

            repositoryService.UseDefaultEndpointRegistration(endpoints);

            server.SetServiceProvider(repositoryService);
            server.Run();
        }
Esempio n. 4
0
        private static void LoadMultipleShells()
        {
            ServerSettings aasRepositorySettings = ServerSettings.CreateSettings();

            aasRepositorySettings.ServerConfig.Hosting.ContentPath = "Content";
            aasRepositorySettings.ServerConfig.Hosting.Urls.Add("http://+:5999");

            MultiAssetAdministrationShellHttpServer           multiServer       = new MultiAssetAdministrationShellHttpServer(aasRepositorySettings);
            AssetAdministrationShellRepositoryServiceProvider repositoryService = new AssetAdministrationShellRepositoryServiceProvider();

            for (int i = 0; i < 3; i++)
            {
                AssetAdministrationShell aas = new AssetAdministrationShell()
                {
                    IdShort        = "MultiAAS_" + i,
                    Identification = new Identifier("http://basyx.de/shells/MultiAAS/" + i, KeyType.IRI),
                    Description    = new LangStringSet()
                    {
                        new LangString("de-DE", i + ". VWS"),
                        new LangString("en-US", i + ". AAS")
                    },
                    Administration = new AdministrativeInformation()
                    {
                        Version  = "1.0",
                        Revision = "120"
                    },
                    Asset = new Asset()
                    {
                        IdShort        = "Asset_" + i,
                        Identification = new Identifier("http://basyx.de/assets/MultiAsset/" + i, KeyType.IRI),
                        Kind           = AssetKind.Instance,
                        Description    = new LangStringSet()
                        {
                            new LangString("de-DE", i + ". Asset"),
                            new LangString("en-US", i + ". Asset")
                        }
                    }
                };

                aas.Submodels.Create(new Submodel()
                {
                    Identification   = new Identifier("http://basyx.de/submodels/" + i, KeyType.IRI),
                    IdShort          = "TestSubmodel",
                    SubmodelElements = new ElementContainer <ISubmodelElement>()
                    {
                        new Property <string>()
                        {
                            IdShort = "Property_" + i,
                            Value   = "TestValue_" + i
                        },
                        new SubmodelElementCollection()
                        {
                            IdShort = "Coll_" + i,
                            Value   = new ElementContainer <ISubmodelElement>()
                            {
                                new Property <string>()
                                {
                                    IdShort = "SubProperty_" + i,
                                    Value   = "TestSubValue_" + i
                                }
                            }
                        }
                    }
                });

                var aasServiceProvider = aas.CreateServiceProvider(true);
                repositoryService.RegisterAssetAdministrationShellServiceProvider(aas.IdShort, aasServiceProvider);
            }

            List <HttpEndpoint> endpoints = multiServer.Settings.ServerConfig.Hosting.Urls.ConvertAll(c => new HttpEndpoint(c.Replace("+", "127.0.0.1")));

            repositoryService.UseDefaultEndpointRegistration(endpoints);

            multiServer.SetServiceProvider(repositoryService);
            multiServer.ApplicationStopping = () =>
            {
                foreach (var aasDescriptor in repositoryService.ServiceDescriptor.AssetAdministrationShellDescriptors)
                {
                    registryClient.DeleteAssetAdministrationShell(aasDescriptor.Identification.Id);
                }
            };

            multiServer.RunAsync();

            foreach (var aasDescriptor in repositoryService.ServiceDescriptor.AssetAdministrationShellDescriptors)
            {
                registryClient.CreateAssetAdministrationShell(aasDescriptor);
            }
        }