Package: aas-core-codegen
Aas-core-codegen:generates code for different programming environments and schemasto handle asset administration shellsbased on the meta-model in simplified Python.MotivationThe meta-model is still at the stage where it changes frequently.
However, we need SDKs in different languages (C#, C++, C, Java, Golang, Erlangetc.) as well as different schemas (JSON Schema, XSD, RDFetc.).
Keeping up with the changes is hard, time-consuming and error-prone aseachSDK and schema needs to be reviewed independently.To make the whole development cycle of the meta-model, SDKs and schemas more maintainable, we wrote a code and schema generator.
We write a meta-model in a subset of Python language, parse it and, based on this meta-model, generate the code for different languages and schemas.Therefore we can easily scale to many languages and schemas.Here is a diagram to illustrate the whole process:Warning about StabilityWhile we aim for long-term stability of the generators, mind that the current version of the meta-model, version 3 release candidate 2 (V3RC2) is in too much flux to make any solid claims about the short-term stability.For example, not even the set of basic types is still defined, and there is an on-going discussion in the UAG Verwaltungsschale what this set might be.
Same holds about the definitions of references and how we should deal with them.Moreover, the serialization approaches are not finalized either.
For example, the current JSON schema does not allow for one-pass serialization (a.k.a. streaming-based serialization).
We are discussing in UAG Verwaltungsschale to use JSON tuples with the model type as prefix instead of JSON objects, but this discussion is still at an early stage.As long as V3RC2 does not stabilize, consider the generated code and schemas to be insufficient for any serious use (either experimental or in production).InstallationSingle-File ReleasePlease download and unzip the latest release fromthe GitHub release page.From PyPIThe tool is also available onPyPI.Create a virtual environment:python -m venv venv-aas-core-codegenActivate it (in Windows):venv-venv-aas-core-codegen\Scripts\activateor in Linux and OS X:source venv-aas-core-codegen/bin/activateInstall the tool in the virtual environment:pip3 install aas-core-codegenUsageWrite your meta-model somewhere as well as the code snippets for implementation specific classes and functions.
For example, take ourtest meta-modelfor inspiration how to write the meta-model and the snippets.Make sure you are within the virtual environment where you installed the generator.
Alternatively, if you are using the binary release, make sure the release is on your path.Call the generator with the appropriate target:aas-core-codegen \
    --model_path path/to/meta_model.py \
    --snippets_dir path/to/snippets \
    --output_dir path/to/output \
    --target csharp--helpusage: aas-core-codegen [-h] --model_path MODEL_PATH --snippets_dir
                        SNIPPETS_DIR --output_dir OUTPUT_DIR --target
                        {csharp,jsonschema,rdf_shacl,xsd} [--version]

Generate different implementations and schemas based on an AAS meta-model.

optional arguments:
  -h, --help            show this help message and exit
  --model_path MODEL_PATH
                        path to the meta-model
  --snippets_dir SNIPPETS_DIR
                        path to the directory containing implementation-
                        specific code snippets
  --output_dir OUTPUT_DIR
                        path to the generated code
  --target {csharp,jsonschema,rdf_shacl,xsd}
                        target language or schema
  --version             show the current version and exitVersioningWe are still not clear about how to version the generator.
For the moment, we use a lax incremental versioning with0.0prefix (0.0.1, 0.0.2``)etc.The changelog is available inCHANGELOG.rst.ContributingFeature requests or bug reports are always very, very welcome!Please see quickly if the issue does not already exist in theissue sectionand, if not, createa new issue.Contributions in code are also welcome!
Please seeCONTRIBUTING.rstfor developing guidelines.