Visual block diagram editor for STEPSS CODEGEN power system models
Project description
CODEGEN Studio
CODEGEN Studio is a browser-based, drag-and-drop visual editor for building STEPSS CODEGEN User-Defined Models — part of the STEPSS power system simulation suite. It lets you create device models by wiring blocks on a canvas instead of manually writing DSL files.
STEPSS has been developed by Dr. Petros Aristidou (Cyprus University of Technology) and Dr. Thierry Van Cutsem (Emeritus, University of Liège).
Overview
CODEGEN Studio replaces the manual editing of CODEGEN DSL .txt files with a graphical workflow. You drag blocks from a categorised palette, connect input/output ports to define signal flow, fill in metadata tables, and export ready-to-compile DSL files — or run the codegen binary directly from the editor to generate Fortran .f90 source.
The tool supports all four CODEGEN model types:
| Type | Purpose | Mandatory Outputs |
|---|---|---|
| EXC | Excitation controller | vf |
| TOR | Torque controller | tm |
| INJ | Current injector | ix, iy |
| TWOP | Two-port device | ix1, iy1, ix2, iy2 |
Key Features
- Drag-and-drop block diagram editor — assemble models visually on a canvas with 51 built-in blocks
- Live DSL preview — syntax-highlighted code updates in real time as you edit
- Lossless round-trip — import existing
.txtDSL files with automatic canvas layout, edit, and re-export - One-click Fortran generation — run the
codegenbinary directly from the browser - Project save/load —
.cgprojfiles preserve full editor state including block positions - Mandatory output validation — warns when required outputs for the model type are missing
- Undo/redo — 60-step history with keyboard shortcuts
- Extensible block catalogue — add new blocks via a single JSON entry, no code changes required
- No build step — vanilla JavaScript frontend served by a Python backend
Installation
Requirements
- Python ≥ 3.10
- A modern browser (Chrome, Firefox, or Edge)
- (Optional) CODEGEN binary for
.f90generation
Install
git clone https://github.com/SPS-L/stepss-cg-studio.git
cd stepss-cg-studio
pip install -r requirements.txt
Quick Start
# Start the server
python server/app.py
# Open in browser
# http://localhost:8765
On Windows, double-click run.bat. On Linux/macOS, run ./run.sh.
Building a model
- Select model type and name — choose EXC, TOR, INJ, or TWOP from the toolbar dropdown
- Add blocks — drag blocks from the left-hand palette onto the canvas
- Connect blocks — wire output ports to input ports to define signal flow
- Edit block properties — select a block to configure output names and arguments in the inspector
- Populate metadata — fill in Data, Parameters, States, and Observables in the tabs below the canvas
- Export — click "Export DSL" for the
.txtfile, or "Run Codegen" to generate Fortran directly
Keyboard shortcuts
| Shortcut | Action |
|---|---|
| Ctrl/Cmd + S | Save project |
| Ctrl/Cmd + Z | Undo |
| Ctrl/Cmd + Shift + Z | Redo |
| Delete / Backspace | Delete selected block |
| Escape | Close modal |
Project Structure
stepss-cg-studio/
├── server/
│ ├── app.py # FastAPI server & API endpoints
│ ├── dsl_parser.py # DSL .txt → ModelProject dict
│ ├── dsl_emitter.py # ModelProject dict → DSL .txt
│ └── config.json # Runtime config (codegen path, host, port)
├── frontend/
│ ├── index.html # Single-page app
│ ├── css/style.css
│ ├── js/
│ │ ├── main.js # App bootstrap, toolbar, file I/O
│ │ ├── canvas.js # Drawflow integration & auto-layout
│ │ ├── store.js # ModelProject state, topological sort, undo/redo
│ │ ├── forms.js # Metadata tables & block inspector
│ │ ├── palette.js # Block palette with search
│ │ ├── dsl_preview.js # Live DSL preview (CodeMirror)
│ │ └── api.js # Backend API wrappers
│ └── blocks.json # Block catalogue (51 blocks, extend here)
├── examples/ # Example .cgproj project files
├── tests/ # Pytest test suite (~75 tests)
├── docs/ # Design documents
├── requirements.txt
├── run.bat # Windows launcher
└── run.sh # Linux/macOS launcher
Adding New Blocks
Edit frontend/blocks.json — add a single JSON entry with the block name, ports, argument schema, DSL line templates, and category. No JavaScript or Python changes required.
Running Tests
# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_parser.py -v
# Run a single test
pytest tests/test_parser.py::test_function_name -v
CI runs pytest on Python 3.10–3.12 via GitHub Actions.
Settings
Access via the gear icon in the toolbar:
- Codegen binary path — full path to the
codegenexecutable (default:codegenon system PATH) - Server host — change to
0.0.0.0for network access (default:127.0.0.1) - Server port — HTTP port (default:
8765)
Settings are stored in server/config.json and also editable via the REST API at /docs.
Documentation
Full documentation is available at https://stepss.sps-lab.org/developer/cg-studio/.
- User-Defined Models — DSL format specification
- CODEGEN Blocks Library — complete block reference
- CODEGEN Model Examples — annotated example files
License
MIT — see LICENSE.
Authors
Developed by the Sustainable Power Systems Lab (SPS-L), Cyprus University of Technology.
- Dr. Petros Aristidou — Cyprus University of Technology
- Dr. Thierry Van Cutsem — Emeritus, University of Liège
Support
- Documentation: https://stepss.sps-lab.org/developer/cg-studio/
- Issues: https://github.com/SPS-L/stepss-cg-studio/issues
- Project page: https://sps-lab.org/
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 Distributions
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 stepss_cg_studio-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stepss_cg_studio-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
971865e0c96fb0e55a17099731d79586227ea7fc67c06777ef568658a81ad133
|
|
| MD5 |
0351a1af167f7ca515eaa162543d4e2d
|
|
| BLAKE2b-256 |
286cae0f579f0ec9d1404a2c7b6f91e54afbe93b5b59020667f5082cd3424fb4
|
Provenance
The following attestation bundles were made for stepss_cg_studio-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on SPS-L/stepss-cg-studio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stepss_cg_studio-0.1.0-py3-none-any.whl -
Subject digest:
971865e0c96fb0e55a17099731d79586227ea7fc67c06777ef568658a81ad133 - Sigstore transparency entry: 1238699715
- Sigstore integration time:
-
Permalink:
SPS-L/stepss-cg-studio@a85199e922b1a8eace14e549f79b81cff12b662f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/SPS-L
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@a85199e922b1a8eace14e549f79b81cff12b662f -
Trigger Event:
push
-
Statement type: