Prototype for code generation from SysML v2.
Project description
This is a demonstration project. It is not suitable for productive use.
SysML v2 Code Generator
This is a prototype project for code generation from SysML v2 models to demonstrate the potential of code generation in a SysML v2 context.
Preconditions
For direct usage:
- python ^3.9
- pip
For interactive debugging and development (recommended):
- poetry
- professional Python IDE
Optional:
- SysML v2 Pilot Implementation for generation of own models (JupyterNotebook => JSON/API)
- gcc for compiling generated C files
- pyinstaller for bundling generated gui simulators as standalone executables
Installation
as a python package and CLI tool
pip install fcp89-sysml-v2-code-generator
as development project
- check out the project with git clone
- install project dependencies into a python virtual environment with
poetry install
Basic Usage
Within your activated python virtual environment run:
sysml-code-generator
This will generate an example in the current working directory.
Options
Show options with
sysml-code-generator -h
Available options (from the help):
usage: SysML v2 Code Generator [-h] [--json JSON] [--element ELEMENT] [--output OUTPUT] [--build]
[--generator {auto,state_c,state_c_sim_cli,state_c_sim_gui,action_c}]
[--api_url API_URL] [--project_name PROJECT_NAME] [--disable_ssl_verification]
Generate executable code from a SysML v2 model.
options:
-h, --help show this help message and exit
--element ELEMENT Qualified name of the element to build code for.
--output OUTPUT Existing folder for the generated files.
--build Compile the result. May need additional installed software on the system.
--generator {auto,state_c,state_c_sim_cli,state_c_sim_gui,action_c}
Generator type.
JSON source:
--json JSON URL of a json file to load the model from.
API source:
--api_url API_URL Base URL of the API to fetch the data from.
--project_name PROJECT_NAME
Project name.
--disable_ssl_verification
More Examples
Running via python in virtual environment
python application.py
Generating C code for an exported State Machine
- Model a SysML v2 State Machine (restrictions apply).
- Export the package of the statemachine to JSON. (e.g. JupyterNotebook %export MyProject)
- Run:
sysml-code-generator --json_url MyProject.json --element_qualified_name MyProject::MyStateMachine
Generating simulator for example state machine
sysml-code-generator --json_url MyProject.json --element_qualified_name MyProject::MyStateMachine
Including gcc compilation (requires installed gcc):
sysml-code-generator --generator state_c_sim_cli
Developing
This project uses dependency injection.
Instances are assembled in container.py.
Developing a new code generator
- set up simple example files
- set up your debugger
- see sysml_code_generator/generator for existing generators
- add your generator
- test and develop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fcp89_sysml_v2_code_generator-1.0.0.tar.gz.
File metadata
- Download URL: fcp89_sysml_v2_code_generator-1.0.0.tar.gz
- Upload date:
- Size: 513.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.2 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
977e67e5d8663ec567e302d2d96216aa27b9d1cad2ab91eb3233dbf9e776c3cf
|
|
| MD5 |
7b929b3c040aee1a7bd842acdb981ba3
|
|
| BLAKE2b-256 |
051c072d5b8e222bcd9f8ba3b2d0af0ac532f925ce5220ff2405e9ac57ef8e1e
|
File details
Details for the file fcp89_sysml_v2_code_generator-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fcp89_sysml_v2_code_generator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 533.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.2 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad47e68ff5548286215f54396537c75567552fa0b81d51843b14443ab094be2b
|
|
| MD5 |
bffdf008ee03bfd2071ec2799b1f8cf6
|
|
| BLAKE2b-256 |
69b313a24bc863839da8d4665eceaee0dc3a697cf46309daccb94c3ab72c3c56
|