Skip to main content
Jump to: navigation, search

BaSyx / Introductory Examples / Java / Step 5

Step 5: Creating the AAS, registering it, uploading to the AAS server and setting up the UI

The last example did create the oven Submodel. This Submodel is available in the network and can be accessed by the users. In this example step, an Asset Administration Shell will be created as a unified representation of the oven. The AAS provides an asset independent digital representation. All asset specific data, such as temperature sensors and invokable operations are provided through Submodels of the AAS. The created AAS for the oven with therefore reference one Submodel, which is the oven Submodel from the previous steps. The AAS of the oven will be hosted on the AAS server in the IT infrastructure. It is registered in the AASRegistry using an AAS descriptor to ensure that it can be found in the network. The descriptor also contains a Submodel descriptor. Once the model is registered, it is accessible by its IT. If the model is re-deployed to a different location, it is sufficient to update the registry entry.

The created AAS then can be explored through its HTTP-Rest with any HTTP client, e.g. with a web browser.


Creating the AAS

The Asset Administration Shell is a digital representation of a real world asset. Every asset is described at least by a short name (in this example ovenAsset), and by an URN. The short name does not need to be globally unique, it is sufficient if it is unique in the local context. The URN is used to refer to the asset, and therefore it should be unique. In this example, we will be using "urn:org.eclipse.basyx:OvenAsset". A guide for creating global URNs, and a proposal for an URN scheme that also includes versioning and revision information is provided here - Asset Administration Shell.

A device may come with an initial AAS that is transferred to an AAS server when the device is connected. Alternatively, an AAS may be sent in a serialized format, e.g. as .aasx or as JSON file before a physical device is delivered. In this example, the AAS is created with Java code, and uploaded by the device to the AAS server, and also registered in the registry.


  1. 	// The URN is a unique name, and refers to the asset
  2. 	ModelUrn aasURN = new ModelUrn("urn:org.eclipse.basyx:OvenAAS");
  3.  
  4. 	// A digital representation of the asset
  5. 	Asset asset = new Asset("ovenAsset", aasURN, AssetKind.INSTANCE);
  6.  
  7. 	// Create the Asset Administration Shell object
  8. 	AssetAdministrationShell aas = new AssetAdministrationShell("oven", aasURN, asset);


The created Asset Administration Shell needs to be populated with the Submodels of the AAS. For this example, this will be the oven Submodel. This code should be placed after the last lines of the main function from the previous step.


  1. 	// Now add the references of the submodels to the AAS header
  2. 	aas.addSubmodel(ovenModel);


Creating the AAS descriptor and registering everything

The created Asset Administration Shell needs to be uploaded to the AAS server, and to the AAS registry. The registry requires an AAS descriptor that contains information about the AAS itself, and about the Submodels of the AAS. Make sure your docker Containers we created in Step 2 are running.

  1. 	// Create a descriptor for the AAS
  2. 	AASDescriptor aasDescriptor = new AASDescriptor(aas, "http://localhost:8081/aasServer");
  3. 	// Explicitly create and add submodel descriptors
  4. 	SubmodelDescriptor sensorSMDescriptor = new SubmodelDescriptor(ovenModel, "http://localhost:4001/handson/oven/submodel");
  5.  
  6.         // Depending on the registry endpoint, this path needs to be adapted (cf. step 2)
  7. 	final String REGISTRYPATH = "http://localhost:8082/registry/";
  8.  
  9.         // Register the oven Submodel at the registry
  10.         AASRegistryProxy registry = new AASRegistryProxy(REGISTRYPATH);

Uploading the AAS

  1. 	ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry, new HTTPConnectorFactory());
  2. 	// Create the AAS on the remote AAS Server
  3. 	manager.createAAS(aas, "http://localhost:8081/aasServer");
  4. 	// Create the submodel on the remote AAS Server
  5. 	manager.createSubmodel(aasURN, ovenModel);

The final code should look like this:

  1. 	public static void createShell() {
  2.  
  3. 		// The URN is a unique name, and refers to the asset
  4. 		ModelUrn aasURN = new ModelUrn("urn:org.eclipse.basyx:OvenAAS");
  5.  
  6. 		// A digital representation of the asset
  7. 		Asset asset = new Asset("ovenAsset", aasURN, AssetKind.INSTANCE);
  8.  
  9. 		// Create the Asset Administration Shell object
  10. 		AssetAdministrationShell aas = new AssetAdministrationShell("oven", aasURN, asset);
  11. 		// Now add the references of the submodels to the AAS header
  12. 		aas.addSubmodel(ovenModel);
  13.  
  14. 		// Create a descriptor for the AAS
  15. 		AASDescriptor aasDescriptor = new AASDescriptor(aas, "http://localhost:8081/aasServer");
  16.  
  17. 		// Explicitly create and add submodel descriptors
  18. 		SubmodelDescriptor sensorSMDescriptor = new SubmodelDescriptor(ovenModel, "http://localhost:4001/handson/oven/submodel");
  19.  
  20. 		// Depending on the registry endpoint, this path needs to be adapted (cf. step
  21. 		// 2)
  22. 		final String REGISTRYPATH = "http://localhost:8082/registry/";
  23.  
  24. 		// Register the oven Submodel at the registry
  25. 		AASRegistryProxy registry = new AASRegistryProxy(REGISTRYPATH);
  26.  
  27. 		ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry, new HTTPConnectorFactory());
  28.  
  29. 		manager.createAAS(aas, "http://localhost:8081/aasServer");
  30. 		manager.createSubmodel(aasURN, ovenModel);
  31. 	}

The last thing to do is to call the method createShell() after the server.start() call in the main method of your class.

Setting up the Registry UI

To visualize data there is a practical UI which u can run in a docker container. Execute the following command to start the container.

docker run -p 8080:8080 --name=aasGui eclipsebasyx/aas-gui:v220729

When the container is started up, you should be able to connect to the GUI via

http://localhost:8080

Now, in the top bar, enter the URL of the registry server. If unchanged this would be:

http://localhost:8082/registry

Reminder: Make sure that the AAS Server, Registry, and Submodel Server are running..


Once you hit connect you should see your uploaded AAS and, once you click on it, the oven Submodel.

AasGui.png


Now we have a working Asset Administration Shell that has been uploaded to the AAS server, as well as an oven Submodel. Both, the Submodel and the AAS have been registered at the registry, and you can access the data via the AAS GUI.

Back to the top