Commit b27ed194 authored by Sebastian Heppner's avatar Sebastian Heppner
Browse files

readme: Change "Getting Started"."Example" to creation and serialization of submodel

parent 1ce9e8ea
Pipeline #259856 passed with stage
in 3 minutes and 2 seconds
......@@ -42,36 +42,45 @@ pip install pyi40aas
### Example
Following `examples.tutorial_create_simple_ass`, these are the steps to take to set up an exemplary
Asset Administration Shell with PyI40AAS:
Creation of a `Submodel` with a `Propery` and serialization of said `Submodel` to `XML`:
First, we create an `Asset`, for which we need an `Identifier`:
Create a `Submodel`:
from aas import model # Import all PYI40AAS classes from the model package
id_type = model.IdentifierType.IRI
id_ = ''
identifier = model.Identifier(id_, id_type)
asset = model.Asset(
kind=model.AssetKind.INSTANCE, # define that the asset is of kind instance
identification=identifier # set identifier
identifier = model.Identifier('', model.IdentifierType.IRI)
submodel = model.Submodel(identification=identifier)
Now, we can create the `AssetAdministrationShell`, which needs an `Identifier` as well. The method
`model.AASReference.from_referable()` lets us create a `Reference` to the `Asset` we just created from the asset itself,
in order to add it to our `AssetAdministrationShell`.
Create a `Property` and add it to the `Submodel`:
identifier = model.Identifier('', model.IdentifierType.IRI)
aas = model.AssetAdministrationShell(
identification=identifier, # set identifier
# create a global reference to a semantic description of the property
semantic_reference = model.Reference(
property = model.Property(
id_short='ExampleProperty', # Identifying string of the element within the submodel namespace
value_type=model.datatypes.String, # Data type of the value
value='exampleValue', # Value of the property
semantic_id=semantic_reference # set the semantic reference
Congratulations: Now you have created your first `AssetAdministrationShell` with PyI40AAS. From here, you can continue
by creating submodels (`model.Submodel`) and submodel elements like properties (`model.Property`).
Alternatively you can look into storing the information your `AssetAdministrationShell` contains, either with JSON, XML
or CouchDB.
Serialize the `Submodel` to `XML`:
import aas.adapter.xml.xml_serialization
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
file = io.BytesIO()
aas.adapter.xml.xml_serialization.write_aas_xml_file(file=file, data=data)
### Examples and Tutorials
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment