This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
GCtrl is a C++23 control systems IDE and programming language for control engineers. It provides visual diagram-driven development, automatic C++ code generation, and cross-platform deployment (Windows, Linux, embedded systems).
Prerequisites:
sudo apt-get install libsdl2-dev libglew-dev libglm-dev libgl1-mesa-devBuild:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build buildRun:
./build/engine/gctrl [path_to_project.ctrl]Prerequisites:
- CMake must be installed and available in PATH (the pre-build step uses it)
Build:
- Open
gctrl.slnin Visual Studio - Build > Build Solution (F7)
The pre-build event automatically generates engine/generated/templates.hpp using CMake.
Run:
x64\Release\gctrl.exe [path_to_project.ctrl]The core domain model follows this hierarchy (top to bottom):
- Network (
engine/controls/network/) - Top-level container holding multiple machines - Machine (
engine/controls/machine/) - System containing controllers and drivers - Controller (
engine/controls/controller/) - Subsystem containing element instances and connections - Element (
engine/controls/element/) - Reusable computational unit with inputs, outputs, memory, and code blocks - Function (
engine/controls/function/) - Pure computational functions (no state) - Port (
engine/controls/port/) - Interface connectors (sockets=input, plugs=output) - Signal (
engine/controls/signal/) - Data type definitions with C++ type mappings - Driver (
engine/controls/driver/) - Hardware interface components (UDP, Config)
Per-machine runtime state tracking in engine/controls/runtime/:
- state.hpp - Runtime status enum (stopped, building, running, error) and tracker
- build.hpp - Build/run/stop functions for machines
GCtrl auto-detects UDP ports from machine drivers for debug communication:
- Listens on machine's
send_port(receives what machine sends) - Sends to machine's
listen_port(where machine listens)
- Object/Instance Pattern:
*_objectclasses define specifications,*_instanceclasses reference them - JSON Serialization: All domain objects implement
serialize()using nlohmann/json - Record Base Class: Common base providing UUID, metadata, and serialization
- Header-Only Design: Most code is in
.hppfiles
Platform-specific code in engine/platform/ with conditional compilation:
#if GCTRL_PLATFORM_WINDOWS
#elif GCTRL_PLATFORM_LINUX
#endifImGui-based UI in engine/ui/:
ui.hpp- Main UI orchestrationgraph.hpp- Visual node editor (using imgui-node-editor)navigation.hpp- Modal navigation systemchart.hpp- Real-time data visualization (using ImPlot)
engine/controls/code/generator.hpp transforms control system definitions into deployable C++ code.
Projects are stored as .ctrl files (JSON format) containing machines, controllers, elements, functions, signals, and UI settings. Recent projects tracked in ~/.gctrlrc.json.
- SDL2 - Windowing/input
- OpenGL/GLEW - Rendering
- ImGui, ImPlot, imgui-node-editor - UI (in
lib/) - nlohmann/json - Serialization (in
lib/)
- Use short, single-word names when possible
- No abbreviations unless widely known (e.g.,
id,ui,config) - Getters and setters share the same name:
float value(); // getter void value(float v); // setter
- Avoid lambda functions; use named functions or function objects instead
- Prefer references over pointers; use pointers only when null state is needed
- Create inline wrappers in the
uinamespace for ImGui functions - Application code uses
std::string, UI wrappers handle conversion toconst char* - Icons are centralized in
ui::icon::namespace (engine/ui/icons.hpp)// Icons only (single glyph) ui::icon::trash ui::icon::play // Button labels (icon + text, ready to use) ui::icon::remove // "🗑 Delete" ui::icon::run // "▶ Run"
- Use
std::stringthroughout application code - UI layer handles conversion to C-strings internally
- String concatenation happens in application code, not at call sites
Open source libraries included in the project are open for extension and bug fixes when it simplifies application code and keeps it clean.
Contributors must sign the CLA. Use feature branches and pull requests. License: GPL v3.0.